| 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/macros.h" | 10 #include "base/macros.h" |
| 11 #include "components/mus/public/interfaces/display.mojom.h" | 11 #include "components/mus/public/interfaces/display.mojom.h" |
| 12 #include "components/mus/ws/user_id.h" | 12 #include "components/mus/ws/user_id.h" |
| 13 #include "mojo/public/cpp/bindings/binding_set.h" | 13 #include "mojo/public/cpp/bindings/binding_set.h" |
| 14 #include "mojo/public/cpp/bindings/interface_ptr_set.h" | 14 #include "mojo/public/cpp/bindings/interface_ptr_set.h" |
| 15 #include "ui/gfx/geometry/point.h" |
| 15 | 16 |
| 16 namespace mus { | 17 namespace mus { |
| 17 namespace ws { | 18 namespace ws { |
| 18 | 19 |
| 19 class Display; | 20 class Display; |
| 20 class DisplayManager; | 21 class DisplayManager; |
| 21 class WindowManagerState; | 22 class WindowManagerState; |
| 22 | 23 |
| 23 namespace test { | 24 namespace test { |
| 24 class UserDisplayManagerTestApi; | 25 class UserDisplayManagerTestApi; |
| 25 } | 26 } |
| 26 | 27 |
| 27 // Provides per user display state. | 28 // Provides per user display state. |
| 28 class UserDisplayManager : public mojom::DisplayManager { | 29 class UserDisplayManager : public mojom::DisplayManager { |
| 29 public: | 30 public: |
| 30 UserDisplayManager(ws::DisplayManager* display_manager, | 31 UserDisplayManager(ws::DisplayManager* display_manager, |
| 31 const UserId& user_id); | 32 const UserId& user_id); |
| 32 ~UserDisplayManager() override; | 33 ~UserDisplayManager() override; |
| 33 | 34 |
| 34 void OnFrameDecorationValuesChanged(WindowManagerState* wms); | 35 void OnFrameDecorationValuesChanged(WindowManagerState* wms); |
| 35 | 36 |
| 36 void AddDisplayManagerBinding( | 37 void AddDisplayManagerBinding( |
| 37 mojo::InterfaceRequest<mojom::DisplayManager> request); | 38 mojo::InterfaceRequest<mojom::DisplayManager> request); |
| 38 | 39 |
| 39 // Called by Display prior to |display| being removed and destroyed. | 40 // Called by Display prior to |display| being removed and destroyed. |
| 40 void OnWillDestroyDisplay(Display* display); | 41 void OnWillDestroyDisplay(Display* display); |
| 41 | 42 |
| 43 // Updates the location of the cursor on this user's display. |
| 44 void OnMouseCursorLocationChanged(const gfx::Point& location); |
| 45 |
| 42 private: | 46 private: |
| 43 friend class test::UserDisplayManagerTestApi; | 47 friend class test::UserDisplayManagerTestApi; |
| 44 | 48 |
| 45 // Returns the WindowManagerStates for the associated user that have frame | 49 // Returns the WindowManagerStates for the associated user that have frame |
| 46 // decoration values. | 50 // decoration values. |
| 47 std::set<const WindowManagerState*> GetWindowManagerStatesForUser() const; | 51 std::set<const WindowManagerState*> GetWindowManagerStatesForUser() const; |
| 48 | 52 |
| 49 void OnObserverAdded(mojom::DisplayManagerObserver* observer); | 53 void OnObserverAdded(mojom::DisplayManagerObserver* observer); |
| 50 | 54 |
| 51 // Calls OnDisplays() on |observer|. | 55 // Calls OnDisplays() on |observer|. |
| 52 void CallOnDisplays(mojom::DisplayManagerObserver* observer); | 56 void CallOnDisplays(mojom::DisplayManagerObserver* observer); |
| 53 | 57 |
| 54 // Calls observer->OnDisplaysChanged() with the display for |display|. | 58 // Calls observer->OnDisplaysChanged() with the display for |display|. |
| 55 void CallOnDisplayChanged(WindowManagerState* wms, | 59 void CallOnDisplayChanged(WindowManagerState* wms, |
| 56 mojom::DisplayManagerObserver* observer); | 60 mojom::DisplayManagerObserver* observer); |
| 57 | 61 |
| 58 // Overriden from mojom::DisplayManager: | 62 // Overriden from mojom::DisplayManager: |
| 59 void AddObserver(mojom::DisplayManagerObserverPtr observer) override; | 63 void AddObserver(mojom::DisplayManagerObserverPtr observer) override; |
| 64 void GetCursorScreenPoint( |
| 65 const GetCursorScreenPointCallback& callback) override; |
| 60 | 66 |
| 61 ws::DisplayManager* display_manager_; | 67 ws::DisplayManager* display_manager_; |
| 62 | 68 |
| 63 const UserId user_id_; | 69 const UserId user_id_; |
| 64 | 70 |
| 65 // Set to true the first time at least one Display has valid frame values. | 71 // Set to true the first time at least one Display has valid frame values. |
| 66 bool got_valid_frame_decorations_ = false; | 72 bool got_valid_frame_decorations_ = false; |
| 67 | 73 |
| 68 mojo::BindingSet<mojom::DisplayManager> display_manager_bindings_; | 74 mojo::BindingSet<mojom::DisplayManager> display_manager_bindings_; |
| 69 | 75 |
| 70 // WARNING: only use these once |got_valid_frame_decorations_| is true. | 76 // WARNING: only use these once |got_valid_frame_decorations_| is true. |
| 71 mojo::InterfacePtrSet<mojom::DisplayManagerObserver> | 77 mojo::InterfacePtrSet<mojom::DisplayManagerObserver> |
| 72 display_manager_observers_; | 78 display_manager_observers_; |
| 73 | 79 |
| 80 gfx::Point mouse_location_; |
| 81 |
| 74 // Observer used for tests. | 82 // Observer used for tests. |
| 75 mojom::DisplayManagerObserver* test_observer_ = nullptr; | 83 mojom::DisplayManagerObserver* test_observer_ = nullptr; |
| 76 | 84 |
| 77 DISALLOW_COPY_AND_ASSIGN(UserDisplayManager); | 85 DISALLOW_COPY_AND_ASSIGN(UserDisplayManager); |
| 78 }; | 86 }; |
| 79 | 87 |
| 80 } // namespace ws | 88 } // namespace ws |
| 81 } // namespace mus | 89 } // namespace mus |
| 82 | 90 |
| 83 #endif // COMPONENTS_MUS_WS_USER_DISPLAY_MANAGER_H_ | 91 #endif // COMPONENTS_MUS_WS_USER_DISPLAY_MANAGER_H_ |
| OLD | NEW |