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