| 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 "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "base/trace_event/trace_event.h" | 8 #include "base/trace_event/trace_event.h" |
| 9 #include "services/ui/display/platform_screen.h" | 9 #include "services/ui/display/platform_screen.h" |
| 10 #include "services/ui/ws/display.h" | 10 #include "services/ui/ws/display.h" |
| 11 #include "services/ui/ws/display_binding.h" | 11 #include "services/ui/ws/display_binding.h" |
| 12 #include "services/ui/ws/event_dispatcher.h" | 12 #include "services/ui/ws/event_dispatcher.h" |
| 13 #include "services/ui/ws/platform_display_init_params.h" | 13 #include "services/ui/ws/platform_display_init_params.h" |
| 14 #include "services/ui/ws/server_window.h" | 14 #include "services/ui/ws/server_window.h" |
| 15 #include "services/ui/ws/user_display_manager.h" | 15 #include "services/ui/ws/user_display_manager.h" |
| 16 #include "services/ui/ws/user_display_manager_delegate.h" | 16 #include "services/ui/ws/user_display_manager_delegate.h" |
| 17 #include "services/ui/ws/user_id_tracker.h" | 17 #include "services/ui/ws/user_id_tracker.h" |
| 18 #include "services/ui/ws/window_manager_state.h" | 18 #include "services/ui/ws/window_manager_state.h" |
| 19 #include "services/ui/ws/window_manager_window_tree_factory.h" |
| 19 #include "services/ui/ws/window_server_delegate.h" | 20 #include "services/ui/ws/window_server_delegate.h" |
| 21 #include "services/ui/ws/window_tree.h" |
| 20 | 22 |
| 21 namespace ui { | 23 namespace ui { |
| 22 namespace ws { | 24 namespace ws { |
| 23 | 25 |
| 24 DisplayManager::DisplayManager(WindowServer* window_server, | 26 DisplayManager::DisplayManager(WindowServer* window_server, |
| 25 UserIdTracker* user_id_tracker) | 27 UserIdTracker* user_id_tracker) |
| 26 // |next_root_id_| is used as the lower bits, so that starting at 0 is | 28 // |next_root_id_| is used as the lower bits, so that starting at 0 is |
| 27 // fine. |next_display_id_| is used by itself, so we start at 1 to reserve | 29 // fine. |next_display_id_| is used by itself, so we start at 1 to reserve |
| 28 // 0 as invalid. | 30 // 0 as invalid. |
| 29 : window_server_(window_server), | 31 : window_server_(window_server), |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 previous_window_manager_state->Deactivate(); | 163 previous_window_manager_state->Deactivate(); |
| 162 } | 164 } |
| 163 | 165 |
| 164 WindowManagerState* current_window_manager_state = | 166 WindowManagerState* current_window_manager_state = |
| 165 window_server_->GetWindowManagerStateForUser(active_id); | 167 window_server_->GetWindowManagerStateForUser(active_id); |
| 166 if (current_window_manager_state) | 168 if (current_window_manager_state) |
| 167 current_window_manager_state->Activate(mouse_location_on_screen); | 169 current_window_manager_state->Activate(mouse_location_on_screen); |
| 168 } | 170 } |
| 169 | 171 |
| 170 void DisplayManager::OnDisplayAdded(int64_t id, | 172 void DisplayManager::OnDisplayAdded(int64_t id, |
| 171 const gfx::Rect& bounds, | 173 const display::ViewportMetrics& metrics) { |
| 172 const gfx::Size& pixel_size, | |
| 173 float scale_factor) { | |
| 174 TRACE_EVENT1("mus-ws", "OnDisplayAdded", "id", id); | 174 TRACE_EVENT1("mus-ws", "OnDisplayAdded", "id", id); |
| 175 PlatformDisplayInitParams params; | 175 PlatformDisplayInitParams params; |
| 176 params.display_id = id; | 176 params.display_id = id; |
| 177 params.metrics.bounds = bounds; | 177 params.metrics = metrics; |
| 178 params.metrics.pixel_size = pixel_size; | |
| 179 params.metrics.device_scale_factor = scale_factor; | |
| 180 params.display_compositor = window_server_->GetDisplayCompositor(); | 178 params.display_compositor = window_server_->GetDisplayCompositor(); |
| 181 | 179 |
| 182 ws::Display* display = new ws::Display(window_server_, params); | 180 ws::Display* display = new ws::Display(window_server_, params); |
| 183 display->Init(nullptr); | 181 display->Init(nullptr); |
| 184 | 182 |
| 185 window_server_->delegate()->UpdateTouchTransforms(); | 183 window_server_->delegate()->UpdateTouchTransforms(); |
| 186 } | 184 } |
| 187 | 185 |
| 188 void DisplayManager::OnDisplayRemoved(int64_t id) { | 186 void DisplayManager::OnDisplayRemoved(int64_t id) { |
| 189 TRACE_EVENT1("mus-ws", "OnDisplayRemoved", "id", id); | 187 TRACE_EVENT1("mus-ws", "OnDisplayRemoved", "id", id); |
| 190 Display* display = GetDisplayById(id); | 188 Display* display = GetDisplayById(id); |
| 191 if (display) | 189 if (display) |
| 192 DestroyDisplay(display); | 190 DestroyDisplay(display); |
| 193 } | 191 } |
| 194 | 192 |
| 195 void DisplayManager::OnDisplayModified(int64_t id, | 193 void DisplayManager::OnDisplayModified( |
| 196 const gfx::Rect& bounds, | 194 int64_t id, |
| 197 const gfx::Size& pixel_size, | 195 const display::ViewportMetrics& metrics) { |
| 198 float scale_factor) { | 196 TRACE_EVENT1("mus-ws", "OnDisplayModified", "id", id); |
| 199 // TODO(kylechar): Implement. | 197 |
| 200 NOTREACHED(); | 198 Display* display = GetDisplayById(id); |
| 199 DCHECK(display); |
| 200 |
| 201 // Update the platform display and check if anything has actually changed. |
| 202 if (!display->platform_display()->UpdateViewportMetrics(metrics)) |
| 203 return; |
| 204 |
| 205 // Send IPCs to WM clients first with new display information. |
| 206 std::vector<WindowManagerWindowTreeFactory*> factories = |
| 207 window_server_->window_manager_window_tree_factory_set()->GetFactories(); |
| 208 for (WindowManagerWindowTreeFactory* factory : factories) { |
| 209 if (factory->window_tree()) |
| 210 factory->window_tree()->OnWmDisplayModified(display->ToDisplay()); |
| 211 } |
| 212 |
| 213 display->OnViewportMetricsChanged(metrics); |
| 214 OnDisplayUpdate(display); |
| 201 } | 215 } |
| 202 | 216 |
| 203 } // namespace ws | 217 } // namespace ws |
| 204 } // namespace ui | 218 } // namespace ui |
| OLD | NEW |