diff options
author | sadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-27 20:03:03 +0000 |
---|---|---|
committer | sadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-27 20:03:03 +0000 |
commit | b8b74d1a72f7b5bdcf6b2b6ac282e4a94b6430ec (patch) | |
tree | abdf0e3db5802113b233f3984a6870a73a807682 | |
parent | 79f0fa75f75e4280240927ef8b98192854350f87 (diff) | |
download | chromium_src-b8b74d1a72f7b5bdcf6b2b6ac282e4a94b6430ec.zip chromium_src-b8b74d1a72f7b5bdcf6b2b6ac282e4a94b6430ec.tar.gz chromium_src-b8b74d1a72f7b5bdcf6b2b6ac282e4a94b6430ec.tar.bz2 |
touch: Fix default cursor on re-display.
Unsetting the invisible cursor may not restore the default cursor for the
window. So restore the arrow cursor for the root window when making the cursor
visible again. If child windows had requested other cursors (e.g. hand cursor
for RWHVV) then that is automatically restored.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/6357023
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@72871 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | views/touchui/touch_factory.cc | 26 | ||||
-rw-r--r-- | views/touchui/touch_factory.h | 3 |
2 files changed, 15 insertions, 14 deletions
diff --git a/views/touchui/touch_factory.cc b/views/touchui/touch_factory.cc index 663fb98..99c2ec5 100644 --- a/views/touchui/touch_factory.cc +++ b/views/touchui/touch_factory.cc @@ -4,7 +4,7 @@ #include "views/touchui/touch_factory.h" -#include <gdk/gdkx.h> +#include <X11/cursorfont.h> #include <X11/extensions/XInput2.h> #include "base/compiler_specific.h" @@ -25,22 +25,24 @@ TouchFactory::TouchFactory() : is_cursor_visible_(true), cursor_timer_(), touch_device_list_() { - Pixmap blank; + char nodata[] = { 0, 0, 0, 0, 0, 0, 0, 0 }; XColor black; - static char nodata[] = { 0,0,0,0,0,0,0,0 }; black.red = black.green = black.blue = 0; Display* display = ui::GetXDisplay(); - - blank = XCreateBitmapFromData(display, ui::GetX11RootWindow(), nodata, 8, 8); + Pixmap blank = XCreateBitmapFromData(display, ui::GetX11RootWindow(), + nodata, 8, 8); invisible_cursor_ = XCreatePixmapCursor(display, blank, blank, &black, &black, 0, 0); + arrow_cursor_ = XCreateFontCursor(display, XC_arrow); SetCursorVisible(false, false); } TouchFactory::~TouchFactory() { SetCursorVisible(true, false); - XFreeCursor(ui::GetXDisplay(), invisible_cursor_); + Display* display = ui::GetXDisplay(); + XFreeCursor(display, invisible_cursor_); + XFreeCursor(display, arrow_cursor_); } void TouchFactory::SetTouchDeviceList( @@ -113,17 +115,13 @@ void TouchFactory::SetCursorVisible(bool show, bool start_timer) { is_cursor_visible_ = show; - GdkDisplay* display = gdk_display_get_default(); - if (!display) - return; - - Display* xdisplay = GDK_DISPLAY_XDISPLAY(display); - Window window = DefaultRootWindow(xdisplay); + Display* display = ui::GetXDisplay(); + Window window = DefaultRootWindow(display); if (is_cursor_visible_) { - XUndefineCursor(xdisplay, window); + XDefineCursor(display, window, arrow_cursor_); } else { - XDefineCursor(xdisplay, window, invisible_cursor_); + XDefineCursor(display, window, invisible_cursor_); } } diff --git a/views/touchui/touch_factory.h b/views/touchui/touch_factory.h index 228812a..b3e32ef 100644 --- a/views/touchui/touch_factory.h +++ b/views/touchui/touch_factory.h @@ -71,6 +71,9 @@ class TouchFactory { // is used to keep track of the idleness. base::OneShotTimer<TouchFactory> cursor_timer_; + // The default cursor. + Cursor arrow_cursor_; + // The invisible cursor. Cursor invisible_cursor_; |