Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[macOS] Forward mouseDown/Up to view controller #40241

Merged
merged 1 commit into from Mar 11, 2023

Commits on Mar 11, 2023

  1. [macOS] Forward mouseDown/Up to view controller

    This works around an AppKit bug in which mouseDown/mouseUp events are
    not correctly forwarded up the responder chain for views nested inside
    an NSPopover if (and only if) the macOS "Reduce Transparency"
    accessibility setting is enabled in the System Settings.
    
    When the above conditions are satisfied, the nested NSView receives the
    mouseDown:/mouseUp: call but if it delegates to the default
    implementation (implemented in NSResponder) mouseDown/mouseUp calls are
    triggered on containing views (in our case FlutterViewWrapper) but not
    triggered on the view controller and other responders in the responder
    chain until we an _NSPopoverWindow class is hit.
    
    A minimal AppKit-only (non-Flutter) repro shows this behaviour repros
    with even a minimal NSViewController implementation and an unmodified NSView.
    See: https://github.com/cbracken/PopoverRepro
    
    A radar has been filed with Apple and a copy posted to OpenRadar.
    See: http://www.openradar.me/FB12050037
    
    In order to work around this bug, we override mouseDown/mouseUp in the
    topmost containing view of FlutterView (in our case, FlutterViewWrapper)
    to have the behaviour documented as the default behaviour in
    NSResponder's mouseDown/mouseUp documentation. In otherwords, to simply
    forward the call to self.nextResponder.
    See: https://developer.apple.com/documentation/appkit/nsresponder/1524634-mousedown
    
    Because replicating the exact configuration of a FlutterView contained
    in an NSPopover and System Settings that have been modified to enable
    the "Reduce Transparency" setting is difficult and likely error-prone in
    infra, we instead simulate the bug by testing that even if NSResponder's
    mouseDown/mouseUp method are swizzled to no-op, these calls are
    correctly forwarded to the next responder in the chain.
    
    If, in the future Apple does fix this issue, this workaround can be
    removed once Flutter's minimum supported macOS SDK is at least the
    version that contains the fix.
    
    Issue: flutter/flutter#115015
    cbracken committed Mar 11, 2023
    Configuration menu
    Copy the full SHA
    444708d View commit details
    Browse the repository at this point in the history