72 lines
2.9 KiB
Diff
72 lines
2.9 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`.
|
|
|
|
Additionally, disables usage of some private APIs in MAS builds.
|
|
|
|
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 01159a8b5b28858e899808cc57862e54dd998b48..ff122c32e18fc16efd7c376d38499c1d69fab635 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
|
|
@@ -153,6 +153,11 @@ void ExtractUnderlines(NSAttributedString* string,
|
|
|
|
} // namespace
|
|
|
|
+@interface NSWindow (AtomCustomMethods)
|
|
+- (BOOL)acceptsFirstMouse;
|
|
+- (BOOL)disableAutoHideCursor;
|
|
+@end
|
|
+
|
|
// These are not documented, so use only after checking -respondsToSelector:.
|
|
@interface NSApplication (UndocumentedSpeechMethods)
|
|
- (void)speakString:(NSString*)string;
|
|
@@ -572,6 +577,9 @@ - (BOOL)acceptsMouseEventsWhenInactive {
|
|
}
|
|
|
|
- (BOOL)acceptsFirstMouse:(NSEvent*)theEvent {
|
|
+ if ([self.window respondsToSelector:@selector(acceptsFirstMouse)] &&
|
|
+ [self.window acceptsFirstMouse])
|
|
+ return YES;
|
|
return [self acceptsMouseEventsWhenInactive];
|
|
}
|
|
|
|
@@ -990,6 +998,10 @@ - (void)keyEvent:(NSEvent*)theEvent wasKeyEquivalent:(BOOL)equiv {
|
|
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) {
|
|
_hostHelper->ForwardKeyboardEvent(event, latency_info);
|
|
@@ -1769,9 +1781,11 @@ - (NSAccessibilityRole)accessibilityRole {
|
|
// 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.
|
|
@@ -1780,7 +1794,10 @@ - (NSArray*)validAttributesForMarkedText {
|
|
initWithObjects:NSUnderlineStyleAttributeName,
|
|
NSUnderlineColorAttributeName,
|
|
NSMarkedClauseSegmentAttributeName,
|
|
- NSTextInputReplacementRangeAttributeName, nil]);
|
|
+#ifndef MAS_BUILD
|
|
+ NSTextInputReplacementRangeAttributeName,
|
|
+#endif
|
|
+ nil]);
|
|
}
|
|
return _validAttributesForMarkedText.get();
|
|
}
|