| 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" |
| 11 #include "ash/ash_switches.h" | 11 #include "ash/ash_switches.h" |
| 12 #include "ash/caps_lock_delegate_stub.h" | 12 #include "ash/caps_lock_delegate_stub.h" |
| 13 #include "ash/desktop_background/desktop_background_controller.h" | 13 #include "ash/desktop_background/desktop_background_controller.h" |
| 14 #include "ash/desktop_background/desktop_background_resources.h" | 14 #include "ash/desktop_background/desktop_background_resources.h" |
| 15 #include "ash/desktop_background/desktop_background_view.h" | 15 #include "ash/desktop_background/desktop_background_view.h" |
| 16 #include "ash/display/display_controller.h" | 16 #include "ash/display/display_controller.h" |
| 17 #include "ash/display/mouse_cursor_event_filter.h" | 17 #include "ash/display/mouse_cursor_event_filter.h" |
| 18 #include "ash/display/multi_display_manager.h" | 18 #include "ash/display/multi_display_manager.h" |
| 19 #include "ash/display/screen_position_controller.h" | 19 #include "ash/display/screen_position_controller.h" |
| 20 #include "ash/display/secondary_display_view.h" | 20 #include "ash/display/secondary_display_view.h" |
| 21 #include "ash/drag_drop/drag_drop_controller.h" | 21 #include "ash/drag_drop/drag_drop_controller.h" |
| 22 #include "ash/focus_cycler.h" | 22 #include "ash/focus_cycler.h" |
| 23 #include "ash/high_contrast/high_contrast_controller.h" | 23 #include "ash/high_contrast/high_contrast_controller.h" |
| 24 #include "ash/launcher/launcher.h" | |
| 25 #include "ash/magnifier/magnification_controller.h" | 24 #include "ash/magnifier/magnification_controller.h" |
| 26 #include "ash/root_window_controller.h" | 25 #include "ash/root_window_controller.h" |
| 27 #include "ash/screen_ash.h" | 26 #include "ash/screen_ash.h" |
| 28 #include "ash/shell_context_menu.h" | 27 #include "ash/shell_context_menu.h" |
| 29 #include "ash/shell_delegate.h" | 28 #include "ash/shell_delegate.h" |
| 30 #include "ash/shell_factory.h" | 29 #include "ash/shell_factory.h" |
| 31 #include "ash/shell_window_ids.h" | 30 #include "ash/shell_window_ids.h" |
| 32 #include "ash/system/status_area_widget.h" | 31 #include "ash/system/status_area_widget.h" |
| 33 #include "ash/system/tray/system_tray.h" | |
| 34 #include "ash/tooltips/tooltip_controller.h" | 32 #include "ash/tooltips/tooltip_controller.h" |
| 35 #include "ash/touch/touch_observer_hud.h" | 33 #include "ash/touch/touch_observer_hud.h" |
| 36 #include "ash/wm/activation_controller.h" | 34 #include "ash/wm/activation_controller.h" |
| 37 #include "ash/wm/always_on_top_controller.h" | 35 #include "ash/wm/always_on_top_controller.h" |
| 38 #include "ash/wm/app_list_controller.h" | 36 #include "ash/wm/app_list_controller.h" |
| 39 #include "ash/wm/base_layout_manager.h" | 37 #include "ash/wm/base_layout_manager.h" |
| 40 #include "ash/wm/capture_controller.h" | 38 #include "ash/wm/capture_controller.h" |
| 41 #include "ash/wm/custom_frame_view_ash.h" | 39 #include "ash/wm/custom_frame_view_ash.h" |
| 42 #include "ash/wm/dialog_frame_view.h" | 40 #include "ash/wm/dialog_frame_view.h" |
| 43 #include "ash/wm/event_client_impl.h" | 41 #include "ash/wm/event_client_impl.h" |
| 44 #include "ash/wm/event_rewriter_event_filter.h" | 42 #include "ash/wm/event_rewriter_event_filter.h" |
| 45 #include "ash/wm/overlay_event_filter.h" | 43 #include "ash/wm/overlay_event_filter.h" |
| 46 #include "ash/wm/panel_layout_manager.h" | |
| 47 #include "ash/wm/panel_window_event_filter.h" | |
| 48 #include "ash/wm/power_button_controller.h" | 44 #include "ash/wm/power_button_controller.h" |
| 49 #include "ash/wm/property_util.h" | 45 #include "ash/wm/property_util.h" |
| 50 #include "ash/wm/resize_shadow_controller.h" | 46 #include "ash/wm/resize_shadow_controller.h" |
| 51 #include "ash/wm/root_window_layout_manager.h" | 47 #include "ash/wm/root_window_layout_manager.h" |
| 52 #include "ash/wm/screen_dimmer.h" | 48 #include "ash/wm/screen_dimmer.h" |
| 53 #include "ash/wm/shadow_controller.h" | 49 #include "ash/wm/shadow_controller.h" |
| 54 #include "ash/wm/shelf_layout_manager.h" | |
| 55 #include "ash/wm/stacking_controller.h" | 50 #include "ash/wm/stacking_controller.h" |
| 56 #include "ash/wm/status_area_layout_manager.h" | |
| 57 #include "ash/wm/system_gesture_event_filter.h" | 51 #include "ash/wm/system_gesture_event_filter.h" |
| 58 #include "ash/wm/system_modal_container_event_filter.h" | 52 #include "ash/wm/system_modal_container_event_filter.h" |
| 59 #include "ash/wm/system_modal_container_layout_manager.h" | 53 #include "ash/wm/system_modal_container_layout_manager.h" |
| 60 #include "ash/wm/user_activity_detector.h" | 54 #include "ash/wm/user_activity_detector.h" |
| 61 #include "ash/wm/video_detector.h" | 55 #include "ash/wm/video_detector.h" |
| 62 #include "ash/wm/visibility_controller.h" | 56 #include "ash/wm/visibility_controller.h" |
| 63 #include "ash/wm/window_cycle_controller.h" | 57 #include "ash/wm/window_cycle_controller.h" |
| 64 #include "ash/wm/window_modality_controller.h" | 58 #include "ash/wm/window_modality_controller.h" |
| 65 #include "ash/wm/window_properties.h" | 59 #include "ash/wm/window_properties.h" |
| 66 #include "ash/wm/window_util.h" | 60 #include "ash/wm/window_util.h" |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 | 177 |
| 184 Shell::Shell(ShellDelegate* delegate) | 178 Shell::Shell(ShellDelegate* delegate) |
| 185 : screen_(new ScreenAsh), | 179 : screen_(new ScreenAsh), |
| 186 active_root_window_(NULL), | 180 active_root_window_(NULL), |
| 187 delegate_(delegate), | 181 delegate_(delegate), |
| 188 #if defined(OS_CHROMEOS) | 182 #if defined(OS_CHROMEOS) |
| 189 output_configurator_(new chromeos::OutputConfigurator()), | 183 output_configurator_(new chromeos::OutputConfigurator()), |
| 190 output_configurator_animation_( | 184 output_configurator_animation_( |
| 191 new internal::OutputConfiguratorAnimation()), | 185 new internal::OutputConfiguratorAnimation()), |
| 192 #endif // defined(OS_CHROMEOS) | 186 #endif // defined(OS_CHROMEOS) |
| 193 shelf_(NULL), | |
| 194 panel_layout_manager_(NULL), | |
| 195 status_area_widget_(NULL), | |
| 196 browser_context_(NULL) { | 187 browser_context_(NULL) { |
| 197 gfx::Screen::SetInstance(screen_); | 188 gfx::Screen::SetInstance(screen_); |
| 198 ui_controls::InstallUIControlsAura(internal::CreateUIControls()); | 189 ui_controls::InstallUIControlsAura(internal::CreateUIControls()); |
| 199 #if defined(OS_CHROMEOS) | 190 #if defined(OS_CHROMEOS) |
| 200 output_configurator_->AddObserver(output_configurator_animation_.get()); | 191 output_configurator_->AddObserver(output_configurator_animation_.get()); |
| 201 base::MessagePumpAuraX11::Current()->AddDispatcherForRootWindow( | 192 base::MessagePumpAuraX11::Current()->AddDispatcherForRootWindow( |
| 202 output_configurator()); | 193 output_configurator()); |
| 203 #endif // defined(OS_CHROMEOS) | 194 #endif // defined(OS_CHROMEOS) |
| 204 } | 195 } |
| 205 | 196 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 225 RemoveEnvEventFilter(system_gesture_filter_.get()); | 216 RemoveEnvEventFilter(system_gesture_filter_.get()); |
| 226 #if !defined(OS_MACOSX) | 217 #if !defined(OS_MACOSX) |
| 227 RemoveEnvEventFilter(accelerator_filter_.get()); | 218 RemoveEnvEventFilter(accelerator_filter_.get()); |
| 228 #endif | 219 #endif |
| 229 if (touch_observer_hud_.get()) | 220 if (touch_observer_hud_.get()) |
| 230 RemoveEnvEventFilter(touch_observer_hud_.get()); | 221 RemoveEnvEventFilter(touch_observer_hud_.get()); |
| 231 | 222 |
| 232 // TooltipController is deleted with the Shell so removing its references. | 223 // TooltipController is deleted with the Shell so removing its references. |
| 233 RemoveEnvEventFilter(tooltip_controller_.get()); | 224 RemoveEnvEventFilter(tooltip_controller_.get()); |
| 234 | 225 |
| 235 // The status area needs to be shut down before the windows are destroyed. | |
| 236 status_area_widget_->Shutdown(); | |
| 237 | |
| 238 // AppList needs to be released before shelf layout manager, which is | 226 // AppList needs to be released before shelf layout manager, which is |
| 239 // destroyed with launcher container in the loop below. However, app list | 227 // destroyed with launcher container in the loop below. However, app list |
| 240 // container is now on top of launcher container and released after it. | 228 // container is now on top of launcher container and released after it. |
| 241 // TODO(xiyuan): Move it back when app list container is no longer needed. | 229 // TODO(xiyuan): Move it back when app list container is no longer needed. |
| 242 app_list_controller_.reset(); | 230 app_list_controller_.reset(); |
| 243 | 231 |
| 244 | |
| 245 // Closing the windows frees the workspace controller. | |
| 246 shelf_->set_workspace_controller(NULL); | |
| 247 // Destroy all child windows including widgets. | 232 // Destroy all child windows including widgets. |
| 248 display_controller_->CloseChildWindows(); | 233 display_controller_->CloseChildWindows(); |
| 249 | 234 |
| 250 // These need a valid Shell instance to clean up properly, so explicitly | 235 // These need a valid Shell instance to clean up properly, so explicitly |
| 251 // delete them before invalidating the instance. | 236 // delete them before invalidating the instance. |
| 252 // Alphabetical. | 237 // Alphabetical. |
| 253 drag_drop_controller_.reset(); | 238 drag_drop_controller_.reset(); |
| 254 magnification_controller_.reset(); | 239 magnification_controller_.reset(); |
| 255 power_button_controller_.reset(); | 240 power_button_controller_.reset(); |
| 256 resize_shadow_controller_.reset(); | 241 resize_shadow_controller_.reset(); |
| 257 shadow_controller_.reset(); | 242 shadow_controller_.reset(); |
| 258 tooltip_controller_.reset(); | 243 tooltip_controller_.reset(); |
| 259 event_client_.reset(); | 244 event_client_.reset(); |
| 260 window_cycle_controller_.reset(); | 245 window_cycle_controller_.reset(); |
| 261 capture_controller_.reset(); | 246 capture_controller_.reset(); |
| 262 nested_dispatcher_controller_.reset(); | 247 nested_dispatcher_controller_.reset(); |
| 263 user_action_client_.reset(); | 248 user_action_client_.reset(); |
| 264 visibility_controller_.reset(); | 249 visibility_controller_.reset(); |
| 265 | 250 |
| 266 // This also deletes all RootWindows. | 251 // This also deletes all RootWindows. |
| 267 display_controller_.reset(); | 252 display_controller_.reset(); |
| 268 screen_position_controller_.reset(); | 253 screen_position_controller_.reset(); |
| 269 | 254 |
| 270 // Launcher widget has a InputMethodBridge that references to | |
| 271 // input_method_filter_'s input_method_. So explicitly release launcher_ | |
| 272 // before input_method_filter_. And this needs to be after we delete all | |
| 273 // containers in case there are still live browser windows which access | |
| 274 // LauncherModel during close. | |
| 275 launcher_.reset(); | |
| 276 | |
| 277 // Delete the activation controller after other controllers and launcher | 255 // Delete the activation controller after other controllers and launcher |
| 278 // because they might have registered ActivationChangeObserver. | 256 // because they might have registered ActivationChangeObserver. |
| 279 activation_controller_.reset(); | 257 activation_controller_.reset(); |
| 280 | 258 |
| 281 DCHECK(instance_ == this); | 259 DCHECK(instance_ == this); |
| 282 instance_ = NULL; | 260 instance_ = NULL; |
| 283 | 261 |
| 284 #if defined(OS_CHROMEOS) | 262 #if defined(OS_CHROMEOS) |
| 285 output_configurator_->RemoveObserver(output_configurator_animation_.get()); | 263 output_configurator_->RemoveObserver(output_configurator_animation_.get()); |
| 286 base::MessagePumpAuraX11::Current()->RemoveDispatcherForRootWindow( | 264 base::MessagePumpAuraX11::Current()->RemoveDispatcherForRootWindow( |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 | 334 |
| 357 // static | 335 // static |
| 358 std::vector<aura::Window*> Shell::GetAllContainers(int container_id) { | 336 std::vector<aura::Window*> Shell::GetAllContainers(int container_id) { |
| 359 std::vector<aura::Window*> containers; | 337 std::vector<aura::Window*> containers; |
| 360 aura::Window* container = GetPrimaryRootWindow()->GetChildById(container_id); | 338 aura::Window* container = GetPrimaryRootWindow()->GetChildById(container_id); |
| 361 if (container) | 339 if (container) |
| 362 containers.push_back(container); | 340 containers.push_back(container); |
| 363 return containers; | 341 return containers; |
| 364 } | 342 } |
| 365 | 343 |
| 344 // static |
| 345 bool Shell::IsMultipleLaunchersEnabled() { |
| 346 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 347 return command_line->HasSwitch(switches::kAshMultipleLaunchers); |
| 348 } |
| 349 |
| 366 void Shell::Init() { | 350 void Shell::Init() { |
| 367 // Install the custom factory first so that views::FocusManagers for Tray, | 351 // Install the custom factory first so that views::FocusManagers for Tray, |
| 368 // Launcher, and WallPaper could be created by the factory. | 352 // Launcher, and WallPaper could be created by the factory. |
| 369 views::FocusManagerFactory::Install(new AshFocusManagerFactory); | 353 views::FocusManagerFactory::Install(new AshFocusManagerFactory); |
| 370 | 354 |
| 371 env_filter_.reset(new aura::shared::CompoundEventFilter); | 355 env_filter_.reset(new aura::shared::CompoundEventFilter); |
| 372 AddEnvEventFilter(env_filter_.get()); | 356 AddEnvEventFilter(env_filter_.get()); |
| 373 | 357 |
| 374 cursor_manager_.set_delegate(this); | 358 cursor_manager_.set_delegate(this); |
| 375 | 359 |
| 376 focus_manager_.reset(new aura::FocusManager); | 360 focus_manager_.reset(new aura::FocusManager); |
| 377 activation_controller_.reset( | 361 activation_controller_.reset( |
| 378 new internal::ActivationController(focus_manager_.get())); | 362 new internal::ActivationController(focus_manager_.get())); |
| 379 | 363 |
| 364 focus_cycler_.reset(new internal::FocusCycler()); |
| 365 |
| 380 screen_position_controller_.reset(new internal::ScreenPositionController); | 366 screen_position_controller_.reset(new internal::ScreenPositionController); |
| 381 display_controller_.reset(new DisplayController); | 367 display_controller_.reset(new DisplayController); |
| 382 display_controller_->InitPrimaryDisplay(); | 368 display_controller_->InitPrimaryDisplay(); |
| 383 aura::RootWindow* root_window = display_controller_->GetPrimaryRootWindow(); | 369 aura::RootWindow* root_window = display_controller_->GetPrimaryRootWindow(); |
| 384 active_root_window_ = root_window; | 370 active_root_window_ = root_window; |
| 385 | 371 |
| 386 cursor_manager_.SetDeviceScaleFactor( | 372 cursor_manager_.SetDeviceScaleFactor( |
| 387 root_window->AsRootWindowHostDelegate()->GetDeviceScaleFactor()); | 373 root_window->AsRootWindowHostDelegate()->GetDeviceScaleFactor()); |
| 388 | 374 |
| 389 #if !defined(OS_MACOSX) | 375 #if !defined(OS_MACOSX) |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 468 | 454 |
| 469 // Launcher must be created after secondary displays are initialized. | 455 // Launcher must be created after secondary displays are initialized. |
| 470 display_controller_->InitSecondaryDisplays(); | 456 display_controller_->InitSecondaryDisplays(); |
| 471 | 457 |
| 472 // StatusAreaWidget uses Shell's CapsLockDelegate. | 458 // StatusAreaWidget uses Shell's CapsLockDelegate. |
| 473 if (delegate_.get()) | 459 if (delegate_.get()) |
| 474 caps_lock_delegate_.reset(delegate_->CreateCapsLockDelegate()); | 460 caps_lock_delegate_.reset(delegate_->CreateCapsLockDelegate()); |
| 475 else | 461 else |
| 476 caps_lock_delegate_.reset(new CapsLockDelegateStub); | 462 caps_lock_delegate_.reset(new CapsLockDelegateStub); |
| 477 | 463 |
| 478 // Initialize Primary RootWindow specific items. | |
| 479 status_area_widget_ = new internal::StatusAreaWidget(); | |
| 480 status_area_widget_->CreateTrayViews(delegate_.get()); | |
| 481 // Login screen manages status area visibility by itself. | |
| 482 if (delegate_.get() && delegate_->IsSessionStarted()) | |
| 483 status_area_widget_->Show(); | |
| 484 | |
| 485 focus_cycler_.reset(new internal::FocusCycler()); | |
| 486 focus_cycler_->AddWidget(status_area_widget_); | |
| 487 | |
| 488 InitLayoutManagersForPrimaryDisplay(root_window_controller); | |
| 489 | |
| 490 if (!command_line->HasSwitch(switches::kAuraNoShadows)) { | 464 if (!command_line->HasSwitch(switches::kAuraNoShadows)) { |
| 491 resize_shadow_controller_.reset(new internal::ResizeShadowController()); | 465 resize_shadow_controller_.reset(new internal::ResizeShadowController()); |
| 492 shadow_controller_.reset(new internal::ShadowController()); | 466 shadow_controller_.reset(new internal::ShadowController()); |
| 493 } | 467 } |
| 494 | 468 |
| 495 if (!delegate_.get() || delegate_->IsUserLoggedIn()) | 469 root_window_controller->InitForPrimaryDisplay(); |
| 496 CreateLauncher(); | |
| 497 | 470 |
| 498 // Force Layout | 471 // Force Layout |
| 499 root_window_controller->root_window_layout()->OnWindowResized(); | 472 root_window_controller->root_window_layout()->OnWindowResized(); |
| 500 | 473 |
| 501 // It needs to be created after OnWindowResized has been called, otherwise the | 474 // It needs to be created after OnWindowResized has been called, otherwise the |
| 502 // widget will not paint when restoring after a browser crash. Also it needs | 475 // widget will not paint when restoring after a browser crash. Also it needs |
| 503 // to be created after InitSecondaryDisplays() to initialize the wallpapers in | 476 // to be created after InitSecondaryDisplays() to initialize the wallpapers in |
| 504 // the correct size. | 477 // the correct size. |
| 505 user_wallpaper_delegate_->InitializeWallpaper(); | 478 user_wallpaper_delegate_->InitializeWallpaper(); |
| 506 | 479 |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 598 | 571 |
| 599 void Shell::OnAppTerminating() { | 572 void Shell::OnAppTerminating() { |
| 600 FOR_EACH_OBSERVER(ShellObserver, observers_, OnAppTerminating()); | 573 FOR_EACH_OBSERVER(ShellObserver, observers_, OnAppTerminating()); |
| 601 } | 574 } |
| 602 | 575 |
| 603 void Shell::OnLockStateChanged(bool locked) { | 576 void Shell::OnLockStateChanged(bool locked) { |
| 604 FOR_EACH_OBSERVER(ShellObserver, observers_, OnLockStateChanged(locked)); | 577 FOR_EACH_OBSERVER(ShellObserver, observers_, OnLockStateChanged(locked)); |
| 605 } | 578 } |
| 606 | 579 |
| 607 void Shell::CreateLauncher() { | 580 void Shell::CreateLauncher() { |
| 608 if (launcher_.get()) | 581 GetPrimaryRootWindowController()->CreateLauncher(); |
| 609 return; | |
| 610 | |
| 611 aura::Window* default_container = | |
| 612 GetPrimaryRootWindowController()-> | |
| 613 GetContainer(internal::kShellWindowId_DefaultContainer); | |
| 614 launcher_.reset(new Launcher(default_container, shelf_)); | |
| 615 | |
| 616 launcher_->SetFocusCycler(focus_cycler_.get()); | |
| 617 shelf_->SetLauncher(launcher_.get()); | |
| 618 if (panel_layout_manager_) | |
| 619 panel_layout_manager_->SetLauncher(launcher_.get()); | |
| 620 | |
| 621 if (delegate()) | |
| 622 launcher_->SetVisible(delegate()->IsSessionStarted()); | |
| 623 launcher_->widget()->Show(); | |
| 624 } | 582 } |
| 625 | 583 |
| 626 void Shell::ShowLauncher() { | 584 void Shell::ShowLauncher() { |
| 627 if (!launcher_.get()) | 585 GetPrimaryRootWindowController()->ShowLauncher(); |
| 628 return; | |
| 629 launcher_->SetVisible(true); | |
| 630 } | 586 } |
| 631 | 587 |
| 632 void Shell::AddShellObserver(ShellObserver* observer) { | 588 void Shell::AddShellObserver(ShellObserver* observer) { |
| 633 observers_.AddObserver(observer); | 589 observers_.AddObserver(observer); |
| 634 } | 590 } |
| 635 | 591 |
| 636 void Shell::RemoveShellObserver(ShellObserver* observer) { | 592 void Shell::RemoveShellObserver(ShellObserver* observer) { |
| 637 observers_.RemoveObserver(observer); | 593 observers_.RemoveObserver(observer); |
| 638 } | 594 } |
| 639 | 595 |
| 596 Launcher* Shell::launcher() { |
| 597 return GetPrimaryRootWindowController()->launcher(); |
| 598 } |
| 599 |
| 640 void Shell::UpdateShelfVisibility() { | 600 void Shell::UpdateShelfVisibility() { |
| 641 shelf_->UpdateVisibilityState(); | 601 GetPrimaryRootWindowController()->UpdateShelfVisibility(); |
| 642 } | 602 } |
| 643 | 603 |
| 644 void Shell::SetShelfAutoHideBehavior(ShelfAutoHideBehavior behavior) { | 604 void Shell::SetShelfAutoHideBehavior(ShelfAutoHideBehavior behavior) { |
| 645 shelf_->SetAutoHideBehavior(behavior); | 605 GetPrimaryRootWindowController()->SetShelfAutoHideBehavior(behavior); |
| 646 } | 606 } |
| 647 | 607 |
| 648 ShelfAutoHideBehavior Shell::GetShelfAutoHideBehavior() const { | 608 ShelfAutoHideBehavior Shell::GetShelfAutoHideBehavior() const { |
| 649 return shelf_->auto_hide_behavior(); | 609 return GetPrimaryRootWindowController()->GetShelfAutoHideBehavior(); |
| 650 } | 610 } |
| 651 | 611 |
| 652 void Shell::SetShelfAlignment(ShelfAlignment alignment) { | 612 void Shell::SetShelfAlignment(ShelfAlignment alignment) { |
| 653 if (!shelf_->SetAlignment(alignment)) | 613 if (GetPrimaryRootWindowController()->SetShelfAlignment(alignment)) { |
| 654 return; | 614 FOR_EACH_OBSERVER(ShellObserver, observers_, OnShelfAlignmentChanged()); |
| 655 FOR_EACH_OBSERVER(ShellObserver, observers_, OnShelfAlignmentChanged()); | 615 } |
| 656 } | 616 } |
| 657 | 617 |
| 658 ShelfAlignment Shell::GetShelfAlignment() { | 618 ShelfAlignment Shell::GetShelfAlignment() { |
| 659 return shelf_->alignment(); | 619 return GetPrimaryRootWindowController()->GetShelfAlignment(); |
| 660 } | 620 } |
| 661 | 621 |
| 662 void Shell::SetDimming(bool should_dim) { | 622 void Shell::SetDimming(bool should_dim) { |
| 663 RootWindowControllerList controllers = GetAllRootWindowControllers(); | 623 RootWindowControllerList controllers = GetAllRootWindowControllers(); |
| 664 for (RootWindowControllerList::iterator iter = controllers.begin(); | 624 for (RootWindowControllerList::iterator iter = controllers.begin(); |
| 665 iter != controllers.end(); ++iter) | 625 iter != controllers.end(); ++iter) |
| 666 (*iter)->screen_dimmer()->SetDimming(should_dim); | 626 (*iter)->screen_dimmer()->SetDimming(should_dim); |
| 667 } | 627 } |
| 668 | 628 |
| 669 void Shell::CreateModalBackground() { | 629 void Shell::CreateModalBackground() { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 687 } | 647 } |
| 688 if (!activated) { | 648 if (!activated) { |
| 689 RemoveEnvEventFilter(modality_filter_.get()); | 649 RemoveEnvEventFilter(modality_filter_.get()); |
| 690 modality_filter_.reset(); | 650 modality_filter_.reset(); |
| 691 for (RootWindowControllerList::iterator iter = controllers.begin(); | 651 for (RootWindowControllerList::iterator iter = controllers.begin(); |
| 692 iter != controllers.end(); ++iter) | 652 iter != controllers.end(); ++iter) |
| 693 (*iter)->GetSystemModalLayoutManager()->DestroyModalBackground(); | 653 (*iter)->GetSystemModalLayoutManager()->DestroyModalBackground(); |
| 694 } | 654 } |
| 695 } | 655 } |
| 696 | 656 |
| 657 internal::ShelfLayoutManager* Shell::shelf() const { |
| 658 return GetPrimaryRootWindowController()->shelf(); |
| 659 } |
| 660 |
| 661 internal::StatusAreaWidget* Shell::status_area_widget() const { |
| 662 return GetPrimaryRootWindowController()->status_area_widget(); |
| 663 } |
| 664 |
| 697 SystemTrayDelegate* Shell::tray_delegate() { | 665 SystemTrayDelegate* Shell::tray_delegate() { |
| 698 return status_area_widget_->system_tray_delegate(); | 666 return status_area_widget()->system_tray_delegate(); |
| 699 } | 667 } |
| 700 | 668 |
| 701 SystemTray* Shell::system_tray() { | 669 SystemTray* Shell::system_tray() { |
| 702 return status_area_widget_->system_tray(); | 670 return status_area_widget()->system_tray(); |
| 703 } | 671 } |
| 704 | 672 |
| 705 void Shell::InitRootWindowForSecondaryDisplay(aura::RootWindow* root) { | 673 void Shell::InitRootWindowForSecondaryDisplay(aura::RootWindow* root) { |
| 706 root->set_focus_manager(focus_manager_.get()); | 674 root->set_focus_manager(focus_manager_.get()); |
| 707 internal::RootWindowController* controller = | 675 internal::RootWindowController* controller = |
| 708 new internal::RootWindowController(root); | 676 new internal::RootWindowController(root); |
| 709 controller->CreateContainers(); | 677 controller->CreateContainers(); |
| 710 InitRootWindowController(controller); | 678 InitRootWindowController(controller); |
| 711 controller->root_window_layout()->OnWindowResized(); | 679 controller->root_window_layout()->OnWindowResized(); |
| 712 desktop_background_controller_->OnRootWindowAdded(root); | 680 desktop_background_controller_->OnRootWindowAdded(root); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 765 has_modal_background()) { | 733 has_modal_background()) { |
| 766 controller->GetSystemModalLayoutManager()->CreateModalBackground(); | 734 controller->GetSystemModalLayoutManager()->CreateModalBackground(); |
| 767 } | 735 } |
| 768 | 736 |
| 769 window_cycle_controller_->OnRootWindowAdded(root_window); | 737 window_cycle_controller_->OnRootWindowAdded(root_window); |
| 770 } | 738 } |
| 771 | 739 |
| 772 //////////////////////////////////////////////////////////////////////////////// | 740 //////////////////////////////////////////////////////////////////////////////// |
| 773 // Shell, private: | 741 // Shell, private: |
| 774 | 742 |
| 775 void Shell::InitLayoutManagersForPrimaryDisplay( | |
| 776 internal::RootWindowController* controller) { | |
| 777 DCHECK(status_area_widget_); | |
| 778 | |
| 779 internal::ShelfLayoutManager* shelf_layout_manager = | |
| 780 new internal::ShelfLayoutManager(status_area_widget_); | |
| 781 controller->GetContainer(internal::kShellWindowId_LauncherContainer)-> | |
| 782 SetLayoutManager(shelf_layout_manager); | |
| 783 shelf_ = shelf_layout_manager; | |
| 784 | |
| 785 internal::StatusAreaLayoutManager* status_area_layout_manager = | |
| 786 new internal::StatusAreaLayoutManager(shelf_layout_manager); | |
| 787 controller->GetContainer(internal::kShellWindowId_StatusContainer)-> | |
| 788 SetLayoutManager(status_area_layout_manager); | |
| 789 | |
| 790 shelf_layout_manager->set_workspace_controller( | |
| 791 controller->workspace_controller()); | |
| 792 | |
| 793 // TODO(oshima): Support multiple displays. | |
| 794 controller->workspace_controller()->SetShelf(shelf()); | |
| 795 | |
| 796 // Create Panel layout manager | |
| 797 aura::Window* panel_container = GetContainer( | |
| 798 GetPrimaryRootWindow(), | |
| 799 internal::kShellWindowId_PanelContainer); | |
| 800 panel_layout_manager_ = | |
| 801 new internal::PanelLayoutManager(panel_container); | |
| 802 panel_container->SetEventFilter( | |
| 803 new internal::PanelWindowEventFilter( | |
| 804 panel_container, panel_layout_manager_)); | |
| 805 panel_container->SetLayoutManager(panel_layout_manager_); | |
| 806 } | |
| 807 | |
| 808 void Shell::SetCursor(gfx::NativeCursor cursor) { | 743 void Shell::SetCursor(gfx::NativeCursor cursor) { |
| 809 RootWindowList root_windows = GetAllRootWindows(); | 744 RootWindowList root_windows = GetAllRootWindows(); |
| 810 for (RootWindowList::iterator iter = root_windows.begin(); | 745 for (RootWindowList::iterator iter = root_windows.begin(); |
| 811 iter != root_windows.end(); ++iter) | 746 iter != root_windows.end(); ++iter) |
| 812 (*iter)->SetCursor(cursor); | 747 (*iter)->SetCursor(cursor); |
| 813 } | 748 } |
| 814 | 749 |
| 815 void Shell::ShowCursor(bool visible) { | 750 void Shell::ShowCursor(bool visible) { |
| 816 RootWindowList root_windows = GetAllRootWindows(); | 751 RootWindowList root_windows = GetAllRootWindows(); |
| 817 for (RootWindowList::iterator iter = root_windows.begin(); | 752 for (RootWindowList::iterator iter = root_windows.begin(); |
| 818 iter != root_windows.end(); ++iter) | 753 iter != root_windows.end(); ++iter) |
| 819 (*iter)->ShowCursor(visible); | 754 (*iter)->ShowCursor(visible); |
| 820 } | 755 } |
| 821 | 756 |
| 822 bool Shell::CanWindowReceiveEvents(aura::Window* window) { | 757 bool Shell::CanWindowReceiveEvents(aura::Window* window) { |
| 823 RootWindowControllerList controllers = GetAllRootWindowControllers(); | 758 RootWindowControllerList controllers = GetAllRootWindowControllers(); |
| 824 for (RootWindowControllerList::iterator iter = controllers.begin(); | 759 for (RootWindowControllerList::iterator iter = controllers.begin(); |
| 825 iter != controllers.end(); ++iter) { | 760 iter != controllers.end(); ++iter) { |
| 826 if ((*iter)->GetSystemModalLayoutManager()-> | 761 if ((*iter)->GetSystemModalLayoutManager()-> |
| 827 CanWindowReceiveEvents(window)) { | 762 CanWindowReceiveEvents(window)) { |
| 828 return true; | 763 return true; |
| 829 } | 764 } |
| 830 } | 765 } |
| 831 return false; | 766 return false; |
| 832 } | 767 } |
| 833 | 768 |
| 834 } // namespace ash | 769 } // namespace ash |
| OLD | NEW |