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> | |
9 #include <vector> | 8 #include <vector> |
10 | 9 |
11 #include "base/macros.h" | 10 #include "base/macros.h" |
12 #include "mojo/public/cpp/bindings/binding_set.h" | 11 #include "mojo/public/cpp/bindings/binding_set.h" |
13 #include "mojo/public/cpp/bindings/interface_ptr_set.h" | 12 #include "mojo/public/cpp/bindings/interface_ptr_set.h" |
14 #include "services/ui/public/interfaces/display_manager.mojom.h" | 13 #include "services/ui/public/interfaces/display_manager.mojom.h" |
15 #include "services/ui/ws/user_id.h" | 14 #include "services/ui/ws/user_id.h" |
16 | 15 |
| 16 namespace display { |
| 17 class Display; |
| 18 } |
| 19 |
17 namespace ui { | 20 namespace ui { |
18 namespace ws { | 21 namespace ws { |
19 | 22 |
20 class Display; | |
21 class DisplayManager; | |
22 class UserDisplayManagerDelegate; | 23 class UserDisplayManagerDelegate; |
23 | 24 |
24 // Provides per user display state. | 25 // Provides per user display state. |
25 class UserDisplayManager : public mojom::DisplayManager { | 26 class UserDisplayManager : public mojom::DisplayManager { |
26 public: | 27 public: |
27 UserDisplayManager(ws::DisplayManager* display_manager, | 28 UserDisplayManager(UserDisplayManagerDelegate* delegate, |
28 UserDisplayManagerDelegate* delegate, | |
29 const UserId& user_id); | 29 const UserId& user_id); |
30 ~UserDisplayManager() override; | 30 ~UserDisplayManager() override; |
31 | 31 |
32 // Called when the frame decorations for this user change. | 32 // Called when the frame decorations for this user change. |
33 void OnFrameDecorationValuesChanged(); | 33 void OnFrameDecorationValuesChanged(); |
34 | 34 |
35 void AddDisplayManagerBinding( | 35 void AddDisplayManagerBinding( |
36 mojo::InterfaceRequest<mojom::DisplayManager> request); | 36 mojo::InterfaceRequest<mojom::DisplayManager> request); |
37 | 37 |
38 // 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. |
39 void OnDisplayUpdate(Display* display); | 39 void OnDisplayUpdate(const display::Display& display); |
40 | 40 |
41 // Called by Display prior to |display| being removed and destroyed. | 41 // Called when |display_id| is being removed. |
42 void OnWillDestroyDisplay(Display* display); | 42 void OnWillDestroyDisplay(int64_t display_id); |
43 | 43 |
44 // Called when the primary display changes. | 44 // Called when the primary display changes. |
45 void OnPrimaryDisplayChanged(int64_t primary_display_id); | 45 void OnPrimaryDisplayChanged(int64_t primary_display_id); |
46 | 46 |
47 // Overriden from mojom::DisplayManager: | 47 // Overriden from mojom::DisplayManager: |
48 void AddObserver(mojom::DisplayManagerObserverPtr observer) override; | 48 void AddObserver(mojom::DisplayManagerObserverPtr observer) override; |
49 | 49 |
50 private: | 50 private: |
51 // 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 |
52 // notifies the observer immediately. | 52 // notifies the observer immediately. |
53 void OnObserverAdded(mojom::DisplayManagerObserver* observer); | 53 void OnObserverAdded(mojom::DisplayManagerObserver* observer); |
54 | 54 |
55 // Fills in a WsDisplayPtr for |display|. | 55 // Fills in a WsDisplayPtr for |display|. |
56 mojom::WsDisplayPtr GetWsDisplayPtr(const Display& display); | 56 mojom::WsDisplayPtr ToWsDisplayPtr(const display::Display& display); |
57 | 57 |
58 std::vector<mojom::WsDisplayPtr> GetAllDisplays(); | 58 std::vector<mojom::WsDisplayPtr> GetAllDisplays(); |
59 | 59 |
60 // Calls OnDisplays() on |observer|. | 60 // Calls OnDisplays() on |observer|. |
61 void CallOnDisplays(mojom::DisplayManagerObserver* observer); | 61 void CallOnDisplays(mojom::DisplayManagerObserver* observer); |
62 | 62 |
63 ws::DisplayManager* display_manager_; | |
64 | |
65 UserDisplayManagerDelegate* delegate_; | 63 UserDisplayManagerDelegate* delegate_; |
66 | 64 |
67 const UserId user_id_; | 65 const UserId user_id_; |
68 | 66 |
69 // Set to true the first time at least one Display has valid frame values. | 67 // Set to true the first time at least one Display has valid frame values. |
70 bool got_valid_frame_decorations_; | 68 bool got_valid_frame_decorations_; |
71 | 69 |
72 mojo::BindingSet<mojom::DisplayManager> display_manager_bindings_; | 70 mojo::BindingSet<mojom::DisplayManager> display_manager_bindings_; |
73 | 71 |
74 // WARNING: only use these once |got_valid_frame_decorations_| is true. | 72 // WARNING: only use these once |got_valid_frame_decorations_| is true. |
75 mojo::InterfacePtrSet<mojom::DisplayManagerObserver> | 73 mojo::InterfacePtrSet<mojom::DisplayManagerObserver> |
76 display_manager_observers_; | 74 display_manager_observers_; |
77 | 75 |
78 DISALLOW_COPY_AND_ASSIGN(UserDisplayManager); | 76 DISALLOW_COPY_AND_ASSIGN(UserDisplayManager); |
79 }; | 77 }; |
80 | 78 |
81 } // namespace ws | 79 } // namespace ws |
82 } // namespace ui | 80 } // namespace ui |
83 | 81 |
84 #endif // SERVICES_UI_WS_USER_DISPLAY_MANAGER_H_ | 82 #endif // SERVICES_UI_WS_USER_DISPLAY_MANAGER_H_ |
OLD | NEW |