diff options
author | sadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-26 22:24:20 +0000 |
---|---|---|
committer | sadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-26 22:24:20 +0000 |
commit | cdfc519ae46a03b916535c891cd60a5a1cf53376 (patch) | |
tree | a57fc6fb86cafa2f55e5344b7f57467ab6e2139a /views/focus | |
parent | c931d526dc0b7c7c871e6fc408775feb63493fd1 (diff) | |
download | chromium_src-cdfc519ae46a03b916535c891cd60a5a1cf53376.zip chromium_src-cdfc519ae46a03b916535c891cd60a5a1cf53376.tar.gz chromium_src-cdfc519ae46a03b916535c891cd60a5a1cf53376.tar.bz2 |
touch: Hide the X cursor when not in use.
The default X cursor is hidden at startup, and when not in use for 5 seconds. It
is immediately displayed if there is an event from a mouse device, and it's
immediately hidden if there is an event from a touch device.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/6242012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@72702 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/focus')
-rw-r--r-- | views/focus/accelerator_handler_touch.cc | 66 |
1 files changed, 48 insertions, 18 deletions
diff --git a/views/focus/accelerator_handler_touch.cc b/views/focus/accelerator_handler_touch.cc index b24d8f0..4532034f 100644 --- a/views/focus/accelerator_handler_touch.cc +++ b/views/focus/accelerator_handler_touch.cc @@ -62,18 +62,22 @@ bool X2EventIsTouchEvent(XEvent* xev) { #if defined(HAVE_XINPUT2) bool DispatchX2Event(RootView* root, XEvent* xev) { + XGenericEventCookie* cookie = &xev->xcookie; + bool touch_event = false; + if (X2EventIsTouchEvent(xev)) { + // Hide the cursor when a touch event comes in. + TouchFactory::GetInstance()->SetCursorVisible(false, false); + touch_event = true; + // Create a TouchEvent, and send it off to |root|. If the event // is processed by |root|, then return. Otherwise let it fall through so it // can be used (if desired) as a mouse event. - TouchEvent touch(xev); if (root->OnTouchEvent(touch) != views::View::TOUCH_STATUS_UNKNOWN) return true; } - XGenericEventCookie* cookie = &xev->xcookie; - switch (cookie->evtype) { case XI_KeyPress: case XI_KeyRelease: { @@ -81,25 +85,51 @@ bool DispatchX2Event(RootView* root, XEvent* xev) { break; } case XI_ButtonPress: - case XI_ButtonRelease: { + case XI_ButtonRelease: + case XI_Motion: { MouseEvent mouseev(xev); - if (cookie->evtype == XI_ButtonPress) { - return root->OnMousePressed(mouseev); - } else { - root->OnMouseReleased(mouseev, false); - return true; + if (!touch_event) { + // Show the cursor, and decide whether or not the cursor should be + // automatically hidden after a certain time of inactivity. + int button_flags = mouseev.GetFlags() & (Event::EF_RIGHT_BUTTON_DOWN | + Event::EF_MIDDLE_BUTTON_DOWN | Event::EF_LEFT_BUTTON_DOWN); + bool start_timer = false; + + switch (cookie->evtype) { + case XI_ButtonPress: + start_timer = false; + break; + case XI_ButtonRelease: + // For a release, start the timer if this was only button pressed + // that is being released. + if (button_flags == Event::EF_RIGHT_BUTTON_DOWN || + button_flags == Event::EF_LEFT_BUTTON_DOWN || + button_flags == Event::EF_MIDDLE_BUTTON_DOWN) + start_timer = true; + break; + case XI_Motion: + start_timer = !button_flags; + break; + } + TouchFactory::GetInstance()->SetCursorVisible(true, start_timer); } - } - case XI_Motion: { - MouseEvent mouseev(xev); - if (mouseev.GetType() == Event::ET_MOUSE_DRAGGED) { - return root->OnMouseDragged(mouseev); - } else { - root->OnMouseMoved(mouseev); - return true; + // Dispatch the event. + switch (cookie->evtype) { + case XI_ButtonPress: + return root->OnMousePressed(mouseev); + case XI_ButtonRelease: + root->OnMouseReleased(mouseev, false); + return true; + case XI_Motion: { + if (mouseev.GetType() == Event::ET_MOUSE_DRAGGED) { + return root->OnMouseDragged(mouseev); + } else { + root->OnMouseMoved(mouseev); + return true; + } + } } - break; } } |