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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #ifndef SERVICES_UI_WS_CURSOR_LOCATION_MANAGER_H_
6 #define SERVICES_UI_WS_CURSOR_LOCATION_MANAGER_H_
7
8 #include "base/atomicops.h"
9 #include "base/macros.h"
10 #include "mojo/public/cpp/system/buffer.h"
11
12 namespace gfx {
13 class Point;
14 }
15
16 namespace ui {
17 namespace ws {
18
19 // Manages a shared memory buffer that stores the cursor location.
20 class CursorLocationManager {
21 public:
22 CursorLocationManager();
23 ~CursorLocationManager();
24
25 // Sets the current cursor location to |point|. Atomically writes the location
26 // to shared memory.
27 void OnMouseCursorLocationChanged(const gfx::Point& point);
28
29 // Returns a read-only handle to the shared memory which contains the global
30 // mouse cursor position. Each call returns a new handle.
31 mojo::ScopedSharedBufferHandle GetCursorLocationMemory();
32
33 private:
34 base::subtle::Atomic32* cursor_location_memory() {
35 return reinterpret_cast<base::subtle::Atomic32*>(
36 cursor_location_mapping_.get());
37 }
38
39 // The current location of the cursor. This is always kept up to date so we
40 // can atomically write this to |cursor_location_memory()| once it is created.
41 base::subtle::Atomic32 current_cursor_location_ = 0;
42
43 // A handle to a shared memory buffer that is one 32 bit integer long. We
44 // share this with any client as the same user. This buffer is lazily
45 // created on the first access.
46 mojo::ScopedSharedBufferHandle cursor_location_handle_;
47
48 // The one int32 in |cursor_location_handle_|. When we write to this
49 // location, we must always write to it atomically. (On the other side of the
50 // mojo connection, this data must be read atomically.)
51 mojo::ScopedSharedBufferMapping cursor_location_mapping_;
52
53 DISALLOW_COPY_AND_ASSIGN(CursorLocationManager);
54 };
55
56 } // namespace ws
57 } // namespace ui
58
59 #endif // SERVICES_UI_WS_CURSOR_LOCATION_MANAGER_H_
OLDNEW
« 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