Commit 72ed2c72 authored by Joachim Eibl's avatar Joachim Eibl

Fixed mouse wheel problem. (Patch by David Hay)

git-svn-id: https://kdiff3.svn.sourceforge.net/svnroot/kdiff3/trunk@146 c8aa9fed-2811-0410-8543-893ada326672
parent c325dba8
......@@ -325,6 +325,8 @@ class KDiff3App : public QSplitter
void recalcWordWrap(int nofVisibleColumns=-1);
void setHScrollBarRange();
int m_iCumulativeWheelDelta;
public slots:
void resizeDiffTextWindow(int newWidth, int newHeight);
void resizeMergeResultWindow();
......
......@@ -590,6 +590,9 @@ void KDiff3App::init( bool bAuto, TotalDiffStatus* pTotalDiffStatus, bool bLoadF
{
m_pDiffTextWindow1->setFocus();
}
//initialize wheel tracking to zero
m_iCumulativeWheelDelta = 0;
}
......@@ -1019,16 +1022,33 @@ bool KDiff3App::eventFilter( QObject* o, QEvent* e )
}
else if (e->type() == QEvent::Wheel ) // wheel event
{
QWheelEvent *w = (QWheelEvent*)e;
w->accept();
QWheelEvent *w = (QWheelEvent*)e;
w->accept();
int deltaX=0;
int deltaX=0;
int d=w->delta();
int deltaY = -d/120 * QApplication::wheelScrollLines();
int d=w->delta();
scrollDiffTextWindow( deltaX, deltaY );
return true;
//As per QT documentation, some mice/OS combos send delta values
//less than 120 units(15 degrees)
d = d + m_iCumulativeWheelDelta;
if ( d > -120 && d < 120)
{
//not enough for a full step in either direction, add it up
//to use on a successive call
m_iCumulativeWheelDelta = d;
}
else
{
//reset cumulative tracking of the wheel since we have enough
//for a 15 degree movement
m_iCumulativeWheelDelta= 0;
}
int deltaY = -d/120 * QApplication::wheelScrollLines();
scrollDiffTextWindow( deltaX, deltaY );
return true;
}
else if (e->type() == QEvent::Drop )
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment