OLD | NEW |
---|---|
(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 #include "ui/gfx/geometry/point.h" | |
msw
2017/02/16 21:19:49
nit: use a fwd decl instead
kylechar
2017/02/16 22:06:56
Done.
| |
12 | |
13 namespace ui { | |
14 namespace ws { | |
15 | |
16 // Manages a shared memory buffer that stores the cursor location. | |
17 class CursorLocationManager { | |
18 public: | |
19 CursorLocationManager(); | |
20 ~CursorLocationManager(); | |
21 | |
22 // Sets the current cursor location to |point|. Atomically writes the location | |
23 // to shared memory. | |
24 void OnMouseCursorLocationChanged(const gfx::Point& point); | |
25 | |
26 // Returns a read-only handle to the shared memory which contains the global | |
27 // mouse cursor position. Each call returns a new handle. | |
28 mojo::ScopedSharedBufferHandle GetCursorLocationMemory(); | |
29 | |
30 private: | |
31 base::subtle::Atomic32* cursor_location_memory() { | |
32 return reinterpret_cast<base::subtle::Atomic32*>( | |
33 cursor_location_mapping_.get()); | |
34 } | |
35 | |
36 // The current location of the cursor. This is always kept up to date so we | |
37 // can atomically write this to |cursor_location_memory()| once it is created. | |
38 base::subtle::Atomic32 current_cursor_location_ = 0; | |
39 | |
40 // A handle to a shared memory buffer that is one 32 bit integer long. We | |
41 // share this with any client as the same user. This buffer is lazily | |
42 // created on the first access. | |
43 mojo::ScopedSharedBufferHandle cursor_location_handle_; | |
44 | |
45 // The one int32 in |cursor_location_handle_|. When we write to this | |
46 // location, we must always write to it atomically. (On the other side of the | |
47 // mojo connection, this data must be read atomically.) | |
48 mojo::ScopedSharedBufferMapping cursor_location_mapping_; | |
49 | |
50 DISALLOW_COPY_AND_ASSIGN(CursorLocationManager); | |
51 }; | |
52 | |
53 } // namespace ws | |
54 } // namespace ui | |
55 | |
56 #endif // SERVICES_UI_WS_CURSOR_LOCATION_MANAGER_H_ | |
OLD | NEW |