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

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

Issue 2696963003: Split cursor location from UserDisplayManager. (Closed)
Patch Set: Fix nits. Created 3 years, 10 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_location_manager.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/ui/ws/cursor_location_manager.h
diff --git a/services/ui/ws/cursor_location_manager.h b/services/ui/ws/cursor_location_manager.h
new file mode 100644
index 0000000000000000000000000000000000000000..6096cdc5e6446f6ac78e51213b25c601694ac528
--- /dev/null
+++ b/services/ui/ws/cursor_location_manager.h
@@ -0,0 +1,59 @@
+// 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_LOCATION_MANAGER_H_
+#define SERVICES_UI_WS_CURSOR_LOCATION_MANAGER_H_
+
+#include "base/atomicops.h"
+#include "base/macros.h"
+#include "mojo/public/cpp/system/buffer.h"
+
+namespace gfx {
+class Point;
+}
+
+namespace ui {
+namespace ws {
+
+// Manages a shared memory buffer that stores the cursor location.
+class CursorLocationManager {
+ public:
+ CursorLocationManager();
+ ~CursorLocationManager();
+
+ // Sets the current cursor location to |point|. Atomically writes the location
+ // to shared memory.
+ void OnMouseCursorLocationChanged(const gfx::Point& point);
+
+ // Returns a read-only handle to the shared memory which contains the global
+ // mouse cursor position. Each call returns a new handle.
+ mojo::ScopedSharedBufferHandle GetCursorLocationMemory();
+
+ private:
+ base::subtle::Atomic32* cursor_location_memory() {
+ return reinterpret_cast<base::subtle::Atomic32*>(
+ cursor_location_mapping_.get());
+ }
+
+ // The current location of the cursor. This is always kept up to date so we
+ // can atomically write this to |cursor_location_memory()| once it is created.
+ base::subtle::Atomic32 current_cursor_location_ = 0;
+
+ // A handle to a shared memory buffer that is one 32 bit integer long. We
+ // share this with any client as the same user. This buffer is lazily
+ // created on the first access.
+ mojo::ScopedSharedBufferHandle cursor_location_handle_;
+
+ // The one int32 in |cursor_location_handle_|. When we write to this
+ // location, we must always write to it atomically. (On the other side of the
+ // mojo connection, this data must be read atomically.)
+ mojo::ScopedSharedBufferMapping cursor_location_mapping_;
+
+ DISALLOW_COPY_AND_ASSIGN(CursorLocationManager);
+};
+
+} // namespace ws
+} // namespace ui
+
+#endif // SERVICES_UI_WS_CURSOR_LOCATION_MANAGER_H_
« no previous file with comments | « services/ui/ws/BUILD.gn ('k') | services/ui/ws/cursor_location_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698