@@ -875,25 +875,32 @@ LRESULT StWindowImpl::stWndProc(HWND theWin, UINT uMsg, WPARAM wParam, LPARAM lP
875875 return 0 ;
876876 }
877877 case WM_MOUSEWHEEL: // vertical wheel
878- // case WM_MOUSEHWHEEL: // horizontal wheel (only Vista+)
878+ case WM_MOUSEHWHEEL: // horizontal wheel (only Vista+)
879879 {
880880 const StRectI_t aWinRect = getPlacement ();
881881 int aMouseXPx = int (short (LOWORD (lParam))) - aWinRect.left ();
882882 int aMouseYPx = int (short (HIWORD (lParam))) - aWinRect.top ();
883883
884- int aZDelta = GET_WHEEL_DELTA_WPARAM (wParam); // / WHEEL_DELTA;
885- // if(GET_X_LPARAM(lParam) != 0)
886-
887- myStEvent.Type = stEvent_Scroll;
888- myStEvent.Scroll .Time = getEventTime (myEvent.time );
889- myStEvent.Scroll .PointX = double (aMouseXPx) / double (aWinRect.width ());
890- myStEvent.Scroll .PointY = double (aMouseYPx) / double (aWinRect.height ());
891- myStEvent.Scroll .StepsX = 0 ;
892- myStEvent.Scroll .StepsY = (aZDelta > 0 ) ? 1 : -1 ;
893- myStEvent.Scroll .DeltaX = 0.0 ;
894- myStEvent.Scroll .DeltaY = 10 .0f * myStEvent.Scroll .StepsY ;
895- myStEvent.Scroll .IsFromMultiTouch = false ;
896-
884+ const bool isVert = (uMsg == WM_MOUSEWHEEL);
885+ const int aZDelta = GET_WHEEL_DELTA_WPARAM (wParam);
886+ const float aDeltaSt = 10 .0f * (float (aZDelta) / float (WHEEL_DELTA));
887+
888+ myStEvent.Scroll .init (getEventTime (myEvent.time ),
889+ double (aMouseXPx) / double (aWinRect.width ()),
890+ double (aMouseYPx) / double (aWinRect.height ()),
891+ !isVert ? aDeltaSt : 0 .0f ,
892+ isVert ? aDeltaSt : 0 .0f ,
893+ false );
894+ if ((myStEvent.Scroll .Time - myScrollAcc.Time ) > 0.1
895+ || std::abs (aMouseXPx - (int )myScrollAcc.PointX ) > 10
896+ || std::abs (aMouseYPx - (int )myScrollAcc.PointY ) > 10 ) {
897+ myScrollAcc.reset ();
898+ }
899+ myScrollAcc.Time = myStEvent.Scroll .Time ;
900+ myScrollAcc.PointX = aMouseXPx;
901+ myScrollAcc.PointY = aMouseYPx;
902+ myStEvent.Scroll .StepsX = myScrollAcc.accumulateStepsX (!isVert ? aZDelta : 0 , WHEEL_DELTA);
903+ myStEvent.Scroll .StepsY = myScrollAcc.accumulateStepsY ( isVert ? aZDelta : 0 , WHEEL_DELTA);
897904 myEventsBuffer.append (myStEvent);
898905 return 0 ;
899906 }
0 commit comments