dbe170c665
* build: simplify mas patches * build: re-add configs
61 lines
2.4 KiB
Diff
61 lines
2.4 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Cheng Zhao <zcbenz@gmail.com>
|
|
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 81f705328efd2de0957c1ef309e20c421e0959eb..47afd2553bf76b5b185a4be131196d90cf9cad44 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
|
|
@@ -158,6 +158,15 @@ void ExtractUnderlines(NSAttributedString* string,
|
|
|
|
} // namespace
|
|
|
|
+@interface NSWindow (AtomCustomMethods)
|
|
+- (BOOL)acceptsFirstMouse;
|
|
+- (BOOL)disableAutoHideCursor;
|
|
+@end
|
|
+
|
|
+@interface NSView (ElectronCustomMethods)
|
|
+- (BOOL)shouldIgnoreMouseEvent;
|
|
+@end
|
|
+
|
|
// RenderWidgetHostViewCocoa ---------------------------------------------------
|
|
|
|
// Private methods:
|
|
@@ -746,6 +755,9 @@ - (BOOL)acceptsMouseEventsWhenInactive {
|
|
}
|
|
|
|
- (BOOL)acceptsFirstMouse:(NSEvent*)theEvent {
|
|
+ if ([self.window respondsToSelector:@selector(acceptsFirstMouse)] &&
|
|
+ [self.window acceptsFirstMouse])
|
|
+ return YES;
|
|
return [self acceptsMouseEventsWhenInactive];
|
|
}
|
|
|
|
@@ -830,6 +842,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] &&
|
|
@@ -1159,6 +1175,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, latency_info);
|