This repository has been archived by the owner. It is now read-only.
Permalink
...
Comparing changes
Open a pull request
- 3 commits
- 4 files changed
- 0 commit comments
- 2 contributors
Unified
Split
Showing
with
37 additions
and 15 deletions.
- +1 −1 src/lib/platform/OSXScreen.h
- +9 −4 src/lib/platform/OSXScreen.mm
- +16 −10 src/lib/platform/XWindowsScreen.cpp
- +11 −0 src/lib/platform/XWindowsScreen.h
View
2
src/lib/platform/OSXScreen.h
| @@ -147,7 +147,7 @@ class OSXScreen : public PlatformScreen { | ||
| SInt32 mapScrollWheelToSynergy(SInt32) const; | ||
| // map synergy scroll wheel value to a mac scroll wheel value | ||
| - SInt32 mapScrollWheelFromSynergy(SInt32) const; | ||
| + SInt32 mapScrollWheelFromSynergy(float) const; | ||
| // get the current scroll wheel speed | ||
| double getScrollSpeed() const; | ||
View
13
src/lib/platform/OSXScreen.mm
| @@ -1426,7 +1426,7 @@ | ||
| } | ||
| SInt32 | ||
| -OSXScreen::mapScrollWheelFromSynergy(SInt32 x) const | ||
| +OSXScreen::mapScrollWheelFromSynergy(float x) const | ||
| { | ||
| // use server's acceleration with a little boost since other platforms | ||
| // take one wheel step as a larger step than the mac does. | ||
| @@ -1943,10 +1943,15 @@ | ||
| return event; | ||
| break; | ||
| case kCGEventScrollWheel: | ||
| + // http://tinyurl.com/gt98gz7 | ||
| screen->onMouseWheel(screen->mapScrollWheelToSynergy( | ||
| - CGEventGetIntegerValueField(event, kCGScrollWheelEventDeltaAxis2)), | ||
| - screen->mapScrollWheelToSynergy( | ||
| - CGEventGetIntegerValueField(event, kCGScrollWheelEventDeltaAxis1))); | ||
| + CGEventGetIntegerValueField( | ||
| + event, | ||
| + kCGScrollWheelEventFixedPtDeltaAxis2) >> 16), | ||
| + screen->mapScrollWheelToSynergy( | ||
| + CGEventGetIntegerValueField( | ||
| + event, | ||
| + kCGScrollWheelEventFixedPtDeltaAxis1) >> 16)); | ||
| break; | ||
| case kCGEventKeyDown: | ||
| case kCGEventKeyUp: | ||
View
26
src/lib/platform/XWindowsScreen.cpp
| @@ -99,6 +99,7 @@ XWindowsScreen::XWindowsScreen( | ||
| IEventQueue* events) : | ||
| m_isPrimary(isPrimary), | ||
| m_mouseScrollDelta(mouseScrollDelta), | ||
| + m_accumulatedScroll(0), | ||
| m_display(NULL), | ||
| m_root(None), | ||
| m_window(None), | ||
| @@ -868,9 +869,11 @@ XWindowsScreen::fakeMouseWheel(SInt32, SInt32 yDelta) const | ||
| return; | ||
| } | ||
| + int numEvents = accumulateMouseScroll(yDelta); | ||
| + | ||
| // choose button depending on rotation direction | ||
| const unsigned int xButton = mapButtonToX(static_cast<ButtonID>( | ||
| - (yDelta >= 0) ? -1 : -2)); | ||
| + (numEvents >= 0) ? -1 : -2)); | ||
| if (xButton == 0) { | ||
| // If we get here, then the XServer does not support the scroll | ||
| // wheel buttons, so send PageUp/PageDown keystrokes instead. | ||
| @@ -889,20 +892,14 @@ XWindowsScreen::fakeMouseWheel(SInt32, SInt32 yDelta) const | ||
| return; | ||
| } | ||
| - // now use absolute value of delta | ||
| - if (yDelta < 0) { | ||
| - yDelta = -yDelta; | ||
| - } | ||
| - | ||
| - if (yDelta < m_mouseScrollDelta) { | ||
| - LOG((CLOG_WARN "Wheel scroll delta (%d) smaller than threshold (%d)", yDelta, m_mouseScrollDelta)); | ||
| - } | ||
| + numEvents = std::abs(numEvents); | ||
| // send as many clicks as necessary | ||
| - for (; yDelta >= m_mouseScrollDelta; yDelta -= m_mouseScrollDelta) { | ||
| + for (; numEvents > 0; numEvents--) { | ||
| XTestFakeButtonEvent(m_display, xButton, True, CurrentTime); | ||
| XTestFakeButtonEvent(m_display, xButton, False, CurrentTime); | ||
| } | ||
| + | ||
| XFlush(m_display); | ||
| } | ||
| @@ -1662,6 +1659,15 @@ XWindowsScreen::onMouseMove(const XMotionEvent& xmotion) | ||
| } | ||
| } | ||
| +int | ||
| +XWindowsScreen::accumulateMouseScroll(SInt32 yDelta) const | ||
| +{ | ||
| + m_accumulatedScroll += yDelta; | ||
| + int numEvents = m_accumulatedScroll / m_mouseScrollDelta; | ||
| + m_accumulatedScroll -= numEvents * m_mouseScrollDelta; | ||
| + return numEvents; | ||
| +} | ||
| + | ||
| Cursor | ||
| XWindowsScreen::createBlankCursor() const | ||
| { | ||
View
11
src/lib/platform/XWindowsScreen.h
| @@ -136,6 +136,10 @@ class XWindowsScreen : public PlatformScreen { | ||
| void onMouseRelease(const XButtonEvent&); | ||
| void onMouseMove(const XMotionEvent&); | ||
| + // Returns the number of scroll events needed after the current delta has | ||
| + // been taken into account | ||
| + int accumulateMouseScroll(SInt32 yDelta) const; | ||
| + | ||
| bool detectXI2(); | ||
| #ifdef HAVE_XI2 | ||
| void selectXIRawMotion(); | ||
| @@ -172,8 +176,15 @@ class XWindowsScreen : public PlatformScreen { | ||
| // true if screen is being used as a primary screen, false otherwise | ||
| bool m_isPrimary; | ||
| + | ||
| + // The size of a smallest supported scroll event, in points | ||
| int m_mouseScrollDelta; | ||
| + // Accumulates scrolls of less than m_mouseScrollDelta across multiple | ||
| + // scroll events. We dispatch a scroll event whenever the accumulated scroll | ||
| + // becomes larger than m_mouseScrollDelta | ||
| + mutable int m_accumulatedScroll; | ||
| + | ||
| Display* m_display; | ||
| Window m_root; | ||
| Window m_window; | ||