From d9b96e1988f00cfff98087576d259802e0b97c0c Mon Sep 17 00:00:00 2001 From: Igor Sikachyna Date: Wed, 26 May 2021 22:45:45 -0700 Subject: [PATCH] SYNERGY-988 Mac client does not scroll in natural direction (#7012) * SYNERGY-988 - Use system preferences for horizontal scrolling * Update changelog * SYNERGY-988 - Invert xscroll direction * Also revert system event xscroll * SYNERGY-988 - Update directions * SYNERGY-988 - Update changelog * SYNERGY-988 - Update scrolling direction and y scrolling * SYNERGY-988 - Update variable comment Co-authored-by: SerhiiGadzhilov <71632867+SerhiiGadzhilov@users.noreply.github.com> --- ChangeLog | 1 + src/lib/platform/OSXScreen.h | 3 +++ src/lib/platform/OSXScreen.mm | 8 +++++--- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1210bf9a6..33d7a7734 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,7 @@ v1.14.1-snapshot Bug fixes: - #7016 Fix script that generates version number - #7006 Resolve code scanning issues +- #7012 Fix natural horizontal scrolling on Mac client Enhancements: diff --git a/src/lib/platform/OSXScreen.h b/src/lib/platform/OSXScreen.h index 6b1e8211c..13da1368c 100644 --- a/src/lib/platform/OSXScreen.h +++ b/src/lib/platform/OSXScreen.h @@ -339,6 +339,9 @@ private: Thread* m_getDropTargetThread; String m_dropTarget; + + // -1 for natural scrolling direction, 1 otherwise + SInt32 m_scrollDirection = 1; #if defined(MAC_OS_X_VERSION_10_7) Mutex* m_carbonLoopMutex; diff --git a/src/lib/platform/OSXScreen.mm b/src/lib/platform/OSXScreen.mm index aea9b87fe..583c5e2cb 100755 --- a/src/lib/platform/OSXScreen.mm +++ b/src/lib/platform/OSXScreen.mm @@ -681,8 +681,8 @@ OSXScreen::fakeMouseWheel(SInt32 xDelta, SInt32 yDelta) const CGEventRef scrollEvent = CGEventCreateScrollWheelEvent( NULL, kCGScrollEventUnitLine, 2, mapScrollWheelFromSynergy(yDelta), - -mapScrollWheelFromSynergy(xDelta)); - + mapScrollWheelFromSynergy(xDelta)); + // Fix for sticky keys CGEventFlags modifiers = m_keyState->getModifierStateAsOSXFlags(); CGEventSetFlags(scrollEvent, modifiers); @@ -840,6 +840,8 @@ OSXScreen::enter() setZeroSuppressionInterval(); } else { + m_scrollDirection = [[[NSUserDefaults standardUserDefaults] objectForKey:@"com.apple.swipescrolldirection"] boolValue] ? -1 : 1; + // reset buttons m_buttonState.reset(); @@ -1448,7 +1450,7 @@ OSXScreen::mapScrollWheelFromSynergy(SInt32 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. - return static_cast(3.0 * x / 120.0); + return static_cast(m_scrollDirection * 3.0 * x / 120.0); } double