From 3a50c9e48c1e99bc867815d84bb381f190a3934d Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 27 Apr 2015 11:47:26 +0800 Subject: [PATCH 1/3] Update to the new patch for acceptsFirstMouse --- atom/browser/native_window_mac.mm | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/atom/browser/native_window_mac.mm b/atom/browser/native_window_mac.mm index 946b2a41cdd43..12a147ebc2b33 100644 --- a/atom/browser/native_window_mac.mm +++ b/atom/browser/native_window_mac.mm @@ -54,10 +54,8 @@ - (void)viewDidMoveToSuperview { @interface AtomNSWindowDelegate : NSObject { @private atom::NativeWindowMac* shell_; - BOOL acceptsFirstMouse_; } - (id)initWithShell:(atom::NativeWindowMac*)shell; -- (void)setAcceptsFirstMouse:(BOOL)accept; @end @implementation AtomNSWindowDelegate @@ -65,15 +63,10 @@ @implementation AtomNSWindowDelegate - (id)initWithShell:(atom::NativeWindowMac*)shell { if ((self = [super init])) { shell_ = shell; - acceptsFirstMouse_ = NO; } return self; } -- (void)setAcceptsFirstMouse:(BOOL)accept { - acceptsFirstMouse_ = accept; -} - - (void)windowDidBecomeMain:(NSNotification*)notification { content::WebContents* web_contents = shell_->GetWebContents(); if (!web_contents) @@ -151,10 +144,6 @@ - (BOOL)windowShouldClose:(id)window { return NO; } -- (BOOL)acceptsFirstMouse:(NSEvent*)event { - return acceptsFirstMouse_; -} - @end @interface AtomNSWindow : EventProcessingWindow { @@ -162,6 +151,7 @@ @interface AtomNSWindow : EventProcessingWindow { atom::NativeWindowMac* shell_; bool enable_larger_than_screen_; } +@property BOOL acceptsFirstMouse; - (void)setShell:(atom::NativeWindowMac*)shell; - (void)setEnableLargerThanScreen:(bool)enable; @end @@ -355,7 +345,7 @@ - (void)drawRect:(NSRect)dirtyRect { // Enable the NSView to accept first mouse event. bool acceptsFirstMouse = false; options.Get(switches::kAcceptFirstMouse, &acceptsFirstMouse); - [window_delegate_ setAcceptsFirstMouse:acceptsFirstMouse]; + [window_ setAcceptsFirstMouse:acceptsFirstMouse]; // Disable fullscreen button when 'fullscreen' is specified to false. bool fullscreen; From c6cf91d11f6e570d513e592dfbceafe79a79ca77 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 27 Apr 2015 12:08:22 +0800 Subject: [PATCH 2/3] Add 'disable-auto-hide-cursor' option --- atom/browser/native_window_mac.mm | 6 ++++++ atom/common/options_switches.cc | 3 +++ atom/common/options_switches.h | 1 + 3 files changed, 10 insertions(+) diff --git a/atom/browser/native_window_mac.mm b/atom/browser/native_window_mac.mm index 12a147ebc2b33..b7eccd2a6c7c5 100644 --- a/atom/browser/native_window_mac.mm +++ b/atom/browser/native_window_mac.mm @@ -152,6 +152,7 @@ @interface AtomNSWindow : EventProcessingWindow { bool enable_larger_than_screen_; } @property BOOL acceptsFirstMouse; +@property BOOL disableAutoHideCursor; - (void)setShell:(atom::NativeWindowMac*)shell; - (void)setEnableLargerThanScreen:(bool)enable; @end @@ -347,6 +348,11 @@ - (void)drawRect:(NSRect)dirtyRect { options.Get(switches::kAcceptFirstMouse, &acceptsFirstMouse); [window_ setAcceptsFirstMouse:acceptsFirstMouse]; + // Disable auto-hiding cursor. + bool disableAutoHideCursor = false; + options.Get(switches::kDisableAutoHideCursor, &disableAutoHideCursor); + [window_ setDisableAutoHideCursor:disableAutoHideCursor]; + // Disable fullscreen button when 'fullscreen' is specified to false. bool fullscreen; if (!(options.Get(switches::kFullscreen, &fullscreen) && diff --git a/atom/common/options_switches.cc b/atom/common/options_switches.cc index f67a6456964cc..c479b5004d076 100644 --- a/atom/common/options_switches.cc +++ b/atom/common/options_switches.cc @@ -75,6 +75,9 @@ const char kTransparent[] = "transparent"; // Window type hint. const char kType[] = "type"; +// Disable auto-hiding cursor. +const char kDisableAutoHideCursor[] = "disable-auto-hide-cursor"; + // Web runtime features. const char kExperimentalFeatures[] = "experimental-features"; const char kExperimentalCanvasFeatures[] = "experimental-canvas-features"; diff --git a/atom/common/options_switches.h b/atom/common/options_switches.h index 967f626387335..546c6a04eb4d9 100644 --- a/atom/common/options_switches.h +++ b/atom/common/options_switches.h @@ -41,6 +41,7 @@ extern const char kGuestInstanceID[]; extern const char kPreloadScript[]; extern const char kTransparent[]; extern const char kType[]; +extern const char kDisableAutoHideCursor[]; extern const char kExperimentalFeatures[]; extern const char kExperimentalCanvasFeatures[]; From 75b24c7d7671c12699ec1a4dc8c07e2edd172b29 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Wed, 29 Apr 2015 10:28:42 +0800 Subject: [PATCH 3/3] docs: disable-auto-hide-cursor option --- docs/api/browser-window.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/api/browser-window.md b/docs/api/browser-window.md index 8e6262e9275a0..e4cec40f47cf5 100644 --- a/docs/api/browser-window.md +++ b/docs/api/browser-window.md @@ -54,9 +54,10 @@ You can also create a window without chrome by using * `frame` Boolean - Specify `false` to create a [Frameless Window](frameless-window.md) * `node-integration` Boolean - Whether node integration is enabled, default - is `true` + is `true` * `accept-first-mouse` Boolean - Whether the web view accepts a single - mouse-down event that simultaneously activates the window + mouse-down event that simultaneously activates the window + * `disable-auto-hide-cursor` Boolean - Do not hide cursor when typing * `auto-hide-menu-bar` Boolean - Auto hide the menu bar unless the `Alt` key is pressed. * `enable-larger-than-screen` Boolean - Enable the window to be resized larger