Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(183)

Unified Diff: services/ui/ws/cursor_state.h

Issue 2857963003: Add {Lock,Unlock,Show,Hide}Cursor() to the window manager mojom. (Closed)
Patch Set: sky comments Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « services/ui/ws/BUILD.gn ('k') | services/ui/ws/cursor_state.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/ui/ws/cursor_state.h
diff --git a/services/ui/ws/cursor_state.h b/services/ui/ws/cursor_state.h
new file mode 100644
index 0000000000000000000000000000000000000000..b6af262b57eb644341c40243fc2f0ce02eab0358
--- /dev/null
+++ b/services/ui/ws/cursor_state.h
@@ -0,0 +1,65 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SERVICES_UI_WS_CURSOR_STATE_H_
+#define SERVICES_UI_WS_CURSOR_STATE_H_
+
+#include <memory>
+
+#include "base/optional.h"
+#include "ui/base/cursor/cursor_data.h"
+
+namespace ui {
+namespace ws {
+
+class DisplayManager;
+
+// Owns all the state about if and how the cursor is displayed in mus.
+class CursorState {
+ public:
+ explicit CursorState(DisplayManager* display_manager);
+ ~CursorState();
+
+ // Sets the normal cursor which would be used if the window manager hasn't
+ // set an override cursor.
+ void SetCurrentWindowCursor(const ui::CursorData& cursor);
+
+ // When the cursor is locked, changes to the cursor are queued up. Queued
+ // changes are performed atomically when the cursor is unlocked.
+ void LockCursor();
+ void UnlockCursor();
+
+ // Whether the cursor is visible on the display.
+ void SetCursorVisible(bool visible);
+
+ // Sets a cursor globally, which overrides the per-window cursors.
+ void SetGlobalOverrideCursor(const base::Optional<ui::CursorData>& cursor);
+
+ private:
+ // A snapshot of the cursor state at a specific time.
+ class StateSnapshot;
+
+ // Synchronizes |current_state_| with all the platform displays.
+ void SetPlatformCursor();
+
+ // Contains are the displays we notify on cursor changes.
+ DisplayManager* display_manager_;
+
+ // Number of times LockCursor() has been invoked without a corresponding
+ // UnlockCursor().
+ int cursor_lock_count_ = 0;
+
+ // The current state of the cursor.
+ std::unique_ptr<StateSnapshot> current_state_;
+
+ // The cursor state to restore when the cursor is unlocked.
+ std::unique_ptr<StateSnapshot> state_on_unlock_;
+
+ DISALLOW_COPY_AND_ASSIGN(CursorState);
+};
+
+} // namespace ws
+} // namespace ui
+
+#endif // SERVICES_UI_WS_CURSOR_STATE_H_
« no previous file with comments | « services/ui/ws/BUILD.gn ('k') | services/ui/ws/cursor_state.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698