Chris Bracken 761ba30bc7 [macOS] Forward mouseDown/Up to view controller (flutter/engine#40241)
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: https://github.com/flutter/flutter/issues/115015
2023-03-11 12:49:59 -08:00
Languages
Dart 75%
C++ 16.5%
Objective-C++ 2.9%
Java 2.8%
Objective-C 0.7%
Other 1.9%