| 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/shell.h" | 5 #include "ash/shell.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "ash/accelerators/focus_manager_factory.h" | 10 #include "ash/accelerators/focus_manager_factory.h" |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 RemoveEnvEventFilter(accelerator_filter_.get()); | 226 RemoveEnvEventFilter(accelerator_filter_.get()); |
| 227 #endif | 227 #endif |
| 228 if (touch_observer_hud_.get()) | 228 if (touch_observer_hud_.get()) |
| 229 RemoveEnvEventFilter(touch_observer_hud_.get()); | 229 RemoveEnvEventFilter(touch_observer_hud_.get()); |
| 230 | 230 |
| 231 // TooltipController is deleted with the Shell so removing its references. | 231 // TooltipController is deleted with the Shell so removing its references. |
| 232 RemoveEnvEventFilter(tooltip_controller_.get()); | 232 RemoveEnvEventFilter(tooltip_controller_.get()); |
| 233 | 233 |
| 234 // The status area needs to be shut down before the windows are destroyed. | 234 // The status area needs to be shut down before the windows are destroyed. |
| 235 status_area_widget_->Shutdown(); | 235 status_area_widget_->Shutdown(); |
| 236 status_area_widget_ = NULL; |
| 236 | 237 |
| 237 // AppList needs to be released before shelf layout manager, which is | 238 // AppList needs to be released before shelf layout manager, which is |
| 238 // destroyed with launcher container in the loop below. However, app list | 239 // destroyed with launcher container in the loop below. However, app list |
| 239 // container is now on top of launcher container and released after it. | 240 // container is now on top of launcher container and released after it. |
| 240 // TODO(xiyuan): Move it back when app list container is no longer needed. | 241 // TODO(xiyuan): Move it back when app list container is no longer needed. |
| 241 app_list_controller_.reset(); | 242 app_list_controller_.reset(); |
| 242 | 243 |
| 243 | 244 |
| 244 // Closing the windows frees the workspace controller. | 245 // Closing the windows frees the workspace controller. |
| 245 shelf_->set_workspace_controller(NULL); | 246 shelf_->set_workspace_controller(NULL); |
| (...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 664 } | 665 } |
| 665 | 666 |
| 666 void Shell::CreateModalBackground() { | 667 void Shell::CreateModalBackground() { |
| 667 if (!modality_filter_.get()) { | 668 if (!modality_filter_.get()) { |
| 668 modality_filter_.reset(new internal::SystemModalContainerEventFilter(this)); | 669 modality_filter_.reset(new internal::SystemModalContainerEventFilter(this)); |
| 669 AddEnvEventFilter(modality_filter_.get()); | 670 AddEnvEventFilter(modality_filter_.get()); |
| 670 } | 671 } |
| 671 RootWindowControllerList controllers = GetAllRootWindowControllers(); | 672 RootWindowControllerList controllers = GetAllRootWindowControllers(); |
| 672 for (RootWindowControllerList::iterator iter = controllers.begin(); | 673 for (RootWindowControllerList::iterator iter = controllers.begin(); |
| 673 iter != controllers.end(); ++iter) | 674 iter != controllers.end(); ++iter) |
| 674 (*iter)->GetSystemModalLayoutManager()->CreateModalBackground(); | 675 (*iter)->GetSystemModalLayoutManager(NULL)->CreateModalBackground(); |
| 675 } | 676 } |
| 676 | 677 |
| 677 void Shell::OnModalWindowRemoved(aura::Window* removed) { | 678 void Shell::OnModalWindowRemoved(aura::Window* removed) { |
| 678 RootWindowControllerList controllers = GetAllRootWindowControllers(); | 679 RootWindowControllerList controllers = GetAllRootWindowControllers(); |
| 679 bool activated = false; | 680 bool activated = false; |
| 680 for (RootWindowControllerList::iterator iter = controllers.begin(); | 681 for (RootWindowControllerList::iterator iter = controllers.begin(); |
| 681 iter != controllers.end() && !activated; ++iter) { | 682 iter != controllers.end() && !activated; ++iter) { |
| 682 activated = | 683 activated = (*iter)->GetSystemModalLayoutManager(removed)-> |
| 683 (*iter)->GetSystemModalLayoutManager()->ActivateNextModalWindow(); | 684 ActivateNextModalWindow(); |
| 684 } | 685 } |
| 685 if (!activated) { | 686 if (!activated) { |
| 686 RemoveEnvEventFilter(modality_filter_.get()); | 687 RemoveEnvEventFilter(modality_filter_.get()); |
| 687 modality_filter_.reset(); | 688 modality_filter_.reset(); |
| 688 for (RootWindowControllerList::iterator iter = controllers.begin(); | 689 for (RootWindowControllerList::iterator iter = controllers.begin(); |
| 689 iter != controllers.end(); ++iter) | 690 iter != controllers.end(); ++iter) |
| 690 (*iter)->GetSystemModalLayoutManager()->DestroyModalBackground(); | 691 (*iter)->GetSystemModalLayoutManager(removed)->DestroyModalBackground(); |
| 691 } | 692 } |
| 692 } | 693 } |
| 693 | 694 |
| 694 SystemTrayDelegate* Shell::tray_delegate() { | 695 SystemTrayDelegate* Shell::tray_delegate() { |
| 695 return status_area_widget_->system_tray_delegate(); | 696 return status_area_widget_ ? status_area_widget_->system_tray_delegate() : |
| 697 NULL; |
| 696 } | 698 } |
| 697 | 699 |
| 698 SystemTray* Shell::system_tray() { | 700 SystemTray* Shell::system_tray() { |
| 699 return status_area_widget_->system_tray(); | 701 return status_area_widget_ ? status_area_widget_->system_tray() : |
| 702 NULL; |
| 700 } | 703 } |
| 701 | 704 |
| 702 void Shell::InitRootWindowForSecondaryDisplay(aura::RootWindow* root) { | 705 void Shell::InitRootWindowForSecondaryDisplay(aura::RootWindow* root) { |
| 703 root->set_focus_manager(focus_manager_.get()); | 706 root->set_focus_manager(focus_manager_.get()); |
| 704 internal::RootWindowController* controller = | 707 internal::RootWindowController* controller = |
| 705 new internal::RootWindowController(root); | 708 new internal::RootWindowController(root); |
| 706 controller->CreateContainers(); | 709 controller->CreateContainers(); |
| 707 InitRootWindowController(controller); | 710 InitRootWindowController(controller); |
| 708 controller->root_window_layout()->OnWindowResized(); | 711 controller->root_window_layout()->OnWindowResized(); |
| 709 desktop_background_controller_->OnRootWindowAdded(root); | 712 desktop_background_controller_->OnRootWindowAdded(root); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 751 | 754 |
| 752 // TODO(oshima): Move the instance to RootWindowController when | 755 // TODO(oshima): Move the instance to RootWindowController when |
| 753 // the extended desktop is enabled by default. | 756 // the extended desktop is enabled by default. |
| 754 internal::AlwaysOnTopController* always_on_top_controller = | 757 internal::AlwaysOnTopController* always_on_top_controller = |
| 755 new internal::AlwaysOnTopController; | 758 new internal::AlwaysOnTopController; |
| 756 always_on_top_controller->SetContainers( | 759 always_on_top_controller->SetContainers( |
| 757 root_window->GetChildById(internal::kShellWindowId_DefaultContainer), | 760 root_window->GetChildById(internal::kShellWindowId_DefaultContainer), |
| 758 root_window->GetChildById(internal::kShellWindowId_AlwaysOnTopContainer)); | 761 root_window->GetChildById(internal::kShellWindowId_AlwaysOnTopContainer)); |
| 759 root_window->SetProperty(internal::kAlwaysOnTopControllerKey, | 762 root_window->SetProperty(internal::kAlwaysOnTopControllerKey, |
| 760 always_on_top_controller); | 763 always_on_top_controller); |
| 761 if (GetPrimaryRootWindowController()->GetSystemModalLayoutManager()-> | 764 if (GetPrimaryRootWindowController()->GetSystemModalLayoutManager(NULL)-> |
| 762 has_modal_background()) { | 765 has_modal_background()) { |
| 763 controller->GetSystemModalLayoutManager()->CreateModalBackground(); | 766 controller->GetSystemModalLayoutManager(NULL)->CreateModalBackground(); |
| 764 } | 767 } |
| 765 | 768 |
| 766 window_cycle_controller_->OnRootWindowAdded(root_window); | 769 window_cycle_controller_->OnRootWindowAdded(root_window); |
| 767 } | 770 } |
| 768 | 771 |
| 769 //////////////////////////////////////////////////////////////////////////////// | 772 //////////////////////////////////////////////////////////////////////////////// |
| 770 // Shell, private: | 773 // Shell, private: |
| 771 | 774 |
| 772 void Shell::InitLayoutManagersForPrimaryDisplay( | 775 void Shell::InitLayoutManagersForPrimaryDisplay( |
| 773 internal::RootWindowController* controller) { | 776 internal::RootWindowController* controller) { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 813 RootWindowList root_windows = GetAllRootWindows(); | 816 RootWindowList root_windows = GetAllRootWindows(); |
| 814 for (RootWindowList::iterator iter = root_windows.begin(); | 817 for (RootWindowList::iterator iter = root_windows.begin(); |
| 815 iter != root_windows.end(); ++iter) | 818 iter != root_windows.end(); ++iter) |
| 816 (*iter)->ShowCursor(visible); | 819 (*iter)->ShowCursor(visible); |
| 817 } | 820 } |
| 818 | 821 |
| 819 bool Shell::CanWindowReceiveEvents(aura::Window* window) { | 822 bool Shell::CanWindowReceiveEvents(aura::Window* window) { |
| 820 RootWindowControllerList controllers = GetAllRootWindowControllers(); | 823 RootWindowControllerList controllers = GetAllRootWindowControllers(); |
| 821 for (RootWindowControllerList::iterator iter = controllers.begin(); | 824 for (RootWindowControllerList::iterator iter = controllers.begin(); |
| 822 iter != controllers.end(); ++iter) { | 825 iter != controllers.end(); ++iter) { |
| 823 if ((*iter)->GetSystemModalLayoutManager()-> | 826 if ((*iter)->GetSystemModalLayoutManager(window)-> |
| 824 CanWindowReceiveEvents(window)) { | 827 CanWindowReceiveEvents(window)) { |
| 825 return true; | 828 return true; |
| 826 } | 829 } |
| 827 } | 830 } |
| 828 return false; | 831 return false; |
| 829 } | 832 } |
| 830 | 833 |
| 831 } // namespace ash | 834 } // namespace ash |
| OLD | NEW |