| 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 SERVICES_UI_WS_USER_DISPLAY_MANAGER_H_ | 5 #ifndef SERVICES_UI_WS_USER_DISPLAY_MANAGER_H_ |
| 6 #define SERVICES_UI_WS_USER_DISPLAY_MANAGER_H_ | 6 #define SERVICES_UI_WS_USER_DISPLAY_MANAGER_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <vector> |
| 9 | 10 |
| 10 #include "base/atomicops.h" | |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "mojo/public/cpp/bindings/binding_set.h" | 12 #include "mojo/public/cpp/bindings/binding_set.h" |
| 13 #include "mojo/public/cpp/bindings/interface_ptr_set.h" | 13 #include "mojo/public/cpp/bindings/interface_ptr_set.h" |
| 14 #include "services/ui/public/interfaces/display_manager.mojom.h" | 14 #include "services/ui/public/interfaces/display_manager.mojom.h" |
| 15 #include "services/ui/ws/user_id.h" | 15 #include "services/ui/ws/user_id.h" |
| 16 | 16 |
| 17 namespace gfx { | |
| 18 class Point; | |
| 19 } | |
| 20 | |
| 21 namespace ui { | 17 namespace ui { |
| 22 namespace ws { | 18 namespace ws { |
| 23 | 19 |
| 24 class Display; | 20 class Display; |
| 25 class DisplayManager; | 21 class DisplayManager; |
| 26 class UserDisplayManagerDelegate; | 22 class UserDisplayManagerDelegate; |
| 27 | 23 |
| 28 // Provides per user display state. | 24 // Provides per user display state. |
| 29 class UserDisplayManager : public mojom::DisplayManager { | 25 class UserDisplayManager : public mojom::DisplayManager { |
| 30 public: | 26 public: |
| (...skipping 10 matching lines...) Expand all Loading... |
| 41 | 37 |
| 42 // Called when something about the display (e.g. pixel-ratio, size) changes. | 38 // Called when something about the display (e.g. pixel-ratio, size) changes. |
| 43 void OnDisplayUpdate(Display* display); | 39 void OnDisplayUpdate(Display* display); |
| 44 | 40 |
| 45 // Called by Display prior to |display| being removed and destroyed. | 41 // Called by Display prior to |display| being removed and destroyed. |
| 46 void OnWillDestroyDisplay(Display* display); | 42 void OnWillDestroyDisplay(Display* display); |
| 47 | 43 |
| 48 // Called when the primary display changes. | 44 // Called when the primary display changes. |
| 49 void OnPrimaryDisplayChanged(int64_t primary_display_id); | 45 void OnPrimaryDisplayChanged(int64_t primary_display_id); |
| 50 | 46 |
| 51 // Called from WindowManagerState when its EventDispatcher receives a mouse | |
| 52 // event. | |
| 53 void OnMouseCursorLocationChanged(const gfx::Point& point); | |
| 54 | |
| 55 // Returns a read-only handle to the shared memory which contains the global | |
| 56 // mouse cursor position. Each call returns a new handle. | |
| 57 mojo::ScopedSharedBufferHandle GetCursorLocationMemory(); | |
| 58 | |
| 59 // Overriden from mojom::DisplayManager: | 47 // Overriden from mojom::DisplayManager: |
| 60 void AddObserver(mojom::DisplayManagerObserverPtr observer) override; | 48 void AddObserver(mojom::DisplayManagerObserverPtr observer) override; |
| 61 | 49 |
| 62 private: | 50 private: |
| 63 // Called when a new observer is added. If frame decorations are available | 51 // Called when a new observer is added. If frame decorations are available |
| 64 // notifies the observer immediately. | 52 // notifies the observer immediately. |
| 65 void OnObserverAdded(mojom::DisplayManagerObserver* observer); | 53 void OnObserverAdded(mojom::DisplayManagerObserver* observer); |
| 66 | 54 |
| 67 // Fills in a WsDisplayPtr for |display|. | 55 // Fills in a WsDisplayPtr for |display|. |
| 68 mojom::WsDisplayPtr GetWsDisplayPtr(const Display& display); | 56 mojom::WsDisplayPtr GetWsDisplayPtr(const Display& display); |
| 69 | 57 |
| 70 std::vector<mojom::WsDisplayPtr> GetAllDisplays(); | 58 std::vector<mojom::WsDisplayPtr> GetAllDisplays(); |
| 71 | 59 |
| 72 // Calls OnDisplays() on |observer|. | 60 // Calls OnDisplays() on |observer|. |
| 73 void CallOnDisplays(mojom::DisplayManagerObserver* observer); | 61 void CallOnDisplays(mojom::DisplayManagerObserver* observer); |
| 74 | 62 |
| 75 base::subtle::Atomic32* cursor_location_memory() { | |
| 76 return reinterpret_cast<base::subtle::Atomic32*>( | |
| 77 cursor_location_mapping_.get()); | |
| 78 } | |
| 79 | |
| 80 ws::DisplayManager* display_manager_; | 63 ws::DisplayManager* display_manager_; |
| 81 | 64 |
| 82 UserDisplayManagerDelegate* delegate_; | 65 UserDisplayManagerDelegate* delegate_; |
| 83 | 66 |
| 84 const UserId user_id_; | 67 const UserId user_id_; |
| 85 | 68 |
| 86 // Set to true the first time at least one Display has valid frame values. | 69 // Set to true the first time at least one Display has valid frame values. |
| 87 bool got_valid_frame_decorations_; | 70 bool got_valid_frame_decorations_; |
| 88 | 71 |
| 89 mojo::BindingSet<mojom::DisplayManager> display_manager_bindings_; | 72 mojo::BindingSet<mojom::DisplayManager> display_manager_bindings_; |
| 90 | 73 |
| 91 // WARNING: only use these once |got_valid_frame_decorations_| is true. | 74 // WARNING: only use these once |got_valid_frame_decorations_| is true. |
| 92 mojo::InterfacePtrSet<mojom::DisplayManagerObserver> | 75 mojo::InterfacePtrSet<mojom::DisplayManagerObserver> |
| 93 display_manager_observers_; | 76 display_manager_observers_; |
| 94 | 77 |
| 95 // The current location of the cursor. This is always kept up to date so we | |
| 96 // can atomically write this to |cursor_location_memory()| once it is created. | |
| 97 base::subtle::Atomic32 current_cursor_location_; | |
| 98 | |
| 99 // A handle to a shared memory buffer that is one 64 bit integer long. We | |
| 100 // share this with any client as the same user. This buffer is lazily | |
| 101 // created on the first access. | |
| 102 mojo::ScopedSharedBufferHandle cursor_location_handle_; | |
| 103 | |
| 104 // The one int32 in |cursor_location_handle_|. When we write to this | |
| 105 // location, we must always write to it atomically. (On the other side of the | |
| 106 // mojo connection, this data must be read atomically.) | |
| 107 mojo::ScopedSharedBufferMapping cursor_location_mapping_; | |
| 108 | |
| 109 DISALLOW_COPY_AND_ASSIGN(UserDisplayManager); | 78 DISALLOW_COPY_AND_ASSIGN(UserDisplayManager); |
| 110 }; | 79 }; |
| 111 | 80 |
| 112 } // namespace ws | 81 } // namespace ws |
| 113 } // namespace ui | 82 } // namespace ui |
| 114 | 83 |
| 115 #endif // SERVICES_UI_WS_USER_DISPLAY_MANAGER_H_ | 84 #endif // SERVICES_UI_WS_USER_DISPLAY_MANAGER_H_ |
| OLD | NEW |