Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 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 SERVICES_UI_WS_CURSOR_STATE_H_ | |
| 6 #define SERVICES_UI_WS_CURSOR_STATE_H_ | |
| 7 | |
| 8 #include <memory> | |
| 9 | |
| 10 #include "base/optional.h" | |
| 11 #include "ui/base/cursor/cursor_data.h" | |
| 12 | |
| 13 namespace ui { | |
| 14 namespace ws { | |
| 15 | |
| 16 class DisplayManager; | |
| 17 | |
| 18 // Owns all the state about if and how the cursor is displayed in mus. | |
| 19 class CursorState { | |
| 20 public: | |
| 21 CursorState(DisplayManager* display_manager); | |
|
sky
2017/05/14 16:12:31
explicit
| |
| 22 ~CursorState(); | |
| 23 | |
| 24 // Sets the normal cursor which would be used if the window manager hasn't | |
| 25 // set an override cursor. | |
| 26 void SetCurrentWindowCursor(const ui::CursorData& cursor); | |
| 27 | |
| 28 // When the cursor is locked, changes to the cursor are queued up. Queued | |
| 29 // changes are performed atomically when the cursor is unlocked. | |
| 30 void LockCursor(); | |
| 31 void UnlockCursor(); | |
| 32 | |
| 33 // Whether the cursor is visible on the display. | |
| 34 void SetCursorVisible(bool visible); | |
| 35 | |
| 36 // Sets a cursor globally, which overrides the per-window cursors. | |
| 37 void SetGlobalOverrideCursor(const base::Optional<ui::CursorData>& cursor); | |
| 38 | |
| 39 private: | |
| 40 // A snapshot of the cursor state at a specific time. | |
| 41 class StateSnapshot; | |
| 42 | |
| 43 // Synchronizes |current_state_| with all the platform displays. | |
| 44 void SetPlatformCursor(); | |
| 45 | |
| 46 // Contains are the displays we notify on cursor changes. | |
| 47 DisplayManager* display_manager_; | |
| 48 | |
| 49 // Number of times LockCursor() has been invoked without a corresponding | |
| 50 // UnlockCursor(). | |
| 51 int cursor_lock_count_ = 0u; | |
|
sky
2017/05/14 16:12:31
You shouldn't need the 'u' here.
| |
| 52 | |
| 53 // The current state of the cursor. | |
| 54 std::unique_ptr<StateSnapshot> current_state_; | |
| 55 | |
| 56 // The cursor state to restore when the cursor is unlocked. | |
| 57 std::unique_ptr<StateSnapshot> state_on_unlock_; | |
| 58 | |
| 59 DISALLOW_COPY_AND_ASSIGN(CursorState); | |
| 60 }; | |
| 61 | |
| 62 } // namespace ws | |
| 63 } // namespace ui | |
| 64 | |
| 65 #endif // SERVICES_UI_WS_CURSOR_STATE_H_ | |
| OLD | NEW |