| OLD | NEW |
| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <queue> | 8 #include <queue> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "ash/ash_constants.h" | 11 #include "ash/ash_constants.h" |
| 12 #include "ash/ash_switches.h" | 12 #include "ash/ash_switches.h" |
| 13 #include "ash/ash_touch_exploration_manager_chromeos.h" | 13 #include "ash/ash_touch_exploration_manager_chromeos.h" |
| 14 #include "ash/aura/aura_layout_manager_adapter.h" | |
| 15 #include "ash/focus_cycler.h" | 14 #include "ash/focus_cycler.h" |
| 16 #include "ash/high_contrast/high_contrast_controller.h" | 15 #include "ash/high_contrast/high_contrast_controller.h" |
| 17 #include "ash/host/ash_window_tree_host.h" | 16 #include "ash/host/ash_window_tree_host.h" |
| 18 #include "ash/login_status.h" | 17 #include "ash/login_status.h" |
| 19 #include "ash/public/cpp/config.h" | 18 #include "ash/public/cpp/config.h" |
| 20 #include "ash/public/cpp/shelf_types.h" | 19 #include "ash/public/cpp/shelf_types.h" |
| 21 #include "ash/public/cpp/shell_window_ids.h" | 20 #include "ash/public/cpp/shell_window_ids.h" |
| 22 #include "ash/root_window_settings.h" | 21 #include "ash/root_window_settings.h" |
| 23 #include "ash/screen_util.h" | 22 #include "ash/screen_util.h" |
| 24 #include "ash/session/session_controller.h" | 23 #include "ash/session/session_controller.h" |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 for (int id : container_ids) { | 226 for (int id : container_ids) { |
| 228 aura::Window* src_container = src->GetChildById(id); | 227 aura::Window* src_container = src->GetChildById(id); |
| 229 aura::Window* dst_container = dst->GetChildById(id); | 228 aura::Window* dst_container = dst->GetChildById(id); |
| 230 while (!src_container->children().empty()) { | 229 while (!src_container->children().empty()) { |
| 231 // Restart iteration from the source container windows each time as they | 230 // Restart iteration from the source container windows each time as they |
| 232 // may change as a result of moving other windows. | 231 // may change as a result of moving other windows. |
| 233 const aura::Window::Windows& src_container_children = | 232 const aura::Window::Windows& src_container_children = |
| 234 src_container->children(); | 233 src_container->children(); |
| 235 auto iter = src_container_children.begin(); | 234 auto iter = src_container_children.begin(); |
| 236 while (iter != src_container_children.end() && | 235 while (iter != src_container_children.end() && |
| 237 SystemModalContainerLayoutManager::IsModalBackground( | 236 SystemModalContainerLayoutManager::IsModalBackground(*iter)) { |
| 238 WmWindow::Get(*iter))) { | |
| 239 ++iter; | 237 ++iter; |
| 240 } | 238 } |
| 241 // If the entire window list is modal background windows then stop. | 239 // If the entire window list is modal background windows then stop. |
| 242 if (iter == src_container_children.end()) | 240 if (iter == src_container_children.end()) |
| 243 break; | 241 break; |
| 244 ReparentWindow(*iter, dst_container); | 242 ReparentWindow(*iter, dst_container); |
| 245 } | 243 } |
| 246 } | 244 } |
| 247 } | 245 } |
| 248 | 246 |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 Shell::Get()->NotifyShelfCreatedForRootWindow(WmWindow::Get(GetRootWindow())); | 375 Shell::Get()->NotifyShelfCreatedForRootWindow(WmWindow::Get(GetRootWindow())); |
| 378 | 376 |
| 379 wm_shelf_->shelf_widget()->PostCreateShelf(); | 377 wm_shelf_->shelf_widget()->PostCreateShelf(); |
| 380 } | 378 } |
| 381 | 379 |
| 382 ShelfLayoutManager* RootWindowController::GetShelfLayoutManager() { | 380 ShelfLayoutManager* RootWindowController::GetShelfLayoutManager() { |
| 383 return wm_shelf_->shelf_layout_manager(); | 381 return wm_shelf_->shelf_layout_manager(); |
| 384 } | 382 } |
| 385 | 383 |
| 386 SystemModalContainerLayoutManager* | 384 SystemModalContainerLayoutManager* |
| 387 RootWindowController::GetSystemModalLayoutManager(WmWindow* window) { | 385 RootWindowController::GetSystemModalLayoutManager(aura::Window* window) { |
| 388 WmWindow* modal_container = nullptr; | 386 aura::Window* modal_container = nullptr; |
| 389 if (window) { | 387 if (window) { |
| 390 aura::Window* window_container = | 388 aura::Window* window_container = wm::GetContainerForWindow(window); |
| 391 wm::GetContainerForWindow(window->aura_window()); | |
| 392 if (window_container && | 389 if (window_container && |
| 393 window_container->id() >= kShellWindowId_LockScreenContainer) { | 390 window_container->id() >= kShellWindowId_LockScreenContainer) { |
| 394 modal_container = GetWmContainer(kShellWindowId_LockSystemModalContainer); | 391 modal_container = GetContainer(kShellWindowId_LockSystemModalContainer); |
| 395 } else { | 392 } else { |
| 396 modal_container = GetWmContainer(kShellWindowId_SystemModalContainer); | 393 modal_container = GetContainer(kShellWindowId_SystemModalContainer); |
| 397 } | 394 } |
| 398 } else { | 395 } else { |
| 399 int modal_window_id = | 396 int modal_window_id = |
| 400 Shell::Get()->session_controller()->IsUserSessionBlocked() | 397 Shell::Get()->session_controller()->IsUserSessionBlocked() |
| 401 ? kShellWindowId_LockSystemModalContainer | 398 ? kShellWindowId_LockSystemModalContainer |
| 402 : kShellWindowId_SystemModalContainer; | 399 : kShellWindowId_SystemModalContainer; |
| 403 modal_container = GetWmContainer(modal_window_id); | 400 modal_container = GetContainer(modal_window_id); |
| 404 } | 401 } |
| 405 return modal_container ? static_cast<SystemModalContainerLayoutManager*>( | 402 return modal_container ? static_cast<SystemModalContainerLayoutManager*>( |
| 406 modal_container->GetLayoutManager()) | 403 modal_container->layout_manager()) |
| 407 : nullptr; | 404 : nullptr; |
| 408 } | 405 } |
| 409 | 406 |
| 410 StatusAreaWidget* RootWindowController::GetStatusAreaWidget() { | 407 StatusAreaWidget* RootWindowController::GetStatusAreaWidget() { |
| 411 ShelfWidget* shelf_widget = wm_shelf_->shelf_widget(); | 408 ShelfWidget* shelf_widget = wm_shelf_->shelf_widget(); |
| 412 return shelf_widget ? shelf_widget->status_area_widget() : nullptr; | 409 return shelf_widget ? shelf_widget->status_area_widget() : nullptr; |
| 413 } | 410 } |
| 414 | 411 |
| 415 SystemTray* RootWindowController::GetSystemTray() { | 412 SystemTray* RootWindowController::GetSystemTray() { |
| 416 // We assume in throughout the code that this will not return NULL. If code | 413 // We assume in throughout the code that this will not return NULL. If code |
| (...skipping 17 matching lines...) Expand all Loading... |
| 434 if (Shell::Get()->session_controller()->IsUserSessionBlocked()) { | 431 if (Shell::Get()->session_controller()->IsUserSessionBlocked()) { |
| 435 blocking_container = | 432 blocking_container = |
| 436 GetContainer(kShellWindowId_LockScreenContainersContainer); | 433 GetContainer(kShellWindowId_LockScreenContainersContainer); |
| 437 modal_container_id = kShellWindowId_LockSystemModalContainer; | 434 modal_container_id = kShellWindowId_LockSystemModalContainer; |
| 438 } else { | 435 } else { |
| 439 modal_container_id = kShellWindowId_SystemModalContainer; | 436 modal_container_id = kShellWindowId_SystemModalContainer; |
| 440 } | 437 } |
| 441 aura::Window* modal_container = GetContainer(modal_container_id); | 438 aura::Window* modal_container = GetContainer(modal_container_id); |
| 442 SystemModalContainerLayoutManager* modal_layout_manager = nullptr; | 439 SystemModalContainerLayoutManager* modal_layout_manager = nullptr; |
| 443 modal_layout_manager = static_cast<SystemModalContainerLayoutManager*>( | 440 modal_layout_manager = static_cast<SystemModalContainerLayoutManager*>( |
| 444 WmWindow::Get(modal_container)->GetLayoutManager()); | 441 modal_container->layout_manager()); |
| 445 | 442 |
| 446 if (modal_layout_manager->has_window_dimmer()) | 443 if (modal_layout_manager->has_window_dimmer()) |
| 447 blocking_container = modal_container; | 444 blocking_container = modal_container; |
| 448 else | 445 else |
| 449 modal_container = nullptr; // Don't check modal dialogs. | 446 modal_container = nullptr; // Don't check modal dialogs. |
| 450 | 447 |
| 451 // In normal session. | 448 // In normal session. |
| 452 if (!blocking_container) | 449 if (!blocking_container) |
| 453 return true; | 450 return true; |
| 454 | 451 |
| 455 if (!IsWindowAboveContainer(window, blocking_container)) | 452 if (!IsWindowAboveContainer(window, blocking_container)) |
| 456 return false; | 453 return false; |
| 457 | 454 |
| 458 // If the window is in the target modal container, only allow the top most | 455 // If the window is in the target modal container, only allow the top most |
| 459 // one. | 456 // one. |
| 460 if (modal_container && modal_container->Contains(window)) | 457 if (modal_container && modal_container->Contains(window)) |
| 461 return modal_layout_manager->IsPartOfActiveModalWindow( | 458 return modal_layout_manager->IsPartOfActiveModalWindow(window); |
| 462 WmWindow::Get(window)); | |
| 463 | 459 |
| 464 return true; | 460 return true; |
| 465 } | 461 } |
| 466 | 462 |
| 467 WmWindow* RootWindowController::FindEventTarget( | 463 WmWindow* RootWindowController::FindEventTarget( |
| 468 const gfx::Point& location_in_screen) { | 464 const gfx::Point& location_in_screen) { |
| 469 gfx::Point location_in_root(location_in_screen); | 465 gfx::Point location_in_root(location_in_screen); |
| 470 aura::Window* root_window = GetRootWindow(); | 466 aura::Window* root_window = GetRootWindow(); |
| 471 ::wm::ConvertPointFromScreen(root_window, &location_in_root); | 467 ::wm::ConvertPointFromScreen(root_window, &location_in_root); |
| 472 ui::MouseEvent test_event(ui::ET_MOUSE_MOVED, location_in_root, | 468 ui::MouseEvent test_event(ui::ET_MOUSE_MOVED, location_in_root, |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 639 return wm::GetWindowForFullscreenMode(GetRootWindow()); | 635 return wm::GetWindowForFullscreenMode(GetRootWindow()); |
| 640 } | 636 } |
| 641 | 637 |
| 642 void RootWindowController::ActivateKeyboard( | 638 void RootWindowController::ActivateKeyboard( |
| 643 keyboard::KeyboardController* keyboard_controller) { | 639 keyboard::KeyboardController* keyboard_controller) { |
| 644 if (!keyboard::IsKeyboardEnabled() || | 640 if (!keyboard::IsKeyboardEnabled() || |
| 645 GetContainer(kShellWindowId_VirtualKeyboardContainer)) { | 641 GetContainer(kShellWindowId_VirtualKeyboardContainer)) { |
| 646 return; | 642 return; |
| 647 } | 643 } |
| 648 DCHECK(keyboard_controller); | 644 DCHECK(keyboard_controller); |
| 649 Shell::Get()->NotifyVirtualKeyboardActivated(true, | 645 Shell::Get()->NotifyVirtualKeyboardActivated(true, GetRootWindow()); |
| 650 WmWindow::Get(GetRootWindow())); | |
| 651 aura::Window* parent = GetContainer(kShellWindowId_ImeWindowParentContainer); | 646 aura::Window* parent = GetContainer(kShellWindowId_ImeWindowParentContainer); |
| 652 DCHECK(parent); | 647 DCHECK(parent); |
| 653 aura::Window* keyboard_container = keyboard_controller->GetContainerWindow(); | 648 aura::Window* keyboard_container = keyboard_controller->GetContainerWindow(); |
| 654 keyboard_container->set_id(kShellWindowId_VirtualKeyboardContainer); | 649 keyboard_container->set_id(kShellWindowId_VirtualKeyboardContainer); |
| 655 parent->AddChild(keyboard_container); | 650 parent->AddChild(keyboard_container); |
| 656 } | 651 } |
| 657 | 652 |
| 658 void RootWindowController::DeactivateKeyboard( | 653 void RootWindowController::DeactivateKeyboard( |
| 659 keyboard::KeyboardController* keyboard_controller) { | 654 keyboard::KeyboardController* keyboard_controller) { |
| 660 if (!keyboard_controller || | 655 if (!keyboard_controller || |
| 661 !keyboard_controller->keyboard_container_initialized()) { | 656 !keyboard_controller->keyboard_container_initialized()) { |
| 662 return; | 657 return; |
| 663 } | 658 } |
| 664 aura::Window* keyboard_container = keyboard_controller->GetContainerWindow(); | 659 aura::Window* keyboard_container = keyboard_controller->GetContainerWindow(); |
| 665 if (keyboard_container->GetRootWindow() == GetRootWindow()) { | 660 if (keyboard_container->GetRootWindow() == GetRootWindow()) { |
| 666 aura::Window* parent = | 661 aura::Window* parent = |
| 667 GetContainer(kShellWindowId_ImeWindowParentContainer); | 662 GetContainer(kShellWindowId_ImeWindowParentContainer); |
| 668 DCHECK(parent); | 663 DCHECK(parent); |
| 669 // Virtual keyboard may be deactivated while still showing, hide the | 664 // Virtual keyboard may be deactivated while still showing, hide the |
| 670 // keyboard before removing it from view hierarchy. | 665 // keyboard before removing it from view hierarchy. |
| 671 keyboard_controller->HideKeyboard( | 666 keyboard_controller->HideKeyboard( |
| 672 keyboard::KeyboardController::HIDE_REASON_AUTOMATIC); | 667 keyboard::KeyboardController::HIDE_REASON_AUTOMATIC); |
| 673 parent->RemoveChild(keyboard_container); | 668 parent->RemoveChild(keyboard_container); |
| 674 Shell::Get()->NotifyVirtualKeyboardActivated( | 669 Shell::Get()->NotifyVirtualKeyboardActivated(false, GetRootWindow()); |
| 675 false, WmWindow::Get(GetRootWindow())); | |
| 676 } | 670 } |
| 677 } | 671 } |
| 678 | 672 |
| 679 bool RootWindowController::IsVirtualKeyboardWindow(aura::Window* window) { | 673 bool RootWindowController::IsVirtualKeyboardWindow(aura::Window* window) { |
| 680 aura::Window* parent = GetContainer(kShellWindowId_ImeWindowParentContainer); | 674 aura::Window* parent = GetContainer(kShellWindowId_ImeWindowParentContainer); |
| 681 return parent ? parent->Contains(window) : false; | 675 return parent ? parent->Contains(window) : false; |
| 682 } | 676 } |
| 683 | 677 |
| 684 void RootWindowController::SetTouchAccessibilityAnchorPoint( | 678 void RootWindowController::SetTouchAccessibilityAnchorPoint( |
| 685 const gfx::Point& anchor_point) { | 679 const gfx::Point& anchor_point) { |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 788 Shell::GetAshConfig() != Config::MASH) { | 782 Shell::GetAshConfig() != Config::MASH) { |
| 789 touch_exploration_manager_.reset(new AshTouchExplorationManager(this)); | 783 touch_exploration_manager_.reset(new AshTouchExplorationManager(this)); |
| 790 } | 784 } |
| 791 } | 785 } |
| 792 | 786 |
| 793 void RootWindowController::InitLayoutManagers() { | 787 void RootWindowController::InitLayoutManagers() { |
| 794 // Create the shelf and status area widgets. | 788 // Create the shelf and status area widgets. |
| 795 DCHECK(!wm_shelf_->shelf_widget()); | 789 DCHECK(!wm_shelf_->shelf_widget()); |
| 796 GetShelf()->CreateShelfWidget(GetWindow()); | 790 GetShelf()->CreateShelfWidget(GetWindow()); |
| 797 | 791 |
| 798 WmWindow* root = GetWindow(); | 792 aura::Window* root = GetRootWindow(); |
| 799 root_window_layout_manager_ = new wm::RootWindowLayoutManager(root); | 793 root_window_layout_manager_ = new wm::RootWindowLayoutManager(root); |
| 800 root->SetLayoutManager(base::WrapUnique(root_window_layout_manager_)); | 794 root->SetLayoutManager(root_window_layout_manager_); |
| 801 | 795 |
| 802 aura::Window* default_container = | 796 aura::Window* default_container = |
| 803 GetContainer(kShellWindowId_DefaultContainer); | 797 GetContainer(kShellWindowId_DefaultContainer); |
| 804 // Installs WorkspaceLayoutManager on |default_container|. | 798 // Installs WorkspaceLayoutManager on |default_container|. |
| 805 workspace_controller_.reset(new WorkspaceController(default_container)); | 799 workspace_controller_.reset(new WorkspaceController(default_container)); |
| 806 | 800 |
| 807 WmWindow* modal_container = | 801 aura::Window* modal_container = |
| 808 GetWmContainer(kShellWindowId_SystemModalContainer); | 802 GetContainer(kShellWindowId_SystemModalContainer); |
| 809 DCHECK(modal_container); | |
| 810 modal_container->SetLayoutManager( | 803 modal_container->SetLayoutManager( |
| 811 base::MakeUnique<SystemModalContainerLayoutManager>(modal_container)); | 804 new SystemModalContainerLayoutManager(modal_container)); |
| 812 | 805 |
| 813 WmWindow* lock_modal_container = | 806 aura::Window* lock_modal_container = |
| 814 GetWmContainer(kShellWindowId_LockSystemModalContainer); | 807 GetContainer(kShellWindowId_LockSystemModalContainer); |
| 815 DCHECK(lock_modal_container); | 808 DCHECK(lock_modal_container); |
| 816 lock_modal_container->SetLayoutManager( | 809 lock_modal_container->SetLayoutManager( |
| 817 base::MakeUnique<SystemModalContainerLayoutManager>( | 810 new SystemModalContainerLayoutManager(lock_modal_container)); |
| 818 lock_modal_container)); | |
| 819 | 811 |
| 820 WmWindow* lock_container = GetWmContainer(kShellWindowId_LockScreenContainer); | 812 aura::Window* lock_container = |
| 813 GetContainer(kShellWindowId_LockScreenContainer); |
| 821 DCHECK(lock_container); | 814 DCHECK(lock_container); |
| 822 lock_container->SetLayoutManager( | 815 lock_container->SetLayoutManager(new LockLayoutManager(lock_container)); |
| 823 base::MakeUnique<LockLayoutManager>(lock_container)); | |
| 824 | 816 |
| 825 WmWindow* always_on_top_container = | 817 WmWindow* always_on_top_container = |
| 826 GetWmContainer(kShellWindowId_AlwaysOnTopContainer); | 818 GetWmContainer(kShellWindowId_AlwaysOnTopContainer); |
| 827 DCHECK(always_on_top_container); | 819 DCHECK(always_on_top_container); |
| 828 always_on_top_controller_ = | 820 always_on_top_controller_ = |
| 829 base::MakeUnique<AlwaysOnTopController>(always_on_top_container); | 821 base::MakeUnique<AlwaysOnTopController>(always_on_top_container); |
| 830 | 822 |
| 831 // Create Panel layout manager | 823 // Create Panel layout manager |
| 832 WmWindow* wm_panel_container = GetWmContainer(kShellWindowId_PanelContainer); | 824 WmWindow* wm_panel_container = GetWmContainer(kShellWindowId_PanelContainer); |
| 833 panel_layout_manager_ = new PanelLayoutManager(wm_panel_container); | 825 panel_layout_manager_ = new PanelLayoutManager(wm_panel_container); |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1105 EnableTouchHudProjection(); | 1097 EnableTouchHudProjection(); |
| 1106 else | 1098 else |
| 1107 DisableTouchHudProjection(); | 1099 DisableTouchHudProjection(); |
| 1108 } | 1100 } |
| 1109 | 1101 |
| 1110 RootWindowController* GetRootWindowController(const aura::Window* root_window) { | 1102 RootWindowController* GetRootWindowController(const aura::Window* root_window) { |
| 1111 return root_window ? GetRootWindowSettings(root_window)->controller : nullptr; | 1103 return root_window ? GetRootWindowSettings(root_window)->controller : nullptr; |
| 1112 } | 1104 } |
| 1113 | 1105 |
| 1114 } // namespace ash | 1106 } // namespace ash |
| OLD | NEW |