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

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

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/cursor_location_manager.h ('k') | services/ui/ws/cursor_location_manager_unittest.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.cc
diff --git a/services/ui/ws/cursor_location_manager.cc b/services/ui/ws/cursor_location_manager.cc
new file mode 100644
index 0000000000000000000000000000000000000000..c26e15a3c6f5f5f1bc9ecd655d578b920fa8ef43
--- /dev/null
+++ b/services/ui/ws/cursor_location_manager.cc
@@ -0,0 +1,50 @@
+// 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.
+
+#include "services/ui/ws/cursor_location_manager.h"
+
+#include "ui/gfx/geometry/point.h"
+
+namespace ui {
+namespace ws {
+
+CursorLocationManager::CursorLocationManager() {}
+
+CursorLocationManager::~CursorLocationManager() {}
+
+void CursorLocationManager::OnMouseCursorLocationChanged(
+ const gfx::Point& point) {
+ current_cursor_location_ = static_cast<base::subtle::Atomic32>(
+ (point.x() & 0xFFFF) << 16 | (point.y() & 0xFFFF));
+ if (cursor_location_memory()) {
+ base::subtle::NoBarrier_Store(cursor_location_memory(),
+ current_cursor_location_);
+ }
+}
+
+mojo::ScopedSharedBufferHandle
+CursorLocationManager::GetCursorLocationMemory() {
+ if (!cursor_location_handle_.is_valid()) {
+ // Create our shared memory segment to share the cursor state with our
+ // window clients.
+ cursor_location_handle_ =
+ mojo::SharedBufferHandle::Create(sizeof(base::subtle::Atomic32));
+
+ if (!cursor_location_handle_.is_valid())
+ return mojo::ScopedSharedBufferHandle();
+
+ cursor_location_mapping_ =
+ cursor_location_handle_->Map(sizeof(base::subtle::Atomic32));
+ if (!cursor_location_mapping_)
+ return mojo::ScopedSharedBufferHandle();
+ base::subtle::NoBarrier_Store(cursor_location_memory(),
+ current_cursor_location_);
+ }
+
+ return cursor_location_handle_->Clone(
+ mojo::SharedBufferHandle::AccessMode::READ_ONLY);
+}
+
+} // namespace ws
+} // namespace ui
« no previous file with comments | « services/ui/ws/cursor_location_manager.h ('k') | services/ui/ws/cursor_location_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698