Chromium Code Reviews| 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/display_manager.h" | 5 #include "services/ui/ws/display_manager.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/trace_event/trace_event.h" | 10 #include "base/trace_event/trace_event.h" |
| 11 #include "services/ui/display/viewport_metrics.h" | |
| 11 #include "services/ui/ws/cursor_location_manager.h" | 12 #include "services/ui/ws/cursor_location_manager.h" |
| 12 #include "services/ui/ws/display.h" | 13 #include "services/ui/ws/display.h" |
| 13 #include "services/ui/ws/display_binding.h" | 14 #include "services/ui/ws/display_binding.h" |
| 14 #include "services/ui/ws/event_dispatcher.h" | 15 #include "services/ui/ws/event_dispatcher.h" |
| 15 #include "services/ui/ws/platform_display_init_params.h" | |
| 16 #include "services/ui/ws/server_window.h" | 16 #include "services/ui/ws/server_window.h" |
| 17 #include "services/ui/ws/user_display_manager.h" | 17 #include "services/ui/ws/user_display_manager.h" |
| 18 #include "services/ui/ws/user_display_manager_delegate.h" | 18 #include "services/ui/ws/user_display_manager_delegate.h" |
| 19 #include "services/ui/ws/user_id_tracker.h" | 19 #include "services/ui/ws/user_id_tracker.h" |
| 20 #include "services/ui/ws/window_manager_state.h" | 20 #include "services/ui/ws/window_manager_state.h" |
| 21 #include "services/ui/ws/window_manager_window_tree_factory.h" | 21 #include "services/ui/ws/window_manager_window_tree_factory.h" |
| 22 #include "services/ui/ws/window_server_delegate.h" | 22 #include "services/ui/ws/window_server_delegate.h" |
| 23 #include "services/ui/ws/window_tree.h" | 23 #include "services/ui/ws/window_tree.h" |
| 24 | 24 |
| 25 namespace ui { | 25 namespace ui { |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 91 while (!displays_.empty()) | 91 while (!displays_.empty()) |
| 92 DestroyDisplay(*displays_.begin()); | 92 DestroyDisplay(*displays_.begin()); |
| 93 DCHECK(displays_.empty()); | 93 DCHECK(displays_.empty()); |
| 94 } | 94 } |
| 95 | 95 |
| 96 std::set<const Display*> DisplayManager::displays() const { | 96 std::set<const Display*> DisplayManager::displays() const { |
| 97 std::set<const Display*> ret_value(displays_.begin(), displays_.end()); | 97 std::set<const Display*> ret_value(displays_.begin(), displays_.end()); |
| 98 return ret_value; | 98 return ret_value; |
| 99 } | 99 } |
| 100 | 100 |
| 101 void DisplayManager::OnDisplayUpdate(Display* display) { | 101 void DisplayManager::OnDisplayUpdate(const display::Display& display) { |
| 102 for (const auto& pair : user_display_managers_) | 102 for (const auto& pair : user_display_managers_) |
| 103 pair.second->OnDisplayUpdate(display->ToDisplay()); | 103 pair.second->OnDisplayUpdate(display); |
| 104 } | 104 } |
| 105 | 105 |
| 106 Display* DisplayManager::GetDisplayContaining(const ServerWindow* window) { | 106 Display* DisplayManager::GetDisplayContaining(const ServerWindow* window) { |
| 107 return const_cast<Display*>( | 107 return const_cast<Display*>( |
| 108 static_cast<const DisplayManager*>(this)->GetDisplayContaining(window)); | 108 static_cast<const DisplayManager*>(this)->GetDisplayContaining(window)); |
| 109 } | 109 } |
| 110 | 110 |
| 111 const Display* DisplayManager::GetDisplayContaining( | 111 const Display* DisplayManager::GetDisplayContaining( |
| 112 const ServerWindow* window) const { | 112 const ServerWindow* window) const { |
| 113 while (window && window->parent()) | 113 while (window && window->parent()) |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 174 ->mouse_pointer_last_location(); | 174 ->mouse_pointer_last_location(); |
| 175 previous_window_manager_state->Deactivate(); | 175 previous_window_manager_state->Deactivate(); |
| 176 } | 176 } |
| 177 | 177 |
| 178 WindowManagerState* current_window_manager_state = | 178 WindowManagerState* current_window_manager_state = |
| 179 window_server_->GetWindowManagerStateForUser(active_id); | 179 window_server_->GetWindowManagerStateForUser(active_id); |
| 180 if (current_window_manager_state) | 180 if (current_window_manager_state) |
| 181 current_window_manager_state->Activate(mouse_location_on_screen); | 181 current_window_manager_state->Activate(mouse_location_on_screen); |
| 182 } | 182 } |
| 183 | 183 |
| 184 void DisplayManager::OnDisplayAdded(int64_t id, | 184 void DisplayManager::OnDisplayAdded(const display::Display& display, |
| 185 const display::ViewportMetrics& metrics) { | 185 const display::ViewportMetrics& metrics) { |
| 186 TRACE_EVENT1("mus-ws", "OnDisplayAdded", "id", id); | 186 VLOG(1) << "OnDisplayAdded: " << display.ToString(); |
|
sky
2017/03/13 18:29:06
We've been using level 3 for informational message
kylechar
2017/03/13 19:28:02
Done.
| |
| 187 PlatformDisplayInitParams params; | |
| 188 params.display_id = id; | |
| 189 params.metrics = metrics; | |
| 190 | 187 |
| 191 ws::Display* display = new ws::Display(window_server_); | 188 ws::Display* ws_display = new ws::Display(window_server_); |
| 192 display->Init(params, nullptr); | 189 ws_display->SetDisplay(display); |
| 190 ws_display->Init(metrics, nullptr); | |
| 193 } | 191 } |
| 194 | 192 |
| 195 void DisplayManager::OnDisplayRemoved(int64_t id) { | 193 void DisplayManager::OnDisplayRemoved(int64_t display_id) { |
| 196 TRACE_EVENT1("mus-ws", "OnDisplayRemoved", "id", id); | 194 VLOG(1) << "OnDisplayRemoved: " << display_id; |
| 197 Display* display = GetDisplayById(id); | 195 Display* display = GetDisplayById(display_id); |
| 198 if (display) | 196 if (display) |
| 199 DestroyDisplay(display); | 197 DestroyDisplay(display); |
| 200 } | 198 } |
| 201 | 199 |
| 202 void DisplayManager::OnDisplayModified( | 200 void DisplayManager::OnDisplayModified( |
| 203 int64_t id, | 201 const display::Display& display, |
| 204 const display::ViewportMetrics& metrics) { | 202 const display::ViewportMetrics& metrics) { |
| 205 TRACE_EVENT1("mus-ws", "OnDisplayModified", "id", id); | 203 VLOG(1) << "OnDisplayModified: " << display.ToString(); |
| 206 | 204 |
| 207 Display* display = GetDisplayById(id); | 205 Display* ws_display = GetDisplayById(display.id()); |
| 208 DCHECK(display); | 206 DCHECK(ws_display); |
| 209 | 207 |
| 208 ws_display->SetDisplay(display); | |
| 210 // Update the platform display and check if anything has actually changed. | 209 // Update the platform display and check if anything has actually changed. |
| 211 if (!display->platform_display()->UpdateViewportMetrics(metrics)) | 210 if (!ws_display->platform_display()->UpdateViewportMetrics(metrics)) |
| 212 return; | 211 return; |
| 213 | 212 |
| 214 // Send IPCs to WM clients first with new display information. | 213 // Send IPCs to WM clients first with new display information. |
| 215 std::vector<WindowManagerWindowTreeFactory*> factories = | 214 std::vector<WindowManagerWindowTreeFactory*> factories = |
| 216 window_server_->window_manager_window_tree_factory_set()->GetFactories(); | 215 window_server_->window_manager_window_tree_factory_set()->GetFactories(); |
| 217 for (WindowManagerWindowTreeFactory* factory : factories) { | 216 for (WindowManagerWindowTreeFactory* factory : factories) { |
| 218 if (factory->window_tree()) | 217 if (factory->window_tree()) |
| 219 factory->window_tree()->OnWmDisplayModified(display->ToDisplay()); | 218 factory->window_tree()->OnWmDisplayModified(display); |
| 220 } | 219 } |
| 221 | 220 |
| 222 // Change the root ServerWindow size after sending IPC to WM. | 221 // Change the root ServerWindow size after sending IPC to WM. |
| 223 display->OnViewportMetricsChanged(metrics); | 222 ws_display->OnViewportMetricsChanged(metrics); |
| 224 OnDisplayUpdate(display); | 223 OnDisplayUpdate(display); |
| 225 } | 224 } |
| 226 | 225 |
| 227 void DisplayManager::OnPrimaryDisplayChanged(int64_t primary_display_id) { | 226 void DisplayManager::OnPrimaryDisplayChanged(int64_t primary_display_id) { |
| 227 VLOG(1) << "OnPrimaryDisplayChanged: " << primary_display_id; | |
| 228 // TODO(kylechar): Send IPCs to WM clients first. | 228 // TODO(kylechar): Send IPCs to WM clients first. |
| 229 | 229 |
| 230 // Send IPCs to any DisplayManagerObservers. | 230 // Send IPCs to any DisplayManagerObservers. |
| 231 for (const auto& pair : user_display_managers_) | 231 for (const auto& pair : user_display_managers_) |
| 232 pair.second->OnPrimaryDisplayChanged(primary_display_id); | 232 pair.second->OnPrimaryDisplayChanged(primary_display_id); |
| 233 } | 233 } |
| 234 | 234 |
| 235 } // namespace ws | 235 } // namespace ws |
| 236 } // namespace ui | 236 } // namespace ui |
| OLD | NEW |