Merge pull request #1520 from atom/disable-auto-hide-cursor
Add option to disable hiding cursor when typing
This commit is contained in:
		
				commit
				
					
						3f499f69ff
					
				
			
		
					 4 changed files with 15 additions and 14 deletions
				
			
		|  | @ -54,10 +54,8 @@ static const CGFloat kAtomWindowCornerRadius = 4.0; | ||||||
| @interface AtomNSWindowDelegate : NSObject<NSWindowDelegate> { | @interface AtomNSWindowDelegate : NSObject<NSWindowDelegate> { | ||||||
|  @private |  @private | ||||||
|   atom::NativeWindowMac* shell_; |   atom::NativeWindowMac* shell_; | ||||||
|   BOOL acceptsFirstMouse_; |  | ||||||
| } | } | ||||||
| - (id)initWithShell:(atom::NativeWindowMac*)shell; | - (id)initWithShell:(atom::NativeWindowMac*)shell; | ||||||
| - (void)setAcceptsFirstMouse:(BOOL)accept; |  | ||||||
| @end | @end | ||||||
| 
 | 
 | ||||||
| @implementation AtomNSWindowDelegate | @implementation AtomNSWindowDelegate | ||||||
|  | @ -65,15 +63,10 @@ static const CGFloat kAtomWindowCornerRadius = 4.0; | ||||||
| - (id)initWithShell:(atom::NativeWindowMac*)shell { | - (id)initWithShell:(atom::NativeWindowMac*)shell { | ||||||
|   if ((self = [super init])) { |   if ((self = [super init])) { | ||||||
|     shell_ = shell; |     shell_ = shell; | ||||||
|     acceptsFirstMouse_ = NO; |  | ||||||
|   } |   } | ||||||
|   return self; |   return self; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| - (void)setAcceptsFirstMouse:(BOOL)accept { |  | ||||||
|   acceptsFirstMouse_ = accept; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| - (void)windowDidBecomeMain:(NSNotification*)notification { | - (void)windowDidBecomeMain:(NSNotification*)notification { | ||||||
|   content::WebContents* web_contents = shell_->GetWebContents(); |   content::WebContents* web_contents = shell_->GetWebContents(); | ||||||
|   if (!web_contents) |   if (!web_contents) | ||||||
|  | @ -151,10 +144,6 @@ static const CGFloat kAtomWindowCornerRadius = 4.0; | ||||||
|   return NO; |   return NO; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| - (BOOL)acceptsFirstMouse:(NSEvent*)event { |  | ||||||
|   return acceptsFirstMouse_; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| @end | @end | ||||||
| 
 | 
 | ||||||
| @interface AtomNSWindow : EventProcessingWindow { | @interface AtomNSWindow : EventProcessingWindow { | ||||||
|  | @ -162,6 +151,8 @@ static const CGFloat kAtomWindowCornerRadius = 4.0; | ||||||
|   atom::NativeWindowMac* shell_; |   atom::NativeWindowMac* shell_; | ||||||
|   bool enable_larger_than_screen_; |   bool enable_larger_than_screen_; | ||||||
| } | } | ||||||
|  | @property BOOL acceptsFirstMouse; | ||||||
|  | @property BOOL disableAutoHideCursor; | ||||||
| - (void)setShell:(atom::NativeWindowMac*)shell; | - (void)setShell:(atom::NativeWindowMac*)shell; | ||||||
| - (void)setEnableLargerThanScreen:(bool)enable; | - (void)setEnableLargerThanScreen:(bool)enable; | ||||||
| @end | @end | ||||||
|  | @ -355,7 +346,12 @@ NativeWindowMac::NativeWindowMac(content::WebContents* web_contents, | ||||||
|   // Enable the NSView to accept first mouse event. |   // Enable the NSView to accept first mouse event. | ||||||
|   bool acceptsFirstMouse = false; |   bool acceptsFirstMouse = false; | ||||||
|   options.Get(switches::kAcceptFirstMouse, &acceptsFirstMouse); |   options.Get(switches::kAcceptFirstMouse, &acceptsFirstMouse); | ||||||
|   [window_delegate_ setAcceptsFirstMouse: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. |   // Disable fullscreen button when 'fullscreen' is specified to false. | ||||||
|   bool fullscreen; |   bool fullscreen; | ||||||
|  |  | ||||||
|  | @ -75,6 +75,9 @@ const char kTransparent[] = "transparent"; | ||||||
| // Window type hint.
 | // Window type hint.
 | ||||||
| const char kType[] = "type"; | const char kType[] = "type"; | ||||||
| 
 | 
 | ||||||
|  | // Disable auto-hiding cursor.
 | ||||||
|  | const char kDisableAutoHideCursor[] = "disable-auto-hide-cursor"; | ||||||
|  | 
 | ||||||
| // Web runtime features.
 | // Web runtime features.
 | ||||||
| const char kExperimentalFeatures[]       = "experimental-features"; | const char kExperimentalFeatures[]       = "experimental-features"; | ||||||
| const char kExperimentalCanvasFeatures[] = "experimental-canvas-features"; | const char kExperimentalCanvasFeatures[] = "experimental-canvas-features"; | ||||||
|  |  | ||||||
|  | @ -41,6 +41,7 @@ extern const char kGuestInstanceID[]; | ||||||
| extern const char kPreloadScript[]; | extern const char kPreloadScript[]; | ||||||
| extern const char kTransparent[]; | extern const char kTransparent[]; | ||||||
| extern const char kType[]; | extern const char kType[]; | ||||||
|  | extern const char kDisableAutoHideCursor[]; | ||||||
| 
 | 
 | ||||||
| extern const char kExperimentalFeatures[]; | extern const char kExperimentalFeatures[]; | ||||||
| extern const char kExperimentalCanvasFeatures[]; | extern const char kExperimentalCanvasFeatures[]; | ||||||
|  |  | ||||||
|  | @ -57,6 +57,7 @@ You can also create a window without chrome by using | ||||||
|     is `true` |     is `true` | ||||||
|   * `accept-first-mouse` Boolean - Whether the web view accepts a single |   * `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` |   * `auto-hide-menu-bar` Boolean - Auto hide the menu bar unless the `Alt` | ||||||
|     key is pressed. |     key is pressed. | ||||||
|   * `enable-larger-than-screen` Boolean - Enable the window to be resized larger |   * `enable-larger-than-screen` Boolean - Enable the window to be resized larger | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Cheng Zhao
				Cheng Zhao