summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorthakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-10 20:05:29 +0000
committerthakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-10 20:05:29 +0000
commit1aff9b7acb4f40dc23daa43b98405f621d8b9a62 (patch)
tree12e2d86cdea7a915e0c5359ea564eecb02ca748e /chrome
parent8e6d090a58311a404ae44519bb9d2c8684799b20 (diff)
downloadchromium_src-1aff9b7acb4f40dc23daa43b98405f621d8b9a62.zip
chromium_src-1aff9b7acb4f40dc23daa43b98405f621d8b9a62.tar.gz
chromium_src-1aff9b7acb4f40dc23daa43b98405f621d8b9a62.tar.bz2
Make mouse cursor temporarily hide on keyboard input.
Note: We are very liberal in hiding the mouse cursor, much like Preview and some other apps. Safari is much more conservative (e.g., press "x" in random text content), but for us to do that we'd have to wire up the renderer to tell us when to hide the cursor. BUG=14077 TEST=Give web content keyboard focus, press various keys. Patch by viettrungluu@gmail.com Review URL: http://codereview.chromium.org/165252 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@22941 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/renderer_host/render_widget_host_view_mac.mm12
1 files changed, 12 insertions, 0 deletions
diff --git a/chrome/browser/renderer_host/render_widget_host_view_mac.mm b/chrome/browser/renderer_host/render_widget_host_view_mac.mm
index ea3bf8f..ae77260 100644
--- a/chrome/browser/renderer_host/render_widget_host_view_mac.mm
+++ b/chrome/browser/renderer_host/render_widget_host_view_mac.mm
@@ -23,6 +23,7 @@ using WebKit::WebMouseEvent;
using WebKit::WebMouseWheelEvent;
@interface RenderWidgetHostViewCocoa (Private)
++ (BOOL)shouldAutohideCursorForEvent:(NSEvent*)event;
- (id)initWithRenderWidgetHostViewMac:(RenderWidgetHostViewMac*)r;
- (void)cancelChildPopups;
@end
@@ -495,6 +496,10 @@ void RenderWidgetHostViewMac::SetActive(bool active) {
// (See <https://bugs.webkit.org/show_bug.cgi?id=25119>).
if ([theEvent type] == NSKeyDown)
[self interpretKeyEvents:[NSArray arrayWithObject:theEvent]];
+
+ // Possibly autohide the cursor.
+ if ([RenderWidgetHostViewCocoa shouldAutohideCursorForEvent:theEvent])
+ [NSCursor setHiddenUntilMouseMoves:YES];
}
- (void)scrollWheel:(NSEvent *)theEvent {
@@ -667,6 +672,13 @@ void RenderWidgetHostViewMac::SetActive(bool active) {
return renderWidgetHostView_;
}
+// Determine whether we should autohide the cursor (i.e., hide it until mouse
+// move) for the given event. Customize here to be more selective about which
+// key presses to autohide on.
++ (BOOL)shouldAutohideCursorForEvent:(NSEvent*)event {
+ return ([event type] == NSKeyDown) ? YES : NO;
+}
+
// Below is the nasty tooltip stuff -- copied from WebKit's WebHTMLView.mm
// with minor modifications for code style and commenting.