| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef COMPONENTS_MUS_WS_USER_DISPLAY_MANAGER_H_ | 5 #ifndef COMPONENTS_MUS_WS_USER_DISPLAY_MANAGER_H_ |
| 6 #define COMPONENTS_MUS_WS_USER_DISPLAY_MANAGER_H_ | 6 #define COMPONENTS_MUS_WS_USER_DISPLAY_MANAGER_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/atomicops.h" |
| 10 #include "base/macros.h" | 11 #include "base/macros.h" |
| 11 #include "components/mus/public/interfaces/display.mojom.h" | 12 #include "components/mus/public/interfaces/display.mojom.h" |
| 12 #include "components/mus/ws/user_id.h" | 13 #include "components/mus/ws/user_id.h" |
| 13 #include "mojo/public/cpp/bindings/binding_set.h" | 14 #include "mojo/public/cpp/bindings/binding_set.h" |
| 14 #include "mojo/public/cpp/bindings/interface_ptr_set.h" | 15 #include "mojo/public/cpp/bindings/interface_ptr_set.h" |
| 15 | 16 |
| 17 namespace gfx { |
| 18 class Point; |
| 19 } |
| 20 |
| 16 namespace mus { | 21 namespace mus { |
| 17 namespace ws { | 22 namespace ws { |
| 18 | 23 |
| 19 class Display; | 24 class Display; |
| 20 class DisplayManager; | 25 class DisplayManager; |
| 21 class WindowManagerState; | 26 class WindowManagerState; |
| 22 | 27 |
| 23 namespace test { | 28 namespace test { |
| 24 class UserDisplayManagerTestApi; | 29 class UserDisplayManagerTestApi; |
| 25 } | 30 } |
| 26 | 31 |
| 27 // Provides per user display state. | 32 // Provides per user display state. |
| 28 class UserDisplayManager : public mojom::DisplayManager { | 33 class UserDisplayManager : public mojom::DisplayManager { |
| 29 public: | 34 public: |
| 30 UserDisplayManager(ws::DisplayManager* display_manager, | 35 UserDisplayManager(ws::DisplayManager* display_manager, |
| 31 const UserId& user_id); | 36 const UserId& user_id); |
| 32 ~UserDisplayManager() override; | 37 ~UserDisplayManager() override; |
| 33 | 38 |
| 34 void OnFrameDecorationValuesChanged(WindowManagerState* wms); | 39 void OnFrameDecorationValuesChanged(WindowManagerState* wms); |
| 35 | 40 |
| 36 void AddDisplayManagerBinding( | 41 void AddDisplayManagerBinding( |
| 37 mojo::InterfaceRequest<mojom::DisplayManager> request); | 42 mojo::InterfaceRequest<mojom::DisplayManager> request); |
| 38 | 43 |
| 39 // Called by Display prior to |display| being removed and destroyed. | 44 // Called by Display prior to |display| being removed and destroyed. |
| 40 void OnWillDestroyDisplay(Display* display); | 45 void OnWillDestroyDisplay(Display* display); |
| 41 | 46 |
| 47 // Called from WindowManagerState when its EventDispatcher receives a mouse |
| 48 // event. |
| 49 void OnMouseCursorLocationChanged(const gfx::Point& point); |
| 50 |
| 51 // Returns a read-only handle to the shared memory which contains the global |
| 52 // mouse cursor position. Each call returns a new handle. |
| 53 mojo::ScopedSharedBufferHandle GetCursorLocationMemory(); |
| 54 |
| 42 private: | 55 private: |
| 43 friend class test::UserDisplayManagerTestApi; | 56 friend class test::UserDisplayManagerTestApi; |
| 44 | 57 |
| 45 // Returns the WindowManagerStates for the associated user that have frame | 58 // Returns the WindowManagerStates for the associated user that have frame |
| 46 // decoration values. | 59 // decoration values. |
| 47 std::set<const WindowManagerState*> GetWindowManagerStatesForUser() const; | 60 std::set<const WindowManagerState*> GetWindowManagerStatesForUser() const; |
| 48 | 61 |
| 49 void OnObserverAdded(mojom::DisplayManagerObserver* observer); | 62 void OnObserverAdded(mojom::DisplayManagerObserver* observer); |
| 50 | 63 |
| 51 // Calls OnDisplays() on |observer|. | 64 // Calls OnDisplays() on |observer|. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 67 | 80 |
| 68 mojo::BindingSet<mojom::DisplayManager> display_manager_bindings_; | 81 mojo::BindingSet<mojom::DisplayManager> display_manager_bindings_; |
| 69 | 82 |
| 70 // WARNING: only use these once |got_valid_frame_decorations_| is true. | 83 // WARNING: only use these once |got_valid_frame_decorations_| is true. |
| 71 mojo::InterfacePtrSet<mojom::DisplayManagerObserver> | 84 mojo::InterfacePtrSet<mojom::DisplayManagerObserver> |
| 72 display_manager_observers_; | 85 display_manager_observers_; |
| 73 | 86 |
| 74 // Observer used for tests. | 87 // Observer used for tests. |
| 75 mojom::DisplayManagerObserver* test_observer_ = nullptr; | 88 mojom::DisplayManagerObserver* test_observer_ = nullptr; |
| 76 | 89 |
| 90 // The current location of the cursor. This is always kept up to date so we |
| 91 // can atomically write this to |cursor_location_memory_| once it is created. |
| 92 base::subtle::Atomic32 current_cursor_location_; |
| 93 |
| 94 // A handle to a shared memory buffer that is one 64 bit integer long. We |
| 95 // share this with any connection as the same user. This buffer is lazily |
| 96 // created on the first access. |
| 97 mojo::ScopedSharedBufferHandle cursor_location_handle_; |
| 98 |
| 99 // The one int32 in |cursor_location_handle_|. When we write to this |
| 100 // location, we must always write to it atomically. (On the other side of the |
| 101 // mojo connection, this data must be read atomically.) |
| 102 base::subtle::Atomic32* cursor_location_memory_; |
| 103 |
| 77 DISALLOW_COPY_AND_ASSIGN(UserDisplayManager); | 104 DISALLOW_COPY_AND_ASSIGN(UserDisplayManager); |
| 78 }; | 105 }; |
| 79 | 106 |
| 80 } // namespace ws | 107 } // namespace ws |
| 81 } // namespace mus | 108 } // namespace mus |
| 82 | 109 |
| 83 #endif // COMPONENTS_MUS_WS_USER_DISPLAY_MANAGER_H_ | 110 #endif // COMPONENTS_MUS_WS_USER_DISPLAY_MANAGER_H_ |
| OLD | NEW |