2018-10-24 18:24:11 +00:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
2018-09-21 00:30:26 +00:00
|
|
|
From: Cheng Zhao <zcbenz@gmail.com>
|
|
|
|
Date: Thu, 20 Sep 2018 17:46:28 -0700
|
|
|
|
Subject: render_widget_host_view_mac.patch
|
|
|
|
|
2019-12-13 17:18:45 +00:00
|
|
|
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`.
|
|
|
|
|
|
|
|
Additionally, disables usage of some private APIs in MAS builds.
|
2018-09-21 00:30:26 +00:00
|
|
|
|
2019-05-13 18:49:01 +00:00
|
|
|
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
|
2022-10-03 20:21:00 +00:00
|
|
|
index 1f5898124ca5ab45349dd4749c1b33a10723d46a..3c70ba4663b0176167a32e588dfd2840ba13362c 100644
|
2019-05-13 18:49:01 +00:00
|
|
|
--- a/content/app_shim_remote_cocoa/render_widget_host_view_cocoa.mm
|
|
|
|
+++ b/content/app_shim_remote_cocoa/render_widget_host_view_cocoa.mm
|
2022-10-03 20:21:00 +00:00
|
|
|
@@ -158,6 +158,15 @@ void ExtractUnderlines(NSAttributedString* string,
|
2018-09-14 05:02:16 +00:00
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
+@interface NSWindow (AtomCustomMethods)
|
|
|
|
+- (BOOL)acceptsFirstMouse;
|
|
|
|
+- (BOOL)disableAutoHideCursor;
|
|
|
|
+@end
|
2020-11-17 04:41:37 +00:00
|
|
|
+
|
|
|
|
+@interface NSView (ElectronCustomMethods)
|
|
|
|
+- (BOOL)shouldIgnoreMouseEvent;
|
|
|
|
+@end
|
2018-09-14 05:02:16 +00:00
|
|
|
+
|
2022-08-17 18:35:53 +00:00
|
|
|
// RenderWidgetHostViewCocoa ---------------------------------------------------
|
|
|
|
|
|
|
|
// Private methods:
|
2022-10-03 20:21:00 +00:00
|
|
|
@@ -599,6 +608,9 @@ - (BOOL)acceptsMouseEventsWhenInactive {
|
2018-09-14 05:02:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)acceptsFirstMouse:(NSEvent*)theEvent {
|
|
|
|
+ if ([self.window respondsToSelector:@selector(acceptsFirstMouse)] &&
|
|
|
|
+ [self.window acceptsFirstMouse])
|
|
|
|
+ return YES;
|
|
|
|
return [self acceptsMouseEventsWhenInactive];
|
|
|
|
}
|
|
|
|
|
2022-10-03 20:21:00 +00:00
|
|
|
@@ -675,6 +687,10 @@ - (BOOL)shouldIgnoreMouseEvent:(NSEvent*)theEvent {
|
2020-11-17 04:41:37 +00:00
|
|
|
// 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] &&
|
2022-10-03 20:21:00 +00:00
|
|
|
@@ -994,6 +1010,10 @@ - (void)keyEvent:(NSEvent*)theEvent wasKeyEquivalent:(BOOL)equiv {
|
2022-06-01 06:12:47 +00:00
|
|
|
eventType == NSEventTypeKeyDown &&
|
|
|
|
!(modifierFlags & NSEventModifierFlagCommand);
|
2018-09-14 05:02:16 +00:00
|
|
|
|
|
|
|
+ if ([theEvent.window respondsToSelector:@selector(disableAutoHideCursor)] &&
|
|
|
|
+ [theEvent.window disableAutoHideCursor])
|
|
|
|
+ shouldAutohideCursor = NO;
|
|
|
|
+
|
|
|
|
// We only handle key down events and just simply forward other events.
|
2022-06-01 06:12:47 +00:00
|
|
|
if (eventType != NSEventTypeKeyDown) {
|
2019-12-13 20:13:12 +00:00
|
|
|
_hostHelper->ForwardKeyboardEvent(event, latency_info);
|
2022-10-03 20:21:00 +00:00
|
|
|
@@ -1818,9 +1838,11 @@ - (NSAccessibilityRole)accessibilityRole {
|
2018-09-14 05:02:16 +00:00
|
|
|
// Since this implementation doesn't have to wait any IPC calls, this doesn't
|
|
|
|
// make any key-typing jank. --hbono 7/23/09
|
|
|
|
//
|
|
|
|
+#ifndef MAS_BUILD
|
|
|
|
extern "C" {
|
|
|
|
extern NSString* NSTextInputReplacementRangeAttributeName;
|
|
|
|
}
|
|
|
|
+#endif
|
|
|
|
|
|
|
|
- (NSArray*)validAttributesForMarkedText {
|
|
|
|
// This code is just copied from WebKit except renaming variables.
|
2022-10-03 20:21:00 +00:00
|
|
|
@@ -1829,7 +1851,10 @@ - (NSArray*)validAttributesForMarkedText {
|
2018-09-14 05:02:16 +00:00
|
|
|
initWithObjects:NSUnderlineStyleAttributeName,
|
|
|
|
NSUnderlineColorAttributeName,
|
|
|
|
NSMarkedClauseSegmentAttributeName,
|
|
|
|
- NSTextInputReplacementRangeAttributeName, nil]);
|
|
|
|
+#ifndef MAS_BUILD
|
|
|
|
+ NSTextInputReplacementRangeAttributeName,
|
|
|
|
+#endif
|
|
|
|
+ nil]);
|
|
|
|
}
|
2019-12-13 20:13:12 +00:00
|
|
|
return _validAttributesForMarkedText.get();
|
2018-09-14 05:02:16 +00:00
|
|
|
}
|