vcl/inc/osx/salframeview.h | 3 --- vcl/osx/salframeview.mm | 43 +++++++++++++++++-------------------------- 2 files changed, 17 insertions(+), 29 deletions(-)
New commits: commit 3b96af6479ddbbf27834ed93ed9543b91451befb Author: Patrick Luby <guibmac...@gmail.com> AuthorDate: Sat Mar 8 09:49:57 2025 -0500 Commit: Patrick Luby <guibomac...@gmail.com> CommitDate: Sat Mar 8 16:49:44 2025 +0100 tdf#151423 revert commit b197379e867087413be86bd1a32030b912ecaa8a User testing found that scrolling with a Magic Mouse while pressing the Command key only reenables zoooming sporadically so revert commit b197379e867087413be86bd1a32030b912ecaa8a. This revert will disable zooming on a Magic Mouse just like on a trackpad until another heurisic is found to reliably identify a Mouse Magic. Change-Id: I6b4b92bcdea44702385b7db2fe24fb05bfe99df4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182670 Tested-by: Jenkins Reviewed-by: Patrick Luby <guibomac...@gmail.com> diff --git a/vcl/inc/osx/salframeview.h b/vcl/inc/osx/salframeview.h index 52459ea99cde..287ccaedbc06 100644 --- a/vcl/inc/osx/salframeview.h +++ b/vcl/inc/osx/salframeview.h @@ -112,9 +112,6 @@ enum class SalEvent; NSAttributedString* mpLastMarkedText; BOOL mbTextInputWantsNonRepeatKeyDown; NSTrackingArea* mpLastTrackingArea; - - NSTimeInterval mfLastScrollEventTime; - NSEventModifierFlags mnLastScrollModifierFlags; } +(void)unsetMouseFrame: (AquaSalFrame*)pFrame; -(id)initWithSalFrame: (AquaSalFrame*)pFrame; diff --git a/vcl/osx/salframeview.mm b/vcl/osx/salframeview.mm index 60d544fb8fe1..027676c97407 100644 --- a/vcl/osx/salframeview.mm +++ b/vcl/osx/salframeview.mm @@ -45,8 +45,6 @@ #define WHEEL_EVENT_FACTOR 1.5 -const static NSTimeInterval fScrollEventTimeoutTime = 1.0f; - static sal_uInt16 ImplGetModifierMask( unsigned int nMask ) { sal_uInt16 nRet = 0; @@ -240,6 +238,11 @@ static void freezeWindowSizeAndReschedule( NSWindow *pWindow ) } } +static bool isMouseScrollWheelEvent( NSEvent *pEvent ) +{ + return ( pEvent && [pEvent type] == NSEventTypeScrollWheel && [pEvent phase] == NSEventPhaseNone && [pEvent momentumPhase] == NSEventPhaseNone ); +} + static void updateMenuBarVisibility( const AquaSalFrame *pFrame ) { // Show the menubar if application is in native full screen mode @@ -926,9 +929,6 @@ static void updateMenuBarVisibility( const AquaSalFrame *pFrame ) mpLastMarkedText = nil; mbTextInputWantsNonRepeatKeyDown = NO; mpLastTrackingArea = nil; - - mfLastScrollEventTime = 0.0f; - mnLastScrollModifierFlags = 0; } return self; @@ -1343,35 +1343,17 @@ static void updateMenuBarVisibility( const AquaSalFrame *pFrame ) mpFrame->mnLastEventTime = static_cast<sal_uInt64>( [pEvent timestamp] * 1000.0 ); mpFrame->mnLastModifierFlags = [pEvent modifierFlags]; - // tdf#151423 use the same modifier keys during a scrolling session - // Revert commit f5ef5eafdf70a36edd5129147502a9c74df89456 as it - // completely disabled the ability to zoom on mice with limited - // support for gestures such as the Apple Magic Mouse by pressing - // pressing the Command key while scrolling. So try a different - // approach and use the modifier keys that were pressed when the - // current scrolling session was started for the entire scrolling - // session. - // Unfortunately, session state changes such as a scrolling session - // began or ended are not fired when scrolling with a regular mouse - // scrollwheel so use a significant pause between scrolling events - // as a rough indicator that a new scrolling session has begun. - if( [pEvent momentumPhase] == NSEventPhaseNone && mnLastScrollModifierFlags != [pEvent modifierFlags] ) - { - if( [pEvent timestamp] - mfLastScrollEventTime > fScrollEventTimeoutTime ) - mnLastScrollModifierFlags = [pEvent modifierFlags]; - } - // merge pending scroll wheel events CGFloat dX = 0.0; CGFloat dY = 0.0; + bool bAllowModifiers = isMouseScrollWheelEvent( pEvent ); for(;;) { - mfLastScrollEventTime = [pEvent timestamp]; dX += [pEvent deltaX]; dY += [pEvent deltaY]; NSEvent* pNextEvent = [NSApp nextEventMatchingMask: NSEventMaskScrollWheel untilDate: nil inMode: NSDefaultRunLoopMode dequeue: YES ]; - if( !pNextEvent ) + if( !pNextEvent || ( isMouseScrollWheelEvent( pNextEvent ) != bAllowModifiers ) ) break; pEvent = pNextEvent; } @@ -1383,7 +1365,16 @@ static void updateMenuBarVisibility( const AquaSalFrame *pFrame ) aEvent.mnTime = mpFrame->mnLastEventTime; aEvent.mnX = static_cast<tools::Long>(aPt.x) - mpFrame->GetUnmirroredGeometry().x(); aEvent.mnY = static_cast<tools::Long>(aPt.y) - mpFrame->GetUnmirroredGeometry().y(); - aEvent.mnCode = ImplGetModifierMask( mnLastScrollModifierFlags ); + // tdf#151423 Only allow modifiers for mouse scrollwheel events + // The Command modifier converts scrollwheel events into + // magnification events and the Shift modifier converts vertical + // scrollwheel events into horizontal scrollwheel events. This + // behavior is reasonable for mouse scrollwheel events since many + // mice only have a single, vertical scrollwheel but trackpads + // already have specific gestures for magnification and horizontal + // scrolling. So, behave like most macOS applications and ignore + // all modifiers if this a trackpad scrollwheel event. + aEvent.mnCode = bAllowModifiers ? ImplGetModifierMask( mpFrame->mnLastModifierFlags ) : 0; aEvent.mbDeltaIsPixel = false; if( AllSettings::GetLayoutRTL() )