| 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/accelerator_controller.h" | 10 #include "ash/accelerators/accelerator_controller.h" |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 return internal::GetRootWindowController(GetPrimaryRootWindow()); | 194 return internal::GetRootWindowController(GetPrimaryRootWindow()); |
| 195 } | 195 } |
| 196 | 196 |
| 197 // static | 197 // static |
| 198 Shell::RootWindowControllerList Shell::GetAllRootWindowControllers() { | 198 Shell::RootWindowControllerList Shell::GetAllRootWindowControllers() { |
| 199 return Shell::GetInstance()->display_controller()-> | 199 return Shell::GetInstance()->display_controller()-> |
| 200 GetAllRootWindowControllers(); | 200 GetAllRootWindowControllers(); |
| 201 } | 201 } |
| 202 | 202 |
| 203 // static | 203 // static |
| 204 aura::RootWindow* Shell::GetPrimaryRootWindow() { | 204 aura::Window* Shell::GetPrimaryRootWindow() { |
| 205 return GetInstance()->display_controller()->GetPrimaryRootWindow(); | 205 return GetInstance()->display_controller()->GetPrimaryRootWindow(); |
| 206 } | 206 } |
| 207 | 207 |
| 208 // static | 208 // static |
| 209 aura::RootWindow* Shell::GetTargetRootWindow() { | 209 aura::Window* Shell::GetTargetRootWindow() { |
| 210 Shell* shell = GetInstance(); | 210 Shell* shell = GetInstance(); |
| 211 if (shell->scoped_target_root_window_) | 211 if (shell->scoped_target_root_window_) |
| 212 return shell->scoped_target_root_window_; | 212 return shell->scoped_target_root_window_; |
| 213 return shell->target_root_window_; | 213 return shell->target_root_window_; |
| 214 } | 214 } |
| 215 | 215 |
| 216 // static | 216 // static |
| 217 gfx::Screen* Shell::GetScreen() { | 217 gfx::Screen* Shell::GetScreen() { |
| 218 return gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_ALTERNATE); | 218 return gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_ALTERNATE); |
| 219 } | 219 } |
| 220 | 220 |
| 221 // static | 221 // static |
| 222 Shell::RootWindowList Shell::GetAllRootWindows() { | 222 Shell::RootWindowList Shell::GetAllRootWindows() { |
| 223 return Shell::GetInstance()->display_controller()-> | 223 return Shell::GetInstance()->display_controller()-> |
| 224 GetAllRootWindows(); | 224 GetAllRootWindows(); |
| 225 } | 225 } |
| 226 | 226 |
| 227 // static | 227 // static |
| 228 aura::Window* Shell::GetContainer(aura::RootWindow* root_window, | 228 aura::Window* Shell::GetContainer(aura::Window* root_window, |
| 229 int container_id) { | 229 int container_id) { |
| 230 return root_window->GetChildById(container_id); | 230 return root_window->GetChildById(container_id); |
| 231 } | 231 } |
| 232 | 232 |
| 233 // static | 233 // static |
| 234 const aura::Window* Shell::GetContainer(const aura::RootWindow* root_window, | 234 const aura::Window* Shell::GetContainer(const aura::Window* root_window, |
| 235 int container_id) { | 235 int container_id) { |
| 236 return root_window->GetChildById(container_id); | 236 return root_window->GetChildById(container_id); |
| 237 } | 237 } |
| 238 | 238 |
| 239 // static | 239 // static |
| 240 std::vector<aura::Window*> Shell::GetContainersFromAllRootWindows( | 240 std::vector<aura::Window*> Shell::GetContainersFromAllRootWindows( |
| 241 int container_id, | 241 int container_id, |
| 242 aura::RootWindow* priority_root) { | 242 aura::Window* priority_root) { |
| 243 std::vector<aura::Window*> containers; | 243 std::vector<aura::Window*> containers; |
| 244 RootWindowList root_windows = GetAllRootWindows(); | 244 RootWindowList root_windows = GetAllRootWindows(); |
| 245 for (RootWindowList::const_iterator it = root_windows.begin(); | 245 for (RootWindowList::const_iterator it = root_windows.begin(); |
| 246 it != root_windows.end(); ++it) { | 246 it != root_windows.end(); ++it) { |
| 247 aura::Window* container = (*it)->GetChildById(container_id); | 247 aura::Window* container = (*it)->GetChildById(container_id); |
| 248 if (container) { | 248 if (container) { |
| 249 if (priority_root && priority_root->Contains(container)) | 249 if (priority_root && priority_root->Contains(container)) |
| 250 containers.insert(containers.begin(), container); | 250 containers.insert(containers.begin(), container); |
| 251 else | 251 else |
| 252 containers.push_back(container); | 252 containers.push_back(container); |
| 253 } | 253 } |
| 254 } | 254 } |
| 255 return containers; | 255 return containers; |
| 256 } | 256 } |
| 257 | 257 |
| 258 void Shell::ShowContextMenu(const gfx::Point& location_in_screen, | 258 void Shell::ShowContextMenu(const gfx::Point& location_in_screen, |
| 259 ui::MenuSourceType source_type) { | 259 ui::MenuSourceType source_type) { |
| 260 // No context menus if there is no session with an active user. | 260 // No context menus if there is no session with an active user. |
| 261 if (!session_state_delegate_->NumberOfLoggedInUsers()) | 261 if (!session_state_delegate_->NumberOfLoggedInUsers()) |
| 262 return; | 262 return; |
| 263 // No context menus when screen is locked. | 263 // No context menus when screen is locked. |
| 264 if (session_state_delegate_->IsScreenLocked()) | 264 if (session_state_delegate_->IsScreenLocked()) |
| 265 return; | 265 return; |
| 266 | 266 |
| 267 aura::RootWindow* root = | 267 aura::Window* root = |
| 268 wm::GetRootWindowMatching(gfx::Rect(location_in_screen, gfx::Size())); | 268 wm::GetRootWindowMatching(gfx::Rect(location_in_screen, gfx::Size())); |
| 269 internal::GetRootWindowController(root)-> | 269 internal::GetRootWindowController(root)-> |
| 270 ShowContextMenu(location_in_screen, source_type); | 270 ShowContextMenu(location_in_screen, source_type); |
| 271 } | 271 } |
| 272 | 272 |
| 273 void Shell::ToggleAppList(aura::Window* window) { | 273 void Shell::ToggleAppList(aura::Window* window) { |
| 274 // If the context window is not given, show it on the target root window. | 274 // If the context window is not given, show it on the target root window. |
| 275 if (!window) | 275 if (!window) |
| 276 window = GetTargetRootWindow(); | 276 window = GetTargetRootWindow(); |
| 277 if (!app_list_controller_) | 277 if (!app_list_controller_) |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 | 392 |
| 393 void Shell::UpdateShelfVisibility() { | 393 void Shell::UpdateShelfVisibility() { |
| 394 RootWindowControllerList controllers = GetAllRootWindowControllers(); | 394 RootWindowControllerList controllers = GetAllRootWindowControllers(); |
| 395 for (RootWindowControllerList::iterator iter = controllers.begin(); | 395 for (RootWindowControllerList::iterator iter = controllers.begin(); |
| 396 iter != controllers.end(); ++iter) | 396 iter != controllers.end(); ++iter) |
| 397 if ((*iter)->shelf()) | 397 if ((*iter)->shelf()) |
| 398 (*iter)->UpdateShelfVisibility(); | 398 (*iter)->UpdateShelfVisibility(); |
| 399 } | 399 } |
| 400 | 400 |
| 401 void Shell::SetShelfAutoHideBehavior(ShelfAutoHideBehavior behavior, | 401 void Shell::SetShelfAutoHideBehavior(ShelfAutoHideBehavior behavior, |
| 402 aura::RootWindow* root_window) { | 402 aura::Window* root_window) { |
| 403 ash::internal::ShelfLayoutManager::ForLauncher(root_window)-> | 403 ash::internal::ShelfLayoutManager::ForLauncher(root_window)-> |
| 404 SetAutoHideBehavior(behavior); | 404 SetAutoHideBehavior(behavior); |
| 405 } | 405 } |
| 406 | 406 |
| 407 ShelfAutoHideBehavior Shell::GetShelfAutoHideBehavior( | 407 ShelfAutoHideBehavior Shell::GetShelfAutoHideBehavior( |
| 408 aura::RootWindow* root_window) const { | 408 aura::Window* root_window) const { |
| 409 return ash::internal::ShelfLayoutManager::ForLauncher(root_window)-> | 409 return ash::internal::ShelfLayoutManager::ForLauncher(root_window)-> |
| 410 auto_hide_behavior(); | 410 auto_hide_behavior(); |
| 411 } | 411 } |
| 412 | 412 |
| 413 void Shell::SetShelfAlignment(ShelfAlignment alignment, | 413 void Shell::SetShelfAlignment(ShelfAlignment alignment, |
| 414 aura::RootWindow* root_window) { | 414 aura::Window* root_window) { |
| 415 if (ash::internal::ShelfLayoutManager::ForLauncher(root_window)-> | 415 if (ash::internal::ShelfLayoutManager::ForLauncher(root_window)-> |
| 416 SetAlignment(alignment)) { | 416 SetAlignment(alignment)) { |
| 417 FOR_EACH_OBSERVER( | 417 FOR_EACH_OBSERVER( |
| 418 ShellObserver, observers_, OnShelfAlignmentChanged(root_window)); | 418 ShellObserver, observers_, OnShelfAlignmentChanged(root_window)); |
| 419 } | 419 } |
| 420 } | 420 } |
| 421 | 421 |
| 422 ShelfAlignment Shell::GetShelfAlignment(aura::RootWindow* root_window) { | 422 ShelfAlignment Shell::GetShelfAlignment(aura::Window* root_window) { |
| 423 return internal::GetRootWindowController(root_window)-> | 423 return internal::GetRootWindowController(root_window)-> |
| 424 GetShelfLayoutManager()->GetAlignment(); | 424 GetShelfLayoutManager()->GetAlignment(); |
| 425 } | 425 } |
| 426 | 426 |
| 427 void Shell::SetDimming(bool should_dim) { | 427 void Shell::SetDimming(bool should_dim) { |
| 428 RootWindowControllerList controllers = GetAllRootWindowControllers(); | 428 RootWindowControllerList controllers = GetAllRootWindowControllers(); |
| 429 for (RootWindowControllerList::iterator iter = controllers.begin(); | 429 for (RootWindowControllerList::iterator iter = controllers.begin(); |
| 430 iter != controllers.end(); ++iter) | 430 iter != controllers.end(); ++iter) |
| 431 (*iter)->screen_dimmer()->SetDimming(should_dim); | 431 (*iter)->screen_dimmer()->SetDimming(should_dim); |
| 432 } | 432 } |
| 433 | 433 |
| 434 void Shell::NotifyFullscreenStateChange(bool is_fullscreen, | 434 void Shell::NotifyFullscreenStateChange(bool is_fullscreen, |
| 435 aura::RootWindow* root_window) { | 435 aura::Window* root_window) { |
| 436 FOR_EACH_OBSERVER(ShellObserver, observers_, OnFullscreenStateChanged( | 436 FOR_EACH_OBSERVER(ShellObserver, observers_, OnFullscreenStateChanged( |
| 437 is_fullscreen, root_window)); | 437 is_fullscreen, root_window)); |
| 438 } | 438 } |
| 439 | 439 |
| 440 void Shell::CreateModalBackground(aura::Window* window) { | 440 void Shell::CreateModalBackground(aura::Window* window) { |
| 441 if (!modality_filter_) { | 441 if (!modality_filter_) { |
| 442 modality_filter_.reset(new internal::SystemModalContainerEventFilter(this)); | 442 modality_filter_.reset(new internal::SystemModalContainerEventFilter(this)); |
| 443 AddPreTargetHandler(modality_filter_.get()); | 443 AddPreTargetHandler(modality_filter_.get()); |
| 444 } | 444 } |
| 445 RootWindowControllerList controllers = GetAllRootWindowControllers(); | 445 RootWindowControllerList controllers = GetAllRootWindowControllers(); |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 735 focus_client_.reset(focus_controller); | 735 focus_client_.reset(focus_controller); |
| 736 activation_client_ = focus_controller; | 736 activation_client_ = focus_controller; |
| 737 activation_client_->AddObserver(this); | 737 activation_client_->AddObserver(this); |
| 738 focus_cycler_.reset(new internal::FocusCycler()); | 738 focus_cycler_.reset(new internal::FocusCycler()); |
| 739 | 739 |
| 740 screen_position_controller_.reset(new internal::ScreenPositionController); | 740 screen_position_controller_.reset(new internal::ScreenPositionController); |
| 741 root_window_host_factory_.reset(delegate_->CreateRootWindowHostFactory()); | 741 root_window_host_factory_.reset(delegate_->CreateRootWindowHostFactory()); |
| 742 | 742 |
| 743 display_controller_->Start(); | 743 display_controller_->Start(); |
| 744 display_controller_->InitPrimaryDisplay(); | 744 display_controller_->InitPrimaryDisplay(); |
| 745 aura::RootWindow* root_window = display_controller_->GetPrimaryRootWindow(); | 745 aura::Window* root_window = display_controller_->GetPrimaryRootWindow(); |
| 746 target_root_window_ = root_window; | 746 target_root_window_ = root_window; |
| 747 | 747 |
| 748 resolution_notification_controller_.reset( | 748 resolution_notification_controller_.reset( |
| 749 new internal::ResolutionNotificationController); | 749 new internal::ResolutionNotificationController); |
| 750 | 750 |
| 751 cursor_manager_.SetDisplay(DisplayController::GetPrimaryDisplay()); | 751 cursor_manager_.SetDisplay(DisplayController::GetPrimaryDisplay()); |
| 752 | 752 |
| 753 nested_dispatcher_controller_.reset(new NestedDispatcherController); | 753 nested_dispatcher_controller_.reset(new NestedDispatcherController); |
| 754 accelerator_controller_.reset(new AcceleratorController); | 754 accelerator_controller_.reset(new AcceleratorController); |
| 755 | 755 |
| 756 // The order in which event filters are added is significant. | 756 // The order in which event filters are added is significant. |
| 757 event_rewriter_filter_.reset(new internal::EventRewriterEventFilter); | 757 event_rewriter_filter_.reset(new internal::EventRewriterEventFilter); |
| 758 AddPreTargetHandler(event_rewriter_filter_.get()); | 758 AddPreTargetHandler(event_rewriter_filter_.get()); |
| 759 | 759 |
| 760 // UserActivityDetector passes events to observers, so let them get | 760 // UserActivityDetector passes events to observers, so let them get |
| 761 // rewritten first. | 761 // rewritten first. |
| 762 user_activity_detector_.reset(new UserActivityDetector); | 762 user_activity_detector_.reset(new UserActivityDetector); |
| 763 AddPreTargetHandler(user_activity_detector_.get()); | 763 AddPreTargetHandler(user_activity_detector_.get()); |
| 764 | 764 |
| 765 overlay_filter_.reset(new internal::OverlayEventFilter); | 765 overlay_filter_.reset(new internal::OverlayEventFilter); |
| 766 AddPreTargetHandler(overlay_filter_.get()); | 766 AddPreTargetHandler(overlay_filter_.get()); |
| 767 AddShellObserver(overlay_filter_.get()); | 767 AddShellObserver(overlay_filter_.get()); |
| 768 | 768 |
| 769 input_method_filter_.reset(new views::corewm::InputMethodEventFilter( | 769 input_method_filter_.reset(new views::corewm::InputMethodEventFilter( |
| 770 root_window->GetAcceleratedWidget())); | 770 root_window->GetDispatcher()->GetAcceleratedWidget())); |
| 771 AddPreTargetHandler(input_method_filter_.get()); | 771 AddPreTargetHandler(input_method_filter_.get()); |
| 772 | 772 |
| 773 accelerator_filter_.reset(new internal::AcceleratorFilter); | 773 accelerator_filter_.reset(new internal::AcceleratorFilter); |
| 774 AddPreTargetHandler(accelerator_filter_.get()); | 774 AddPreTargetHandler(accelerator_filter_.get()); |
| 775 | 775 |
| 776 event_transformation_handler_.reset(new internal::EventTransformationHandler); | 776 event_transformation_handler_.reset(new internal::EventTransformationHandler); |
| 777 AddPreTargetHandler(event_transformation_handler_.get()); | 777 AddPreTargetHandler(event_transformation_handler_.get()); |
| 778 | 778 |
| 779 system_gesture_filter_.reset(new internal::SystemGestureEventFilter); | 779 system_gesture_filter_.reset(new internal::SystemGestureEventFilter); |
| 780 AddPreTargetHandler(system_gesture_filter_.get()); | 780 AddPreTargetHandler(system_gesture_filter_.get()); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 849 | 849 |
| 850 locale_notification_controller_.reset( | 850 locale_notification_controller_.reset( |
| 851 new internal::LocaleNotificationController); | 851 new internal::LocaleNotificationController); |
| 852 | 852 |
| 853 // Initialize system_tray_delegate_ after StatusAreaWidget is created. | 853 // Initialize system_tray_delegate_ after StatusAreaWidget is created. |
| 854 system_tray_delegate_->Initialize(); | 854 system_tray_delegate_->Initialize(); |
| 855 | 855 |
| 856 // TODO(oshima): Initialize all RootWindowControllers once, and | 856 // TODO(oshima): Initialize all RootWindowControllers once, and |
| 857 // initialize controller/delegates above when initializing the | 857 // initialize controller/delegates above when initializing the |
| 858 // primary root window controller. | 858 // primary root window controller. |
| 859 internal::RootWindowController::CreateForPrimaryDisplay(root_window); | 859 internal::RootWindowController::CreateForPrimaryDisplay( |
| 860 root_window->GetDispatcher()); |
| 860 | 861 |
| 861 display_controller_->InitSecondaryDisplays(); | 862 display_controller_->InitSecondaryDisplays(); |
| 862 | 863 |
| 863 // It needs to be created after RootWindowController has been created | 864 // It needs to be created after RootWindowController has been created |
| 864 // (which calls OnWindowResized has been called, otherwise the | 865 // (which calls OnWindowResized has been called, otherwise the |
| 865 // widget will not paint when restoring after a browser crash. Also it needs | 866 // widget will not paint when restoring after a browser crash. Also it needs |
| 866 // to be created after InitSecondaryDisplays() to initialize the wallpapers in | 867 // to be created after InitSecondaryDisplays() to initialize the wallpapers in |
| 867 // the correct size. | 868 // the correct size. |
| 868 user_wallpaper_delegate_->InitializeWallpaper(); | 869 user_wallpaper_delegate_->InitializeWallpaper(); |
| 869 | 870 |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 973 //////////////////////////////////////////////////////////////////////////////// | 974 //////////////////////////////////////////////////////////////////////////////// |
| 974 // Shell, aura::client::ActivationChangeObserver implementation: | 975 // Shell, aura::client::ActivationChangeObserver implementation: |
| 975 | 976 |
| 976 void Shell::OnWindowActivated(aura::Window* gained_active, | 977 void Shell::OnWindowActivated(aura::Window* gained_active, |
| 977 aura::Window* lost_active) { | 978 aura::Window* lost_active) { |
| 978 if (gained_active) | 979 if (gained_active) |
| 979 target_root_window_ = gained_active->GetRootWindow(); | 980 target_root_window_ = gained_active->GetRootWindow(); |
| 980 } | 981 } |
| 981 | 982 |
| 982 } // namespace ash | 983 } // namespace ash |
| OLD | NEW |