| 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 | 80 |
| 81 DISALLOW_COPY_AND_ASSIGN(WorkspaceLayoutManagerDelegateImpl); | 81 DISALLOW_COPY_AND_ASSIGN(WorkspaceLayoutManagerDelegateImpl); |
| 82 }; | 82 }; |
| 83 | 83 |
| 84 } // namespace | 84 } // namespace |
| 85 | 85 |
| 86 // static | 86 // static |
| 87 RootWindowController* RootWindowController::CreateFromDisplay( | 87 RootWindowController* RootWindowController::CreateFromDisplay( |
| 88 WindowManagerApplication* app, | 88 WindowManagerApplication* app, |
| 89 mus::mojom::DisplayPtr display, | 89 mus::mojom::DisplayPtr display, |
| 90 mojo::InterfaceRequest<mus::mojom::WindowTreeClient> client_request) { | 90 mus::mojom::WindowTreeClientRequest client_request) { |
| 91 RootWindowController* controller = new RootWindowController(app); | 91 RootWindowController* controller = new RootWindowController(app); |
| 92 controller->display_ = display.To<display::Display>(); | 92 controller->display_ = display.To<display::Display>(); |
| 93 mus::WindowTreeConnection::CreateForWindowManager( | 93 new mus::WindowTreeClient(controller, controller->window_manager_.get(), |
| 94 controller, std::move(client_request), | 94 std::move(client_request)); |
| 95 mus::WindowTreeConnection::CreateType::DONT_WAIT_FOR_EMBED, | |
| 96 controller->window_manager_.get()); | |
| 97 return controller; | 95 return controller; |
| 98 } | 96 } |
| 99 | 97 |
| 100 void RootWindowController::Destroy() { | 98 void RootWindowController::Destroy() { |
| 101 // See class description for details on lifetime. | 99 // See class description for details on lifetime. |
| 102 if (root_) { | 100 if (root_) { |
| 103 delete root_->connection(); | 101 delete root_->window_tree(); |
| 104 } else { | 102 } else { |
| 105 // This case only happens if we're destroyed before OnEmbed(). | 103 // This case only happens if we're destroyed before OnEmbed(). |
| 106 delete this; | 104 delete this; |
| 107 } | 105 } |
| 108 } | 106 } |
| 109 | 107 |
| 110 shell::Connector* RootWindowController::GetConnector() { | 108 shell::Connector* RootWindowController::GetConnector() { |
| 111 return app_->connector(); | 109 return app_->connector(); |
| 112 } | 110 } |
| 113 | 111 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 ash::wm::WmWindow* always_on_top_container = | 183 ash::wm::WmWindow* always_on_top_container = |
| 186 wm::WmWindowMus::Get(root)->GetChildByShellWindowId( | 184 wm::WmWindowMus::Get(root)->GetChildByShellWindowId( |
| 187 ash::kShellWindowId_AlwaysOnTopContainer); | 185 ash::kShellWindowId_AlwaysOnTopContainer); |
| 188 always_on_top_controller_.reset( | 186 always_on_top_controller_.reset( |
| 189 new ash::AlwaysOnTopController(always_on_top_container)); | 187 new ash::AlwaysOnTopController(always_on_top_container)); |
| 190 | 188 |
| 191 AddAccelerators(); | 189 AddAccelerators(); |
| 192 | 190 |
| 193 window_manager_->Initialize(this, app_->session()); | 191 window_manager_->Initialize(this, app_->session()); |
| 194 | 192 |
| 195 shadow_controller_.reset(new ShadowController(root->connection())); | 193 shadow_controller_.reset(new ShadowController(root->window_tree())); |
| 196 | 194 |
| 197 app_->OnRootWindowControllerDoneInit(this); | 195 app_->OnRootWindowControllerDoneInit(this); |
| 198 } | 196 } |
| 199 | 197 |
| 200 void RootWindowController::OnConnectionLost( | 198 void RootWindowController::OnWindowTreeClientDestroyed( |
| 201 mus::WindowTreeConnection* connection) { | 199 mus::WindowTreeClient* client) { |
| 202 shadow_controller_.reset(); | 200 shadow_controller_.reset(); |
| 203 delete this; | 201 delete this; |
| 204 } | 202 } |
| 205 | 203 |
| 206 void RootWindowController::OnEventObserved(const ui::Event& event, | 204 void RootWindowController::OnEventObserved(const ui::Event& event, |
| 207 mus::Window* target) { | 205 mus::Window* target) { |
| 208 // Does not use EventObservers. | 206 // Does not use EventObservers. |
| 209 } | 207 } |
| 210 | 208 |
| 211 void RootWindowController::OnWindowDestroyed(mus::Window* window) { | 209 void RootWindowController::OnWindowDestroyed(mus::Window* window) { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 235 mash::wm::mojom::Container container, | 233 mash::wm::mojom::Container container, |
| 236 mash::wm::mojom::Container parent_container) { | 234 mash::wm::mojom::Container parent_container) { |
| 237 // Set the window's name to the container name (e.g. "Container::LOGIN"), | 235 // Set the window's name to the container name (e.g. "Container::LOGIN"), |
| 238 // which makes the window hierarchy easier to read. | 236 // which makes the window hierarchy easier to read. |
| 239 std::map<std::string, std::vector<uint8_t>> properties; | 237 std::map<std::string, std::vector<uint8_t>> properties; |
| 240 std::ostringstream container_name; | 238 std::ostringstream container_name; |
| 241 container_name << container; | 239 container_name << container; |
| 242 properties[mus::mojom::WindowManager::kName_Property] = | 240 properties[mus::mojom::WindowManager::kName_Property] = |
| 243 mojo::ConvertTo<std::vector<uint8_t>>(container_name.str()); | 241 mojo::ConvertTo<std::vector<uint8_t>>(container_name.str()); |
| 244 | 242 |
| 245 mus::Window* window = root_->connection()->NewWindow(&properties); | 243 mus::Window* window = root_->window_tree()->NewWindow(&properties); |
| 246 window->set_local_id(ContainerToLocalId(container)); | 244 window->set_local_id(ContainerToLocalId(container)); |
| 247 layout_managers_[window].reset(new FillLayout(window)); | 245 layout_managers_[window].reset(new FillLayout(window)); |
| 248 WmWindowMus::Get(window)->SetShellWindowId( | 246 WmWindowMus::Get(window)->SetShellWindowId( |
| 249 MashContainerToAshContainer(container)); | 247 MashContainerToAshContainer(container)); |
| 250 | 248 |
| 251 // User private windows are hidden by default until the window manager learns | 249 // User private windows are hidden by default until the window manager learns |
| 252 // the lock state, so their contents are never accidentally revealed. Tests, | 250 // the lock state, so their contents are never accidentally revealed. Tests, |
| 253 // however, usually assume the screen is unlocked. | 251 // however, usually assume the screen is unlocked. |
| 254 const bool is_test = base::CommandLine::ForCurrentProcess()->HasSwitch( | 252 const bool is_test = base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 255 mus::switches::kUseTestConfig); | 253 mus::switches::kUseTestConfig); |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 mus::Window* user_private_panels = | 336 mus::Window* user_private_panels = |
| 339 GetWindowForContainer(mojom::Container::USER_PRIVATE_PANELS); | 337 GetWindowForContainer(mojom::Container::USER_PRIVATE_PANELS); |
| 340 WmWindowMus* user_private_panels_wm = WmWindowMus::Get(user_private_panels); | 338 WmWindowMus* user_private_panels_wm = WmWindowMus::Get(user_private_panels); |
| 341 layout_managers_.erase(user_private_panels); | 339 layout_managers_.erase(user_private_panels); |
| 342 user_private_panels_wm->SetLayoutManager( | 340 user_private_panels_wm->SetLayoutManager( |
| 343 base::WrapUnique(new ash::PanelLayoutManager(user_private_panels_wm))); | 341 base::WrapUnique(new ash::PanelLayoutManager(user_private_panels_wm))); |
| 344 } | 342 } |
| 345 | 343 |
| 346 } // namespace wm | 344 } // namespace wm |
| 347 } // namespace mash | 345 } // namespace mash |
| OLD | NEW |