From b37b7f78bb81d98b0ec7341180339f0e0bfc1910 Mon Sep 17 00:00:00 2001 From: corbin dunn Date: Tue, 2 Mar 2021 10:39:39 -0800 Subject: [PATCH] Fix scrolling with wacom tablets using them as a touch device. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Unfortunately, something is link checking the bundle identifier “org.blenderfoundation.blender” and sending some modifier changed events. This can easily be reproduced with a sample app that implemented - (void)flagsChanged:(NSEvent *)event and sets the bundle identifier to org.blenderfoundation.blender. I can’t isolate what is doing the bundle check (it is outside of blender) and have to change the identifier to get it to work correctly with Wacom Intuous Pro. --- intern/ghost/intern/GHOST_SystemCocoa.h | 4 +-- intern/ghost/intern/GHOST_SystemCocoa.mm | 45 ++++++++---------------- 2 files changed, 16 insertions(+), 33 deletions(-) diff --git a/intern/ghost/intern/GHOST_SystemCocoa.h b/intern/ghost/intern/GHOST_SystemCocoa.h index cee6398b5a6..58ca7730d4c 100644 --- a/intern/ghost/intern/GHOST_SystemCocoa.h +++ b/intern/ghost/intern/GHOST_SystemCocoa.h @@ -302,15 +302,13 @@ class GHOST_SystemCocoa : public GHOST_System { bool m_needDelayedApplicationBecomeActiveEventProcessing; /** State of the modifiers. */ - GHOST_TUns32 m_modifierMask; + GHOST_TUns64 m_modifierMask; // this should be a 64-bit value /** Ignores window size messages (when window is dragged). */ bool m_ignoreWindowSizedMessages; /** Temporarily ignore momentum scroll events */ bool m_ignoreMomentumScroll; - /** Is the scroll wheel event generated by a multitouch trackpad or mouse? */ - bool m_multiTouchScroll; /** To prevent multiple warp, we store the time of the last warp event * and ignore mouse moved events generated before that. */ double m_last_warp_timestamp; diff --git a/intern/ghost/intern/GHOST_SystemCocoa.mm b/intern/ghost/intern/GHOST_SystemCocoa.mm index f42d4af109a..6461d038aeb 100644 --- a/intern/ghost/intern/GHOST_SystemCocoa.mm +++ b/intern/ghost/intern/GHOST_SystemCocoa.mm @@ -538,7 +538,6 @@ - (void)windowWillClose:(NSNotification *)notification m_ignoreWindowSizedMessages = false; m_ignoreMomentumScroll = false; - m_multiTouchScroll = false; m_last_warp_timestamp = 0; } @@ -928,6 +927,7 @@ - (void)windowWillClose:(NSNotification *)notification untilDate:[NSDate distantPast] inMode:NSDefaultRunLoopMode dequeue:YES]; + if (event == nil) { [pool drain]; break; @@ -1672,16 +1672,14 @@ - (void)windowWillClose:(NSNotification *)notification NSEventPhase momentumPhase = NSEventPhaseNone; NSEventPhase phase = NSEventPhaseNone; - if ([event respondsToSelector:@selector(momentumPhase)]) - momentumPhase = [event momentumPhase]; - if ([event respondsToSelector:@selector(phase)]) - phase = [event phase]; + momentumPhase = [event momentumPhase]; + phase = [event phase]; /* when pressing a key while momentum scrolling continues after * lifting fingers off the trackpad, the action can unexpectedly * change from e.g. scrolling to zooming. this works around the * issue by ignoring momentum scroll after a key press */ - if (momentumPhase) { + if (momentumPhase != NSEventPhaseNone) { if (m_ignoreMomentumScroll) break; } @@ -1689,17 +1687,11 @@ - (void)windowWillClose:(NSNotification *)notification m_ignoreMomentumScroll = false; } - /* we assume phases are only set for gestures from trackpad or magic - * mouse events. note that using tablet at the same time may not work - * since this is a static variable */ - if (phase == NSEventPhaseBegan) - m_multiTouchScroll = true; - else if (phase == NSEventPhaseEnded) - m_multiTouchScroll = false; - /* Standard scroll-wheel case, if no swiping happened, * and no momentum (kinetic scroll) works. */ - if (!m_multiTouchScroll && momentumPhase == NSEventPhaseNone) { + // This is really outdated; hasPreciseScrollingDeltas should be used for this older codepath, but I don't think it should even be around anymore. + + if (!event.hasPreciseScrollingDeltas) { GHOST_TInt32 delta; double deltaF = [event deltaY]; @@ -1712,22 +1704,14 @@ - (void)windowWillClose:(NSNotification *)notification delta = deltaF > 0.0 ? 1 : -1; pushEvent(new GHOST_EventWheel([event timestamp] * 1000, window, delta)); } - else { + else + { NSPoint mousePos = [event locationInWindow]; GHOST_TInt32 x, y; - double dx; - double dy; - - /* with 10.7 nice scrolling deltas are supported */ - dx = [event scrollingDeltaX]; - dy = [event scrollingDeltaY]; - - /* However, wacom tablet (intuos5) needs old deltas, - * it then has momentum and phase at zero. */ - if (phase == NSEventPhaseNone && momentumPhase == NSEventPhaseNone) { - dx = [event deltaX]; - dy = [event deltaY]; - } + + double dx = [event scrollingDeltaX]; + double dy = [event scrollingDeltaY]; + window->clientToScreenIntern(mousePos.x, mousePos.y, x, y); NSPoint delta = [[cocoawindow contentView] convertPointToBacking:NSMakePoint(dx, dy)]; @@ -1740,7 +1724,8 @@ - (void)windowWillClose:(NSNotification *)notification delta.y, [event isDirectionInvertedFromDevice])); } - } break; + break; + } case NSEventTypeMagnify: { NSPoint mousePos = [event locationInWindow]; -- 2.24.3 (Apple Git-128)