| 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> |
| 9 |
| 8 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 9 #include "base/macros.h" | 11 #include "base/macros.h" |
| 10 #include "base/memory/scoped_ptr.h" | |
| 11 #include "base/observer_list.h" | 12 #include "base/observer_list.h" |
| 12 #include "ui/aura/client/cursor_client.h" | 13 #include "ui/aura/client/cursor_client.h" |
| 13 #include "ui/base/cursor/cursor.h" | 14 #include "ui/base/cursor/cursor.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_delegate.h" | 17 #include "ui/wm/core/native_cursor_manager_delegate.h" |
| 17 #include "ui/wm/wm_export.h" | 18 #include "ui/wm/wm_export.h" |
| 18 | 19 |
| 19 namespace gfx { | 20 namespace gfx { |
| 20 class Display; | 21 class Display; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 32 | 33 |
| 33 class NativeCursorManager; | 34 class NativeCursorManager; |
| 34 | 35 |
| 35 // This class receives requests to change cursor properties, as well as | 36 // This class receives requests to change cursor properties, as well as |
| 36 // requests to queue any further changes until a later time. It sends changes | 37 // requests to queue any further changes until a later time. It sends changes |
| 37 // to the NativeCursorManager, which communicates back to us when these changes | 38 // to the NativeCursorManager, which communicates back to us when these changes |
| 38 // were made through the NativeCursorManagerDelegate interface. | 39 // were made through the NativeCursorManagerDelegate interface. |
| 39 class WM_EXPORT CursorManager : public aura::client::CursorClient, | 40 class WM_EXPORT CursorManager : public aura::client::CursorClient, |
| 40 public NativeCursorManagerDelegate { | 41 public NativeCursorManagerDelegate { |
| 41 public: | 42 public: |
| 42 explicit CursorManager(scoped_ptr<NativeCursorManager> delegate); | 43 explicit CursorManager(std::unique_ptr<NativeCursorManager> delegate); |
| 43 ~CursorManager() override; | 44 ~CursorManager() override; |
| 44 | 45 |
| 45 // Overridden from aura::client::CursorClient: | 46 // Overridden from aura::client::CursorClient: |
| 46 void SetCursor(gfx::NativeCursor) override; | 47 void SetCursor(gfx::NativeCursor) override; |
| 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 gfx::Display& display) override; | 57 void SetDisplay(const gfx::Display& display) override; |
| 57 void LockCursor() override; | 58 void LockCursor() override; |
| 58 void UnlockCursor() override; | 59 void UnlockCursor() override; |
| 59 bool IsCursorLocked() const override; | 60 bool IsCursorLocked() const override; |
| 60 void AddObserver(aura::client::CursorClientObserver* observer) override; | 61 void AddObserver(aura::client::CursorClientObserver* observer) override; |
| 61 void RemoveObserver(aura::client::CursorClientObserver* observer) override; | 62 void RemoveObserver(aura::client::CursorClientObserver* observer) override; |
| 62 bool ShouldHideCursorOnKeyEvent(const ui::KeyEvent& event) const override; | 63 bool ShouldHideCursorOnKeyEvent(const ui::KeyEvent& event) const override; |
| 63 | 64 |
| 64 private: | 65 private: |
| 65 // Overridden from NativeCursorManagerDelegate: | 66 // Overridden from NativeCursorManagerDelegate: |
| 66 void CommitCursor(gfx::NativeCursor cursor) override; | 67 void CommitCursor(gfx::NativeCursor cursor) override; |
| 67 void CommitVisibility(bool visible) override; | 68 void CommitVisibility(bool visible) override; |
| 68 void CommitCursorSet(ui::CursorSetType cursor_set) override; | 69 void CommitCursorSet(ui::CursorSetType cursor_set) override; |
| 69 void CommitMouseEventsEnabled(bool enabled) override; | 70 void CommitMouseEventsEnabled(bool enabled) override; |
| 70 | 71 |
| 71 scoped_ptr<NativeCursorManager> delegate_; | 72 std::unique_ptr<NativeCursorManager> delegate_; |
| 72 | 73 |
| 73 // Number of times LockCursor() has been invoked without a corresponding | 74 // Number of times LockCursor() has been invoked without a corresponding |
| 74 // UnlockCursor(). | 75 // UnlockCursor(). |
| 75 int cursor_lock_count_; | 76 int cursor_lock_count_; |
| 76 | 77 |
| 77 // The current state of the cursor. | 78 // The current state of the cursor. |
| 78 scoped_ptr<internal::CursorState> current_state_; | 79 std::unique_ptr<internal::CursorState> current_state_; |
| 79 | 80 |
| 80 // The cursor state to restore when the cursor is unlocked. | 81 // The cursor state to restore when the cursor is unlocked. |
| 81 scoped_ptr<internal::CursorState> state_on_unlock_; | 82 std::unique_ptr<internal::CursorState> state_on_unlock_; |
| 82 | 83 |
| 83 base::ObserverList<aura::client::CursorClientObserver> observers_; | 84 base::ObserverList<aura::client::CursorClientObserver> observers_; |
| 84 | 85 |
| 85 // This flag holds the cursor visibility state for the duration of the | 86 // This flag holds the cursor visibility state for the duration of the |
| 86 // process. Defaults to true. This flag helps ensure that when a | 87 // process. Defaults to true. This flag helps ensure that when a |
| 87 // CursorManager instance is created it gets populated with the correct | 88 // CursorManager instance is created it gets populated with the correct |
| 88 // cursor visibility state. | 89 // cursor visibility state. |
| 89 static bool last_cursor_visibility_state_; | 90 static bool last_cursor_visibility_state_; |
| 90 | 91 |
| 91 DISALLOW_COPY_AND_ASSIGN(CursorManager); | 92 DISALLOW_COPY_AND_ASSIGN(CursorManager); |
| 92 }; | 93 }; |
| 93 | 94 |
| 94 } // namespace wm | 95 } // namespace wm |
| 95 | 96 |
| 96 #endif // UI_WM_CORE_CURSOR_MANAGER_H_ | 97 #endif // UI_WM_CORE_CURSOR_MANAGER_H_ |
| OLD | NEW |