12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
- From: Cheng Zhao <[email protected]>
- 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 0bdd7c7813fdbbf148fe1fba2c38ef78d2923efc..c11453b8e3ce6345eead3b80c4f9036a1d07f5c7 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
- @@ -157,6 +157,15 @@ void ExtractUnderlines(NSAttributedString* string,
-
- } // namespace
-
- +@interface NSWindow (AtomCustomMethods)
- +- (BOOL)acceptsFirstMouse;
- +- (BOOL)disableAutoHideCursor;
- +@end
- +
- +@interface NSView (ElectronCustomMethods)
- +- (BOOL)shouldIgnoreMouseEvent;
- +@end
- +
- // RenderWidgetHostViewCocoa ---------------------------------------------------
-
- // Private methods:
- @@ -744,6 +753,9 @@ - (BOOL)acceptsMouseEventsWhenInactive {
- }
-
- - (BOOL)acceptsFirstMouse:(NSEvent*)theEvent {
- + if ([self.window respondsToSelector:@selector(acceptsFirstMouse)] &&
- + [self.window acceptsFirstMouse])
- + return YES;
- return [self acceptsMouseEventsWhenInactive];
- }
-
- @@ -820,6 +832,10 @@ - (BOOL)shouldIgnoreMouseEvent:(NSEvent*)theEvent {
- // 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] &&
- @@ -1139,6 +1155,10 @@ - (void)keyEvent:(NSEvent*)theEvent wasKeyEquivalent:(BOOL)equiv {
- eventType == NSEventTypeKeyDown &&
- !(modifierFlags & NSEventModifierFlagCommand);
-
- + 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 != NSEventTypeKeyDown) {
- _hostHelper->ForwardKeyboardEvent(event, latency_info);
- @@ -1970,15 +1990,21 @@ - (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
- //
- +#if !IS_MAS_BUILD()
- extern "C" {
- extern NSString* NSTextInputReplacementRangeAttributeName;
- }
- +#endif
-
- - (NSArray*)validAttributesForMarkedText {
- // This code is just copied from WebKit except renaming variables.
- static NSArray* const kAttributes = @[
- NSUnderlineStyleAttributeName, NSUnderlineColorAttributeName,
- +#if !IS_MAS_BUILD()
- NSMarkedClauseSegmentAttributeName, NSTextInputReplacementRangeAttributeName
- +#else
- + NSMarkedClauseSegmentAttributeName
- +#endif
- ];
- return kAttributes;
- }
|