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-07-13 21:26:16 +00:00
|
|
|
index 77b20580138a8b3365e82239e9c2b8af7f0e2c05..5c583a2f85565fb52d9cea21c2d08e39fe14086e 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-05-17 16:48:40 +00:00
|
|
|
@@ -155,6 +155,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;
|
2022-06-01 06:12:47 +00:00
|
|
|
@@ -602,6 +611,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-06-01 06:12:47 +00:00
|
|
|
@@ -678,6 +690,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-06-01 06:12:47 +00:00
|
|
|
@@ -997,6 +1013,10 @@ - (void)keyEvent:(NSEvent*)theEvent wasKeyEquivalent:(BOOL)equiv {
|
|
|
|
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-06-27 20:50:08 +00:00
|
|
|
@@ -1778,9 +1798,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-06-27 20:50:08 +00:00
|
|
|
@@ -1789,7 +1811,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
|
|
|
}
|