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
|
2021-03-04 23:46:13 +00:00
|
|
|
index 867eebe26002856bcdc1fcb33ef2619603adbb62..7255671200d83ae4438bed28dbb8eae558b94b47 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
|
2020-12-14 18:57:36 +00:00
|
|
|
@@ -153,6 +153,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
|
|
|
+
|
|
|
|
// These are not documented, so use only after checking -respondsToSelector:.
|
|
|
|
@interface NSApplication (UndocumentedSpeechMethods)
|
|
|
|
- (void)speakString:(NSString*)string;
|
2021-02-09 20:16:21 +00:00
|
|
|
@@ -571,6 +580,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];
|
|
|
|
}
|
|
|
|
|
2021-02-09 20:16:21 +00:00
|
|
|
@@ -646,6 +658,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] &&
|
2021-03-04 23:46:13 +00:00
|
|
|
@@ -999,6 +1015,10 @@ - (void)keyEvent:(NSEvent*)theEvent wasKeyEquivalent:(BOOL)equiv {
|
2018-09-14 05:02:16 +00:00
|
|
|
eventType == NSKeyDown &&
|
|
|
|
!(modifierFlags & NSCommandKeyMask);
|
|
|
|
|
|
|
|
+ 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 != NSKeyDown) {
|
2019-12-13 20:13:12 +00:00
|
|
|
_hostHelper->ForwardKeyboardEvent(event, latency_info);
|
2021-03-04 23:46:13 +00:00
|
|
|
@@ -1727,9 +1747,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.
|
2021-03-04 23:46:13 +00:00
|
|
|
@@ -1738,7 +1760,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
|
|
|
}
|