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 #include "services/ui/ws/user_display_manager.h" | 5 #include "services/ui/ws/user_display_manager.h" |
6 | 6 |
| 7 #include <utility> |
| 8 |
7 #include "services/ui/ws/display.h" | 9 #include "services/ui/ws/display.h" |
8 #include "services/ui/ws/display_manager.h" | 10 #include "services/ui/ws/display_manager.h" |
9 #include "services/ui/ws/display_manager_delegate.h" | 11 #include "services/ui/ws/display_manager_delegate.h" |
10 | 12 |
11 namespace ui { | 13 namespace ui { |
12 namespace ws { | 14 namespace ws { |
13 | 15 |
14 UserDisplayManager::UserDisplayManager(ws::DisplayManager* display_manager, | 16 UserDisplayManager::UserDisplayManager(ws::DisplayManager* display_manager, |
15 DisplayManagerDelegate* delegate, | 17 DisplayManagerDelegate* delegate, |
16 const UserId& user_id) | 18 const UserId& user_id) |
17 : display_manager_(display_manager), | 19 : display_manager_(display_manager), |
18 delegate_(delegate), | 20 delegate_(delegate), |
19 user_id_(user_id), | 21 user_id_(user_id), |
20 got_valid_frame_decorations_( | 22 got_valid_frame_decorations_( |
21 delegate->GetFrameDecorationsForUser(user_id, nullptr)), | 23 delegate->GetFrameDecorationsForUser(user_id, nullptr)), |
22 current_cursor_location_(0) {} | 24 current_cursor_location_(0) {} |
23 | 25 |
24 UserDisplayManager::~UserDisplayManager() {} | 26 UserDisplayManager::~UserDisplayManager() {} |
25 | 27 |
26 void UserDisplayManager::OnFrameDecorationValuesChanged() { | 28 void UserDisplayManager::OnFrameDecorationValuesChanged() { |
27 if (!got_valid_frame_decorations_) { | 29 if (!got_valid_frame_decorations_) { |
28 got_valid_frame_decorations_ = true; | 30 got_valid_frame_decorations_ = true; |
29 display_manager_observers_.ForAllPtrs([this]( | 31 display_manager_observers_.ForAllPtrs([this]( |
30 mojom::DisplayManagerObserver* observer) { CallOnDisplays(observer); }); | 32 mojom::DisplayManagerObserver* observer) { CallOnDisplays(observer); }); |
31 if (test_observer_) | 33 if (test_observer_) |
32 CallOnDisplays(test_observer_); | 34 CallOnDisplays(test_observer_); |
33 return; | 35 return; |
34 } | 36 } |
35 | 37 |
36 mojo::Array<mojom::DisplayPtr> displays = GetAllDisplays(); | 38 mojo::Array<mojom::WsDisplayPtr> displays = GetAllDisplays(); |
37 display_manager_observers_.ForAllPtrs( | 39 display_manager_observers_.ForAllPtrs( |
38 [this, &displays](mojom::DisplayManagerObserver* observer) { | 40 [this, &displays](mojom::DisplayManagerObserver* observer) { |
39 observer->OnDisplaysChanged(displays.Clone()); | 41 observer->OnDisplaysChanged(displays.Clone()); |
40 }); | 42 }); |
41 if (test_observer_) | 43 if (test_observer_) |
42 test_observer_->OnDisplaysChanged(displays.Clone()); | 44 test_observer_->OnDisplaysChanged(displays.Clone()); |
43 } | 45 } |
44 | 46 |
45 void UserDisplayManager::AddDisplayManagerBinding( | 47 void UserDisplayManager::AddDisplayManagerBinding( |
46 mojo::InterfaceRequest<mojom::DisplayManager> request) { | 48 mojo::InterfaceRequest<mojom::DisplayManager> request) { |
(...skipping 19 matching lines...) Expand all Loading... |
66 if (cursor_location_memory()) { | 68 if (cursor_location_memory()) { |
67 base::subtle::NoBarrier_Store(cursor_location_memory(), | 69 base::subtle::NoBarrier_Store(cursor_location_memory(), |
68 current_cursor_location_); | 70 current_cursor_location_); |
69 } | 71 } |
70 } | 72 } |
71 | 73 |
72 void UserDisplayManager::OnDisplayUpdate(Display* display) { | 74 void UserDisplayManager::OnDisplayUpdate(Display* display) { |
73 if (!got_valid_frame_decorations_) | 75 if (!got_valid_frame_decorations_) |
74 return; | 76 return; |
75 | 77 |
76 mojo::Array<mojom::DisplayPtr> displays(1); | 78 mojo::Array<mojom::WsDisplayPtr> displays(1); |
77 displays[0] = display->ToMojomDisplay(); | 79 displays[0] = display->ToWsDisplay(); |
78 delegate_->GetFrameDecorationsForUser( | 80 delegate_->GetFrameDecorationsForUser( |
79 user_id_, &(displays[0]->frame_decoration_values)); | 81 user_id_, &(displays[0]->frame_decoration_values)); |
80 display_manager_observers_.ForAllPtrs( | 82 display_manager_observers_.ForAllPtrs( |
81 [this, &displays](mojom::DisplayManagerObserver* observer) { | 83 [this, &displays](mojom::DisplayManagerObserver* observer) { |
82 observer->OnDisplaysChanged(displays.Clone()); | 84 observer->OnDisplaysChanged(displays.Clone()); |
83 }); | 85 }); |
84 if (test_observer_) | 86 if (test_observer_) |
85 test_observer_->OnDisplaysChanged(displays.Clone()); | 87 test_observer_->OnDisplaysChanged(displays.Clone()); |
86 } | 88 } |
87 | 89 |
(...skipping 24 matching lines...) Expand all Loading... |
112 mojom::DisplayManagerObserver* observer) { | 114 mojom::DisplayManagerObserver* observer) { |
113 // Many clients key off the frame decorations to size widgets. Wait for frame | 115 // Many clients key off the frame decorations to size widgets. Wait for frame |
114 // decorations before notifying so that we don't have to worry about clients | 116 // decorations before notifying so that we don't have to worry about clients |
115 // resizing appropriately. | 117 // resizing appropriately. |
116 if (!got_valid_frame_decorations_) | 118 if (!got_valid_frame_decorations_) |
117 return; | 119 return; |
118 | 120 |
119 CallOnDisplays(observer); | 121 CallOnDisplays(observer); |
120 } | 122 } |
121 | 123 |
122 mojo::Array<mojom::DisplayPtr> UserDisplayManager::GetAllDisplays() { | 124 mojo::Array<mojom::WsDisplayPtr> UserDisplayManager::GetAllDisplays() { |
123 const std::set<Display*>& displays = display_manager_->displays(); | 125 const std::set<Display*>& displays = display_manager_->displays(); |
124 mojo::Array<mojom::DisplayPtr> display_ptrs(displays.size()); | 126 mojo::Array<mojom::WsDisplayPtr> display_ptrs(displays.size()); |
125 { | 127 { |
126 size_t i = 0; | 128 size_t i = 0; |
127 // TODO(sky): need ordering! | 129 // TODO(sky): need ordering! |
128 for (Display* display : displays) { | 130 for (Display* display : displays) { |
129 display_ptrs[i] = display->ToMojomDisplay(); | 131 display_ptrs[i] = display->ToWsDisplay(); |
130 delegate_->GetFrameDecorationsForUser( | 132 delegate_->GetFrameDecorationsForUser( |
131 user_id_, &(display_ptrs[i]->frame_decoration_values)); | 133 user_id_, &(display_ptrs[i]->frame_decoration_values)); |
132 ++i; | 134 ++i; |
133 } | 135 } |
134 } | 136 } |
135 return display_ptrs; | 137 return display_ptrs; |
136 } | 138 } |
137 | 139 |
138 void UserDisplayManager::CallOnDisplays( | 140 void UserDisplayManager::CallOnDisplays( |
139 mojom::DisplayManagerObserver* observer) { | 141 mojom::DisplayManagerObserver* observer) { |
140 observer->OnDisplays(GetAllDisplays()); | 142 observer->OnDisplays(GetAllDisplays()); |
141 } | 143 } |
142 | 144 |
143 void UserDisplayManager::AddObserver( | 145 void UserDisplayManager::AddObserver( |
144 mojom::DisplayManagerObserverPtr observer) { | 146 mojom::DisplayManagerObserverPtr observer) { |
145 mojom::DisplayManagerObserver* observer_impl = observer.get(); | 147 mojom::DisplayManagerObserver* observer_impl = observer.get(); |
146 display_manager_observers_.AddPtr(std::move(observer)); | 148 display_manager_observers_.AddPtr(std::move(observer)); |
147 OnObserverAdded(observer_impl); | 149 OnObserverAdded(observer_impl); |
148 } | 150 } |
149 | 151 |
150 } // namespace ws | 152 } // namespace ws |
151 } // namespace ui | 153 } // namespace ui |
OLD | NEW |