Chromium Code Reviews| Index: ui/aura/root_window_host_linux.cc |
| diff --git a/ui/aura/root_window_host_linux.cc b/ui/aura/root_window_host_linux.cc |
| index 57f6394bfef26de22d21c9eb358a00656ce8303b..e4622b696641b00182716b03796686eaf60681f5 100644 |
| --- a/ui/aura/root_window_host_linux.cc |
| +++ b/ui/aura/root_window_host_linux.cc |
| @@ -152,9 +152,11 @@ int CursorShapeFromNative(gfx::NativeCursor native_cursor) { |
| case aura::kCursorZoomOut: |
| case aura::kCursorGrab: |
| case aura::kCursorGrabbing: |
| - case aura::kCursorCustom: |
| // TODO(jamescook): Need cursors for these. crbug.com/111650 |
| return XC_left_ptr; |
| + case aura::kCursorCustom: |
| + NOTREACHED(); |
| + return XC_left_ptr; |
| } |
| NOTREACHED(); |
| return XC_left_ptr; |
| @@ -273,6 +275,7 @@ RootWindowHostLinux::RootWindowHostLinux(const gfx::Rect& bounds) |
| xwindow_(0), |
| x_root_window_(DefaultRootWindow(xdisplay_)), |
| current_cursor_(aura::kCursorNull), |
| + custom_cursor_(0), |
| cursor_shown_(true), |
| bounds_(bounds) { |
| XSetWindowAttributes swa; |
| @@ -317,6 +320,11 @@ RootWindowHostLinux::RootWindowHostLinux(const gfx::Rect& bounds) |
| } |
| RootWindowHostLinux::~RootWindowHostLinux() { |
| + if (custom_cursor_) { |
| + ui::UnrefCustomXCursor(custom_cursor_); |
| + custom_cursor_ = 0; |
| + } |
| + |
| XDestroyWindow(xdisplay_, xwindow_); |
| // Clears XCursorCache. |
| @@ -542,14 +550,26 @@ void RootWindowHostLinux::SetCursor(gfx::NativeCursor cursor) { |
| return; |
| current_cursor_ = cursor; |
| - // Custom web cursors are handled directly. |
| - if (cursor == kCursorCustom) |
| - return; |
| + if (custom_cursor_) { |
| + ui::UnrefCustomXCursor(custom_cursor_); |
| + custom_cursor_ = 0; |
| + } |
| if (cursor_shown_) |
| SetCursorInternal(cursor); |
| } |
| +void RootWindowHostLinux::SetCustomCursor(const gfx::PlatformCursor& cursor) { |
| + if (custom_cursor_) |
| + ui::UnrefCustomXCursor(custom_cursor_); |
| + custom_cursor_ = cursor; |
| + if (custom_cursor_) |
|
Daniel Erat
2012/02/24 23:19:31
should this method CHECK(cursor)? i'm pretty sure
sadrul
2012/02/25 00:02:30
I just removed the if check here. The XCustomCurso
|
| + ui::RefCustomXCursor(custom_cursor_); |
| + current_cursor_ = kCursorCustom; |
| + if (cursor_shown_) |
| + SetCursorInternal(current_cursor_); |
| +} |
| + |
| void RootWindowHostLinux::ShowCursor(bool show) { |
| if (show == cursor_shown_) |
| return; |
| @@ -645,6 +665,8 @@ void RootWindowHostLinux::SetCursorInternal(gfx::NativeCursor cursor) { |
| ::Cursor xcursor = |
| cursor == kCursorNone ? |
| invisible_cursor_ : |
| + cursor == kCursorCustom ? |
| + custom_cursor_ : |
| ui::GetXCursor(CursorShapeFromNative(cursor)); |
| XDefineCursor(xdisplay_, xwindow_, xcursor); |
| } |