OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef UI_BASE_CURSOR_CURSOR_LOADER_X11_H_ |
| 6 #define UI_BASE_CURSOR_CURSOR_LOADER_X11_H_ |
| 7 |
| 8 #include <X11/Xcursor/Xcursor.h> |
| 9 #include <map> |
| 10 |
| 11 #include "base/compiler_specific.h" |
| 12 #include "ui/base/cursor/cursor.h" |
| 13 #include "ui/base/cursor/cursor_loader.h" |
| 14 |
| 15 namespace ui { |
| 16 |
| 17 class CursorLoaderX11 : public CursorLoader { |
| 18 public: |
| 19 CursorLoaderX11(); |
| 20 virtual ~CursorLoaderX11(); |
| 21 |
| 22 // Overridden from CursorLoader: |
| 23 virtual void LoadImageCursor(int id, |
| 24 int resource_id, |
| 25 const gfx::Point& hot) OVERRIDE; |
| 26 virtual void LoadAnimatedCursor(int id, |
| 27 int resource_id, |
| 28 const gfx::Point& hot, |
| 29 int frame_delay_ms) OVERRIDE; |
| 30 virtual void UnloadAll() OVERRIDE; |
| 31 virtual void SetPlatformCursor(gfx::NativeCursor* cursor) OVERRIDE; |
| 32 |
| 33 private: |
| 34 // Returns true if we have an image resource loaded for the |native_cursor|. |
| 35 bool IsImageCursor(gfx::NativeCursor native_cursor); |
| 36 |
| 37 // Gets the X Cursor corresponding to the |native_cursor|. |
| 38 ::Cursor ImageCursorFromNative(gfx::NativeCursor native_cursor); |
| 39 |
| 40 // A map to hold all image cursors. It maps the cursor ID to the X Cursor. |
| 41 typedef std::map<int, ::Cursor> ImageCursorMap; |
| 42 ImageCursorMap cursors_; |
| 43 |
| 44 // A map to hold all animated cursors. It maps the cursor ID to the pair of |
| 45 // the X Cursor and the corresponding XcursorImages. We need a pointer to the |
| 46 // images so that we can free them on destruction. |
| 47 typedef std::map<int, std::pair< ::Cursor, XcursorImages*> > |
| 48 AnimatedCursorMap; |
| 49 AnimatedCursorMap animated_cursors_; |
| 50 |
| 51 ::Cursor invisible_cursor_; |
| 52 |
| 53 DISALLOW_COPY_AND_ASSIGN(CursorLoaderX11); |
| 54 }; |
| 55 |
| 56 } // namespace ui |
| 57 |
| 58 #endif // UI_BASE_CURSOR_CURSOR_LOADER_X11_H_ |
OLD | NEW |