| 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 #ifndef ASH_WM_ASH_NATIVE_CURSOR_MANAGER_H_ | 5 #ifndef ASH_WM_ASH_NATIVE_CURSOR_MANAGER_H_ |
| 6 #define ASH_WM_ASH_NATIVE_CURSOR_MANAGER_H_ | 6 #define ASH_WM_ASH_NATIVE_CURSOR_MANAGER_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "ash/ash_export.h" | 10 #include "ash/ash_export.h" |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/observer_list.h" |
| 13 #include "base/strings/string16.h" | 14 #include "base/strings/string16.h" |
| 14 #include "ui/gfx/geometry/point.h" | 15 #include "ui/gfx/geometry/point.h" |
| 15 #include "ui/gfx/native_widget_types.h" | 16 #include "ui/gfx/native_widget_types.h" |
| 16 #include "ui/wm/core/native_cursor_manager.h" | 17 #include "ui/wm/core/native_cursor_manager.h" |
| 17 #include "ui/wm/core/native_cursor_manager_delegate.h" | 18 #include "ui/wm/core/native_cursor_manager_delegate.h" |
| 18 | 19 |
| 19 namespace ui { | 20 namespace ui { |
| 20 class ImageCursors; | 21 class ImageCursors; |
| 21 } | 22 } |
| 22 | 23 |
| 23 namespace ash { | 24 namespace ash { |
| 24 | 25 |
| 25 namespace test { | 26 namespace test { |
| 26 class CursorManagerTestApi; | 27 class CursorManagerTestApi; |
| 27 } | 28 } |
| 28 | 29 |
| 29 // This does the ash-specific setting of cursor details like cursor | 30 // This does the ash-specific setting of cursor details like cursor |
| 30 // visibility. It communicates back with the CursorManager through the | 31 // visibility. It communicates back with the CursorManager through the |
| 31 // NativeCursorManagerDelegate interface, which receives messages about what | 32 // NativeCursorManagerDelegate interface, which receives messages about what |
| 32 // changes were acted on. | 33 // changes were acted on. |
| 33 class ASH_EXPORT AshNativeCursorManager : public ::wm::NativeCursorManager { | 34 class ASH_EXPORT AshNativeCursorManager : public ::wm::NativeCursorManager { |
| 34 public: | 35 public: |
| 36 class Observer { |
| 37 public: |
| 38 virtual void OnCursorDisplayChanging(const display::Display& display) = 0; |
| 39 |
| 40 protected: |
| 41 virtual ~Observer() {} |
| 42 }; |
| 43 |
| 35 AshNativeCursorManager(); | 44 AshNativeCursorManager(); |
| 36 ~AshNativeCursorManager() override; | 45 ~AshNativeCursorManager() override; |
| 37 | 46 |
| 47 void AddObserver(Observer* observer); |
| 48 void RemoveObserver(Observer* observer); |
| 49 |
| 38 // Toggle native cursor enabled/disabled. | 50 // Toggle native cursor enabled/disabled. |
| 39 // The native cursor is enabled by default. When disabled, we hide the native | 51 // The native cursor is enabled by default. When disabled, we hide the native |
| 40 // cursor regardless of visibility state, and let CursorWindowManager draw | 52 // cursor regardless of visibility state, and let CursorWindowManager draw |
| 41 // the cursor. | 53 // the cursor. |
| 42 void SetNativeCursorEnabled(bool enabled); | 54 void SetNativeCursorEnabled(bool enabled); |
| 43 | 55 |
| 44 private: | 56 private: |
| 45 friend class test::CursorManagerTestApi; | 57 friend class test::CursorManagerTestApi; |
| 46 | 58 |
| 47 // Overridden from ::wm::NativeCursorManager: | 59 // Overridden from ::wm::NativeCursorManager: |
| 48 void SetDisplay(const display::Display& display, | 60 void SetDisplay(const display::Display& display, |
| 49 ::wm::NativeCursorManagerDelegate* delegate) override; | 61 ::wm::NativeCursorManagerDelegate* delegate) override; |
| 50 void SetCursor(gfx::NativeCursor cursor, | 62 void SetCursor(gfx::NativeCursor cursor, |
| 51 ::wm::NativeCursorManagerDelegate* delegate) override; | 63 ::wm::NativeCursorManagerDelegate* delegate) override; |
| 52 void SetVisibility(bool visible, | 64 void SetVisibility(bool visible, |
| 53 ::wm::NativeCursorManagerDelegate* delegate) override; | 65 ::wm::NativeCursorManagerDelegate* delegate) override; |
| 54 void SetCursorSet(ui::CursorSetType cursor_set, | 66 void SetCursorSet(ui::CursorSetType cursor_set, |
| 55 ::wm::NativeCursorManagerDelegate* delegate) override; | 67 ::wm::NativeCursorManagerDelegate* delegate) override; |
| 56 void SetMouseEventsEnabled( | 68 void SetMouseEventsEnabled( |
| 57 bool enabled, | 69 bool enabled, |
| 58 ::wm::NativeCursorManagerDelegate* delegate) override; | 70 ::wm::NativeCursorManagerDelegate* delegate) override; |
| 59 | 71 |
| 60 // The cursor location where the cursor was disabled. | 72 // The cursor location where the cursor was disabled. |
| 61 gfx::Point disabled_cursor_location_; | 73 gfx::Point disabled_cursor_location_; |
| 62 | 74 |
| 63 bool native_cursor_enabled_; | 75 bool native_cursor_enabled_; |
| 64 | 76 |
| 65 std::unique_ptr<ui::ImageCursors> image_cursors_; | 77 std::unique_ptr<ui::ImageCursors> image_cursors_; |
| 66 | 78 |
| 79 base::ObserverList<Observer> observers_; |
| 80 |
| 67 DISALLOW_COPY_AND_ASSIGN(AshNativeCursorManager); | 81 DISALLOW_COPY_AND_ASSIGN(AshNativeCursorManager); |
| 68 }; | 82 }; |
| 69 | 83 |
| 70 } // namespace ash | 84 } // namespace ash |
| 71 | 85 |
| 72 #endif // ASH_WM_ASH_NATIVE_CURSOR_MANAGER_H_ | 86 #endif // ASH_WM_ASH_NATIVE_CURSOR_MANAGER_H_ |
| OLD | NEW |