12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
- From: Cheng Zhao <[email protected]>
- Date: Thu, 20 Sep 2018 17:46:28 -0700
- Subject: render_widget_host_view_mac.patch
- This allows Electron to override `acceptsFirstMouse` on Mac so that windows can
- respond to the first mouse click in their window, which is desirable for some
- kinds of utility windows. Similarly for `disableAutoHideCursor`.
- diff --git a/content/app_shim_remote_cocoa/render_widget_host_view_cocoa.mm b/content/app_shim_remote_cocoa/render_widget_host_view_cocoa.mm
- index ccfac3b103824eaa59dbe1e02dcec6c8dbf3f555..a76028eed0249244d0559de102a756e3b2771b63 100644
- --- a/content/app_shim_remote_cocoa/render_widget_host_view_cocoa.mm
- +++ b/content/app_shim_remote_cocoa/render_widget_host_view_cocoa.mm
- @@ -169,6 +169,15 @@ void ExtractUnderlines(NSAttributedString* string,
-
- } // namespace
-
- +@interface NSWindow (AtomCustomMethods)
- +- (BOOL)acceptsFirstMouse;
- +- (BOOL)disableAutoHideCursor;
- +@end
- +
- +@interface NSView (ElectronCustomMethods)
- +- (BOOL)shouldIgnoreMouseEvent;
- +@end
- +
- // RenderWidgetHostViewCocoa ---------------------------------------------------
-
- // Private methods:
- @@ -789,6 +798,9 @@ - (AcceptMouseEventsOption)acceptsMouseEventsOption {
- }
-
- - (BOOL)acceptsFirstMouse:(NSEvent*)theEvent {
- + if ([self.window respondsToSelector:@selector(acceptsFirstMouse)] &&
- + [self.window acceptsFirstMouse])
- + return YES;
- // Enable "click-through" if mouse clicks are accepted in inactive windows
- return [self acceptsMouseEventsOption] > kAcceptMouseEventsInActiveWindow;
- }
- @@ -934,6 +946,10 @@ - (BOOL)shouldIgnoreMouseEvent:(NSEvent*)theEvent {
- // its parent view.
- BOOL hitSelf = NO;
- while (view) {
- + if ([view respondsToSelector:@selector(shouldIgnoreMouseEvent)] && ![view shouldIgnoreMouseEvent]) {
- + return NO;
- + }
- +
- if (view == self)
- hitSelf = YES;
- if ([view isKindOfClass:[self class]] && ![view isEqual:self] &&
- @@ -1268,6 +1284,10 @@ - (void)keyEvent:(NSEvent*)theEvent wasKeyEquivalent:(BOOL)equiv {
- eventType == NSEventTypeKeyDown &&
- !(modifierFlags & NSEventModifierFlagCommand);
-
- + if ([theEvent.window respondsToSelector:@selector(disableAutoHideCursor)] &&
- + [theEvent.window disableAutoHideCursor])
- + shouldAutohideCursor = NO;
- +
- // We only handle key down events and just simply forward other events.
- if (eventType != NSEventTypeKeyDown) {
- _hostHelper->ForwardKeyboardEvent(event, latencyInfo);
|