macOS: Add @available check at macOS 12 workaround (flutter/engine#54784)
Use default mouse event handling behaviour on macOS 13.3.1 onwards. This has two positive effects: * Avoids the workaround on newer macOS versions where it's unnecessary, thereby giving us confidence that the underlying AppKit issue is fixed and the whole method can later be removed. * Will be caught by tooling when we drop support for versions of macOS prior to the fixed version. Issue: https://github.com/flutter/flutter/issues/154063 Issue: https://github.com/flutter/flutter/issues/115015 No tests modified since there is no semantic change, either on versions of macOS where the issue is fixed (and thus the default event handler is correct) or on versions where it is not (and we still use the workaround). Re-tested manually with the reduced transparency setting on macOS 14.6.1. [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
This commit is contained in:
parent
bd0e73d5b0
commit
40ce12e1e1
@ -286,38 +286,44 @@ static void OnKeyboardLayoutChanged(CFNotificationCenterRef center,
|
|||||||
return @[ _flutterView ];
|
return @[ _flutterView ];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO(cbracken): https://github.com/flutter/flutter/issues/154063
|
||||||
|
// Remove this whole method override when we drop support for macOS 12 (Monterey).
|
||||||
- (void)mouseDown:(NSEvent*)event {
|
- (void)mouseDown:(NSEvent*)event {
|
||||||
// Work around an AppKit bug where mouseDown/mouseUp are not called on the view controller if the
|
if (@available(macOS 13.3.1, *)) {
|
||||||
// view is the content view of an NSPopover AND macOS's Reduced Transparency accessibility setting
|
[super mouseDown:event];
|
||||||
// is enabled.
|
} else {
|
||||||
//
|
// Work around an AppKit bug where mouseDown/mouseUp are not called on the view controller if
|
||||||
// This simply calls mouseDown on the next responder in the responder chain as the default
|
// the view is the content view of an NSPopover AND macOS's Reduced Transparency accessibility
|
||||||
// implementation on NSResponder is documented to do.
|
// setting is enabled.
|
||||||
//
|
//
|
||||||
// See: https://github.com/flutter/flutter/issues/115015
|
// This simply calls mouseDown on the next responder in the responder chain as the default
|
||||||
// See: http://www.openradar.me/FB12050037
|
// implementation on NSResponder is documented to do.
|
||||||
// See: https://developer.apple.com/documentation/appkit/nsresponder/1524634-mousedown
|
//
|
||||||
//
|
// See: https://github.com/flutter/flutter/issues/115015
|
||||||
// TODO(cbracken): https://github.com/flutter/flutter/issues/154063
|
// See: http://www.openradar.me/FB12050037
|
||||||
// Remove this workaround when we drop support for macOS 12 (Monterey).
|
// See: https://developer.apple.com/documentation/appkit/nsresponder/1524634-mousedown
|
||||||
[self.nextResponder mouseDown:event];
|
[self.nextResponder mouseDown:event];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO(cbracken): https://github.com/flutter/flutter/issues/154063
|
||||||
|
// Remove this workaround when we drop support for macOS 12 (Monterey).
|
||||||
- (void)mouseUp:(NSEvent*)event {
|
- (void)mouseUp:(NSEvent*)event {
|
||||||
// Work around an AppKit bug where mouseDown/mouseUp are not called on the view controller if the
|
if (@available(macOS 13.3.1, *)) {
|
||||||
// view is the content view of an NSPopover AND macOS's Reduced Transparency accessibility setting
|
[super mouseUp:event];
|
||||||
// is enabled.
|
} else {
|
||||||
//
|
// Work around an AppKit bug where mouseDown/mouseUp are not called on the view controller if
|
||||||
// This simply calls mouseUp on the next responder in the responder chain as the default
|
// the view is the content view of an NSPopover AND macOS's Reduced Transparency accessibility
|
||||||
// implementation on NSResponder is documented to do.
|
// setting is enabled.
|
||||||
//
|
//
|
||||||
// See: https://github.com/flutter/flutter/issues/115015
|
// This simply calls mouseUp on the next responder in the responder chain as the default
|
||||||
// See: http://www.openradar.me/FB12050037
|
// implementation on NSResponder is documented to do.
|
||||||
// See: https://developer.apple.com/documentation/appkit/nsresponder/1535349-mouseup
|
//
|
||||||
//
|
// See: https://github.com/flutter/flutter/issues/115015
|
||||||
// TODO(cbracken): https://github.com/flutter/flutter/issues/154063
|
// See: http://www.openradar.me/FB12050037
|
||||||
// Remove this workaround when we drop support for macOS 12 (Monterey).
|
// See: https://developer.apple.com/documentation/appkit/nsresponder/1535349-mouseup
|
||||||
[self.nextResponder mouseUp:event];
|
[self.nextResponder mouseUp:event];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@ -1082,7 +1082,16 @@ static void SwizzledNoop(id self, SEL _cmd) {}
|
|||||||
// See: https://github.com/flutter/flutter/issues/115015
|
// See: https://github.com/flutter/flutter/issues/115015
|
||||||
// See: http://www.openradar.me/FB12050037
|
// See: http://www.openradar.me/FB12050037
|
||||||
// See: https://developer.apple.com/documentation/appkit/nsresponder/1524634-mousedown
|
// See: https://developer.apple.com/documentation/appkit/nsresponder/1524634-mousedown
|
||||||
|
//
|
||||||
|
// TODO(cbracken): https://github.com/flutter/flutter/issues/154063
|
||||||
|
// Remove this test when we drop support for macOS 12 (Monterey).
|
||||||
- (bool)testMouseDownUpEventsSentToNextResponder:(id)engineMock {
|
- (bool)testMouseDownUpEventsSentToNextResponder:(id)engineMock {
|
||||||
|
if (@available(macOS 13.3.1, *)) {
|
||||||
|
// This workaround is disabled for macOS 13.3.1 onwards, since the underlying AppKit bug is
|
||||||
|
// fixed.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// The root cause of the above bug is NSResponder mouseDown/mouseUp methods that don't correctly
|
// The root cause of the above bug is NSResponder mouseDown/mouseUp methods that don't correctly
|
||||||
// walk the responder chain calling the appropriate method on the next responder under certain
|
// walk the responder chain calling the appropriate method on the next responder under certain
|
||||||
// conditions. Simulate this by swizzling out the default implementations and replacing them with
|
// conditions. Simulate this by swizzling out the default implementations and replacing them with
|
||||||
|
Loading…
x
Reference in New Issue
Block a user