diff options
author | Yevgeny Makarov <jenkm> | 2020-11-09 14:26:53 +0300 |
---|---|---|
committer | Brecht Van Lommel <brecht@blender.org> | 2020-11-09 15:51:08 +0300 |
commit | 055ed335a111bebed7193acd083f54d5c82929ff (patch) | |
tree | 2d36a6ea151c60eb53cd2a7dfb4a398df0b2f8d9 /intern/ghost | |
parent | 0c4d12986a746b644c177224e4f70edec1f50d7a (diff) |
macOS: follow system preference for natural trackpad scroll direction
And remove Blender preference, which was expected to be set to match the system
preference for correct behavior. Instead just handle this automatically.
Differential Revision: https://developer.blender.org/D9402
Diffstat (limited to 'intern/ghost')
-rw-r--r-- | intern/ghost/GHOST_Types.h | 2 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_EventTrackpad.h | 4 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_SystemCocoa.mm | 26 |
3 files changed, 25 insertions, 7 deletions
diff --git a/intern/ghost/GHOST_Types.h b/intern/ghost/GHOST_Types.h index 547be04ac86..a03b59d14b0 100644 --- a/intern/ghost/GHOST_Types.h +++ b/intern/ghost/GHOST_Types.h @@ -470,6 +470,8 @@ typedef struct { GHOST_TInt32 deltaX; /** The y-delta (currently only for scroll subtype) of the trackpad event */ GHOST_TInt32 deltaY; + /** The delta is inverted from the device due to system preferences. */ + char isDirectionInverted; } GHOST_TEventTrackpadData; typedef enum { diff --git a/intern/ghost/intern/GHOST_EventTrackpad.h b/intern/ghost/intern/GHOST_EventTrackpad.h index 3bbb29821a1..d4f9d0f2b55 100644 --- a/intern/ghost/intern/GHOST_EventTrackpad.h +++ b/intern/ghost/intern/GHOST_EventTrackpad.h @@ -45,7 +45,8 @@ class GHOST_EventTrackpad : public GHOST_Event { GHOST_TInt32 x, GHOST_TInt32 y, GHOST_TInt32 deltaX, - GHOST_TInt32 deltaY) + GHOST_TInt32 deltaY, + bool isDirectionInverted) : GHOST_Event(msec, GHOST_kEventTrackpad, window) { m_trackpadEventData.subtype = subtype; @@ -53,6 +54,7 @@ class GHOST_EventTrackpad : public GHOST_Event { m_trackpadEventData.y = y; m_trackpadEventData.deltaX = deltaX; m_trackpadEventData.deltaY = deltaY; + m_trackpadEventData.isDirectionInverted = isDirectionInverted; m_data = &m_trackpadEventData; } diff --git a/intern/ghost/intern/GHOST_SystemCocoa.mm b/intern/ghost/intern/GHOST_SystemCocoa.mm index 19753bca2c7..c1c1070d346 100644 --- a/intern/ghost/intern/GHOST_SystemCocoa.mm +++ b/intern/ghost/intern/GHOST_SystemCocoa.mm @@ -1716,8 +1716,14 @@ GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr) } window->clientToScreenIntern(mousePos.x, mousePos.y, x, y); - pushEvent(new GHOST_EventTrackpad( - [event timestamp] * 1000, window, GHOST_kTrackpadEventScroll, x, y, dx, dy)); + pushEvent(new GHOST_EventTrackpad([event timestamp] * 1000, + window, + GHOST_kTrackpadEventScroll, + x, + y, + dx, + dy, + [event isDirectionInvertedFromDevice])); } } break; @@ -1731,15 +1737,22 @@ GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr) x, y, [event magnification] * 125.0 + 0.1, - 0)); + 0, + false)); } break; case NSEventTypeSmartMagnify: { NSPoint mousePos = [event locationInWindow]; GHOST_TInt32 x, y; window->clientToScreenIntern(mousePos.x, mousePos.y, x, y); - pushEvent(new GHOST_EventTrackpad( - [event timestamp] * 1000, window, GHOST_kTrackpadEventSmartMagnify, x, y, 0, 0)); + pushEvent(new GHOST_EventTrackpad([event timestamp] * 1000, + window, + GHOST_kTrackpadEventSmartMagnify, + x, + y, + 0, + 0, + false)); } break; case NSEventTypeRotate: { @@ -1752,7 +1765,8 @@ GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr) x, y, [event rotation] * -5.0, - 0)); + 0, + false)); } default: return GHOST_kFailure; |