| 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 "mash/wm/root_window_controller.h" | 5 #include "mash/wm/root_window_controller.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <sstream> | 10 #include <sstream> |
| 11 | 11 |
| 12 #include "ash/wm/common/always_on_top_controller.h" | 12 #include "ash/wm/common/always_on_top_controller.h" |
| 13 #include "ash/wm/common/dock/docked_window_layout_manager.h" | 13 #include "ash/wm/common/dock/docked_window_layout_manager.h" |
| 14 #include "ash/wm/common/panels/panel_layout_manager.h" | 14 #include "ash/wm/common/panels/panel_layout_manager.h" |
| 15 #include "ash/wm/common/wm_shell_window_ids.h" | 15 #include "ash/wm/common/wm_shell_window_ids.h" |
| 16 #include "ash/wm/common/workspace/workspace_layout_manager.h" | 16 #include "ash/wm/common/workspace/workspace_layout_manager.h" |
| 17 #include "ash/wm/common/workspace/workspace_layout_manager_delegate.h" | 17 #include "ash/wm/common/workspace/workspace_layout_manager_delegate.h" |
| 18 #include "base/bind.h" | 18 #include "base/bind.h" |
| 19 #include "base/command_line.h" | 19 #include "base/command_line.h" |
| 20 #include "base/memory/ptr_util.h" | 20 #include "base/memory/ptr_util.h" |
| 21 #include "components/mus/common/event_matcher_util.h" | 21 #include "components/mus/common/event_matcher_util.h" |
| 22 #include "components/mus/common/switches.h" | 22 #include "components/mus/common/switches.h" |
| 23 #include "components/mus/common/util.h" | 23 #include "components/mus/common/util.h" |
| 24 #include "components/mus/public/cpp/property_type_converters.h" | 24 #include "components/mus/public/cpp/property_type_converters.h" |
| 25 #include "components/mus/public/cpp/window.h" | 25 #include "components/mus/public/cpp/window.h" |
| 26 #include "components/mus/public/cpp/window_tree_connection.h" | 26 #include "components/mus/public/cpp/window_tree_client.h" |
| 27 #include "components/mus/public/cpp/window_tree_host_factory.h" | 27 #include "components/mus/public/cpp/window_tree_host_factory.h" |
| 28 #include "components/mus/public/interfaces/window_manager.mojom.h" | 28 #include "components/mus/public/interfaces/window_manager.mojom.h" |
| 29 #include "mash/session/public/interfaces/session.mojom.h" | 29 #include "mash/session/public/interfaces/session.mojom.h" |
| 30 #include "mash/wm/background_layout.h" | 30 #include "mash/wm/background_layout.h" |
| 31 #include "mash/wm/bridge/wm_globals_mus.h" | 31 #include "mash/wm/bridge/wm_globals_mus.h" |
| 32 #include "mash/wm/bridge/wm_root_window_controller_mus.h" | 32 #include "mash/wm/bridge/wm_root_window_controller_mus.h" |
| 33 #include "mash/wm/bridge/wm_shelf_mus.h" | 33 #include "mash/wm/bridge/wm_shelf_mus.h" |
| 34 #include "mash/wm/bridge/wm_window_mus.h" | 34 #include "mash/wm/bridge/wm_window_mus.h" |
| 35 #include "mash/wm/container_ids.h" | 35 #include "mash/wm/container_ids.h" |
| 36 #include "mash/wm/fill_layout.h" | 36 #include "mash/wm/fill_layout.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 | 81 |
| 82 DISALLOW_COPY_AND_ASSIGN(WorkspaceLayoutManagerDelegateImpl); | 82 DISALLOW_COPY_AND_ASSIGN(WorkspaceLayoutManagerDelegateImpl); |
| 83 }; | 83 }; |
| 84 | 84 |
| 85 } // namespace | 85 } // namespace |
| 86 | 86 |
| 87 // static | 87 // static |
| 88 RootWindowController* RootWindowController::CreateFromDisplay( | 88 RootWindowController* RootWindowController::CreateFromDisplay( |
| 89 WindowManagerApplication* app, | 89 WindowManagerApplication* app, |
| 90 mus::mojom::DisplayPtr display, | 90 mus::mojom::DisplayPtr display, |
| 91 mojo::InterfaceRequest<mus::mojom::WindowTreeClient> client_request) { | 91 mus::mojom::WindowTreeClientRequest client_request) { |
| 92 RootWindowController* controller = new RootWindowController(app); | 92 RootWindowController* controller = new RootWindowController(app); |
| 93 controller->display_ = display.To<display::Display>(); | 93 controller->display_ = display.To<display::Display>(); |
| 94 mus::WindowTreeConnection::CreateForWindowManager( | 94 new mus::WindowTreeClient(controller, controller->window_manager_.get(), |
| 95 controller, std::move(client_request), | 95 std::move(client_request)); |
| 96 mus::WindowTreeConnection::CreateType::DONT_WAIT_FOR_EMBED, | |
| 97 controller->window_manager_.get()); | |
| 98 return controller; | 96 return controller; |
| 99 } | 97 } |
| 100 | 98 |
| 101 void RootWindowController::Destroy() { | 99 void RootWindowController::Destroy() { |
| 102 // See class description for details on lifetime. | 100 // See class description for details on lifetime. |
| 103 if (root_) { | 101 if (root_) { |
| 104 delete root_->connection(); | 102 delete root_->window_tree(); |
| 105 } else { | 103 } else { |
| 106 // This case only happens if we're destroyed before OnEmbed(). | 104 // This case only happens if we're destroyed before OnEmbed(). |
| 107 delete this; | 105 delete this; |
| 108 } | 106 } |
| 109 } | 107 } |
| 110 | 108 |
| 111 shell::Connector* RootWindowController::GetConnector() { | 109 shell::Connector* RootWindowController::GetConnector() { |
| 112 return app_->connector(); | 110 return app_->connector(); |
| 113 } | 111 } |
| 114 | 112 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 ash::wm::WmWindow* always_on_top_container = | 184 ash::wm::WmWindow* always_on_top_container = |
| 187 wm::WmWindowMus::Get(root)->GetChildByShellWindowId( | 185 wm::WmWindowMus::Get(root)->GetChildByShellWindowId( |
| 188 ash::kShellWindowId_AlwaysOnTopContainer); | 186 ash::kShellWindowId_AlwaysOnTopContainer); |
| 189 always_on_top_controller_.reset( | 187 always_on_top_controller_.reset( |
| 190 new ash::AlwaysOnTopController(always_on_top_container)); | 188 new ash::AlwaysOnTopController(always_on_top_container)); |
| 191 | 189 |
| 192 AddAccelerators(); | 190 AddAccelerators(); |
| 193 | 191 |
| 194 window_manager_->Initialize(this, app_->session()); | 192 window_manager_->Initialize(this, app_->session()); |
| 195 | 193 |
| 196 shadow_controller_.reset(new ShadowController(root->connection())); | 194 shadow_controller_.reset(new ShadowController(root->window_tree())); |
| 197 | 195 |
| 198 app_->OnRootWindowControllerDoneInit(this); | 196 app_->OnRootWindowControllerDoneInit(this); |
| 199 } | 197 } |
| 200 | 198 |
| 201 void RootWindowController::OnConnectionLost( | 199 void RootWindowController::OnWindowTreeClientDestroyed( |
| 202 mus::WindowTreeConnection* connection) { | 200 mus::WindowTreeClient* client) { |
| 203 shadow_controller_.reset(); | 201 shadow_controller_.reset(); |
| 204 delete this; | 202 delete this; |
| 205 } | 203 } |
| 206 | 204 |
| 207 void RootWindowController::OnEventObserved(const ui::Event& event, | 205 void RootWindowController::OnEventObserved(const ui::Event& event, |
| 208 mus::Window* target) { | 206 mus::Window* target) { |
| 209 // Does not use EventObservers. | 207 // Does not use EventObservers. |
| 210 } | 208 } |
| 211 | 209 |
| 212 void RootWindowController::OnWindowDestroyed(mus::Window* window) { | 210 void RootWindowController::OnWindowDestroyed(mus::Window* window) { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 236 mash::wm::mojom::Container container, | 234 mash::wm::mojom::Container container, |
| 237 mash::wm::mojom::Container parent_container) { | 235 mash::wm::mojom::Container parent_container) { |
| 238 // Set the window's name to the container name (e.g. "Container::LOGIN"), | 236 // Set the window's name to the container name (e.g. "Container::LOGIN"), |
| 239 // which makes the window hierarchy easier to read. | 237 // which makes the window hierarchy easier to read. |
| 240 std::map<std::string, std::vector<uint8_t>> properties; | 238 std::map<std::string, std::vector<uint8_t>> properties; |
| 241 std::ostringstream container_name; | 239 std::ostringstream container_name; |
| 242 container_name << container; | 240 container_name << container; |
| 243 properties[mus::mojom::WindowManager::kName_Property] = | 241 properties[mus::mojom::WindowManager::kName_Property] = |
| 244 mojo::ConvertTo<std::vector<uint8_t>>(container_name.str()); | 242 mojo::ConvertTo<std::vector<uint8_t>>(container_name.str()); |
| 245 | 243 |
| 246 mus::Window* window = root_->connection()->NewWindow(&properties); | 244 mus::Window* window = root_->window_tree()->NewWindow(&properties); |
| 247 window->set_local_id(ContainerToLocalId(container)); | 245 window->set_local_id(ContainerToLocalId(container)); |
| 248 layout_managers_[window].reset(new FillLayout(window)); | 246 layout_managers_[window].reset(new FillLayout(window)); |
| 249 WmWindowMus::Get(window)->SetShellWindowId( | 247 WmWindowMus::Get(window)->SetShellWindowId( |
| 250 MashContainerToAshContainer(container)); | 248 MashContainerToAshContainer(container)); |
| 251 | 249 |
| 252 // User private windows are hidden by default until the window manager learns | 250 // User private windows are hidden by default until the window manager learns |
| 253 // the lock state, so their contents are never accidentally revealed. Tests, | 251 // the lock state, so their contents are never accidentally revealed. Tests, |
| 254 // however, usually assume the screen is unlocked. | 252 // however, usually assume the screen is unlocked. |
| 255 const bool is_test = base::CommandLine::ForCurrentProcess()->HasSwitch( | 253 const bool is_test = base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 256 mus::switches::kUseTestConfig); | 254 mus::switches::kUseTestConfig); |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 mus::Window* user_private_panels = | 337 mus::Window* user_private_panels = |
| 340 GetWindowForContainer(mojom::Container::USER_PRIVATE_PANELS); | 338 GetWindowForContainer(mojom::Container::USER_PRIVATE_PANELS); |
| 341 WmWindowMus* user_private_panels_wm = WmWindowMus::Get(user_private_panels); | 339 WmWindowMus* user_private_panels_wm = WmWindowMus::Get(user_private_panels); |
| 342 layout_managers_.erase(user_private_panels); | 340 layout_managers_.erase(user_private_panels); |
| 343 user_private_panels_wm->SetLayoutManager( | 341 user_private_panels_wm->SetLayoutManager( |
| 344 base::WrapUnique(new ash::PanelLayoutManager(user_private_panels_wm))); | 342 base::WrapUnique(new ash::PanelLayoutManager(user_private_panels_wm))); |
| 345 } | 343 } |
| 346 | 344 |
| 347 } // namespace wm | 345 } // namespace wm |
| 348 } // namespace mash | 346 } // namespace mash |
| OLD | NEW |