| 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 "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "components/mus/common/event_matcher_util.h" | 10 #include "components/mus/common/event_matcher_util.h" |
| 11 #include "components/mus/common/util.h" | 11 #include "components/mus/common/util.h" |
| 12 #include "components/mus/public/cpp/window.h" | 12 #include "components/mus/public/cpp/window.h" |
| 13 #include "components/mus/public/cpp/window_tree_connection.h" | 13 #include "components/mus/public/cpp/window_tree_connection.h" |
| 14 #include "components/mus/public/cpp/window_tree_host_factory.h" | 14 #include "components/mus/public/cpp/window_tree_host_factory.h" |
| 15 #include "mash/session/public/interfaces/session.mojom.h" | 15 #include "mash/session/public/interfaces/session.mojom.h" |
| 16 #include "mash/wm/background_layout.h" | 16 #include "mash/wm/background_layout.h" |
| 17 #include "mash/wm/container_ids.h" |
| 17 #include "mash/wm/fill_layout.h" | 18 #include "mash/wm/fill_layout.h" |
| 18 #include "mash/wm/screenlock_layout.h" | 19 #include "mash/wm/screenlock_layout.h" |
| 19 #include "mash/wm/shadow_controller.h" | 20 #include "mash/wm/shadow_controller.h" |
| 20 #include "mash/wm/shelf_layout_manager.h" | 21 #include "mash/wm/shelf_layout_manager.h" |
| 21 #include "mash/wm/status_layout_manager.h" | 22 #include "mash/wm/status_layout_manager.h" |
| 22 #include "mash/wm/window_layout.h" | 23 #include "mash/wm/window_layout.h" |
| 23 #include "mash/wm/window_manager.h" | 24 #include "mash/wm/window_manager.h" |
| 24 #include "mash/wm/window_manager_application.h" | 25 #include "mash/wm/window_manager_application.h" |
| 25 #include "services/shell/public/cpp/connector.h" | 26 #include "services/shell/public/cpp/connector.h" |
| 26 #include "ui/mojo/display/display_type_converters.h" | 27 #include "ui/mojo/display/display_type_converters.h" |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 window_manager_client()->ActivateNextWindow(); | 91 window_manager_client()->ActivateNextWindow(); |
| 91 break; | 92 break; |
| 92 default: | 93 default: |
| 93 app_->OnAccelerator(id, event); | 94 app_->OnAccelerator(id, event); |
| 94 break; | 95 break; |
| 95 } | 96 } |
| 96 } | 97 } |
| 97 | 98 |
| 98 ShelfLayoutManager* RootWindowController::GetShelfLayoutManager() { | 99 ShelfLayoutManager* RootWindowController::GetShelfLayoutManager() { |
| 99 return static_cast<ShelfLayoutManager*>( | 100 return static_cast<ShelfLayoutManager*>( |
| 100 layout_manager_[GetWindowForContainer(mojom::Container::USER_SHELF)] | 101 layout_managers_[GetWindowForContainer( |
| 102 mojom::Container::USER_PRIVATE_SHELF)] |
| 101 .get()); | 103 .get()); |
| 102 } | 104 } |
| 103 | 105 |
| 104 StatusLayoutManager* RootWindowController::GetStatusLayoutManager() { | 106 StatusLayoutManager* RootWindowController::GetStatusLayoutManager() { |
| 105 return static_cast<StatusLayoutManager*>( | 107 return static_cast<StatusLayoutManager*>( |
| 106 layout_manager_[GetWindowForContainer(mojom::Container::STATUS)].get()); | 108 layout_managers_[GetWindowForContainer(mojom::Container::STATUS)].get()); |
| 107 } | 109 } |
| 108 | 110 |
| 109 RootWindowController::RootWindowController(WindowManagerApplication* app) | 111 RootWindowController::RootWindowController(WindowManagerApplication* app) |
| 110 : app_(app), root_(nullptr), window_count_(0) { | 112 : app_(app), root_(nullptr), window_count_(0) { |
| 111 window_manager_.reset(new WindowManager); | 113 window_manager_.reset(new WindowManager); |
| 112 } | 114 } |
| 113 | 115 |
| 114 RootWindowController::~RootWindowController() {} | 116 RootWindowController::~RootWindowController() {} |
| 115 | 117 |
| 116 void RootWindowController::AddAccelerators() { | 118 void RootWindowController::AddAccelerators() { |
| 117 window_manager_client()->AddAccelerator( | 119 window_manager_client()->AddAccelerator( |
| 118 kWindowSwitchAccelerator, | 120 kWindowSwitchAccelerator, |
| 119 mus::CreateKeyMatcher(mus::mojom::KeyboardCode::TAB, | 121 mus::CreateKeyMatcher(mus::mojom::KeyboardCode::TAB, |
| 120 mus::mojom::kEventFlagControlDown), | 122 mus::mojom::kEventFlagControlDown), |
| 121 base::Bind(&AssertTrue)); | 123 base::Bind(&AssertTrue)); |
| 122 } | 124 } |
| 123 | 125 |
| 124 void RootWindowController::OnEmbed(mus::Window* root) { | 126 void RootWindowController::OnEmbed(mus::Window* root) { |
| 125 root_ = root; | 127 root_ = root; |
| 126 root_->set_local_id(ContainerToLocalId(mojom::Container::ROOT)); | 128 root_->set_local_id(ContainerToLocalId(mojom::Container::ROOT)); |
| 127 root_->AddObserver(this); | 129 root_->AddObserver(this); |
| 128 layout_manager_[root_].reset(new FillLayout(root_)); | 130 layout_managers_[root_].reset(new FillLayout(root_)); |
| 129 | 131 |
| 130 app_->OnRootWindowControllerGotRoot(this); | 132 app_->OnRootWindowControllerGotRoot(this); |
| 131 | 133 |
| 132 CreateContainers(); | 134 CreateContainers(); |
| 133 | 135 |
| 134 // Override the default layout managers for certain containers. | 136 for (size_t i = 0; i < kNumActivationContainers; ++i) { |
| 135 mus::Window* user_background = | 137 window_manager_client()->AddActivationParent( |
| 136 GetWindowForContainer(mojom::Container::USER_BACKGROUND); | 138 GetWindowForContainer(kActivationContainers[i])); |
| 137 layout_manager_[user_background].reset(new BackgroundLayout(user_background)); | 139 } |
| 138 mus::Window* login_app = GetWindowForContainer(mojom::Container::LOGIN_APP); | |
| 139 layout_manager_[login_app].reset(new ScreenlockLayout(login_app)); | |
| 140 mus::Window* user_shelf = GetWindowForContainer(mojom::Container::USER_SHELF); | |
| 141 layout_manager_[user_shelf].reset(new ShelfLayoutManager(user_shelf)); | |
| 142 mus::Window* status = GetWindowForContainer(mojom::Container::STATUS); | |
| 143 layout_manager_[status].reset(new StatusLayoutManager(status)); | |
| 144 | |
| 145 mus::Window* window = GetWindowForContainer(mojom::Container::USER_WINDOWS); | |
| 146 layout_manager_[window].reset(new WindowLayout(window)); | |
| 147 window_manager_client()->AddActivationParent(window); | |
| 148 | |
| 149 // Bubble windows must be allowed to activate because some of them rely on | |
| 150 // deactivation to close. | |
| 151 mus::Window* bubbles = GetWindowForContainer(mojom::Container::BUBBLES); | |
| 152 window_manager_client()->AddActivationParent(bubbles); | |
| 153 | 140 |
| 154 AddAccelerators(); | 141 AddAccelerators(); |
| 155 | 142 |
| 156 window_manager_->Initialize(this, app_->session()); | 143 window_manager_->Initialize(this, app_->session()); |
| 157 | 144 |
| 158 shadow_controller_.reset(new ShadowController(root->connection())); | 145 shadow_controller_.reset(new ShadowController(root->connection())); |
| 159 | 146 |
| 160 app_->OnRootWindowControllerDoneInit(this); | 147 app_->OnRootWindowControllerDoneInit(this); |
| 161 } | 148 } |
| 162 | 149 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 179 // worry about the possibility of |root_| being null. | 166 // worry about the possibility of |root_| being null. |
| 180 window_manager_.reset(); | 167 window_manager_.reset(); |
| 181 root_ = nullptr; | 168 root_ = nullptr; |
| 182 } | 169 } |
| 183 | 170 |
| 184 void RootWindowController::CreateContainer( | 171 void RootWindowController::CreateContainer( |
| 185 mash::wm::mojom::Container container, | 172 mash::wm::mojom::Container container, |
| 186 mash::wm::mojom::Container parent_container) { | 173 mash::wm::mojom::Container parent_container) { |
| 187 mus::Window* window = root_->connection()->NewWindow(); | 174 mus::Window* window = root_->connection()->NewWindow(); |
| 188 window->set_local_id(ContainerToLocalId(container)); | 175 window->set_local_id(ContainerToLocalId(container)); |
| 189 layout_manager_[window].reset(new FillLayout(window)); | 176 layout_managers_[window].reset(new FillLayout(window)); |
| 177 |
| 190 // User private windows are hidden by default until the window manager learns | 178 // User private windows are hidden by default until the window manager learns |
| 191 // the lock state, so their contents are never accidentally revealed. | 179 // the lock state, so their contents are never accidentally revealed. |
| 192 window->SetVisible(container != mojom::Container::USER_PRIVATE); | 180 window->SetVisible(container != mojom::Container::USER_PRIVATE); |
| 193 mus::Window* parent = | 181 mus::Window* parent = |
| 194 root_->GetChildByLocalId(ContainerToLocalId(parent_container)); | 182 root_->GetChildByLocalId(ContainerToLocalId(parent_container)); |
| 195 parent->AddChild(window); | 183 parent->AddChild(window); |
| 196 } | 184 } |
| 197 | 185 |
| 198 void RootWindowController::CreateContainers() { | 186 void RootWindowController::CreateContainers() { |
| 199 CreateContainer(mojom::Container::ALL_USER_BACKGROUND, | 187 CreateContainer(mojom::Container::ALL_USER_BACKGROUND, |
| 200 mojom::Container::ROOT); | 188 mojom::Container::ROOT); |
| 201 CreateContainer(mojom::Container::USER_WORKSPACE, mojom::Container::ROOT); | 189 CreateContainer(mojom::Container::USER, mojom::Container::ROOT); |
| 202 CreateContainer(mojom::Container::USER_BACKGROUND, | 190 CreateContainer(mojom::Container::USER_BACKGROUND, mojom::Container::USER); |
| 203 mojom::Container::USER_WORKSPACE); | 191 CreateContainer(mojom::Container::USER_PRIVATE, mojom::Container::USER); |
| 204 CreateContainer(mojom::Container::USER_PRIVATE, | 192 CreateContainer(mojom::Container::USER_PRIVATE_WINDOWS, |
| 205 mojom::Container::USER_WORKSPACE); | |
| 206 CreateContainer(mojom::Container::USER_WINDOWS, | |
| 207 mojom::Container::USER_PRIVATE); | 193 mojom::Container::USER_PRIVATE); |
| 208 CreateContainer(mojom::Container::USER_ALWAYS_ON_TOP_WINDOWS, | 194 CreateContainer(mojom::Container::USER_PRIVATE_ALWAYS_ON_TOP_WINDOWS, |
| 209 mojom::Container::USER_PRIVATE); | 195 mojom::Container::USER_PRIVATE); |
| 210 CreateContainer(mojom::Container::USER_PRESENTATION_WINDOWS, | 196 CreateContainer(mojom::Container::USER_PRIVATE_DOCKED_WINDOWS, |
| 211 mojom::Container::USER_PRIVATE); | 197 mojom::Container::USER_PRIVATE); |
| 212 CreateContainer(mojom::Container::USER_SHELF, mojom::Container::USER_PRIVATE); | 198 CreateContainer(mojom::Container::USER_PRIVATE_PRESENTATION_WINDOWS, |
| 213 CreateContainer(mojom::Container::LOGIN_WINDOWS, mojom::Container::ROOT); | 199 mojom::Container::USER_PRIVATE); |
| 214 CreateContainer(mojom::Container::LOGIN_APP, mojom::Container::LOGIN_WINDOWS); | 200 CreateContainer(mojom::Container::USER_PRIVATE_SHELF, |
| 215 CreateContainer(mojom::Container::LOGIN_SHELF, | 201 mojom::Container::USER_PRIVATE); |
| 216 mojom::Container::LOGIN_WINDOWS); | 202 CreateContainer(mojom::Container::USER_PRIVATE_PANELS, |
| 203 mojom::Container::USER_PRIVATE); |
| 204 CreateContainer(mojom::Container::USER_PRIVATE_APP_LIST, |
| 205 mojom::Container::USER_PRIVATE); |
| 206 CreateContainer(mojom::Container::USER_PRIVATE_SYSTEM_MODAL, |
| 207 mojom::Container::USER_PRIVATE); |
| 208 CreateContainer(mojom::Container::LOGIN, mojom::Container::ROOT); |
| 209 CreateContainer(mojom::Container::LOGIN_WINDOWS, mojom::Container::LOGIN); |
| 210 CreateContainer(mojom::Container::LOGIN_APP, mojom::Container::LOGIN); |
| 211 CreateContainer(mojom::Container::LOGIN_SHELF, mojom::Container::LOGIN); |
| 217 CreateContainer(mojom::Container::STATUS, mojom::Container::ROOT); | 212 CreateContainer(mojom::Container::STATUS, mojom::Container::ROOT); |
| 218 CreateContainer(mojom::Container::BUBBLES, mojom::Container::ROOT); | 213 CreateContainer(mojom::Container::BUBBLES, mojom::Container::ROOT); |
| 219 CreateContainer(mojom::Container::SYSTEM_MODAL_WINDOWS, | 214 CreateContainer(mojom::Container::SYSTEM_MODAL_WINDOWS, |
| 220 mojom::Container::ROOT); | 215 mojom::Container::ROOT); |
| 221 CreateContainer(mojom::Container::KEYBOARD, mojom::Container::ROOT); | 216 CreateContainer(mojom::Container::KEYBOARD, mojom::Container::ROOT); |
| 222 CreateContainer(mojom::Container::MENUS, mojom::Container::ROOT); | 217 CreateContainer(mojom::Container::MENUS, mojom::Container::ROOT); |
| 223 CreateContainer(mojom::Container::TOOLTIPS, mojom::Container::ROOT); | 218 CreateContainer(mojom::Container::DRAG_AND_TOOLTIPS, mojom::Container::ROOT); |
| 219 |
| 220 // Override the default layout managers for certain containers. |
| 221 mus::Window* user_background = |
| 222 GetWindowForContainer(mojom::Container::USER_BACKGROUND); |
| 223 layout_managers_[user_background].reset( |
| 224 new BackgroundLayout(user_background)); |
| 225 |
| 226 mus::Window* login_app = GetWindowForContainer(mojom::Container::LOGIN_APP); |
| 227 layout_managers_[login_app].reset(new ScreenlockLayout(login_app)); |
| 228 |
| 229 mus::Window* user_shelf = |
| 230 GetWindowForContainer(mojom::Container::USER_PRIVATE_SHELF); |
| 231 layout_managers_[user_shelf].reset(new ShelfLayoutManager(user_shelf)); |
| 232 |
| 233 mus::Window* status = GetWindowForContainer(mojom::Container::STATUS); |
| 234 layout_managers_[status].reset(new StatusLayoutManager(status)); |
| 235 |
| 236 mus::Window* user_private_windows = |
| 237 GetWindowForContainer(mojom::Container::USER_PRIVATE_WINDOWS); |
| 238 layout_managers_[user_private_windows].reset( |
| 239 new WindowLayout(user_private_windows)); |
| 224 } | 240 } |
| 225 | 241 |
| 226 } // namespace wm | 242 } // namespace wm |
| 227 } // namespace mash | 243 } // namespace mash |
| OLD | NEW |