| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/base/cursor/cursor_loader_x11.h" | 5 #include "ui/base/cursor/cursor_loader_x11.h" |
| 6 | 6 |
| 7 #include <float.h> | 7 #include <float.h> |
| 8 #include <X11/cursorfont.h> | 8 #include <X11/cursorfont.h> |
| 9 #include <X11/Xlib.h> | 9 #include <X11/Xlib.h> |
| 10 | 10 |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "build/build_config.h" | 12 #include "build/build_config.h" |
| 13 #include "skia/ext/image_operations.h" | 13 #include "skia/ext/image_operations.h" |
| 14 #include "ui/base/cursor/cursor.h" | 14 #include "ui/base/cursor/cursor.h" |
| 15 #include "ui/base/cursor/cursor_util.h" | 15 #include "ui/base/cursor/cursor_util.h" |
| 16 #include "ui/base/x/x11_util.h" | 16 #include "ui/base/x/x11_util.h" |
| 17 #include "ui/display/display.h" |
| 17 #include "ui/gfx/geometry/point_conversions.h" | 18 #include "ui/gfx/geometry/point_conversions.h" |
| 18 #include "ui/gfx/geometry/size_conversions.h" | 19 #include "ui/gfx/geometry/size_conversions.h" |
| 19 #include "ui/gfx/image/image.h" | 20 #include "ui/gfx/image/image.h" |
| 20 #include "ui/gfx/skbitmap_operations.h" | 21 #include "ui/gfx/skbitmap_operations.h" |
| 21 #include "ui/gfx/skia_util.h" | 22 #include "ui/gfx/skia_util.h" |
| 22 | 23 |
| 23 namespace { | 24 namespace { |
| 24 | 25 |
| 25 // Returns X font cursor shape from an Aura cursor. | 26 // Returns X font cursor shape from an Aura cursor. |
| 26 int CursorShapeFromNative(const gfx::NativeCursor& native_cursor) { | 27 int CursorShapeFromNative(const gfx::NativeCursor& native_cursor) { |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 void CursorLoaderX11::SetPlatformCursor(gfx::NativeCursor* cursor) { | 203 void CursorLoaderX11::SetPlatformCursor(gfx::NativeCursor* cursor) { |
| 203 DCHECK(cursor); | 204 DCHECK(cursor); |
| 204 | 205 |
| 205 ::Cursor xcursor; | 206 ::Cursor xcursor; |
| 206 if (IsImageCursor(*cursor)) | 207 if (IsImageCursor(*cursor)) |
| 207 xcursor = ImageCursorFromNative(*cursor); | 208 xcursor = ImageCursorFromNative(*cursor); |
| 208 else if (*cursor == kCursorNone) | 209 else if (*cursor == kCursorNone) |
| 209 xcursor = invisible_cursor_.get(); | 210 xcursor = invisible_cursor_.get(); |
| 210 else if (*cursor == kCursorCustom) | 211 else if (*cursor == kCursorCustom) |
| 211 xcursor = cursor->platform(); | 212 xcursor = cursor->platform(); |
| 212 else if (scale() == 1.0f && rotation() == gfx::Display::ROTATE_0) { | 213 else if (scale() == 1.0f && rotation() == display::Display::ROTATE_0) { |
| 213 xcursor = GetXCursor(CursorShapeFromNative(*cursor)); | 214 xcursor = GetXCursor(CursorShapeFromNative(*cursor)); |
| 214 } else { | 215 } else { |
| 215 xcursor = ImageCursorFromNative(kCursorPointer); | 216 xcursor = ImageCursorFromNative(kCursorPointer); |
| 216 } | 217 } |
| 217 | 218 |
| 218 cursor->SetPlatformCursor(xcursor); | 219 cursor->SetPlatformCursor(xcursor); |
| 219 } | 220 } |
| 220 | 221 |
| 221 const XcursorImage* CursorLoaderX11::GetXcursorImageForTest(int id) { | 222 const XcursorImage* CursorLoaderX11::GetXcursorImageForTest(int id) { |
| 222 return test::GetCachedXcursorImage(cursors_[id]); | 223 return test::GetCachedXcursorImage(cursors_[id]); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 233 if (animated_cursors_.count(type)) | 234 if (animated_cursors_.count(type)) |
| 234 return animated_cursors_[type].first; | 235 return animated_cursors_[type].first; |
| 235 | 236 |
| 236 ImageCursorMap::iterator find = cursors_.find(type); | 237 ImageCursorMap::iterator find = cursors_.find(type); |
| 237 if (find != cursors_.end()) | 238 if (find != cursors_.end()) |
| 238 return cursors_[type]; | 239 return cursors_[type]; |
| 239 return GetXCursor(CursorShapeFromNative(native_cursor)); | 240 return GetXCursor(CursorShapeFromNative(native_cursor)); |
| 240 } | 241 } |
| 241 | 242 |
| 242 } // namespace ui | 243 } // namespace ui |
| OLD | NEW |