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