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

Side by Side 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 unified diff | Download patch
OLDNEW
(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 #include "services/ui/ws/cursor_location_manager.h"
6
7 #include "ui/gfx/geometry/point.h"
8
9 namespace ui {
10 namespace ws {
11
12 CursorLocationManager::CursorLocationManager() {}
13
14 CursorLocationManager::~CursorLocationManager() {}
15
16 void CursorLocationManager::OnMouseCursorLocationChanged(
17 const gfx::Point& point) {
18 current_cursor_location_ = static_cast<base::subtle::Atomic32>(
19 (point.x() & 0xFFFF) << 16 | (point.y() & 0xFFFF));
20 if (cursor_location_memory()) {
21 base::subtle::NoBarrier_Store(cursor_location_memory(),
22 current_cursor_location_);
23 }
24 }
25
26 mojo::ScopedSharedBufferHandle
27 CursorLocationManager::GetCursorLocationMemory() {
28 if (!cursor_location_handle_.is_valid()) {
29 // Create our shared memory segment to share the cursor state with our
30 // window clients.
31 cursor_location_handle_ =
32 mojo::SharedBufferHandle::Create(sizeof(base::subtle::Atomic32));
33
34 if (!cursor_location_handle_.is_valid())
35 return mojo::ScopedSharedBufferHandle();
36
37 cursor_location_mapping_ =
38 cursor_location_handle_->Map(sizeof(base::subtle::Atomic32));
39 if (!cursor_location_mapping_)
40 return mojo::ScopedSharedBufferHandle();
41 base::subtle::NoBarrier_Store(cursor_location_memory(),
42 current_cursor_location_);
43 }
44
45 return cursor_location_handle_->Clone(
46 mojo::SharedBufferHandle::AccessMode::READ_ONLY);
47 }
48
49 } // namespace ws
50 } // namespace ui
OLDNEW
« 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