diff options
author | mazda@chromium.org <mazda@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-11 20:18:35 +0000 |
---|---|---|
committer | mazda@chromium.org <mazda@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-11 20:18:35 +0000 |
commit | 151ffdff429adc13dea9afbe18602745981a9dcc (patch) | |
tree | 65ea7ff184d3e543d2a6213e29a96119eed4081b /ui/base/x | |
parent | 843fe4276bb2a001d6bdbb74dda7ef44a707cec7 (diff) | |
download | chromium_src-151ffdff429adc13dea9afbe18602745981a9dcc.zip chromium_src-151ffdff429adc13dea9afbe18602745981a9dcc.tar.gz chromium_src-151ffdff429adc13dea9afbe18602745981a9dcc.tar.bz2 |
Move ash specific cursor code to CursorManager.
Main changes are as follows.
- Move the responsibility of managing cursors to ash::CursorManager from aura::RootWindowHostLinux.
- Set the same cursor to all root windows with CursorManager so that cursor is updated properly while dragging across displays
- Introduce CursorLoader class, which implements platform specific cursor loading.
- Add SetDeviceScaleFactor to CursorClient, which sets the device scale factor used for the cursor.
BUG=132862,144756
Review URL: https://chromiumcodereview.appspot.com/10919135
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@156109 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/base/x')
-rw-r--r-- | ui/base/x/events_x.cc | 4 | ||||
-rw-r--r-- | ui/base/x/x11_util.cc | 41 | ||||
-rw-r--r-- | ui/base/x/x11_util.h | 24 |
3 files changed, 69 insertions, 0 deletions
diff --git a/ui/base/x/events_x.cc b/ui/base/x/events_x.cc index dff3298..1dd3a66 100644 --- a/ui/base/x/events_x.cc +++ b/ui/base/x/events_x.cc @@ -775,6 +775,10 @@ base::TimeDelta EventTimeFromNative(const base::NativeEvent& native_event) { case MotionNotify: return base::TimeDelta::FromMilliseconds(native_event->xmotion.time); break; + case EnterNotify: + case LeaveNotify: + return base::TimeDelta::FromMilliseconds(native_event->xcrossing.time); + break; case GenericEvent: { double start, end; if (GetGestureTimes(native_event, &start, &end)) { diff --git a/ui/base/x/x11_util.cc b/ui/base/x/x11_util.cc index efe05af..05f50ec 100644 --- a/ui/base/x/x11_util.cc +++ b/ui/base/x/x11_util.cc @@ -453,6 +453,28 @@ XcursorImage* SkBitmapToXcursorImage(const SkBitmap* bitmap, } #endif +void HideHostCursor() { + CR_DEFINE_STATIC_LOCAL(XScopedCursor, invisible_cursor, + (CreateInvisibleCursor(), ui::GetXDisplay())); + XDefineCursor(ui::GetXDisplay(), DefaultRootWindow(ui::GetXDisplay()), + invisible_cursor.get()); +} + +::Cursor CreateInvisibleCursor() { + Display* xdisplay = ui::GetXDisplay(); + ::Cursor invisible_cursor; + char nodata[] = { 0, 0, 0, 0, 0, 0, 0, 0 }; + XColor black; + black.red = black.green = black.blue = 0; + Pixmap blank = XCreateBitmapFromData(xdisplay, + DefaultRootWindow(xdisplay), + nodata, 8, 8); + invisible_cursor = XCreatePixmapCursor(xdisplay, blank, blank, + &black, &black, 0, 0); + XFreePixmap(xdisplay, blank); + return invisible_cursor; +} + XID GetX11RootWindow() { return DefaultRootWindow(GetXDisplay()); } @@ -1352,6 +1374,25 @@ XScopedString::~XScopedString() { XFree(string_); } +XScopedCursor::XScopedCursor(::Cursor cursor, Display* display) + : cursor_(cursor), + display_(display) { +} + +XScopedCursor::~XScopedCursor() { + reset(0U); +} + +::Cursor XScopedCursor::get() const { + return cursor_; +} + +void XScopedCursor::reset(::Cursor cursor) { + if (cursor_) + XFreeCursor(display_, cursor_); + cursor_ = cursor; +} + // ---------------------------------------------------------------------------- // These functions are declared in x11_util_internal.h because they require // XLib.h to be included, and it conflicts with many other headers. diff --git a/ui/base/x/x11_util.h b/ui/base/x/x11_util.h index 869ef7c..d6dc0c3 100644 --- a/ui/base/x/x11_util.h +++ b/ui/base/x/x11_util.h @@ -97,6 +97,12 @@ UI_EXPORT XcursorImage* SkBitmapToXcursorImage(const SkBitmap* bitmap, const gfx::Point& hotspot); #endif +// Hides the host cursor. +UI_EXPORT void HideHostCursor(); + +// Returns an invisible cursor. +UI_EXPORT ::Cursor CreateInvisibleCursor(); + // These functions do not cache their results -------------------------- // Get the X window id for the default root window @@ -319,6 +325,24 @@ class UI_EXPORT XScopedString { DISALLOW_COPY_AND_ASSIGN(XScopedString); }; +// Keeps track of a cursor returned by an X function and makes sure it's +// XFreeCursor'd. +class UI_EXPORT XScopedCursor { + public: + // Keeps track of |cursor| created with |display|. + XScopedCursor(::Cursor cursor, Display* display); + ~XScopedCursor(); + + ::Cursor get() const; + void reset(::Cursor cursor); + + private: + ::Cursor cursor_; + Display* display_; + + DISALLOW_COPY_AND_ASSIGN(XScopedCursor); +}; + } // namespace ui #endif // UI_BASE_X_X11_UTIL_H_ |