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