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 <queue> | 7 #include <queue> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "ash/ash_constants.h" | 10 #include "ash/ash_constants.h" |
11 #include "ash/ash_switches.h" | 11 #include "ash/ash_switches.h" |
| 12 #include "ash/aura/aura_layout_manager_adapter.h" |
| 13 #include "ash/aura/wm_shelf_aura.h" |
| 14 #include "ash/aura/wm_window_aura.h" |
12 #include "ash/common/root_window_controller_common.h" | 15 #include "ash/common/root_window_controller_common.h" |
13 #include "ash/common/shell_window_ids.h" | 16 #include "ash/common/shell_window_ids.h" |
14 #include "ash/common/wm/always_on_top_controller.h" | 17 #include "ash/common/wm/always_on_top_controller.h" |
15 #include "ash/common/wm/container_finder.h" | 18 #include "ash/common/wm/container_finder.h" |
16 #include "ash/common/wm/dock/docked_window_layout_manager.h" | 19 #include "ash/common/wm/dock/docked_window_layout_manager.h" |
17 #include "ash/common/wm/fullscreen_window_finder.h" | 20 #include "ash/common/wm/fullscreen_window_finder.h" |
18 #include "ash/common/wm/panels/panel_layout_manager.h" | 21 #include "ash/common/wm/panels/panel_layout_manager.h" |
19 #include "ash/common/wm/root_window_layout_manager.h" | 22 #include "ash/common/wm/root_window_layout_manager.h" |
20 #include "ash/common/wm/switchable_windows.h" | 23 #include "ash/common/wm/switchable_windows.h" |
21 #include "ash/common/wm/window_state.h" | 24 #include "ash/common/wm/window_state.h" |
22 #include "ash/common/wm/wm_globals.h" | |
23 #include "ash/common/wm/wm_window.h" | |
24 #include "ash/common/wm/workspace/workspace_layout_manager.h" | 25 #include "ash/common/wm/workspace/workspace_layout_manager.h" |
25 #include "ash/common/wm/workspace/workspace_layout_manager_delegate.h" | 26 #include "ash/common/wm/workspace/workspace_layout_manager_delegate.h" |
| 27 #include "ash/common/wm_shell.h" |
| 28 #include "ash/common/wm_window.h" |
26 #include "ash/desktop_background/desktop_background_controller.h" | 29 #include "ash/desktop_background/desktop_background_controller.h" |
27 #include "ash/desktop_background/desktop_background_widget_controller.h" | 30 #include "ash/desktop_background/desktop_background_widget_controller.h" |
28 #include "ash/desktop_background/user_wallpaper_delegate.h" | 31 #include "ash/desktop_background/user_wallpaper_delegate.h" |
29 #include "ash/display/display_manager.h" | 32 #include "ash/display/display_manager.h" |
30 #include "ash/focus_cycler.h" | 33 #include "ash/focus_cycler.h" |
31 #include "ash/high_contrast/high_contrast_controller.h" | 34 #include "ash/high_contrast/high_contrast_controller.h" |
32 #include "ash/host/ash_window_tree_host.h" | 35 #include "ash/host/ash_window_tree_host.h" |
33 #include "ash/root_window_settings.h" | 36 #include "ash/root_window_settings.h" |
34 #include "ash/session/session_state_delegate.h" | 37 #include "ash/session/session_state_delegate.h" |
35 #include "ash/shelf/shelf_layout_manager.h" | 38 #include "ash/shelf/shelf_layout_manager.h" |
36 #include "ash/shelf/shelf_types.h" | 39 #include "ash/shelf/shelf_types.h" |
37 #include "ash/shelf/shelf_widget.h" | 40 #include "ash/shelf/shelf_widget.h" |
38 #include "ash/shell.h" | 41 #include "ash/shell.h" |
39 #include "ash/shell_delegate.h" | 42 #include "ash/shell_delegate.h" |
40 #include "ash/shell_factory.h" | 43 #include "ash/shell_factory.h" |
41 #include "ash/system/status_area_widget.h" | 44 #include "ash/system/status_area_widget.h" |
42 #include "ash/system/tray/system_tray_delegate.h" | 45 #include "ash/system/tray/system_tray_delegate.h" |
43 #include "ash/system/tray/system_tray_notifier.h" | 46 #include "ash/system/tray/system_tray_notifier.h" |
44 #include "ash/touch/touch_hud_debug.h" | 47 #include "ash/touch/touch_hud_debug.h" |
45 #include "ash/touch/touch_hud_projection.h" | 48 #include "ash/touch/touch_hud_projection.h" |
46 #include "ash/touch/touch_observer_hud.h" | 49 #include "ash/touch/touch_observer_hud.h" |
47 #include "ash/wm/aura/aura_layout_manager_adapter.h" | |
48 #include "ash/wm/aura/wm_shelf_aura.h" | |
49 #include "ash/wm/aura/wm_window_aura.h" | |
50 #include "ash/wm/lock_layout_manager.h" | 50 #include "ash/wm/lock_layout_manager.h" |
51 #include "ash/wm/panels/attached_panel_window_targeter.h" | 51 #include "ash/wm/panels/attached_panel_window_targeter.h" |
52 #include "ash/wm/panels/panel_window_event_handler.h" | 52 #include "ash/wm/panels/panel_window_event_handler.h" |
53 #include "ash/wm/stacking_controller.h" | 53 #include "ash/wm/stacking_controller.h" |
54 #include "ash/wm/status_area_layout_manager.h" | 54 #include "ash/wm/status_area_layout_manager.h" |
55 #include "ash/wm/system_background_controller.h" | 55 #include "ash/wm/system_background_controller.h" |
56 #include "ash/wm/system_modal_container_layout_manager.h" | 56 #include "ash/wm/system_modal_container_layout_manager.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" |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 const gfx::Size dst_size = new_parent->bounds().size(); | 122 const gfx::Size dst_size = new_parent->bounds().size(); |
123 // Update the restore bounds to make it relative to the display. | 123 // Update the restore bounds to make it relative to the display. |
124 wm::WindowState* state = wm::GetWindowState(window); | 124 wm::WindowState* state = wm::GetWindowState(window); |
125 gfx::Rect restore_bounds; | 125 gfx::Rect restore_bounds; |
126 bool has_restore_bounds = state->HasRestoreBounds(); | 126 bool has_restore_bounds = state->HasRestoreBounds(); |
127 | 127 |
128 bool update_bounds = (state->IsNormalOrSnapped() || state->IsMinimized()) && | 128 bool update_bounds = (state->IsNormalOrSnapped() || state->IsMinimized()) && |
129 new_parent->id() != kShellWindowId_DockedContainer; | 129 new_parent->id() != kShellWindowId_DockedContainer; |
130 gfx::Rect local_bounds; | 130 gfx::Rect local_bounds; |
131 if (update_bounds) { | 131 if (update_bounds) { |
132 local_bounds = wm::WmWindowAura::GetAuraWindow(state->window())->bounds(); | 132 local_bounds = WmWindowAura::GetAuraWindow(state->window())->bounds(); |
133 MoveOriginRelativeToSize(src_size, dst_size, &local_bounds); | 133 MoveOriginRelativeToSize(src_size, dst_size, &local_bounds); |
134 } | 134 } |
135 | 135 |
136 if (has_restore_bounds) { | 136 if (has_restore_bounds) { |
137 restore_bounds = state->GetRestoreBoundsInParent(); | 137 restore_bounds = state->GetRestoreBoundsInParent(); |
138 MoveOriginRelativeToSize(src_size, dst_size, &restore_bounds); | 138 MoveOriginRelativeToSize(src_size, dst_size, &restore_bounds); |
139 } | 139 } |
140 | 140 |
141 new_parent->AddChild(window); | 141 new_parent->AddChild(window); |
142 | 142 |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 ash_host_->PrepareForShutdown(); | 360 ash_host_->PrepareForShutdown(); |
361 | 361 |
362 system_background_.reset(); | 362 system_background_.reset(); |
363 aura::client::SetScreenPositionClient(root_window, NULL); | 363 aura::client::SetScreenPositionClient(root_window, NULL); |
364 } | 364 } |
365 | 365 |
366 SystemModalContainerLayoutManager* | 366 SystemModalContainerLayoutManager* |
367 RootWindowController::GetSystemModalLayoutManager(aura::Window* window) { | 367 RootWindowController::GetSystemModalLayoutManager(aura::Window* window) { |
368 aura::Window* modal_container = NULL; | 368 aura::Window* modal_container = NULL; |
369 if (window) { | 369 if (window) { |
370 aura::Window* window_container = wm::WmWindowAura::GetAuraWindow( | 370 aura::Window* window_container = WmWindowAura::GetAuraWindow( |
371 wm::GetContainerForWindow(wm::WmWindowAura::Get(window))); | 371 wm::GetContainerForWindow(WmWindowAura::Get(window))); |
372 if (window_container && | 372 if (window_container && |
373 window_container->id() >= kShellWindowId_LockScreenContainer) { | 373 window_container->id() >= kShellWindowId_LockScreenContainer) { |
374 modal_container = GetContainer(kShellWindowId_LockSystemModalContainer); | 374 modal_container = GetContainer(kShellWindowId_LockSystemModalContainer); |
375 } else { | 375 } else { |
376 modal_container = GetContainer(kShellWindowId_SystemModalContainer); | 376 modal_container = GetContainer(kShellWindowId_SystemModalContainer); |
377 } | 377 } |
378 } else { | 378 } else { |
379 int modal_window_id = Shell::GetInstance()->session_state_delegate() | 379 int modal_window_id = Shell::GetInstance()->session_state_delegate() |
380 ->IsUserSessionBlocked() ? kShellWindowId_LockSystemModalContainer : | 380 ->IsUserSessionBlocked() ? kShellWindowId_LockSystemModalContainer : |
381 kShellWindowId_SystemModalContainer; | 381 kShellWindowId_SystemModalContainer; |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
585 menu_runner_->RunMenuAt(wallpaper_controller_->widget(), NULL, | 585 menu_runner_->RunMenuAt(wallpaper_controller_->widget(), NULL, |
586 gfx::Rect(location_in_screen, gfx::Size()), | 586 gfx::Rect(location_in_screen, gfx::Size()), |
587 views::MENU_ANCHOR_TOPLEFT, source_type)); | 587 views::MENU_ANCHOR_TOPLEFT, source_type)); |
588 } | 588 } |
589 | 589 |
590 void RootWindowController::UpdateShelfVisibility() { | 590 void RootWindowController::UpdateShelfVisibility() { |
591 shelf_widget_->shelf_layout_manager()->UpdateVisibilityState(); | 591 shelf_widget_->shelf_layout_manager()->UpdateVisibilityState(); |
592 } | 592 } |
593 | 593 |
594 aura::Window* RootWindowController::GetWindowForFullscreenMode() { | 594 aura::Window* RootWindowController::GetWindowForFullscreenMode() { |
595 return wm::WmWindowAura::GetAuraWindow( | 595 return WmWindowAura::GetAuraWindow( |
596 wm::GetWindowForFullscreenMode(wm::WmWindowAura::Get(GetRootWindow()))); | 596 wm::GetWindowForFullscreenMode(WmWindowAura::Get(GetRootWindow()))); |
597 } | 597 } |
598 | 598 |
599 void RootWindowController::ActivateKeyboard( | 599 void RootWindowController::ActivateKeyboard( |
600 keyboard::KeyboardController* keyboard_controller) { | 600 keyboard::KeyboardController* keyboard_controller) { |
601 if (!keyboard::IsKeyboardEnabled() || | 601 if (!keyboard::IsKeyboardEnabled() || |
602 GetContainer(kShellWindowId_VirtualKeyboardContainer)) { | 602 GetContainer(kShellWindowId_VirtualKeyboardContainer)) { |
603 return; | 603 return; |
604 } | 604 } |
605 DCHECK(keyboard_controller); | 605 DCHECK(keyboard_controller); |
606 keyboard_controller->AddObserver(shelf_widget()->shelf_layout_manager()); | 606 keyboard_controller->AddObserver(shelf_widget()->shelf_layout_manager()); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
654 // RootWindowController, private: | 654 // RootWindowController, private: |
655 | 655 |
656 RootWindowController::RootWindowController(AshWindowTreeHost* ash_host) | 656 RootWindowController::RootWindowController(AshWindowTreeHost* ash_host) |
657 : ash_host_(ash_host), | 657 : ash_host_(ash_host), |
658 docked_layout_manager_(NULL), | 658 docked_layout_manager_(NULL), |
659 panel_layout_manager_(NULL), | 659 panel_layout_manager_(NULL), |
660 touch_hud_debug_(NULL), | 660 touch_hud_debug_(NULL), |
661 touch_hud_projection_(NULL) { | 661 touch_hud_projection_(NULL) { |
662 aura::Window* root_window = GetRootWindow(); | 662 aura::Window* root_window = GetRootWindow(); |
663 root_window_controller_common_.reset( | 663 root_window_controller_common_.reset( |
664 new RootWindowControllerCommon(wm::WmWindowAura::Get(root_window))); | 664 new RootWindowControllerCommon(WmWindowAura::Get(root_window))); |
665 GetRootWindowSettings(root_window)->controller = this; | 665 GetRootWindowSettings(root_window)->controller = this; |
666 | 666 |
667 stacking_controller_.reset(new StackingController); | 667 stacking_controller_.reset(new StackingController); |
668 aura::client::SetWindowTreeClient(root_window, stacking_controller_.get()); | 668 aura::client::SetWindowTreeClient(root_window, stacking_controller_.get()); |
669 capture_client_.reset(new ::wm::ScopedCaptureClient(root_window)); | 669 capture_client_.reset(new ::wm::ScopedCaptureClient(root_window)); |
670 } | 670 } |
671 | 671 |
672 void RootWindowController::Init(RootWindowType root_window_type, | 672 void RootWindowController::Init(RootWindowType root_window_type, |
673 bool first_run_after_boot) { | 673 bool first_run_after_boot) { |
674 aura::Window* root_window = GetRootWindow(); | 674 aura::Window* root_window = GetRootWindow(); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
735 root_window->GetChildById(kShellWindowId_LockSystemModalContainer); | 735 root_window->GetChildById(kShellWindowId_LockSystemModalContainer); |
736 DCHECK(lock_modal_container); | 736 DCHECK(lock_modal_container); |
737 lock_modal_container->SetLayoutManager( | 737 lock_modal_container->SetLayoutManager( |
738 new SystemModalContainerLayoutManager(lock_modal_container)); | 738 new SystemModalContainerLayoutManager(lock_modal_container)); |
739 | 739 |
740 WorkspaceLayoutManagerDelegateImpl* workspace_layout_manager_delegate = | 740 WorkspaceLayoutManagerDelegateImpl* workspace_layout_manager_delegate = |
741 new WorkspaceLayoutManagerDelegateImpl(root_window); | 741 new WorkspaceLayoutManagerDelegateImpl(root_window); |
742 workspace_controller_.reset(new WorkspaceController( | 742 workspace_controller_.reset(new WorkspaceController( |
743 default_container, base::WrapUnique(workspace_layout_manager_delegate))); | 743 default_container, base::WrapUnique(workspace_layout_manager_delegate))); |
744 | 744 |
745 wm::WmWindow* always_on_top_container = | 745 WmWindow* always_on_top_container = |
746 wm::WmWindowAura::Get(GetContainer(kShellWindowId_AlwaysOnTopContainer)); | 746 WmWindowAura::Get(GetContainer(kShellWindowId_AlwaysOnTopContainer)); |
747 always_on_top_controller_.reset( | 747 always_on_top_controller_.reset( |
748 new AlwaysOnTopController(always_on_top_container)); | 748 new AlwaysOnTopController(always_on_top_container)); |
749 | 749 |
750 DCHECK(!shelf_widget_.get()); | 750 DCHECK(!shelf_widget_.get()); |
751 wm::WmWindow* shelf_container = | 751 WmWindow* shelf_container = |
752 wm::WmWindowAura::Get(GetContainer(kShellWindowId_ShelfContainer)); | 752 WmWindowAura::Get(GetContainer(kShellWindowId_ShelfContainer)); |
753 wm::WmWindow* status_container = | 753 WmWindow* status_container = |
754 wm::WmWindowAura::Get(GetContainer(kShellWindowId_StatusContainer)); | 754 WmWindowAura::Get(GetContainer(kShellWindowId_StatusContainer)); |
755 shelf_widget_.reset(new ShelfWidget(shelf_container, status_container, | 755 shelf_widget_.reset(new ShelfWidget(shelf_container, status_container, |
756 workspace_controller())); | 756 workspace_controller())); |
757 workspace_layout_manager_delegate->set_shelf( | 757 workspace_layout_manager_delegate->set_shelf( |
758 shelf_widget_->shelf_layout_manager()); | 758 shelf_widget_->shelf_layout_manager()); |
759 | 759 |
760 if (!Shell::GetInstance()->session_state_delegate()-> | 760 if (!Shell::GetInstance()->session_state_delegate()-> |
761 IsActiveUserSessionStarted()) { | 761 IsActiveUserSessionStarted()) { |
762 // This window exists only to be a event target on login screen. | 762 // This window exists only to be a event target on login screen. |
763 // It does not have to handle events, nor be visible. | 763 // It does not have to handle events, nor be visible. |
764 mouse_event_target_.reset(new aura::Window(new EmptyWindowDelegate)); | 764 mouse_event_target_.reset(new aura::Window(new EmptyWindowDelegate)); |
765 mouse_event_target_->Init(ui::LAYER_NOT_DRAWN); | 765 mouse_event_target_->Init(ui::LAYER_NOT_DRAWN); |
766 | 766 |
767 aura::Window* lock_background_container = | 767 aura::Window* lock_background_container = |
768 GetContainer(kShellWindowId_LockScreenBackgroundContainer); | 768 GetContainer(kShellWindowId_LockScreenBackgroundContainer); |
769 lock_background_container->AddChild(mouse_event_target_.get()); | 769 lock_background_container->AddChild(mouse_event_target_.get()); |
770 mouse_event_target_->Show(); | 770 mouse_event_target_->Show(); |
771 } | 771 } |
772 | 772 |
773 // Create Docked windows layout manager | 773 // Create Docked windows layout manager |
774 wm::WmWindow* docked_container = | 774 WmWindow* docked_container = |
775 wm::WmWindowAura::Get(GetContainer(kShellWindowId_DockedContainer)); | 775 WmWindowAura::Get(GetContainer(kShellWindowId_DockedContainer)); |
776 docked_layout_manager_ = new DockedWindowLayoutManager(docked_container); | 776 docked_layout_manager_ = new DockedWindowLayoutManager(docked_container); |
777 docked_container->SetLayoutManager(base::WrapUnique(docked_layout_manager_)); | 777 docked_container->SetLayoutManager(base::WrapUnique(docked_layout_manager_)); |
778 | 778 |
779 // Installs SnapLayoutManager to containers who set the | 779 // Installs SnapLayoutManager to containers who set the |
780 // |kSnapsChildrenToPhysicalPixelBoundary| property. | 780 // |kSnapsChildrenToPhysicalPixelBoundary| property. |
781 wm::InstallSnapLayoutManagerToContainers(root_window); | 781 wm::InstallSnapLayoutManagerToContainers(root_window); |
782 | 782 |
783 // Create Panel layout manager | 783 // Create Panel layout manager |
784 aura::Window* panel_container = GetContainer(kShellWindowId_PanelContainer); | 784 aura::Window* panel_container = GetContainer(kShellWindowId_PanelContainer); |
785 wm::WmWindow* wm_panel_container = wm::WmWindowAura::Get(panel_container); | 785 WmWindow* wm_panel_container = WmWindowAura::Get(panel_container); |
786 panel_layout_manager_ = new PanelLayoutManager(wm_panel_container); | 786 panel_layout_manager_ = new PanelLayoutManager(wm_panel_container); |
787 wm_panel_container->SetLayoutManager(base::WrapUnique(panel_layout_manager_)); | 787 wm_panel_container->SetLayoutManager(base::WrapUnique(panel_layout_manager_)); |
788 panel_container_handler_.reset(new PanelWindowEventHandler); | 788 panel_container_handler_.reset(new PanelWindowEventHandler); |
789 panel_container->AddPreTargetHandler(panel_container_handler_.get()); | 789 panel_container->AddPreTargetHandler(panel_container_handler_.get()); |
790 | 790 |
791 // Install an AttachedPanelWindowTargeter on the panel container to make it | 791 // Install an AttachedPanelWindowTargeter on the panel container to make it |
792 // easier to correctly target shelf buttons with touch. | 792 // easier to correctly target shelf buttons with touch. |
793 gfx::Insets mouse_extend(-kResizeOutsideBoundsSize, | 793 gfx::Insets mouse_extend(-kResizeOutsideBoundsSize, |
794 -kResizeOutsideBoundsSize, | 794 -kResizeOutsideBoundsSize, |
795 -kResizeOutsideBoundsSize, | 795 -kResizeOutsideBoundsSize, |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
875 aura::Window* primary_root_window = Shell::GetInstance() | 875 aura::Window* primary_root_window = Shell::GetInstance() |
876 ->window_tree_host_manager() | 876 ->window_tree_host_manager() |
877 ->GetPrimaryRootWindow(); | 877 ->GetPrimaryRootWindow(); |
878 return GetRootWindowSettings(primary_root_window)->controller; | 878 return GetRootWindowSettings(primary_root_window)->controller; |
879 } | 879 } |
880 | 880 |
881 return GetRootWindowSettings(root_window)->controller; | 881 return GetRootWindowSettings(root_window)->controller; |
882 } | 882 } |
883 | 883 |
884 } // namespace ash | 884 } // namespace ash |
OLD | NEW |