| 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 "base/debug/debugger.h" | 7 #include "base/debug/debugger.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "components/mus/common/types.h" | 9 #include "components/mus/common/types.h" |
| 10 #include "components/mus/ws/display_binding.h" | 10 #include "components/mus/ws/display_binding.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 // Destroy any trees, which triggers destroying the WindowManagerState. Copy | 54 // Destroy any trees, which triggers destroying the WindowManagerState. Copy |
| 55 // off the WindowManagerStates as destruction mutates | 55 // off the WindowManagerStates as destruction mutates |
| 56 // |window_manager_state_map_|. | 56 // |window_manager_state_map_|. |
| 57 std::set<WindowManagerState*> states; | 57 std::set<WindowManagerState*> states; |
| 58 for (auto& pair : window_manager_state_map_) | 58 for (auto& pair : window_manager_state_map_) |
| 59 states.insert(pair.second.get()); | 59 states.insert(pair.second.get()); |
| 60 for (WindowManagerState* state : states) | 60 for (WindowManagerState* state : states) |
| 61 window_server_->DestroyTree(state->tree()); | 61 window_server_->DestroyTree(state->tree()); |
| 62 } | 62 } |
| 63 | 63 |
| 64 void Display::Init(scoped_ptr<DisplayBinding> binding) { | 64 void Display::Init(std::unique_ptr<DisplayBinding> binding) { |
| 65 init_called_ = true; | 65 init_called_ = true; |
| 66 binding_ = std::move(binding); | 66 binding_ = std::move(binding); |
| 67 display_manager()->AddDisplay(this); | 67 display_manager()->AddDisplay(this); |
| 68 InitWindowManagersIfNecessary(); | 68 InitWindowManagersIfNecessary(); |
| 69 } | 69 } |
| 70 | 70 |
| 71 DisplayManager* Display::display_manager() { | 71 DisplayManager* Display::display_manager() { |
| 72 return window_server_->display_manager(); | 72 return window_server_->display_manager(); |
| 73 } | 73 } |
| 74 | 74 |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 void Display::SetTitle(const mojo::String& title) { | 243 void Display::SetTitle(const mojo::String& title) { |
| 244 platform_display_->SetTitle(title.To<base::string16>()); | 244 platform_display_->SetTitle(title.To<base::string16>()); |
| 245 } | 245 } |
| 246 | 246 |
| 247 void Display::InitWindowManagersIfNecessary() { | 247 void Display::InitWindowManagersIfNecessary() { |
| 248 if (!init_called_ || !root_) | 248 if (!init_called_ || !root_) |
| 249 return; | 249 return; |
| 250 | 250 |
| 251 display_manager()->OnDisplayAcceleratedWidgetAvailable(this); | 251 display_manager()->OnDisplayAcceleratedWidgetAvailable(this); |
| 252 if (binding_) { | 252 if (binding_) { |
| 253 scoped_ptr<WindowManagerState> wms_ptr(new WindowManagerState( | 253 std::unique_ptr<WindowManagerState> wms_ptr(new WindowManagerState( |
| 254 this, platform_display_.get(), top_level_surface_id_)); | 254 this, platform_display_.get(), top_level_surface_id_)); |
| 255 WindowManagerState* wms = wms_ptr.get(); | 255 WindowManagerState* wms = wms_ptr.get(); |
| 256 // For this case we never create additional WindowManagerStates, so any | 256 // For this case we never create additional WindowManagerStates, so any |
| 257 // id works. | 257 // id works. |
| 258 window_manager_state_map_[shell::mojom::kRootUserID] = std::move(wms_ptr); | 258 window_manager_state_map_[shell::mojom::kRootUserID] = std::move(wms_ptr); |
| 259 wms->tree_ = binding_->CreateWindowTree(wms->root()); | 259 wms->tree_ = binding_->CreateWindowTree(wms->root()); |
| 260 } else { | 260 } else { |
| 261 CreateWindowManagerStatesFromRegistry(); | 261 CreateWindowManagerStatesFromRegistry(); |
| 262 } | 262 } |
| 263 } | 263 } |
| 264 | 264 |
| 265 void Display::CreateWindowManagerStatesFromRegistry() { | 265 void Display::CreateWindowManagerStatesFromRegistry() { |
| 266 std::vector<WindowManagerFactoryService*> services = | 266 std::vector<WindowManagerFactoryService*> services = |
| 267 window_server_->window_manager_factory_registry()->GetServices(); | 267 window_server_->window_manager_factory_registry()->GetServices(); |
| 268 for (WindowManagerFactoryService* service : services) { | 268 for (WindowManagerFactoryService* service : services) { |
| 269 if (service->window_manager_factory()) | 269 if (service->window_manager_factory()) |
| 270 CreateWindowManagerStateFromService(service); | 270 CreateWindowManagerStateFromService(service); |
| 271 } | 271 } |
| 272 } | 272 } |
| 273 | 273 |
| 274 void Display::CreateWindowManagerStateFromService( | 274 void Display::CreateWindowManagerStateFromService( |
| 275 WindowManagerFactoryService* service) { | 275 WindowManagerFactoryService* service) { |
| 276 scoped_ptr<WindowManagerState> wms_ptr( | 276 std::unique_ptr<WindowManagerState> wms_ptr( |
| 277 new WindowManagerState(this, platform_display_.get(), | 277 new WindowManagerState(this, platform_display_.get(), |
| 278 top_level_surface_id_, service->user_id())); | 278 top_level_surface_id_, service->user_id())); |
| 279 WindowManagerState* wms = wms_ptr.get(); | 279 WindowManagerState* wms = wms_ptr.get(); |
| 280 window_manager_state_map_[service->user_id()] = std::move(wms_ptr); | 280 window_manager_state_map_[service->user_id()] = std::move(wms_ptr); |
| 281 wms->tree_ = window_server_->CreateTreeForWindowManager( | 281 wms->tree_ = window_server_->CreateTreeForWindowManager( |
| 282 this, service->window_manager_factory(), wms->root(), service->user_id()); | 282 this, service->window_manager_factory(), wms->root(), service->user_id()); |
| 283 if (!binding_) { | 283 if (!binding_) { |
| 284 const bool is_active = | 284 const bool is_active = |
| 285 service->user_id() == window_server_->user_id_tracker()->active_id(); | 285 service->user_id() == window_server_->user_id_tracker()->active_id(); |
| 286 wms->root()->SetVisible(is_active); | 286 wms->root()->SetVisible(is_active); |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 481 DCHECK_EQ(0u, window_manager_state_map_.count(id)); | 481 DCHECK_EQ(0u, window_manager_state_map_.count(id)); |
| 482 } | 482 } |
| 483 | 483 |
| 484 void Display::OnWindowManagerFactorySet(WindowManagerFactoryService* service) { | 484 void Display::OnWindowManagerFactorySet(WindowManagerFactoryService* service) { |
| 485 if (!binding_) | 485 if (!binding_) |
| 486 CreateWindowManagerStateFromService(service); | 486 CreateWindowManagerStateFromService(service); |
| 487 } | 487 } |
| 488 | 488 |
| 489 } // namespace ws | 489 } // namespace ws |
| 490 } // namespace mus | 490 } // namespace mus |
| OLD | NEW |