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

Unified Diff: components/mus/ws/user_display_manager.cc

Issue 1881253002: mus: Implement ScreenMus::GetCursorScreenPoint(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge with tot Created 4 years, 8 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 | « components/mus/ws/user_display_manager.h ('k') | components/mus/ws/user_display_manager_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/mus/ws/user_display_manager.cc
diff --git a/components/mus/ws/user_display_manager.cc b/components/mus/ws/user_display_manager.cc
index e54e9b7fc444c6813b186f2c49f3824770563253..979a5d420501229a35d72a4d5ae7c6119a5be899 100644
--- a/components/mus/ws/user_display_manager.cc
+++ b/components/mus/ws/user_display_manager.cc
@@ -13,7 +13,10 @@ namespace ws {
UserDisplayManager::UserDisplayManager(ws::DisplayManager* display_manager,
const UserId& user_id)
- : display_manager_(display_manager), user_id_(user_id) {
+ : display_manager_(display_manager),
+ user_id_(user_id),
+ current_cursor_location_(0),
+ cursor_location_memory_(nullptr) {
for (const WindowManagerState* wms : GetWindowManagerStatesForUser()) {
if (wms->got_frame_decoration_values()) {
got_valid_frame_decorations_ = true;
@@ -62,6 +65,54 @@ void UserDisplayManager::OnWillDestroyDisplay(Display* display) {
test_observer_->OnDisplayRemoved(display->id());
}
+void UserDisplayManager::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 UserDisplayManager::GetCursorLocationMemory() {
+ if (!cursor_location_memory_) {
+ // Create our shared memory segment to share the cursor state with our
+ // window clients.
+ MojoResult result = mojo::CreateSharedBuffer(nullptr,
+ sizeof(base::subtle::Atomic32),
+ &cursor_location_handle_);
+ if (result != MOJO_RESULT_OK)
+ return mojo::ScopedSharedBufferHandle();
+ DCHECK(cursor_location_handle_.is_valid());
+
+ result = mojo::MapBuffer(cursor_location_handle_.get(), 0,
+ sizeof(base::subtle::Atomic32),
+ reinterpret_cast<void**>(&cursor_location_memory_),
+ MOJO_MAP_BUFFER_FLAG_NONE);
+ if (result != MOJO_RESULT_OK)
+ return mojo::ScopedSharedBufferHandle();
+ DCHECK(cursor_location_memory_);
+
+ base::subtle::NoBarrier_Store(cursor_location_memory_,
+ current_cursor_location_);
+ }
+
+ mojo::ScopedSharedBufferHandle duped;
+ MojoDuplicateBufferHandleOptions options = {
+ sizeof(MojoDuplicateBufferHandleOptions),
+ MOJO_DUPLICATE_BUFFER_HANDLE_OPTIONS_FLAG_READ_ONLY
+ };
+ MojoResult result = mojo::DuplicateBuffer(cursor_location_handle_.get(),
+ &options, &duped);
+ if (result != MOJO_RESULT_OK)
+ return mojo::ScopedSharedBufferHandle();
+ DCHECK(duped.is_valid());
+
+ return duped;
+}
+
+
std::set<const WindowManagerState*>
UserDisplayManager::GetWindowManagerStatesForUser() const {
std::set<const WindowManagerState*> result;
« no previous file with comments | « components/mus/ws/user_display_manager.h ('k') | components/mus/ws/user_display_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698