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

Side by Side Diff: ash/root_window_controller.cc

Issue 2336653002: Ports SystemModalContainerLayoutManager to ash/common (Closed)
Patch Set: merge again Created 4 years, 3 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') | 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/aura/aura_layout_manager_adapter.h" 10 #include "ash/aura/aura_layout_manager_adapter.h"
(...skipping 16 matching lines...) Expand all
27 #include "ash/common/system/tray/system_tray_delegate.h" 27 #include "ash/common/system/tray/system_tray_delegate.h"
28 #include "ash/common/wallpaper/wallpaper_delegate.h" 28 #include "ash/common/wallpaper/wallpaper_delegate.h"
29 #include "ash/common/wallpaper/wallpaper_widget_controller.h" 29 #include "ash/common/wallpaper/wallpaper_widget_controller.h"
30 #include "ash/common/wm/always_on_top_controller.h" 30 #include "ash/common/wm/always_on_top_controller.h"
31 #include "ash/common/wm/container_finder.h" 31 #include "ash/common/wm/container_finder.h"
32 #include "ash/common/wm/dock/docked_window_layout_manager.h" 32 #include "ash/common/wm/dock/docked_window_layout_manager.h"
33 #include "ash/common/wm/fullscreen_window_finder.h" 33 #include "ash/common/wm/fullscreen_window_finder.h"
34 #include "ash/common/wm/panels/panel_layout_manager.h" 34 #include "ash/common/wm/panels/panel_layout_manager.h"
35 #include "ash/common/wm/root_window_layout_manager.h" 35 #include "ash/common/wm/root_window_layout_manager.h"
36 #include "ash/common/wm/switchable_windows.h" 36 #include "ash/common/wm/switchable_windows.h"
37 #include "ash/common/wm/system_modal_container_layout_manager.h"
37 #include "ash/common/wm/window_state.h" 38 #include "ash/common/wm/window_state.h"
38 #include "ash/common/wm/workspace/workspace_layout_manager.h" 39 #include "ash/common/wm/workspace/workspace_layout_manager.h"
39 #include "ash/common/wm/workspace_controller.h" 40 #include "ash/common/wm/workspace_controller.h"
40 #include "ash/common/wm_shell.h" 41 #include "ash/common/wm_shell.h"
41 #include "ash/common/wm_window.h" 42 #include "ash/common/wm_window.h"
42 #include "ash/display/display_manager.h" 43 #include "ash/display/display_manager.h"
43 #include "ash/high_contrast/high_contrast_controller.h" 44 #include "ash/high_contrast/high_contrast_controller.h"
44 #include "ash/host/ash_window_tree_host.h" 45 #include "ash/host/ash_window_tree_host.h"
45 #include "ash/root_window_settings.h" 46 #include "ash/root_window_settings.h"
46 #include "ash/shelf/shelf_window_targeter.h" 47 #include "ash/shelf/shelf_window_targeter.h"
47 #include "ash/shell.h" 48 #include "ash/shell.h"
48 #include "ash/touch/touch_hud_debug.h" 49 #include "ash/touch/touch_hud_debug.h"
49 #include "ash/touch/touch_hud_projection.h" 50 #include "ash/touch/touch_hud_projection.h"
50 #include "ash/touch/touch_observer_hud.h" 51 #include "ash/touch/touch_observer_hud.h"
51 #include "ash/wm/lock_layout_manager.h" 52 #include "ash/wm/lock_layout_manager.h"
52 #include "ash/wm/panels/attached_panel_window_targeter.h" 53 #include "ash/wm/panels/attached_panel_window_targeter.h"
53 #include "ash/wm/panels/panel_window_event_handler.h" 54 #include "ash/wm/panels/panel_window_event_handler.h"
54 #include "ash/wm/stacking_controller.h" 55 #include "ash/wm/stacking_controller.h"
55 #include "ash/wm/system_modal_container_layout_manager.h"
56 #include "ash/wm/system_wallpaper_controller.h" 56 #include "ash/wm/system_wallpaper_controller.h"
57 #include "ash/wm/window_properties.h" 57 #include "ash/wm/window_properties.h"
58 #include "ash/wm/window_state_aura.h" 58 #include "ash/wm/window_state_aura.h"
59 #include "ash/wm/window_util.h" 59 #include "ash/wm/window_util.h"
60 #include "base/command_line.h" 60 #include "base/command_line.h"
61 #include "base/macros.h" 61 #include "base/macros.h"
62 #include "base/memory/ptr_util.h" 62 #include "base/memory/ptr_util.h"
63 #include "base/time/time.h" 63 #include "base/time/time.h"
64 #include "ui/aura/client/aura_constants.h" 64 #include "ui/aura/client/aura_constants.h"
65 #include "ui/aura/client/screen_position_client.h" 65 #include "ui/aura/client/screen_position_client.h"
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 178
179 for (int id : container_ids) { 179 for (int id : container_ids) {
180 aura::Window* src_container = Shell::GetContainer(src, id); 180 aura::Window* src_container = Shell::GetContainer(src, id);
181 aura::Window* dst_container = Shell::GetContainer(dst, id); 181 aura::Window* dst_container = Shell::GetContainer(dst, id);
182 while (!src_container->children().empty()) { 182 while (!src_container->children().empty()) {
183 // Restart iteration from the source container windows each time as they 183 // Restart iteration from the source container windows each time as they
184 // may change as a result of moving other windows. 184 // may change as a result of moving other windows.
185 aura::Window::Windows::const_iterator iter = 185 aura::Window::Windows::const_iterator iter =
186 src_container->children().begin(); 186 src_container->children().begin();
187 while (iter != src_container->children().end() && 187 while (iter != src_container->children().end() &&
188 SystemModalContainerLayoutManager::IsModalBackground(*iter)) { 188 SystemModalContainerLayoutManager::IsModalBackground(
189 WmWindowAura::Get(*iter))) {
189 ++iter; 190 ++iter;
190 } 191 }
191 // If the entire window list is modal background windows then stop. 192 // If the entire window list is modal background windows then stop.
192 if (iter == src_container->children().end()) 193 if (iter == src_container->children().end())
193 break; 194 break;
194 ReparentWindow(*iter, dst_container); 195 ReparentWindow(*iter, dst_container);
195 } 196 }
196 } 197 }
197 } 198 }
198 199
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 if (WmShell::Get()->GetSessionStateDelegate()->IsUserSessionBlocked()) { 386 if (WmShell::Get()->GetSessionStateDelegate()->IsUserSessionBlocked()) {
386 blocking_container = 387 blocking_container =
387 GetContainer(kShellWindowId_LockScreenContainersContainer); 388 GetContainer(kShellWindowId_LockScreenContainersContainer);
388 modal_container_id = kShellWindowId_LockSystemModalContainer; 389 modal_container_id = kShellWindowId_LockSystemModalContainer;
389 } else { 390 } else {
390 modal_container_id = kShellWindowId_SystemModalContainer; 391 modal_container_id = kShellWindowId_SystemModalContainer;
391 } 392 }
392 aura::Window* modal_container = GetContainer(modal_container_id); 393 aura::Window* modal_container = GetContainer(modal_container_id);
393 SystemModalContainerLayoutManager* modal_layout_manager = nullptr; 394 SystemModalContainerLayoutManager* modal_layout_manager = nullptr;
394 modal_layout_manager = static_cast<SystemModalContainerLayoutManager*>( 395 modal_layout_manager = static_cast<SystemModalContainerLayoutManager*>(
395 modal_container->layout_manager()); 396 WmWindowAura::Get(modal_container)->GetLayoutManager());
396 397
397 if (modal_layout_manager->has_window_dimmer()) 398 if (modal_layout_manager->has_window_dimmer())
398 blocking_container = modal_container; 399 blocking_container = modal_container;
399 else 400 else
400 modal_container = nullptr; // Don't check modal dialogs. 401 modal_container = nullptr; // Don't check modal dialogs.
401 402
402 // In normal session. 403 // In normal session.
403 if (!blocking_container) 404 if (!blocking_container)
404 return true; 405 return true;
405 406
406 if (!IsWindowAboveContainer(window, blocking_container)) 407 if (!IsWindowAboveContainer(window, blocking_container))
407 return false; 408 return false;
408 409
409 // If the window is in the target modal container, only allow the top most 410 // If the window is in the target modal container, only allow the top most
410 // one. 411 // one.
411 if (modal_container && modal_container->Contains(window)) 412 if (modal_container && modal_container->Contains(window))
412 return modal_layout_manager->IsPartOfActiveModalWindow(window); 413 return modal_layout_manager->IsPartOfActiveModalWindow(
414 WmWindowAura::Get(window));
413 415
414 return true; 416 return true;
415 } 417 }
416 418
417 SystemModalContainerLayoutManager*
418 RootWindowController::GetSystemModalLayoutManager(aura::Window* window) {
419 aura::Window* modal_container = NULL;
420 if (window) {
421 aura::Window* window_container = WmWindowAura::GetAuraWindow(
422 wm::GetContainerForWindow(WmWindowAura::Get(window)));
423 if (window_container &&
424 window_container->id() >= kShellWindowId_LockScreenContainer) {
425 modal_container = GetContainer(kShellWindowId_LockSystemModalContainer);
426 } else {
427 modal_container = GetContainer(kShellWindowId_SystemModalContainer);
428 }
429 } else {
430 int modal_window_id =
431 WmShell::Get()->GetSessionStateDelegate()->IsUserSessionBlocked()
432 ? kShellWindowId_LockSystemModalContainer
433 : kShellWindowId_SystemModalContainer;
434 modal_container = GetContainer(modal_window_id);
435 }
436 return modal_container ? static_cast<SystemModalContainerLayoutManager*>(
437 modal_container->layout_manager())
438 : NULL;
439 }
440
441 aura::Window* RootWindowController::GetContainer(int container_id) { 419 aura::Window* RootWindowController::GetContainer(int container_id) {
442 return GetRootWindow()->GetChildById(container_id); 420 return GetRootWindow()->GetChildById(container_id);
443 } 421 }
444 422
445 const aura::Window* RootWindowController::GetContainer(int container_id) const { 423 const aura::Window* RootWindowController::GetContainer(int container_id) const {
446 return ash_host_->AsWindowTreeHost()->window()->GetChildById(container_id); 424 return ash_host_->AsWindowTreeHost()->window()->GetChildById(container_id);
447 } 425 }
448 426
449 void RootWindowController::ShowShelf() { 427 void RootWindowController::ShowShelf() {
450 if (!wm_shelf_aura_->IsShelfInitialized()) 428 if (!wm_shelf_aura_->IsShelfInitialized())
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
725 Shell* shell = Shell::GetInstance(); 703 Shell* shell = Shell::GetInstance();
726 shell->InitRootWindow(root_window); 704 shell->InitRootWindow(root_window);
727 705
728 wm_root_window_controller_->CreateContainers(); 706 wm_root_window_controller_->CreateContainers();
729 707
730 CreateSystemWallpaper(first_run_after_boot); 708 CreateSystemWallpaper(first_run_after_boot);
731 709
732 InitLayoutManagers(); 710 InitLayoutManagers();
733 InitTouchHuds(); 711 InitTouchHuds();
734 712
735 if (Shell::GetPrimaryRootWindowController() 713 if (WmShell::Get()
714 ->GetPrimaryRootWindowController()
736 ->GetSystemModalLayoutManager(nullptr) 715 ->GetSystemModalLayoutManager(nullptr)
737 ->has_window_dimmer()) { 716 ->has_window_dimmer()) {
738 GetSystemModalLayoutManager(nullptr)->CreateModalBackground(); 717 wm_root_window_controller_->GetSystemModalLayoutManager(nullptr)
718 ->CreateModalBackground();
739 } 719 }
740 720
741 WmShell::Get()->AddShellObserver(this); 721 WmShell::Get()->AddShellObserver(this);
742 722
743 wm_root_window_controller_->root_window_layout_manager()->OnWindowResized(); 723 wm_root_window_controller_->root_window_layout_manager()->OnWindowResized();
744 if (root_window_type == PRIMARY) { 724 if (root_window_type == PRIMARY) {
745 shell->InitKeyboard(); 725 shell->InitKeyboard();
746 } else { 726 } else {
747 ash_host_->AsWindowTreeHost()->Show(); 727 ash_host_->AsWindowTreeHost()->Show();
748 728
(...skipping 11 matching lines...) Expand all
760 touch_exploration_manager_.reset(new AshTouchExplorationManager(this)); 740 touch_exploration_manager_.reset(new AshTouchExplorationManager(this));
761 } 741 }
762 #endif 742 #endif
763 } 743 }
764 744
765 void RootWindowController::InitLayoutManagers() { 745 void RootWindowController::InitLayoutManagers() {
766 wm_root_window_controller_->CreateLayoutManagers(); 746 wm_root_window_controller_->CreateLayoutManagers();
767 747
768 aura::Window* root_window = GetRootWindow(); 748 aura::Window* root_window = GetRootWindow();
769 749
770 aura::Window* modal_container =
771 root_window->GetChildById(kShellWindowId_SystemModalContainer);
772 DCHECK(modal_container);
773 modal_container->SetLayoutManager(
774 new SystemModalContainerLayoutManager(modal_container));
775
776 aura::Window* lock_container = 750 aura::Window* lock_container =
777 root_window->GetChildById(kShellWindowId_LockScreenContainer); 751 root_window->GetChildById(kShellWindowId_LockScreenContainer);
778 DCHECK(lock_container); 752 DCHECK(lock_container);
779 lock_container->SetLayoutManager(new LockLayoutManager(lock_container)); 753 lock_container->SetLayoutManager(new LockLayoutManager(lock_container));
780 754
781 aura::Window* lock_modal_container =
782 root_window->GetChildById(kShellWindowId_LockSystemModalContainer);
783 DCHECK(lock_modal_container);
784 lock_modal_container->SetLayoutManager(
785 new SystemModalContainerLayoutManager(lock_modal_container));
786
787 WmWindow* always_on_top_container = 755 WmWindow* always_on_top_container =
788 WmWindowAura::Get(GetContainer(kShellWindowId_AlwaysOnTopContainer)); 756 WmWindowAura::Get(GetContainer(kShellWindowId_AlwaysOnTopContainer));
789 always_on_top_controller_.reset( 757 always_on_top_controller_.reset(
790 new AlwaysOnTopController(always_on_top_container)); 758 new AlwaysOnTopController(always_on_top_container));
791 759
792 // Create the shelf and status area widgets. 760 // Create the shelf and status area widgets.
793 DCHECK(!wm_shelf_aura_->shelf_widget()); 761 DCHECK(!wm_shelf_aura_->shelf_widget());
794 aura::Window* shelf_container = GetContainer(kShellWindowId_ShelfContainer); 762 aura::Window* shelf_container = GetContainer(kShellWindowId_ShelfContainer);
795 aura::Window* status_container = GetContainer(kShellWindowId_StatusContainer); 763 aura::Window* status_container = GetContainer(kShellWindowId_StatusContainer);
796 WmWindow* wm_shelf_container = WmWindowAura::Get(shelf_container); 764 WmWindow* wm_shelf_container = WmWindowAura::Get(shelf_container);
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
920 aura::Window* primary_root_window = Shell::GetInstance() 888 aura::Window* primary_root_window = Shell::GetInstance()
921 ->window_tree_host_manager() 889 ->window_tree_host_manager()
922 ->GetPrimaryRootWindow(); 890 ->GetPrimaryRootWindow();
923 return GetRootWindowSettings(primary_root_window)->controller; 891 return GetRootWindowSettings(primary_root_window)->controller;
924 } 892 }
925 893
926 return GetRootWindowSettings(root_window)->controller; 894 return GetRootWindowSettings(root_window)->controller;
927 } 895 }
928 896
929 } // namespace ash 897 } // namespace ash
OLDNEW
« no previous file with comments | « ash/root_window_controller.h ('k') | ash/root_window_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698