Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 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 ASH_WM_ASH_NATIVE_CURSOR_MANAGER_H_ |
| 6 | #define ASH_WM_ASH_NATIVE_CURSOR_MANAGER_H_ |
| 7 | |
| 8 | #include "ash/ash_export.h" |
| 9 | #include "base/basictypes.h" |
| 10 | #include "base/compiler_specific.h" |
| 11 | #include "base/memory/scoped_ptr.h" |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 12 | #include "base/strings/string16.h" |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 13 | #include "ui/gfx/native_widget_types.h" |
| 14 | #include "ui/gfx/point.h" |
Torne (Richard Coles) | a140131 | 2014-03-18 10:20:56 +0000 | [diff] [blame] | 15 | #include "ui/wm/core/native_cursor_manager.h" |
| 16 | #include "ui/wm/core/native_cursor_manager_delegate.h" |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 17 | |
Bo Liu | 5c02ac1 | 2014-05-01 10:37:37 -0700 | [diff] [blame] | 18 | namespace ui { |
| 19 | class ImageCursors; |
| 20 | } |
| 21 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 22 | namespace ash { |
| 23 | |
| 24 | namespace test { |
| 25 | class CursorManagerTestApi; |
| 26 | } |
| 27 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 28 | // This does the ash-specific setting of cursor details like cursor |
| 29 | // visibility. It communicates back with the CursorManager through the |
| 30 | // NativeCursorManagerDelegate interface, which receives messages about what |
| 31 | // changes were acted on. |
| 32 | class ASH_EXPORT AshNativeCursorManager |
Torne (Richard Coles) | a140131 | 2014-03-18 10:20:56 +0000 | [diff] [blame] | 33 | : public ::wm::NativeCursorManager { |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 34 | public: |
| 35 | AshNativeCursorManager(); |
| 36 | virtual ~AshNativeCursorManager(); |
| 37 | |
Torne (Richard Coles) | 5d1f7b1 | 2014-02-21 12:16:55 +0000 | [diff] [blame] | 38 | // Toggle native cursor enabled/disabled. |
| 39 | // The native cursor is enabled by default. When disabled, we hide the native |
| 40 | // cursor regardless of visibility state, and let CursorWindowManager draw |
| 41 | // the cursor. |
| 42 | void SetNativeCursorEnabled(bool enabled); |
| 43 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 44 | private: |
| 45 | friend class test::CursorManagerTestApi; |
| 46 | |
Torne (Richard Coles) | a140131 | 2014-03-18 10:20:56 +0000 | [diff] [blame] | 47 | // Overridden from ::wm::NativeCursorManager: |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 48 | virtual void SetDisplay( |
| 49 | const gfx::Display& display, |
Torne (Richard Coles) | a140131 | 2014-03-18 10:20:56 +0000 | [diff] [blame] | 50 | ::wm::NativeCursorManagerDelegate* delegate) OVERRIDE; |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 51 | virtual void SetCursor( |
| 52 | gfx::NativeCursor cursor, |
Torne (Richard Coles) | a140131 | 2014-03-18 10:20:56 +0000 | [diff] [blame] | 53 | ::wm::NativeCursorManagerDelegate* delegate) OVERRIDE; |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 54 | virtual void SetVisibility( |
| 55 | bool visible, |
Torne (Richard Coles) | a140131 | 2014-03-18 10:20:56 +0000 | [diff] [blame] | 56 | ::wm::NativeCursorManagerDelegate* delegate) OVERRIDE; |
Torne (Richard Coles) | 424c4d7 | 2013-08-30 15:14:49 +0100 | [diff] [blame] | 57 | virtual void SetCursorSet( |
| 58 | ui::CursorSetType cursor_set, |
Torne (Richard Coles) | a140131 | 2014-03-18 10:20:56 +0000 | [diff] [blame] | 59 | ::wm::NativeCursorManagerDelegate* delegate) OVERRIDE; |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 60 | virtual void SetMouseEventsEnabled( |
| 61 | bool enabled, |
Torne (Richard Coles) | a140131 | 2014-03-18 10:20:56 +0000 | [diff] [blame] | 62 | ::wm::NativeCursorManagerDelegate* delegate) OVERRIDE; |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 63 | |
| 64 | // The cursor location where the cursor was disabled. |
| 65 | gfx::Point disabled_cursor_location_; |
| 66 | |
Torne (Richard Coles) | 5d1f7b1 | 2014-02-21 12:16:55 +0000 | [diff] [blame] | 67 | bool native_cursor_enabled_; |
| 68 | |
Bo Liu | 5c02ac1 | 2014-05-01 10:37:37 -0700 | [diff] [blame] | 69 | scoped_ptr<ui::ImageCursors> image_cursors_; |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 70 | |
| 71 | DISALLOW_COPY_AND_ASSIGN(AshNativeCursorManager); |
| 72 | }; |
| 73 | |
| 74 | } // namespace ash |
| 75 | |
| 76 | #endif // ASH_WM_ASH_NATIVE_CURSOR_MANAGER_H_ |