Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to disable hiding cursor when typing #1520

Merged
merged 3 commits into from
Apr 29, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 8 additions & 12 deletions atom/browser/native_window_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -54,26 +54,19 @@ - (void)viewDidMoveToSuperview {
@interface AtomNSWindowDelegate : NSObject<NSWindowDelegate> {
@private
atom::NativeWindowMac* shell_;
BOOL acceptsFirstMouse_;
}
- (id)initWithShell:(atom::NativeWindowMac*)shell;
- (void)setAcceptsFirstMouse:(BOOL)accept;
@end

@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)
Expand Down Expand Up @@ -151,17 +144,15 @@ - (BOOL)windowShouldClose:(id)window {
return NO;
}

- (BOOL)acceptsFirstMouse:(NSEvent*)event {
return acceptsFirstMouse_;
}

@end

@interface AtomNSWindow : EventProcessingWindow {
@private
atom::NativeWindowMac* shell_;
bool enable_larger_than_screen_;
}
@property BOOL acceptsFirstMouse;
@property BOOL disableAutoHideCursor;
- (void)setShell:(atom::NativeWindowMac*)shell;
- (void)setEnableLargerThanScreen:(bool)enable;
@end
Expand Down Expand Up @@ -355,7 +346,12 @@ - (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 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;
Expand Down
3 changes: 3 additions & 0 deletions atom/common/options_switches.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
1 change: 1 addition & 0 deletions atom/common/options_switches.h
Original file line number Diff line number Diff line change
Expand Up @@ -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[];
Expand Down
5 changes: 3 additions & 2 deletions docs/api/browser-window.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down