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
|
2023-10-24 15:24:20 +00:00
|
|
|
index 81f705328efd2de0957c1ef309e20c421e0959eb..d6f9998890d7a83a8fb221691aa2f1e761461d52 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
|
2023-10-24 15:24:20 +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:
|
2023-10-24 15:24:20 +00:00
|
|
|
@@ -746,6 +755,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];
|
|
|
|
}
|
|
|
|
|
2023-10-24 15:24:20 +00:00
|
|
|
@@ -830,6 +842,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] &&
|
2023-10-24 15:24:20 +00:00
|
|
|
@@ -1159,6 +1175,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);
|
2023-10-24 15:24:20 +00:00
|
|
|
@@ -1999,15 +2019,21 @@ - (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
|
|
|
|
//
|
2022-11-14 20:46:52 +00:00
|
|
|
+#if !IS_MAS_BUILD()
|
2018-09-14 05:02:16 +00:00
|
|
|
extern "C" {
|
|
|
|
extern NSString* NSTextInputReplacementRangeAttributeName;
|
|
|
|
}
|
|
|
|
+#endif
|
|
|
|
|
|
|
|
- (NSArray*)validAttributesForMarkedText {
|
|
|
|
// This code is just copied from WebKit except renaming variables.
|
2023-07-16 14:14:43 +00:00
|
|
|
static NSArray* const kAttributes = @[
|
|
|
|
NSUnderlineStyleAttributeName, NSUnderlineColorAttributeName,
|
2022-11-14 20:46:52 +00:00
|
|
|
+#if !IS_MAS_BUILD()
|
2023-07-16 14:14:43 +00:00
|
|
|
NSMarkedClauseSegmentAttributeName, NSTextInputReplacementRangeAttributeName
|
|
|
|
+#else
|
|
|
|
+ NSMarkedClauseSegmentAttributeName
|
2018-09-14 05:02:16 +00:00
|
|
|
+#endif
|
2023-07-16 14:14:43 +00:00
|
|
|
];
|
|
|
|
return kAttributes;
|
2018-09-14 05:02:16 +00:00
|
|
|
}
|