| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/mus/ws/display.h" | 5 #include "components/mus/ws/display.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/debug/debugger.h" | 10 #include "base/debug/debugger.h" |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 void Display::SetTitle(const mojo::String& title) { | 229 void Display::SetTitle(const mojo::String& title) { |
| 230 platform_display_->SetTitle(title.To<base::string16>()); | 230 platform_display_->SetTitle(title.To<base::string16>()); |
| 231 } | 231 } |
| 232 | 232 |
| 233 void Display::InitWindowManagersIfNecessary() { | 233 void Display::InitWindowManagersIfNecessary() { |
| 234 if (!init_called_ || !root_) | 234 if (!init_called_ || !root_) |
| 235 return; | 235 return; |
| 236 | 236 |
| 237 display_manager()->OnDisplayAcceleratedWidgetAvailable(this); | 237 display_manager()->OnDisplayAcceleratedWidgetAvailable(this); |
| 238 if (binding_) { | 238 if (binding_) { |
| 239 std::unique_ptr<WindowManagerState> wms_ptr(new WindowManagerState( | 239 std::unique_ptr<WindowManagerState> wms_ptr( |
| 240 this, platform_display_.get(), top_level_surface_id_)); | 240 new WindowManagerState(this, platform_display_.get())); |
| 241 WindowManagerState* wms = wms_ptr.get(); | 241 WindowManagerState* wms = wms_ptr.get(); |
| 242 // For this case we never create additional WindowManagerStates, so any | 242 // For this case we never create additional WindowManagerStates, so any |
| 243 // id works. | 243 // id works. |
| 244 window_manager_state_map_[shell::mojom::kRootUserID] = std::move(wms_ptr); | 244 window_manager_state_map_[shell::mojom::kRootUserID] = std::move(wms_ptr); |
| 245 wms->tree_ = binding_->CreateWindowTree(wms->root()); | 245 wms->tree_ = binding_->CreateWindowTree(wms->root()); |
| 246 } else { | 246 } else { |
| 247 CreateWindowManagerStatesFromRegistry(); | 247 CreateWindowManagerStatesFromRegistry(); |
| 248 } | 248 } |
| 249 } | 249 } |
| 250 | 250 |
| 251 void Display::CreateWindowManagerStatesFromRegistry() { | 251 void Display::CreateWindowManagerStatesFromRegistry() { |
| 252 std::vector<WindowManagerFactoryService*> services = | 252 std::vector<WindowManagerFactoryService*> services = |
| 253 window_server_->window_manager_factory_registry()->GetServices(); | 253 window_server_->window_manager_factory_registry()->GetServices(); |
| 254 for (WindowManagerFactoryService* service : services) { | 254 for (WindowManagerFactoryService* service : services) { |
| 255 if (service->window_manager_factory()) | 255 if (service->window_manager_factory()) |
| 256 CreateWindowManagerStateFromService(service); | 256 CreateWindowManagerStateFromService(service); |
| 257 } | 257 } |
| 258 } | 258 } |
| 259 | 259 |
| 260 void Display::CreateWindowManagerStateFromService( | 260 void Display::CreateWindowManagerStateFromService( |
| 261 WindowManagerFactoryService* service) { | 261 WindowManagerFactoryService* service) { |
| 262 std::unique_ptr<WindowManagerState> wms_ptr( | 262 std::unique_ptr<WindowManagerState> wms_ptr(new WindowManagerState( |
| 263 new WindowManagerState(this, platform_display_.get(), | 263 this, platform_display_.get(), service->user_id())); |
| 264 top_level_surface_id_, service->user_id())); | |
| 265 WindowManagerState* wms = wms_ptr.get(); | 264 WindowManagerState* wms = wms_ptr.get(); |
| 266 window_manager_state_map_[service->user_id()] = std::move(wms_ptr); | 265 window_manager_state_map_[service->user_id()] = std::move(wms_ptr); |
| 267 wms->tree_ = window_server_->CreateTreeForWindowManager( | 266 wms->tree_ = window_server_->CreateTreeForWindowManager( |
| 268 this, service->window_manager_factory(), wms->root(), service->user_id()); | 267 this, service->window_manager_factory(), wms->root(), service->user_id()); |
| 269 if (!binding_) { | 268 if (!binding_) { |
| 270 const bool is_active = | 269 const bool is_active = |
| 271 service->user_id() == window_server_->user_id_tracker()->active_id(); | 270 service->user_id() == window_server_->user_id_tracker()->active_id(); |
| 272 wms->root()->SetVisible(is_active); | 271 wms->root()->SetVisible(is_active); |
| 273 } | 272 } |
| 274 } | 273 } |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 root_->SetBounds(gfx::Rect(new_metrics.size_in_pixels.To<gfx::Size>())); | 308 root_->SetBounds(gfx::Rect(new_metrics.size_in_pixels.To<gfx::Size>())); |
| 310 const gfx::Rect wm_bounds(root_->bounds().size()); | 309 const gfx::Rect wm_bounds(root_->bounds().size()); |
| 311 for (auto& pair : window_manager_state_map_) | 310 for (auto& pair : window_manager_state_map_) |
| 312 pair.second->root()->SetBounds(wm_bounds); | 311 pair.second->root()->SetBounds(wm_bounds); |
| 313 } | 312 } |
| 314 // TODO(sky): if bounds changed, then need to update | 313 // TODO(sky): if bounds changed, then need to update |
| 315 // Display/WindowManagerState appropriately (e.g. notify observers). | 314 // Display/WindowManagerState appropriately (e.g. notify observers). |
| 316 window_server_->ProcessViewportMetricsChanged(this, old_metrics, new_metrics); | 315 window_server_->ProcessViewportMetricsChanged(this, old_metrics, new_metrics); |
| 317 } | 316 } |
| 318 | 317 |
| 319 void Display::OnTopLevelSurfaceChanged(cc::SurfaceId surface_id) { | |
| 320 DCHECK(!root_); | |
| 321 // This should only be called once, and before we've created root_. | |
| 322 top_level_surface_id_ = surface_id; | |
| 323 } | |
| 324 | |
| 325 void Display::OnCompositorFrameDrawn() { | 318 void Display::OnCompositorFrameDrawn() { |
| 326 std::set<ServerWindow*> windows; | 319 std::set<ServerWindow*> windows; |
| 327 windows.swap(windows_needing_frame_destruction_); | 320 windows.swap(windows_needing_frame_destruction_); |
| 328 for (ServerWindow* window : windows) { | 321 for (ServerWindow* window : windows) { |
| 329 window->RemoveObserver(this); | 322 window->RemoveObserver(this); |
| 330 window->DestroySurfacesScheduledForDestruction(); | 323 window->DestroySurfacesScheduledForDestruction(); |
| 331 } | 324 } |
| 332 } | 325 } |
| 333 | 326 |
| 334 bool Display::CanHaveActiveChildren(ServerWindow* window) const { | 327 bool Display::CanHaveActiveChildren(ServerWindow* window) const { |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 467 DCHECK_EQ(0u, window_manager_state_map_.count(id)); | 460 DCHECK_EQ(0u, window_manager_state_map_.count(id)); |
| 468 } | 461 } |
| 469 | 462 |
| 470 void Display::OnWindowManagerFactorySet(WindowManagerFactoryService* service) { | 463 void Display::OnWindowManagerFactorySet(WindowManagerFactoryService* service) { |
| 471 if (!binding_) | 464 if (!binding_) |
| 472 CreateWindowManagerStateFromService(service); | 465 CreateWindowManagerStateFromService(service); |
| 473 } | 466 } |
| 474 | 467 |
| 475 } // namespace ws | 468 } // namespace ws |
| 476 } // namespace mus | 469 } // namespace mus |
| OLD | NEW |