OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 UI_WM_CORE_CURSOR_MANAGER_H_ | 5 #ifndef UI_WM_CORE_CURSOR_MANAGER_H_ |
6 #define UI_WM_CORE_CURSOR_MANAGER_H_ | 6 #define UI_WM_CORE_CURSOR_MANAGER_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/observer_list.h" | 12 #include "base/observer_list.h" |
13 #include "ui/aura/client/cursor_client.h" | 13 #include "ui/aura/client/cursor_client.h" |
14 #include "ui/base/cursor/cursor.h" | 14 #include "ui/base/cursor/cursor.h" |
| 15 #include "ui/display/display.h" |
15 #include "ui/gfx/geometry/point.h" | 16 #include "ui/gfx/geometry/point.h" |
16 #include "ui/gfx/native_widget_types.h" | 17 #include "ui/gfx/native_widget_types.h" |
17 #include "ui/wm/core/native_cursor_manager_delegate.h" | 18 #include "ui/wm/core/native_cursor_manager_delegate.h" |
18 #include "ui/wm/wm_export.h" | 19 #include "ui/wm/wm_export.h" |
19 | 20 |
20 namespace ui { | 21 namespace ui { |
21 class KeyEvent; | 22 class KeyEvent; |
22 } | 23 } |
23 | 24 |
24 namespace wm { | 25 namespace wm { |
(...skipping 22 matching lines...) Loading... |
47 gfx::NativeCursor GetCursor() const override; | 48 gfx::NativeCursor GetCursor() const override; |
48 void ShowCursor() override; | 49 void ShowCursor() override; |
49 void HideCursor() override; | 50 void HideCursor() override; |
50 bool IsCursorVisible() const override; | 51 bool IsCursorVisible() const override; |
51 void SetCursorSet(ui::CursorSetType cursor_set) override; | 52 void SetCursorSet(ui::CursorSetType cursor_set) override; |
52 ui::CursorSetType GetCursorSet() const override; | 53 ui::CursorSetType GetCursorSet() const override; |
53 void EnableMouseEvents() override; | 54 void EnableMouseEvents() override; |
54 void DisableMouseEvents() override; | 55 void DisableMouseEvents() override; |
55 bool IsMouseEventsEnabled() const override; | 56 bool IsMouseEventsEnabled() const override; |
56 void SetDisplay(const display::Display& display) override; | 57 void SetDisplay(const display::Display& display) override; |
| 58 const display::Display& GetDisplay() const override; |
57 void LockCursor() override; | 59 void LockCursor() override; |
58 void UnlockCursor() override; | 60 void UnlockCursor() override; |
59 bool IsCursorLocked() const override; | 61 bool IsCursorLocked() const override; |
60 void AddObserver(aura::client::CursorClientObserver* observer) override; | 62 void AddObserver(aura::client::CursorClientObserver* observer) override; |
61 void RemoveObserver(aura::client::CursorClientObserver* observer) override; | 63 void RemoveObserver(aura::client::CursorClientObserver* observer) override; |
62 bool ShouldHideCursorOnKeyEvent(const ui::KeyEvent& event) const override; | 64 bool ShouldHideCursorOnKeyEvent(const ui::KeyEvent& event) const override; |
63 | 65 |
64 private: | 66 private: |
65 // Overridden from NativeCursorManagerDelegate: | 67 // Overridden from NativeCursorManagerDelegate: |
66 void CommitCursor(gfx::NativeCursor cursor) override; | 68 void CommitCursor(gfx::NativeCursor cursor) override; |
67 void CommitVisibility(bool visible) override; | 69 void CommitVisibility(bool visible) override; |
68 void CommitCursorSet(ui::CursorSetType cursor_set) override; | 70 void CommitCursorSet(ui::CursorSetType cursor_set) override; |
69 void CommitMouseEventsEnabled(bool enabled) override; | 71 void CommitMouseEventsEnabled(bool enabled) override; |
70 | 72 |
71 std::unique_ptr<NativeCursorManager> delegate_; | 73 std::unique_ptr<NativeCursorManager> delegate_; |
72 | 74 |
| 75 // Display where the cursor is located. |
| 76 display::Display display_; |
| 77 |
73 // Number of times LockCursor() has been invoked without a corresponding | 78 // Number of times LockCursor() has been invoked without a corresponding |
74 // UnlockCursor(). | 79 // UnlockCursor(). |
75 int cursor_lock_count_; | 80 int cursor_lock_count_; |
76 | 81 |
77 // The current state of the cursor. | 82 // The current state of the cursor. |
78 std::unique_ptr<internal::CursorState> current_state_; | 83 std::unique_ptr<internal::CursorState> current_state_; |
79 | 84 |
80 // The cursor state to restore when the cursor is unlocked. | 85 // The cursor state to restore when the cursor is unlocked. |
81 std::unique_ptr<internal::CursorState> state_on_unlock_; | 86 std::unique_ptr<internal::CursorState> state_on_unlock_; |
82 | 87 |
83 base::ObserverList<aura::client::CursorClientObserver> observers_; | 88 base::ObserverList<aura::client::CursorClientObserver> observers_; |
84 | 89 |
85 // This flag holds the cursor visibility state for the duration of the | 90 // This flag holds the cursor visibility state for the duration of the |
86 // process. Defaults to true. This flag helps ensure that when a | 91 // process. Defaults to true. This flag helps ensure that when a |
87 // CursorManager instance is created it gets populated with the correct | 92 // CursorManager instance is created it gets populated with the correct |
88 // cursor visibility state. | 93 // cursor visibility state. |
89 static bool last_cursor_visibility_state_; | 94 static bool last_cursor_visibility_state_; |
90 | 95 |
91 DISALLOW_COPY_AND_ASSIGN(CursorManager); | 96 DISALLOW_COPY_AND_ASSIGN(CursorManager); |
92 }; | 97 }; |
93 | 98 |
94 } // namespace wm | 99 } // namespace wm |
95 | 100 |
96 #endif // UI_WM_CORE_CURSOR_MANAGER_H_ | 101 #endif // UI_WM_CORE_CURSOR_MANAGER_H_ |
OLD | NEW |