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

Side by Side Diff: ash/root_window_controller.cc

Issue 2629643002: chromeos: Renames WmWindowAura to WmWindow (Closed)
Patch Set: feedback 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/mus/window_manager.cc ('k') | ash/root_window_controller_unittest.cc » ('j') | 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"
11 #include "ash/aura/aura_layout_manager_adapter.h" 11 #include "ash/aura/aura_layout_manager_adapter.h"
12 #include "ash/aura/wm_window_aura.h"
13 #include "ash/common/ash_constants.h" 12 #include "ash/common/ash_constants.h"
14 #include "ash/common/ash_switches.h" 13 #include "ash/common/ash_switches.h"
15 #include "ash/common/focus_cycler.h" 14 #include "ash/common/focus_cycler.h"
16 #include "ash/common/login_status.h" 15 #include "ash/common/login_status.h"
17 #include "ash/common/session/session_state_delegate.h" 16 #include "ash/common/session/session_state_delegate.h"
18 #include "ash/common/shelf/shelf_delegate.h" 17 #include "ash/common/shelf/shelf_delegate.h"
19 #include "ash/common/shelf/shelf_layout_manager.h" 18 #include "ash/common/shelf/shelf_layout_manager.h"
20 #include "ash/common/shelf/shelf_widget.h" 19 #include "ash/common/shelf/shelf_widget.h"
21 #include "ash/common/shelf/wm_shelf.h" 20 #include "ash/common/shelf/wm_shelf.h"
22 #include "ash/common/shell_delegate.h" 21 #include "ash/common/shell_delegate.h"
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 window->SetShellWindowId(window_id); 250 window->SetShellWindowId(window_id);
252 window->SetName(name); 251 window->SetName(name);
253 parent->AddChild(window); 252 parent->AddChild(window);
254 if (window_id != kShellWindowId_UnparentedControlContainer) 253 if (window_id != kShellWindowId_UnparentedControlContainer)
255 window->Show(); 254 window->Show();
256 return window; 255 return window;
257 } 256 }
258 257
259 // TODO(sky): This should take an aura::Window. http://crbug.com/671246. 258 // TODO(sky): This should take an aura::Window. http://crbug.com/671246.
260 bool ShouldDestroyWindowInCloseChildWindows(WmWindow* window) { 259 bool ShouldDestroyWindowInCloseChildWindows(WmWindow* window) {
261 if (!WmWindowAura::GetAuraWindow(window)->owned_by_parent()) 260 if (!WmWindow::GetAuraWindow(window)->owned_by_parent())
262 return false; 261 return false;
263 262
264 if (!WmShell::Get()->IsRunningInMash()) 263 if (!WmShell::Get()->IsRunningInMash())
265 return true; 264 return true;
266 265
267 aura::WindowMus* window_mus = 266 aura::WindowMus* window_mus =
268 aura::WindowMus::Get(WmWindowAura::GetAuraWindow(window)); 267 aura::WindowMus::Get(WmWindow::GetAuraWindow(window));
269 return Shell::window_tree_client()->WasCreatedByThisClient(window_mus) || 268 return Shell::window_tree_client()->WasCreatedByThisClient(window_mus) ||
270 Shell::window_tree_client()->IsRoot(window_mus); 269 Shell::window_tree_client()->IsRoot(window_mus);
271 } 270 }
272 271
273 } // namespace 272 } // namespace
274 273
275 RootWindowController::~RootWindowController() { 274 RootWindowController::~RootWindowController() {
276 Shutdown(); 275 Shutdown();
277 ash_host_.reset(); 276 ash_host_.reset();
278 mus_window_tree_host_.reset(); 277 mus_window_tree_host_.reset();
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 324
326 aura::Window* RootWindowController::GetRootWindow() { 325 aura::Window* RootWindowController::GetRootWindow() {
327 return GetHost()->window(); 326 return GetHost()->window();
328 } 327 }
329 328
330 const aura::Window* RootWindowController::GetRootWindow() const { 329 const aura::Window* RootWindowController::GetRootWindow() const {
331 return GetHost()->window(); 330 return GetHost()->window();
332 } 331 }
333 332
334 const WmWindow* RootWindowController::GetWindow() const { 333 const WmWindow* RootWindowController::GetWindow() const {
335 return WmWindowAura::Get(GetRootWindow()); 334 return WmWindow::Get(GetRootWindow());
336 } 335 }
337 336
338 wm::WorkspaceWindowState RootWindowController::GetWorkspaceWindowState() { 337 wm::WorkspaceWindowState RootWindowController::GetWorkspaceWindowState() {
339 return workspace_controller_ ? workspace_controller()->GetWindowState() 338 return workspace_controller_ ? workspace_controller()->GetWindowState()
340 : wm::WORKSPACE_WINDOW_STATE_DEFAULT; 339 : wm::WORKSPACE_WINDOW_STATE_DEFAULT;
341 } 340 }
342 341
343 bool RootWindowController::HasShelf() { 342 bool RootWindowController::HasShelf() {
344 return wm_shelf_->shelf_widget() != nullptr; 343 return wm_shelf_->shelf_widget() != nullptr;
345 } 344 }
(...skipping 13 matching lines...) Expand all
359 docked_window_layout_manager_->SetShelf(wm_shelf_.get()); 358 docked_window_layout_manager_->SetShelf(wm_shelf_.get());
360 if (wm_shelf_->shelf_layout_manager()) 359 if (wm_shelf_->shelf_layout_manager())
361 docked_window_layout_manager_->AddObserver( 360 docked_window_layout_manager_->AddObserver(
362 wm_shelf_->shelf_layout_manager()); 361 wm_shelf_->shelf_layout_manager());
363 } 362 }
364 363
365 // Notify shell observers that the shelf has been created. 364 // Notify shell observers that the shelf has been created.
366 // TODO(jamescook): Move this into WmShelf::InitializeShelf(). This will 365 // TODO(jamescook): Move this into WmShelf::InitializeShelf(). This will
367 // require changing AttachedPanelWidgetTargeter's access to WmShelf. 366 // require changing AttachedPanelWidgetTargeter's access to WmShelf.
368 WmShell::Get()->NotifyShelfCreatedForRootWindow( 367 WmShell::Get()->NotifyShelfCreatedForRootWindow(
369 WmWindowAura::Get(GetRootWindow())); 368 WmWindow::Get(GetRootWindow()));
370 369
371 wm_shelf_->shelf_widget()->PostCreateShelf(); 370 wm_shelf_->shelf_widget()->PostCreateShelf();
372 } 371 }
373 372
374 ShelfLayoutManager* RootWindowController::GetShelfLayoutManager() { 373 ShelfLayoutManager* RootWindowController::GetShelfLayoutManager() {
375 return wm_shelf_->shelf_layout_manager(); 374 return wm_shelf_->shelf_layout_manager();
376 } 375 }
377 376
378 SystemModalContainerLayoutManager* 377 SystemModalContainerLayoutManager*
379 RootWindowController::GetSystemModalLayoutManager(WmWindow* window) { 378 RootWindowController::GetSystemModalLayoutManager(WmWindow* window) {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 if (WmShell::Get()->GetSessionStateDelegate()->IsUserSessionBlocked()) { 425 if (WmShell::Get()->GetSessionStateDelegate()->IsUserSessionBlocked()) {
427 blocking_container = 426 blocking_container =
428 GetContainer(kShellWindowId_LockScreenContainersContainer); 427 GetContainer(kShellWindowId_LockScreenContainersContainer);
429 modal_container_id = kShellWindowId_LockSystemModalContainer; 428 modal_container_id = kShellWindowId_LockSystemModalContainer;
430 } else { 429 } else {
431 modal_container_id = kShellWindowId_SystemModalContainer; 430 modal_container_id = kShellWindowId_SystemModalContainer;
432 } 431 }
433 aura::Window* modal_container = GetContainer(modal_container_id); 432 aura::Window* modal_container = GetContainer(modal_container_id);
434 SystemModalContainerLayoutManager* modal_layout_manager = nullptr; 433 SystemModalContainerLayoutManager* modal_layout_manager = nullptr;
435 modal_layout_manager = static_cast<SystemModalContainerLayoutManager*>( 434 modal_layout_manager = static_cast<SystemModalContainerLayoutManager*>(
436 WmWindowAura::Get(modal_container)->GetLayoutManager()); 435 WmWindow::Get(modal_container)->GetLayoutManager());
437 436
438 if (modal_layout_manager->has_window_dimmer()) 437 if (modal_layout_manager->has_window_dimmer())
439 blocking_container = modal_container; 438 blocking_container = modal_container;
440 else 439 else
441 modal_container = nullptr; // Don't check modal dialogs. 440 modal_container = nullptr; // Don't check modal dialogs.
442 441
443 // In normal session. 442 // In normal session.
444 if (!blocking_container) 443 if (!blocking_container)
445 return true; 444 return true;
446 445
447 if (!IsWindowAboveContainer(window, blocking_container)) 446 if (!IsWindowAboveContainer(window, blocking_container))
448 return false; 447 return false;
449 448
450 // If the window is in the target modal container, only allow the top most 449 // If the window is in the target modal container, only allow the top most
451 // one. 450 // one.
452 if (modal_container && modal_container->Contains(window)) 451 if (modal_container && modal_container->Contains(window))
453 return modal_layout_manager->IsPartOfActiveModalWindow( 452 return modal_layout_manager->IsPartOfActiveModalWindow(
454 WmWindowAura::Get(window)); 453 WmWindow::Get(window));
455 454
456 return true; 455 return true;
457 } 456 }
458 457
459 WmWindow* RootWindowController::FindEventTarget( 458 WmWindow* RootWindowController::FindEventTarget(
460 const gfx::Point& location_in_screen) { 459 const gfx::Point& location_in_screen) {
461 gfx::Point location_in_root(location_in_screen); 460 gfx::Point location_in_root(location_in_screen);
462 aura::Window* root_window = GetRootWindow(); 461 aura::Window* root_window = GetRootWindow();
463 ::wm::ConvertPointFromScreen(root_window, &location_in_root); 462 ::wm::ConvertPointFromScreen(root_window, &location_in_root);
464 ui::MouseEvent test_event(ui::ET_MOUSE_MOVED, location_in_root, 463 ui::MouseEvent test_event(ui::ET_MOUSE_MOVED, location_in_root,
465 location_in_root, ui::EventTimeForNow(), 464 location_in_root, ui::EventTimeForNow(),
466 ui::EF_NONE, ui::EF_NONE); 465 ui::EF_NONE, ui::EF_NONE);
467 ui::EventTarget* event_handler = 466 ui::EventTarget* event_handler =
468 static_cast<ui::EventTarget*>(root_window) 467 static_cast<ui::EventTarget*>(root_window)
469 ->GetEventTargeter() 468 ->GetEventTargeter()
470 ->FindTargetForEvent(root_window, &test_event); 469 ->FindTargetForEvent(root_window, &test_event);
471 return WmWindowAura::Get(static_cast<aura::Window*>(event_handler)); 470 return WmWindow::Get(static_cast<aura::Window*>(event_handler));
472 } 471 }
473 472
474 gfx::Point RootWindowController::GetLastMouseLocationInRoot() { 473 gfx::Point RootWindowController::GetLastMouseLocationInRoot() {
475 return window_tree_host_->dispatcher()->GetLastMouseLocationInRoot(); 474 return window_tree_host_->dispatcher()->GetLastMouseLocationInRoot();
476 } 475 }
477 476
478 aura::Window* RootWindowController::GetContainer(int container_id) { 477 aura::Window* RootWindowController::GetContainer(int container_id) {
479 return GetRootWindow()->GetChildById(container_id); 478 return GetRootWindow()->GetChildById(container_id);
480 } 479 }
481 480
482 const aura::Window* RootWindowController::GetContainer(int container_id) const { 481 const aura::Window* RootWindowController::GetContainer(int container_id) const {
483 return window_tree_host_->window()->GetChildById(container_id); 482 return window_tree_host_->window()->GetChildById(container_id);
484 } 483 }
485 484
486 const WmWindow* RootWindowController::GetWmContainer(int container_id) const { 485 const WmWindow* RootWindowController::GetWmContainer(int container_id) const {
487 const aura::Window* window = GetContainer(container_id); 486 const aura::Window* window = GetContainer(container_id);
488 return WmWindowAura::Get(window); 487 return WmWindow::Get(window);
489 } 488 }
490 489
491 void RootWindowController::SetWallpaperWidgetController( 490 void RootWindowController::SetWallpaperWidgetController(
492 WallpaperWidgetController* controller) { 491 WallpaperWidgetController* controller) {
493 wallpaper_widget_controller_.reset(controller); 492 wallpaper_widget_controller_.reset(controller);
494 } 493 }
495 494
496 void RootWindowController::SetAnimatingWallpaperWidgetController( 495 void RootWindowController::SetAnimatingWallpaperWidgetController(
497 AnimatingWallpaperWidgetController* controller) { 496 AnimatingWallpaperWidgetController* controller) {
498 if (animating_wallpaper_widget_controller_.get()) 497 if (animating_wallpaper_widget_controller_.get())
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
615 if (shelf->IsShelfInitialized()) 614 if (shelf->IsShelfInitialized())
616 shelf->ShutdownShelf(); 615 shelf->ShutdownShelf();
617 616
618 aura::client::SetDragDropClient(GetRootWindow(), nullptr); 617 aura::client::SetDragDropClient(GetRootWindow(), nullptr);
619 aura::client::SetTooltipClient(GetRootWindow(), nullptr); 618 aura::client::SetTooltipClient(GetRootWindow(), nullptr);
620 } 619 }
621 620
622 void RootWindowController::MoveWindowsTo(aura::Window* dst) { 621 void RootWindowController::MoveWindowsTo(aura::Window* dst) {
623 // Clear the workspace controller, so it doesn't incorrectly update the shelf. 622 // Clear the workspace controller, so it doesn't incorrectly update the shelf.
624 workspace_controller_.reset(); 623 workspace_controller_.reset();
625 ReparentAllWindows(GetWindow(), WmWindowAura::Get(dst)); 624 ReparentAllWindows(GetWindow(), WmWindow::Get(dst));
626 } 625 }
627 626
628 void RootWindowController::UpdateShelfVisibility() { 627 void RootWindowController::UpdateShelfVisibility() {
629 wm_shelf_->UpdateVisibilityState(); 628 wm_shelf_->UpdateVisibilityState();
630 } 629 }
631 630
632 void RootWindowController::InitTouchHuds() { 631 void RootWindowController::InitTouchHuds() {
633 if (WmShell::Get()->IsRunningInMash()) 632 if (WmShell::Get()->IsRunningInMash())
634 return; 633 return;
635 634
636 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); 635 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
637 if (command_line->HasSwitch(switches::kAshTouchHud)) 636 if (command_line->HasSwitch(switches::kAshTouchHud))
638 set_touch_hud_debug(new TouchHudDebug(GetRootWindow())); 637 set_touch_hud_debug(new TouchHudDebug(GetRootWindow()));
639 if (Shell::GetInstance()->is_touch_hud_projection_enabled()) 638 if (Shell::GetInstance()->is_touch_hud_projection_enabled())
640 EnableTouchHudProjection(); 639 EnableTouchHudProjection();
641 } 640 }
642 641
643 aura::Window* RootWindowController::GetWindowForFullscreenMode() { 642 aura::Window* RootWindowController::GetWindowForFullscreenMode() {
644 return WmWindowAura::GetAuraWindow( 643 return WmWindow::GetAuraWindow(
645 wm::GetWindowForFullscreenMode(WmWindowAura::Get(GetRootWindow()))); 644 wm::GetWindowForFullscreenMode(WmWindow::Get(GetRootWindow())));
646 } 645 }
647 646
648 void RootWindowController::ActivateKeyboard( 647 void RootWindowController::ActivateKeyboard(
649 keyboard::KeyboardController* keyboard_controller) { 648 keyboard::KeyboardController* keyboard_controller) {
650 if (!keyboard::IsKeyboardEnabled() || 649 if (!keyboard::IsKeyboardEnabled() ||
651 GetContainer(kShellWindowId_VirtualKeyboardContainer)) { 650 GetContainer(kShellWindowId_VirtualKeyboardContainer)) {
652 return; 651 return;
653 } 652 }
654 DCHECK(keyboard_controller); 653 DCHECK(keyboard_controller);
655 keyboard_controller->AddObserver(wm_shelf_->shelf_layout_manager()); 654 keyboard_controller->AddObserver(wm_shelf_->shelf_layout_manager());
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
787 shell->InitKeyboard(); 786 shell->InitKeyboard();
788 } else { 787 } else {
789 window_tree_host_->Show(); 788 window_tree_host_->Show();
790 789
791 // Create a shelf if a user is already logged in. 790 // Create a shelf if a user is already logged in.
792 if (wm_shell->GetSessionStateDelegate()->NumberOfLoggedInUsers()) 791 if (wm_shell->GetSessionStateDelegate()->NumberOfLoggedInUsers())
793 CreateShelf(); 792 CreateShelf();
794 793
795 // Notify shell observers about new root window. 794 // Notify shell observers about new root window.
796 if (!wm_shell->IsRunningInMash()) 795 if (!wm_shell->IsRunningInMash())
797 shell->OnRootWindowAdded(WmWindowAura::Get(root_window)); 796 shell->OnRootWindowAdded(WmWindow::Get(root_window));
798 } 797 }
799 798
800 // TODO: AshTouchExplorationManager doesn't work with mus. 799 // TODO: AshTouchExplorationManager doesn't work with mus.
801 // http://crbug.com/679782 800 // http://crbug.com/679782
802 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( 801 if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
803 switches::kAshDisableTouchExplorationMode) && 802 switches::kAshDisableTouchExplorationMode) &&
804 !wm_shell->IsRunningInMash()) { 803 !wm_shell->IsRunningInMash()) {
805 touch_exploration_manager_.reset(new AshTouchExplorationManager(this)); 804 touch_exploration_manager_.reset(new AshTouchExplorationManager(this));
806 } 805 }
807 } 806 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
853 // Create Panel layout manager 852 // Create Panel layout manager
854 WmWindow* wm_panel_container = GetWmContainer(kShellWindowId_PanelContainer); 853 WmWindow* wm_panel_container = GetWmContainer(kShellWindowId_PanelContainer);
855 panel_layout_manager_ = new PanelLayoutManager(wm_panel_container); 854 panel_layout_manager_ = new PanelLayoutManager(wm_panel_container);
856 wm_panel_container->SetLayoutManager(base::WrapUnique(panel_layout_manager_)); 855 wm_panel_container->SetLayoutManager(base::WrapUnique(panel_layout_manager_));
857 856
858 wm::WmSnapToPixelLayoutManager::InstallOnContainers(root); 857 wm::WmSnapToPixelLayoutManager::InstallOnContainers(root);
859 858
860 // Make it easier to resize windows that partially overlap the shelf. Must 859 // Make it easier to resize windows that partially overlap the shelf. Must
861 // occur after the ShelfLayoutManager is constructed by ShelfWidget. 860 // occur after the ShelfLayoutManager is constructed by ShelfWidget.
862 aura::Window* shelf_container = GetContainer(kShellWindowId_ShelfContainer); 861 aura::Window* shelf_container = GetContainer(kShellWindowId_ShelfContainer);
863 WmWindow* wm_shelf_container = WmWindowAura::Get(shelf_container); 862 WmWindow* wm_shelf_container = WmWindow::Get(shelf_container);
864 shelf_container->SetEventTargeter(base::MakeUnique<ShelfWindowTargeter>( 863 shelf_container->SetEventTargeter(base::MakeUnique<ShelfWindowTargeter>(
865 wm_shelf_container, wm_shelf_.get())); 864 wm_shelf_container, wm_shelf_.get()));
866 aura::Window* status_container = GetContainer(kShellWindowId_StatusContainer); 865 aura::Window* status_container = GetContainer(kShellWindowId_StatusContainer);
867 WmWindow* wm_status_container = WmWindowAura::Get(status_container); 866 WmWindow* wm_status_container = WmWindow::Get(status_container);
868 status_container->SetEventTargeter(base::MakeUnique<ShelfWindowTargeter>( 867 status_container->SetEventTargeter(base::MakeUnique<ShelfWindowTargeter>(
869 wm_status_container, wm_shelf_.get())); 868 wm_status_container, wm_shelf_.get()));
870 869
871 panel_container_handler_ = base::MakeUnique<PanelWindowEventHandler>(); 870 panel_container_handler_ = base::MakeUnique<PanelWindowEventHandler>();
872 GetContainer(kShellWindowId_PanelContainer) 871 GetContainer(kShellWindowId_PanelContainer)
873 ->AddPreTargetHandler(panel_container_handler_.get()); 872 ->AddPreTargetHandler(panel_container_handler_.get());
874 873
875 // Install an AttachedPanelWindowTargeter on the panel container to make it 874 // Install an AttachedPanelWindowTargeter on the panel container to make it
876 // easier to correctly target shelf buttons with touch. 875 // easier to correctly target shelf buttons with touch.
877 gfx::Insets mouse_extend(-kResizeOutsideBoundsSize, -kResizeOutsideBoundsSize, 876 gfx::Insets mouse_extend(-kResizeOutsideBoundsSize, -kResizeOutsideBoundsSize,
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
1131 EnableTouchHudProjection(); 1130 EnableTouchHudProjection();
1132 else 1131 else
1133 DisableTouchHudProjection(); 1132 DisableTouchHudProjection();
1134 } 1133 }
1135 1134
1136 RootWindowController* GetRootWindowController(const aura::Window* root_window) { 1135 RootWindowController* GetRootWindowController(const aura::Window* root_window) {
1137 return root_window ? GetRootWindowSettings(root_window)->controller : nullptr; 1136 return root_window ? GetRootWindowSettings(root_window)->controller : nullptr;
1138 } 1137 }
1139 1138
1140 } // namespace ash 1139 } // namespace ash
OLDNEW
« no previous file with comments | « ash/mus/window_manager.cc ('k') | ash/root_window_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698