Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(626)

Side by Side Diff: ash/root_window_controller.cc

Issue 2628973002: Moves definitions of RootWindowController into root_window_controller.cc (Closed)
Patch Set: merged to trunk Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ash/root_window_controller.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ash/root_window_controller.h" 5 #include "ash/root_window_controller.h"
6 6
7 #include <queue> 7 #include <queue>
8 #include <vector> 8 #include <vector>
9 9
10 #include "ash/ash_touch_exploration_manager_chromeos.h" 10 #include "ash/ash_touch_exploration_manager_chromeos.h"
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 aura::Window::Windows windows = common_parent->children(); 137 aura::Window::Windows windows = common_parent->children();
138 auto blocking_iter = std::find(windows.begin(), windows.end(), blocking); 138 auto blocking_iter = std::find(windows.begin(), windows.end(), blocking);
139 // If the target window is above blocking window, the window can handle 139 // If the target window is above blocking window, the window can handle
140 // events. 140 // events.
141 return std::find(blocking_iter, windows.end(), target) != windows.end(); 141 return std::find(blocking_iter, windows.end(), target) != windows.end();
142 } 142 }
143 143
144 return true; 144 return true;
145 } 145 }
146 146
147 // Scales |value| that is originally between 0 and |src_max| to be between
148 // 0 and |dst_max|.
149 float ToRelativeValue(int value, int src_max, int dst_max) {
150 return static_cast<float>(value) / static_cast<float>(src_max) * dst_max;
151 }
152
153 // Uses ToRelativeValue() to scale the origin of |bounds_in_out|. The
154 // width/height are not changed.
155 void MoveOriginRelativeToSize(const gfx::Size& src_size,
156 const gfx::Size& dst_size,
157 gfx::Rect* bounds_in_out) {
158 gfx::Point origin = bounds_in_out->origin();
159 bounds_in_out->set_origin(gfx::Point(
160 ToRelativeValue(origin.x(), src_size.width(), dst_size.width()),
161 ToRelativeValue(origin.y(), src_size.height(), dst_size.height())));
162 }
163
164 // Reparents |window| to |new_parent|.
165 // TODO(sky): This should take an aura::Window. http://crbug.com/671246.
166 void ReparentWindow(WmWindow* window, WmWindow* new_parent) {
167 const gfx::Size src_size = window->GetParent()->GetBounds().size();
168 const gfx::Size dst_size = new_parent->GetBounds().size();
169 // Update the restore bounds to make it relative to the display.
170 wm::WindowState* state = window->GetWindowState();
171 gfx::Rect restore_bounds;
172 bool has_restore_bounds = state->HasRestoreBounds();
173
174 bool update_bounds =
175 (state->IsNormalOrSnapped() || state->IsMinimized()) &&
176 new_parent->GetShellWindowId() != kShellWindowId_DockedContainer;
177 gfx::Rect local_bounds;
178 if (update_bounds) {
179 local_bounds = state->window()->GetBounds();
180 MoveOriginRelativeToSize(src_size, dst_size, &local_bounds);
181 }
182
183 if (has_restore_bounds) {
184 restore_bounds = state->GetRestoreBoundsInParent();
185 MoveOriginRelativeToSize(src_size, dst_size, &restore_bounds);
186 }
187
188 new_parent->AddChild(window);
189
190 // Docked windows have bounds handled by the layout manager in AddChild().
191 if (update_bounds)
192 window->SetBounds(local_bounds);
193
194 if (has_restore_bounds)
195 state->SetRestoreBoundsInParent(restore_bounds);
196 }
197
198 // Reparents the appropriate set of windows from |src| to |dst|.
199 // TODO(sky): This should take an aura::Window. http://crbug.com/671246.
200 void ReparentAllWindows(WmWindow* src, WmWindow* dst) {
201 // Set of windows to move.
202 const int kContainerIdsToMove[] = {
203 kShellWindowId_DefaultContainer,
204 kShellWindowId_DockedContainer,
205 kShellWindowId_PanelContainer,
206 kShellWindowId_AlwaysOnTopContainer,
207 kShellWindowId_SystemModalContainer,
208 kShellWindowId_LockSystemModalContainer,
209 kShellWindowId_UnparentedControlContainer,
210 kShellWindowId_OverlayContainer,
211 };
212 const int kExtraContainerIdsToMoveInUnifiedMode[] = {
213 kShellWindowId_LockScreenContainer,
214 kShellWindowId_LockScreenWallpaperContainer,
215 };
216 std::vector<int> container_ids(
217 kContainerIdsToMove,
218 kContainerIdsToMove + arraysize(kContainerIdsToMove));
219 // Check the display mode as this is also necessary when trasitioning between
220 // mirror and unified mode.
221 if (WmShell::Get()->IsInUnifiedModeIgnoreMirroring()) {
222 for (int id : kExtraContainerIdsToMoveInUnifiedMode)
223 container_ids.push_back(id);
224 }
225
226 for (int id : container_ids) {
227 WmWindow* src_container = src->GetChildByShellWindowId(id);
228 WmWindow* dst_container = dst->GetChildByShellWindowId(id);
229 while (!src_container->GetChildren().empty()) {
230 // Restart iteration from the source container windows each time as they
231 // may change as a result of moving other windows.
232 WmWindow::Windows src_container_children = src_container->GetChildren();
233 WmWindow::Windows::const_iterator iter = src_container_children.begin();
234 while (iter != src_container_children.end() &&
235 SystemModalContainerLayoutManager::IsModalBackground(*iter)) {
236 ++iter;
237 }
238 // If the entire window list is modal background windows then stop.
239 if (iter == src_container_children.end())
240 break;
241 ReparentWindow(*iter, dst_container);
242 }
243 }
244 }
245
246 // Creates a new window for use as a container.
247 // TODO(sky): This should create an aura::Window. http://crbug.com/671246.
248 WmWindow* CreateContainer(int window_id, const char* name, WmWindow* parent) {
249 WmWindow* window = WmShell::Get()->NewWindow(ui::wm::WINDOW_TYPE_UNKNOWN,
250 ui::LAYER_NOT_DRAWN);
251 window->SetShellWindowId(window_id);
252 window->SetName(name);
253 parent->AddChild(window);
254 if (window_id != kShellWindowId_UnparentedControlContainer)
255 window->Show();
256 return window;
257 }
258
259 // TODO(sky): This should take an aura::Window. http://crbug.com/671246.
260 bool ShouldDestroyWindowInCloseChildWindows(WmWindow* window) {
261 if (!WmWindowAura::GetAuraWindow(window)->owned_by_parent())
262 return false;
263
264 if (!WmShell::Get()->IsRunningInMash())
265 return true;
266
267 aura::WindowMus* window_mus =
268 aura::WindowMus::Get(WmWindowAura::GetAuraWindow(window));
269 return Shell::window_tree_client()->WasCreatedByThisClient(window_mus) ||
270 Shell::window_tree_client()->IsRoot(window_mus);
271 }
272
147 } // namespace 273 } // namespace
148 274
149 RootWindowController::~RootWindowController() { 275 RootWindowController::~RootWindowController() {
150 Shutdown(); 276 Shutdown();
151 ash_host_.reset(); 277 ash_host_.reset();
152 mus_window_tree_host_.reset(); 278 mus_window_tree_host_.reset();
153 // The CaptureClient needs to be around for as long as the RootWindow is 279 // The CaptureClient needs to be around for as long as the RootWindow is
154 // valid. 280 // valid.
155 capture_client_.reset(); 281 capture_client_.reset();
156 if (animating_wallpaper_widget_controller_.get()) 282 if (animating_wallpaper_widget_controller_.get())
(...skipping 18 matching lines...) Expand all
175 (WmShell::Get()->IsRunningInMash() || Shell::HasInstance())); 301 (WmShell::Get()->IsRunningInMash() || Shell::HasInstance()));
176 return GetRootWindowController(window->GetRootWindow()); 302 return GetRootWindowController(window->GetRootWindow());
177 } 303 }
178 304
179 // static 305 // static
180 RootWindowController* RootWindowController::ForTargetRootWindow() { 306 RootWindowController* RootWindowController::ForTargetRootWindow() {
181 CHECK(Shell::HasInstance()); 307 CHECK(Shell::HasInstance());
182 return GetRootWindowController(Shell::GetTargetRootWindow()); 308 return GetRootWindowController(Shell::GetTargetRootWindow());
183 } 309 }
184 310
311 void RootWindowController::ConfigureWidgetInitParamsForContainer(
312 views::Widget* widget,
313 int shell_container_id,
314 views::Widget::InitParams* init_params) {
315 init_params->parent = GetContainer(shell_container_id);
316 }
317
185 aura::WindowTreeHost* RootWindowController::GetHost() { 318 aura::WindowTreeHost* RootWindowController::GetHost() {
186 return window_tree_host_; 319 return window_tree_host_;
187 } 320 }
188 321
189 const aura::WindowTreeHost* RootWindowController::GetHost() const { 322 const aura::WindowTreeHost* RootWindowController::GetHost() const {
190 return window_tree_host_; 323 return window_tree_host_;
191 } 324 }
192 325
193 aura::Window* RootWindowController::GetRootWindow() { 326 aura::Window* RootWindowController::GetRootWindow() {
194 return GetHost()->window(); 327 return GetHost()->window();
195 } 328 }
196 329
197 const aura::Window* RootWindowController::GetRootWindow() const { 330 const aura::Window* RootWindowController::GetRootWindow() const {
198 return GetHost()->window(); 331 return GetHost()->window();
199 } 332 }
200 333
201 void RootWindowController::Shutdown() { 334 const WmWindow* RootWindowController::GetWindow() const {
202 WmShell::Get()->RemoveShellObserver(this); 335 return WmWindowAura::Get(GetRootWindow());
336 }
203 337
204 touch_exploration_manager_.reset(); 338 wm::WorkspaceWindowState RootWindowController::GetWorkspaceWindowState() {
339 return workspace_controller_ ? workspace_controller()->GetWindowState()
340 : wm::WORKSPACE_WINDOW_STATE_DEFAULT;
341 }
205 342
206 ResetRootForNewWindowsIfNecessary(); 343 bool RootWindowController::HasShelf() {
344 return wm_shelf_->shelf_widget() != nullptr;
345 }
207 346
208 CloseChildWindows(); 347 WmShelf* RootWindowController::GetShelf() {
209 aura::Window* root_window = GetRootWindow(); 348 return wm_shelf_.get();
210 GetRootWindowSettings(root_window)->controller = NULL; 349 }
211 // Forget with the display ID so that display lookup
212 // ends up with invalid display.
213 GetRootWindowSettings(root_window)->display_id = display::kInvalidDisplayId;
214 if (ash_host_)
215 ash_host_->PrepareForShutdown();
216 350
217 system_wallpaper_.reset(); 351 void RootWindowController::CreateShelf() {
218 aura::client::SetScreenPositionClient(root_window, NULL); 352 if (wm_shelf_->IsShelfInitialized())
353 return;
354 wm_shelf_->InitializeShelf();
355
356 if (panel_layout_manager_)
357 panel_layout_manager_->SetShelf(wm_shelf_.get());
358 if (docked_window_layout_manager_) {
359 docked_window_layout_manager_->SetShelf(wm_shelf_.get());
360 if (wm_shelf_->shelf_layout_manager())
361 docked_window_layout_manager_->AddObserver(
362 wm_shelf_->shelf_layout_manager());
363 }
364
365 // Notify shell observers that the shelf has been created.
366 // TODO(jamescook): Move this into WmShelf::InitializeShelf(). This will
367 // require changing AttachedPanelWidgetTargeter's access to WmShelf.
368 WmShell::Get()->NotifyShelfCreatedForRootWindow(
369 WmWindowAura::Get(GetRootWindow()));
370
371 wm_shelf_->shelf_widget()->PostCreateShelf();
372 }
373
374 void RootWindowController::ShowShelf() {
375 if (!wm_shelf_->IsShelfInitialized())
376 return;
377 // TODO(jamescook): Move this into WmShelf.
378 wm_shelf_->shelf_widget()->SetShelfVisibility(true);
379 wm_shelf_->shelf_widget()->status_area_widget()->Show();
380 }
381
382 ShelfLayoutManager* RootWindowController::GetShelfLayoutManager() {
383 return wm_shelf_->shelf_layout_manager();
384 }
385
386 SystemModalContainerLayoutManager*
387 RootWindowController::GetSystemModalLayoutManager(WmWindow* window) {
388 WmWindow* modal_container = nullptr;
389 if (window) {
390 WmWindow* window_container = wm::GetContainerForWindow(window);
391 if (window_container &&
392 window_container->GetShellWindowId() >=
393 kShellWindowId_LockScreenContainer) {
394 modal_container = GetWmContainer(kShellWindowId_LockSystemModalContainer);
395 } else {
396 modal_container = GetWmContainer(kShellWindowId_SystemModalContainer);
397 }
398 } else {
399 int modal_window_id =
400 WmShell::Get()->GetSessionStateDelegate()->IsUserSessionBlocked()
401 ? kShellWindowId_LockSystemModalContainer
402 : kShellWindowId_SystemModalContainer;
403 modal_container = GetWmContainer(modal_window_id);
404 }
405 return modal_container ? static_cast<SystemModalContainerLayoutManager*>(
406 modal_container->GetLayoutManager())
407 : nullptr;
408 }
409
410 StatusAreaWidget* RootWindowController::GetStatusAreaWidget() {
411 ShelfWidget* shelf_widget = wm_shelf_->shelf_widget();
412 return shelf_widget ? shelf_widget->status_area_widget() : nullptr;
413 }
414
415 SystemTray* RootWindowController::GetSystemTray() {
416 // We assume in throughout the code that this will not return NULL. If code
417 // triggers this for valid reasons, it should test status_area_widget first.
418 CHECK(wm_shelf_->shelf_widget()->status_area_widget());
419 return wm_shelf_->shelf_widget()->status_area_widget()->system_tray();
219 } 420 }
220 421
221 bool RootWindowController::CanWindowReceiveEvents(aura::Window* window) { 422 bool RootWindowController::CanWindowReceiveEvents(aura::Window* window) {
222 if (GetRootWindow() != window->GetRootWindow()) 423 if (GetRootWindow() != window->GetRootWindow())
223 return false; 424 return false;
224 425
225 // Always allow events to fall through to the virtual keyboard even if 426 // Always allow events to fall through to the virtual keyboard even if
226 // displaying a system modal dialog. 427 // displaying a system modal dialog.
227 if (IsVirtualKeyboardWindow(window)) 428 if (IsVirtualKeyboardWindow(window))
228 return true; 429 return true;
(...skipping 27 matching lines...) Expand all
256 457
257 // If the window is in the target modal container, only allow the top most 458 // If the window is in the target modal container, only allow the top most
258 // one. 459 // one.
259 if (modal_container && modal_container->Contains(window)) 460 if (modal_container && modal_container->Contains(window))
260 return modal_layout_manager->IsPartOfActiveModalWindow( 461 return modal_layout_manager->IsPartOfActiveModalWindow(
261 WmWindowAura::Get(window)); 462 WmWindowAura::Get(window));
262 463
263 return true; 464 return true;
264 } 465 }
265 466
467 WmWindow* RootWindowController::FindEventTarget(
468 const gfx::Point& location_in_screen) {
469 gfx::Point location_in_root(location_in_screen);
470 aura::Window* root_window = GetRootWindow();
471 ::wm::ConvertPointFromScreen(root_window, &location_in_root);
472 ui::MouseEvent test_event(ui::ET_MOUSE_MOVED, location_in_root,
473 location_in_root, ui::EventTimeForNow(),
474 ui::EF_NONE, ui::EF_NONE);
475 ui::EventTarget* event_handler =
476 static_cast<ui::EventTarget*>(root_window)
477 ->GetEventTargeter()
478 ->FindTargetForEvent(root_window, &test_event);
479 return WmWindowAura::Get(static_cast<aura::Window*>(event_handler));
480 }
481
482 gfx::Point RootWindowController::GetLastMouseLocationInRoot() {
483 return window_tree_host_->dispatcher()->GetLastMouseLocationInRoot();
484 }
485
266 aura::Window* RootWindowController::GetContainer(int container_id) { 486 aura::Window* RootWindowController::GetContainer(int container_id) {
267 return GetRootWindow()->GetChildById(container_id); 487 return GetRootWindow()->GetChildById(container_id);
268 } 488 }
269 489
270 const aura::Window* RootWindowController::GetContainer(int container_id) const { 490 const aura::Window* RootWindowController::GetContainer(int container_id) const {
271 return window_tree_host_->window()->GetChildById(container_id); 491 return window_tree_host_->window()->GetChildById(container_id);
272 } 492 }
273 493
494 const WmWindow* RootWindowController::GetWmContainer(int container_id) const {
495 const aura::Window* window = GetContainer(container_id);
496 return WmWindowAura::Get(window);
497 }
498
499 void RootWindowController::SetWallpaperWidgetController(
500 WallpaperWidgetController* controller) {
501 wallpaper_widget_controller_.reset(controller);
502 }
503
504 void RootWindowController::SetAnimatingWallpaperWidgetController(
505 AnimatingWallpaperWidgetController* controller) {
506 if (animating_wallpaper_widget_controller_.get())
507 animating_wallpaper_widget_controller_->StopAnimating();
508 animating_wallpaper_widget_controller_.reset(controller);
509 }
510
274 void RootWindowController::OnInitialWallpaperAnimationStarted() { 511 void RootWindowController::OnInitialWallpaperAnimationStarted() {
275 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 512 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
276 switches::kAshAnimateFromBootSplashScreen) && 513 switches::kAshAnimateFromBootSplashScreen) &&
277 boot_splash_screen_.get()) { 514 boot_splash_screen_.get()) {
278 // Make the splash screen fade out so it doesn't obscure the wallpaper's 515 // Make the splash screen fade out so it doesn't obscure the wallpaper's
279 // brightness/grayscale animation. 516 // brightness/grayscale animation.
280 boot_splash_screen_->StartHideAnimation( 517 boot_splash_screen_->StartHideAnimation(
281 base::TimeDelta::FromMilliseconds(kBootSplashScreenHideDurationMs)); 518 base::TimeDelta::FromMilliseconds(kBootSplashScreenHideDurationMs));
282 } 519 }
283 } 520 }
284 521
285 void RootWindowController::OnWallpaperAnimationFinished(views::Widget* widget) { 522 void RootWindowController::OnWallpaperAnimationFinished(views::Widget* widget) {
286 // Make sure the wallpaper is visible. 523 // Make sure the wallpaper is visible.
287 system_wallpaper_->SetColor(SK_ColorBLACK); 524 system_wallpaper_->SetColor(SK_ColorBLACK);
288 boot_splash_screen_.reset(); 525 boot_splash_screen_.reset();
289 WmShell::Get()->wallpaper_delegate()->OnWallpaperAnimationFinished(); 526 WmShell::Get()->wallpaper_delegate()->OnWallpaperAnimationFinished();
290 // Only removes old component when wallpaper animation finished. If we 527 // Only removes old component when wallpaper animation finished. If we
291 // remove the old one before the new wallpaper is done fading in there will 528 // remove the old one before the new wallpaper is done fading in there will
292 // be a white flash during the animation. 529 // be a white flash during the animation.
293 if (animating_wallpaper_widget_controller()) { 530 if (animating_wallpaper_widget_controller()) {
294 WallpaperWidgetController* controller = 531 WallpaperWidgetController* controller =
295 animating_wallpaper_widget_controller()->GetController(true); 532 animating_wallpaper_widget_controller()->GetController(true);
296 DCHECK_EQ(controller->widget(), widget); 533 DCHECK_EQ(controller->widget(), widget);
297 // Release the old controller and close its wallpaper widget. 534 // Release the old controller and close its wallpaper widget.
298 SetWallpaperWidgetController(controller); 535 SetWallpaperWidgetController(controller);
299 } 536 }
300 } 537 }
301 538
539 void RootWindowController::Shutdown() {
540 WmShell::Get()->RemoveShellObserver(this);
541
542 touch_exploration_manager_.reset();
543
544 ResetRootForNewWindowsIfNecessary();
545
546 CloseChildWindows();
547 aura::Window* root_window = GetRootWindow();
548 GetRootWindowSettings(root_window)->controller = nullptr;
549 // Forget with the display ID so that display lookup
550 // ends up with invalid display.
551 GetRootWindowSettings(root_window)->display_id = display::kInvalidDisplayId;
552 if (ash_host_)
553 ash_host_->PrepareForShutdown();
554
555 system_wallpaper_.reset();
556 aura::client::SetScreenPositionClient(root_window, nullptr);
557 }
558
302 void RootWindowController::CloseChildWindows() { 559 void RootWindowController::CloseChildWindows() {
560 // NOTE: this may be called multiple times.
561
303 // Remove observer as deactivating keyboard causes 562 // Remove observer as deactivating keyboard causes
304 // docked_window_layout_manager() to fire notifications. 563 // docked_window_layout_manager() to fire notifications.
305 if (docked_window_layout_manager() && wm_shelf_->shelf_layout_manager()) { 564 if (docked_window_layout_manager() && wm_shelf_->shelf_layout_manager()) {
306 docked_window_layout_manager()->RemoveObserver( 565 docked_window_layout_manager()->RemoveObserver(
307 wm_shelf_->shelf_layout_manager()); 566 wm_shelf_->shelf_layout_manager());
308 } 567 }
309 568
310 // Deactivate keyboard container before closing child windows and shutting 569 // Deactivate keyboard container before closing child windows and shutting
311 // down associated layout managers. 570 // down associated layout managers.
312 DeactivateKeyboard(keyboard::KeyboardController::GetInstance()); 571 DeactivateKeyboard(keyboard::KeyboardController::GetInstance());
313 572
314 CloseChildWindowsImpl(); 573 // |panel_layout_manager_| needs to be shut down before windows are destroyed.
574 if (panel_layout_manager_) {
575 panel_layout_manager_->Shutdown();
576 panel_layout_manager_ = nullptr;
577 }
578
579 // |docked_window_layout_manager_| needs to be shut down before windows are
580 // destroyed.
581 if (docked_window_layout_manager_) {
582 docked_window_layout_manager_->Shutdown();
583 docked_window_layout_manager_ = nullptr;
584 }
585
586 WmShelf* shelf = GetShelf();
587 shelf->ShutdownShelfWidget();
588
589 workspace_controller_.reset();
590
591 // Explicitly destroy top level windows. We do this because such windows may
592 // query the RootWindow for state.
593 WmWindowTracker non_toplevel_windows;
594 WmWindow* root = GetWindow();
595 non_toplevel_windows.Add(root);
596 while (!non_toplevel_windows.windows().empty()) {
597 WmWindow* non_toplevel_window = non_toplevel_windows.Pop();
598 WmWindowTracker toplevel_windows;
599 for (WmWindow* child : non_toplevel_window->GetChildren()) {
600 if (!ShouldDestroyWindowInCloseChildWindows(child))
601 continue;
602 if (child->HasNonClientArea())
603 toplevel_windows.Add(child);
604 else
605 non_toplevel_windows.Add(child);
606 }
607 while (!toplevel_windows.windows().empty())
608 toplevel_windows.Pop()->Destroy();
609 }
610 // And then remove the containers.
611 while (!root->GetChildren().empty()) {
612 WmWindow* child = root->GetChildren()[0];
613 if (ShouldDestroyWindowInCloseChildWindows(child))
614 child->Destroy();
615 else
616 root->RemoveChild(child);
617 }
618
619 shelf->DestroyShelfWidget();
620
621 // CloseChildWindows() may be called twice during the shutdown of ash
622 // unittests. Avoid notifying WmShelf that the shelf has been destroyed twice.
623 if (shelf->IsShelfInitialized())
624 shelf->ShutdownShelf();
315 625
316 aura::client::SetDragDropClient(GetRootWindow(), nullptr); 626 aura::client::SetDragDropClient(GetRootWindow(), nullptr);
317 aura::client::SetTooltipClient(GetRootWindow(), nullptr); 627 aura::client::SetTooltipClient(GetRootWindow(), nullptr);
318 } 628 }
319 629
320 ShelfLayoutManager* RootWindowController::GetShelfLayoutManager() { 630 void RootWindowController::MoveWindowsTo(aura::Window* dst) {
321 return wm_shelf_->shelf_layout_manager(); 631 // Clear the workspace controller, so it doesn't incorrectly update the shelf.
322 } 632 workspace_controller_.reset();
323 633 ReparentAllWindows(GetWindow(), WmWindowAura::Get(dst));
324 StatusAreaWidget* RootWindowController::GetStatusAreaWidget() {
325 ShelfWidget* shelf_widget = wm_shelf_->shelf_widget();
326 return shelf_widget ? shelf_widget->status_area_widget() : nullptr;
327 }
328
329 SystemTray* RootWindowController::GetSystemTray() {
330 // We assume in throughout the code that this will not return NULL. If code
331 // triggers this for valid reasons, it should test status_area_widget first.
332 CHECK(wm_shelf_->shelf_widget()->status_area_widget());
333 return wm_shelf_->shelf_widget()->status_area_widget()->system_tray();
334 } 634 }
335 635
336 void RootWindowController::UpdateShelfVisibility() { 636 void RootWindowController::UpdateShelfVisibility() {
337 wm_shelf_->UpdateVisibilityState(); 637 wm_shelf_->UpdateVisibilityState();
338 } 638 }
339 639
640 void RootWindowController::InitTouchHuds() {
641 if (WmShell::Get()->IsRunningInMash())
642 return;
643
644 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
645 if (command_line->HasSwitch(switches::kAshTouchHud))
646 set_touch_hud_debug(new TouchHudDebug(GetRootWindow()));
647 if (Shell::GetInstance()->is_touch_hud_projection_enabled())
648 EnableTouchHudProjection();
649 }
650
340 aura::Window* RootWindowController::GetWindowForFullscreenMode() { 651 aura::Window* RootWindowController::GetWindowForFullscreenMode() {
341 return WmWindowAura::GetAuraWindow( 652 return WmWindowAura::GetAuraWindow(
342 wm::GetWindowForFullscreenMode(WmWindowAura::Get(GetRootWindow()))); 653 wm::GetWindowForFullscreenMode(WmWindowAura::Get(GetRootWindow())));
343 } 654 }
344 655
345 void RootWindowController::ActivateKeyboard( 656 void RootWindowController::ActivateKeyboard(
346 keyboard::KeyboardController* keyboard_controller) { 657 keyboard::KeyboardController* keyboard_controller) {
347 if (!keyboard::IsKeyboardEnabled() || 658 if (!keyboard::IsKeyboardEnabled() ||
348 GetContainer(kShellWindowId_VirtualKeyboardContainer)) { 659 GetContainer(kShellWindowId_VirtualKeyboardContainer)) {
349 return; 660 return;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 aura::Window* parent = GetContainer(kShellWindowId_ImeWindowParentContainer); 704 aura::Window* parent = GetContainer(kShellWindowId_ImeWindowParentContainer);
394 return parent ? parent->Contains(window) : false; 705 return parent ? parent->Contains(window) : false;
395 } 706 }
396 707
397 void RootWindowController::SetTouchAccessibilityAnchorPoint( 708 void RootWindowController::SetTouchAccessibilityAnchorPoint(
398 const gfx::Point& anchor_point) { 709 const gfx::Point& anchor_point) {
399 if (touch_exploration_manager_) 710 if (touch_exploration_manager_)
400 touch_exploration_manager_->SetTouchAccessibilityAnchorPoint(anchor_point); 711 touch_exploration_manager_->SetTouchAccessibilityAnchorPoint(anchor_point);
401 } 712 }
402 713
714 void RootWindowController::ShowContextMenu(const gfx::Point& location_in_screen,
715 ui::MenuSourceType source_type) {
716 ShellDelegate* delegate = WmShell::Get()->delegate();
717 DCHECK(delegate);
718 menu_model_.reset(delegate->CreateContextMenu(wm_shelf_.get(), nullptr));
719 if (!menu_model_)
720 return;
721
722 menu_model_adapter_ = base::MakeUnique<views::MenuModelAdapter>(
723 menu_model_.get(),
724 base::Bind(&RootWindowController::OnMenuClosed, base::Unretained(this)));
725
726 // The wallpaper controller may not be set yet if the user clicked on the
727 // status area before the initial animation completion. See crbug.com/222218
728 if (!wallpaper_widget_controller())
729 return;
730
731 menu_runner_ = base::MakeUnique<views::MenuRunner>(
732 menu_model_adapter_->CreateMenu(),
733 views::MenuRunner::CONTEXT_MENU | views::MenuRunner::ASYNC);
734 ignore_result(
735 menu_runner_->RunMenuAt(wallpaper_widget_controller()->widget(), nullptr,
736 gfx::Rect(location_in_screen, gfx::Size()),
737 views::MENU_ANCHOR_TOPLEFT, source_type));
738 }
739
740 void RootWindowController::UpdateAfterLoginStatusChange(LoginStatus status) {
741 StatusAreaWidget* status_area_widget =
742 wm_shelf_->shelf_widget()->status_area_widget();
743 if (status_area_widget)
744 status_area_widget->UpdateAfterLoginStatusChange(status);
745 }
746
403 //////////////////////////////////////////////////////////////////////////////// 747 ////////////////////////////////////////////////////////////////////////////////
404 // RootWindowController, private: 748 // RootWindowController, private:
405 749
406 RootWindowController::RootWindowController( 750 RootWindowController::RootWindowController(
407 AshWindowTreeHost* ash_host, 751 AshWindowTreeHost* ash_host,
408 aura::WindowTreeHost* window_tree_host) 752 aura::WindowTreeHost* window_tree_host)
409 : ash_host_(ash_host), 753 : ash_host_(ash_host),
410 mus_window_tree_host_(window_tree_host), 754 mus_window_tree_host_(window_tree_host),
411 window_tree_host_(ash_host ? ash_host->AsWindowTreeHost() 755 window_tree_host_(ash_host ? ash_host->AsWindowTreeHost()
412 : window_tree_host), 756 : window_tree_host),
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( 810 if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
467 switches::kAshDisableTouchExplorationMode) && 811 switches::kAshDisableTouchExplorationMode) &&
468 !wm_shell->IsRunningInMash()) { 812 !wm_shell->IsRunningInMash()) {
469 touch_exploration_manager_.reset(new AshTouchExplorationManager(this)); 813 touch_exploration_manager_.reset(new AshTouchExplorationManager(this));
470 } 814 }
471 } 815 }
472 816
473 void RootWindowController::InitLayoutManagers() { 817 void RootWindowController::InitLayoutManagers() {
474 // Create the shelf and status area widgets. 818 // Create the shelf and status area widgets.
475 DCHECK(!wm_shelf_->shelf_widget()); 819 DCHECK(!wm_shelf_->shelf_widget());
476 aura::Window* shelf_container = GetContainer(kShellWindowId_ShelfContainer); 820 GetShelf()->CreateShelfWidget(GetWindow());
477 aura::Window* status_container = GetContainer(kShellWindowId_StatusContainer);
478 WmWindow* wm_shelf_container = WmWindowAura::Get(shelf_container);
479 WmWindow* wm_status_container = WmWindowAura::Get(status_container);
480 821
481 CreateLayoutManagers(); 822 WmWindow* root = GetWindow();
823 root_window_layout_manager_ = new wm::RootWindowLayoutManager(root);
824 root->SetLayoutManager(base::WrapUnique(root_window_layout_manager_));
825
826 WmWindow* default_container = GetWmContainer(kShellWindowId_DefaultContainer);
827 // Installs WorkspaceLayoutManager on |default_container|.
828 workspace_controller_.reset(new WorkspaceController(default_container));
829
830 WmWindow* modal_container =
831 GetWmContainer(kShellWindowId_SystemModalContainer);
832 DCHECK(modal_container);
833 modal_container->SetLayoutManager(
834 base::MakeUnique<SystemModalContainerLayoutManager>(modal_container));
835
836 WmWindow* lock_modal_container =
837 GetWmContainer(kShellWindowId_LockSystemModalContainer);
838 DCHECK(lock_modal_container);
839 lock_modal_container->SetLayoutManager(
840 base::MakeUnique<SystemModalContainerLayoutManager>(
841 lock_modal_container));
842
843 WmWindow* lock_container = GetWmContainer(kShellWindowId_LockScreenContainer);
844 DCHECK(lock_container);
845 lock_container->SetLayoutManager(
846 base::MakeUnique<LockLayoutManager>(lock_container));
847
848 WmWindow* always_on_top_container =
849 GetWmContainer(kShellWindowId_AlwaysOnTopContainer);
850 DCHECK(always_on_top_container);
851 always_on_top_controller_ =
852 base::MakeUnique<AlwaysOnTopController>(always_on_top_container);
853
854 // Create Docked windows layout manager
855 WmWindow* docked_container = GetWmContainer(kShellWindowId_DockedContainer);
856 docked_window_layout_manager_ =
857 new DockedWindowLayoutManager(docked_container);
858 docked_container->SetLayoutManager(
859 base::WrapUnique(docked_window_layout_manager_));
860
861 // Create Panel layout manager
862 WmWindow* wm_panel_container = GetWmContainer(kShellWindowId_PanelContainer);
863 panel_layout_manager_ = new PanelLayoutManager(wm_panel_container);
864 wm_panel_container->SetLayoutManager(base::WrapUnique(panel_layout_manager_));
865
866 wm::WmSnapToPixelLayoutManager::InstallOnContainers(root);
482 867
483 // Make it easier to resize windows that partially overlap the shelf. Must 868 // Make it easier to resize windows that partially overlap the shelf. Must
484 // occur after the ShelfLayoutManager is constructed by ShelfWidget. 869 // occur after the ShelfLayoutManager is constructed by ShelfWidget.
870 aura::Window* shelf_container = GetContainer(kShellWindowId_ShelfContainer);
871 WmWindow* wm_shelf_container = WmWindowAura::Get(shelf_container);
485 shelf_container->SetEventTargeter(base::MakeUnique<ShelfWindowTargeter>( 872 shelf_container->SetEventTargeter(base::MakeUnique<ShelfWindowTargeter>(
486 wm_shelf_container, wm_shelf_.get())); 873 wm_shelf_container, wm_shelf_.get()));
874 aura::Window* status_container = GetContainer(kShellWindowId_StatusContainer);
875 WmWindow* wm_status_container = WmWindowAura::Get(status_container);
487 status_container->SetEventTargeter(base::MakeUnique<ShelfWindowTargeter>( 876 status_container->SetEventTargeter(base::MakeUnique<ShelfWindowTargeter>(
488 wm_status_container, wm_shelf_.get())); 877 wm_status_container, wm_shelf_.get()));
489 878
490 panel_container_handler_ = base::MakeUnique<PanelWindowEventHandler>(); 879 panel_container_handler_ = base::MakeUnique<PanelWindowEventHandler>();
491 GetContainer(kShellWindowId_PanelContainer) 880 GetContainer(kShellWindowId_PanelContainer)
492 ->AddPreTargetHandler(panel_container_handler_.get()); 881 ->AddPreTargetHandler(panel_container_handler_.get());
493 882
494 // Install an AttachedPanelWindowTargeter on the panel container to make it 883 // Install an AttachedPanelWindowTargeter on the panel container to make it
495 // easier to correctly target shelf buttons with touch. 884 // easier to correctly target shelf buttons with touch.
496 gfx::Insets mouse_extend(-kResizeOutsideBoundsSize, -kResizeOutsideBoundsSize, 885 gfx::Insets mouse_extend(-kResizeOutsideBoundsSize, -kResizeOutsideBoundsSize,
497 -kResizeOutsideBoundsSize, 886 -kResizeOutsideBoundsSize,
498 -kResizeOutsideBoundsSize); 887 -kResizeOutsideBoundsSize);
499 gfx::Insets touch_extend = 888 gfx::Insets touch_extend =
500 mouse_extend.Scale(kResizeOutsideBoundsScaleForTouch); 889 mouse_extend.Scale(kResizeOutsideBoundsScaleForTouch);
501 aura::Window* panel_container = GetContainer(kShellWindowId_PanelContainer); 890 aura::Window* panel_container = GetContainer(kShellWindowId_PanelContainer);
502 panel_container->SetEventTargeter(std::unique_ptr<ui::EventTargeter>( 891 panel_container->SetEventTargeter(std::unique_ptr<ui::EventTargeter>(
503 new AttachedPanelWindowTargeter(panel_container, mouse_extend, 892 new AttachedPanelWindowTargeter(panel_container, mouse_extend,
504 touch_extend, panel_layout_manager()))); 893 touch_extend, panel_layout_manager())));
505 } 894 }
506 895
507 void RootWindowController::InitTouchHuds() { 896 void RootWindowController::CreateContainers() {
508 if (WmShell::Get()->IsRunningInMash()) 897 WmWindow* root = GetWindow();
509 return; 898 // These containers are just used by PowerButtonController to animate groups
899 // of containers simultaneously without messing up the current transformations
900 // on those containers. These are direct children of the root window; all of
901 // the other containers are their children.
510 902
511 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); 903 // The wallpaper container is not part of the lock animation, so it is not
512 if (command_line->HasSwitch(switches::kAshTouchHud)) 904 // included in those animate groups. When the screen is locked, the wallpaper
513 set_touch_hud_debug(new TouchHudDebug(GetRootWindow())); 905 // is moved to the lock screen wallpaper container (and moved back on unlock).
514 if (Shell::GetInstance()->is_touch_hud_projection_enabled()) 906 // Ensure that there's an opaque layer occluding the non-lock-screen layers.
515 EnableTouchHudProjection(); 907 WmWindow* wallpaper_container = CreateContainer(
908 kShellWindowId_WallpaperContainer, "WallpaperContainer", root);
909 wallpaper_container->SetChildWindowVisibilityChangesAnimated();
910
911 WmWindow* non_lock_screen_containers =
912 CreateContainer(kShellWindowId_NonLockScreenContainersContainer,
913 "NonLockScreenContainersContainer", root);
914 // Clip all windows inside this container, as half pixel of the window's
915 // texture may become visible when the screen is scaled. crbug.com/368591.
916 non_lock_screen_containers->SetMasksToBounds(true);
917
918 WmWindow* lock_wallpaper_containers =
919 CreateContainer(kShellWindowId_LockScreenWallpaperContainer,
920 "LockScreenWallpaperContainer", root);
921 lock_wallpaper_containers->SetChildWindowVisibilityChangesAnimated();
922
923 WmWindow* lock_screen_containers =
924 CreateContainer(kShellWindowId_LockScreenContainersContainer,
925 "LockScreenContainersContainer", root);
926 WmWindow* lock_screen_related_containers =
927 CreateContainer(kShellWindowId_LockScreenRelatedContainersContainer,
928 "LockScreenRelatedContainersContainer", root);
929
930 CreateContainer(kShellWindowId_UnparentedControlContainer,
931 "UnparentedControlContainer", non_lock_screen_containers);
932
933 WmWindow* default_container =
934 CreateContainer(kShellWindowId_DefaultContainer, "DefaultContainer",
935 non_lock_screen_containers);
936 default_container->SetChildWindowVisibilityChangesAnimated();
937 default_container->SetSnapsChildrenToPhysicalPixelBoundary();
938 default_container->SetBoundsInScreenBehaviorForChildren(
939 WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES);
940 default_container->SetChildrenUseExtendedHitRegion();
941
942 WmWindow* always_on_top_container =
943 CreateContainer(kShellWindowId_AlwaysOnTopContainer,
944 "AlwaysOnTopContainer", non_lock_screen_containers);
945 always_on_top_container->SetChildWindowVisibilityChangesAnimated();
946 always_on_top_container->SetSnapsChildrenToPhysicalPixelBoundary();
947 always_on_top_container->SetBoundsInScreenBehaviorForChildren(
948 WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES);
949
950 WmWindow* docked_container =
951 CreateContainer(kShellWindowId_DockedContainer, "DockedContainer",
952 non_lock_screen_containers);
953 docked_container->SetChildWindowVisibilityChangesAnimated();
954 docked_container->SetSnapsChildrenToPhysicalPixelBoundary();
955 docked_container->SetBoundsInScreenBehaviorForChildren(
956 WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES);
957 docked_container->SetChildrenUseExtendedHitRegion();
958
959 WmWindow* shelf_container =
960 CreateContainer(kShellWindowId_ShelfContainer, "ShelfContainer",
961 non_lock_screen_containers);
962 shelf_container->SetSnapsChildrenToPhysicalPixelBoundary();
963 shelf_container->SetBoundsInScreenBehaviorForChildren(
964 WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES);
965 shelf_container->SetLockedToRoot(true);
966
967 WmWindow* panel_container =
968 CreateContainer(kShellWindowId_PanelContainer, "PanelContainer",
969 non_lock_screen_containers);
970 panel_container->SetSnapsChildrenToPhysicalPixelBoundary();
971 panel_container->SetBoundsInScreenBehaviorForChildren(
972 WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES);
973
974 WmWindow* shelf_bubble_container =
975 CreateContainer(kShellWindowId_ShelfBubbleContainer,
976 "ShelfBubbleContainer", non_lock_screen_containers);
977 shelf_bubble_container->SetSnapsChildrenToPhysicalPixelBoundary();
978 shelf_bubble_container->SetBoundsInScreenBehaviorForChildren(
979 WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES);
980 shelf_bubble_container->SetLockedToRoot(true);
981
982 WmWindow* app_list_container =
983 CreateContainer(kShellWindowId_AppListContainer, "AppListContainer",
984 non_lock_screen_containers);
985 app_list_container->SetSnapsChildrenToPhysicalPixelBoundary();
986 app_list_container->SetBoundsInScreenBehaviorForChildren(
987 WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES);
988
989 WmWindow* modal_container =
990 CreateContainer(kShellWindowId_SystemModalContainer,
991 "SystemModalContainer", non_lock_screen_containers);
992 modal_container->SetSnapsChildrenToPhysicalPixelBoundary();
993 modal_container->SetChildWindowVisibilityChangesAnimated();
994 modal_container->SetBoundsInScreenBehaviorForChildren(
995 WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES);
996 modal_container->SetChildrenUseExtendedHitRegion();
997
998 // TODO(beng): Figure out if we can make this use
999 // SystemModalContainerEventFilter instead of stops_event_propagation.
1000 WmWindow* lock_container =
1001 CreateContainer(kShellWindowId_LockScreenContainer, "LockScreenContainer",
1002 lock_screen_containers);
1003 lock_container->SetSnapsChildrenToPhysicalPixelBoundary();
1004 lock_container->SetBoundsInScreenBehaviorForChildren(
1005 WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES);
1006 // TODO(beng): stopsevents
1007
1008 WmWindow* lock_modal_container =
1009 CreateContainer(kShellWindowId_LockSystemModalContainer,
1010 "LockSystemModalContainer", lock_screen_containers);
1011 lock_modal_container->SetSnapsChildrenToPhysicalPixelBoundary();
1012 lock_modal_container->SetChildWindowVisibilityChangesAnimated();
1013 lock_modal_container->SetBoundsInScreenBehaviorForChildren(
1014 WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES);
1015 lock_modal_container->SetChildrenUseExtendedHitRegion();
1016
1017 WmWindow* status_container =
1018 CreateContainer(kShellWindowId_StatusContainer, "StatusContainer",
1019 lock_screen_related_containers);
1020 status_container->SetSnapsChildrenToPhysicalPixelBoundary();
1021 status_container->SetBoundsInScreenBehaviorForChildren(
1022 WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES);
1023 status_container->SetLockedToRoot(true);
1024
1025 WmWindow* settings_bubble_container =
1026 CreateContainer(kShellWindowId_SettingBubbleContainer,
1027 "SettingBubbleContainer", lock_screen_related_containers);
1028 settings_bubble_container->SetChildWindowVisibilityChangesAnimated();
1029 settings_bubble_container->SetSnapsChildrenToPhysicalPixelBoundary();
1030 settings_bubble_container->SetBoundsInScreenBehaviorForChildren(
1031 WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES);
1032 settings_bubble_container->SetLockedToRoot(true);
1033
1034 WmWindow* virtual_keyboard_parent_container = CreateContainer(
1035 kShellWindowId_ImeWindowParentContainer, "VirtualKeyboardParentContainer",
1036 lock_screen_related_containers);
1037 virtual_keyboard_parent_container->SetSnapsChildrenToPhysicalPixelBoundary();
1038 virtual_keyboard_parent_container->SetBoundsInScreenBehaviorForChildren(
1039 WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES);
1040
1041 WmWindow* menu_container =
1042 CreateContainer(kShellWindowId_MenuContainer, "MenuContainer",
1043 lock_screen_related_containers);
1044 menu_container->SetChildWindowVisibilityChangesAnimated();
1045 menu_container->SetSnapsChildrenToPhysicalPixelBoundary();
1046 menu_container->SetBoundsInScreenBehaviorForChildren(
1047 WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES);
1048
1049 WmWindow* drag_drop_container = CreateContainer(
1050 kShellWindowId_DragImageAndTooltipContainer,
1051 "DragImageAndTooltipContainer", lock_screen_related_containers);
1052 drag_drop_container->SetChildWindowVisibilityChangesAnimated();
1053 drag_drop_container->SetSnapsChildrenToPhysicalPixelBoundary();
1054 drag_drop_container->SetBoundsInScreenBehaviorForChildren(
1055 WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES);
1056
1057 WmWindow* overlay_container =
1058 CreateContainer(kShellWindowId_OverlayContainer, "OverlayContainer",
1059 lock_screen_related_containers);
1060 overlay_container->SetSnapsChildrenToPhysicalPixelBoundary();
1061 overlay_container->SetBoundsInScreenBehaviorForChildren(
1062 WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES);
1063
1064 WmWindow* mouse_cursor_container = CreateContainer(
1065 kShellWindowId_MouseCursorContainer, "MouseCursorContainer", root);
1066 mouse_cursor_container->SetBoundsInScreenBehaviorForChildren(
1067 WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES);
1068
1069 CreateContainer(kShellWindowId_PowerButtonAnimationContainer,
1070 "PowerButtonAnimationContainer", root);
516 } 1071 }
517 1072
518 void RootWindowController::CreateSystemWallpaper( 1073 void RootWindowController::CreateSystemWallpaper(
519 RootWindowType root_window_type) { 1074 RootWindowType root_window_type) {
520 SkColor color = SK_ColorBLACK; 1075 SkColor color = SK_ColorBLACK;
521 // The splash screen appears on the primary display at boot. If this is a 1076 // The splash screen appears on the primary display at boot. If this is a
522 // secondary monitor (either connected at boot or connected later) or if the 1077 // secondary monitor (either connected at boot or connected later) or if the
523 // browser restarted for a second login then don't use the boot color. 1078 // browser restarted for a second login then don't use the boot color.
524 const bool is_boot_splash_screen = 1079 const bool is_boot_splash_screen =
525 root_window_type == RootWindowType::PRIMARY && 1080 root_window_type == RootWindowType::PRIMARY &&
(...skipping 19 matching lines...) Expand all
545 return; 1100 return;
546 set_touch_hud_projection(new TouchHudProjection(GetRootWindow())); 1101 set_touch_hud_projection(new TouchHudProjection(GetRootWindow()));
547 } 1102 }
548 1103
549 void RootWindowController::DisableTouchHudProjection() { 1104 void RootWindowController::DisableTouchHudProjection() {
550 if (!touch_hud_projection_) 1105 if (!touch_hud_projection_)
551 return; 1106 return;
552 touch_hud_projection_->Remove(); 1107 touch_hud_projection_->Remove();
553 } 1108 }
554 1109
1110 void RootWindowController::ResetRootForNewWindowsIfNecessary() {
1111 WmShell* shell = WmShell::Get();
1112 // Change the target root window before closing child windows. If any child
1113 // being removed triggers a relayout of the shelf it will try to build a
1114 // window list adding windows from the target root window's containers which
1115 // may have already gone away.
1116 WmWindow* root = GetWindow();
1117 if (shell->GetRootWindowForNewWindows() == root) {
1118 // The root window for new windows is being destroyed. Switch to the primary
1119 // root window if possible.
1120 WmWindow* primary_root = shell->GetPrimaryRootWindow();
1121 shell->set_root_window_for_new_windows(primary_root == root ? nullptr
1122 : primary_root);
1123 }
1124 }
1125
1126 void RootWindowController::OnMenuClosed() {
1127 menu_runner_.reset();
1128 menu_model_adapter_.reset();
1129 menu_model_.reset();
1130 wm_shelf_->UpdateVisibilityState();
1131 }
1132
555 void RootWindowController::OnLoginStateChanged(LoginStatus status) { 1133 void RootWindowController::OnLoginStateChanged(LoginStatus status) {
556 wm_shelf_->UpdateVisibilityState(); 1134 wm_shelf_->UpdateVisibilityState();
557 } 1135 }
558 1136
559 void RootWindowController::OnTouchHudProjectionToggled(bool enabled) { 1137 void RootWindowController::OnTouchHudProjectionToggled(bool enabled) {
560 if (enabled) 1138 if (enabled)
561 EnableTouchHudProjection(); 1139 EnableTouchHudProjection();
562 else 1140 else
563 DisableTouchHudProjection(); 1141 DisableTouchHudProjection();
564 } 1142 }
565 1143
566 RootWindowController* GetRootWindowController(const aura::Window* root_window) { 1144 RootWindowController* GetRootWindowController(const aura::Window* root_window) {
567 return root_window ? GetRootWindowSettings(root_window)->controller : nullptr; 1145 return root_window ? GetRootWindowSettings(root_window)->controller : nullptr;
568 } 1146 }
569 1147
570 } // namespace ash 1148 } // namespace ash
OLDNEW
« no previous file with comments | « ash/root_window_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698