Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Side by Side Diff: ash/shell.cc

Issue 11093050: Move shelf/launcher/status_area_widget/panel_layout_manager to RootWindowController (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« ash/shell.h ('K') | « ash/shell.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 window_cycle_controller_.reset(); 244 window_cycle_controller_.reset();
260 capture_controller_.reset(); 245 capture_controller_.reset();
261 nested_dispatcher_controller_.reset(); 246 nested_dispatcher_controller_.reset();
262 user_action_client_.reset(); 247 user_action_client_.reset();
263 visibility_controller_.reset(); 248 visibility_controller_.reset();
264 249
265 // This also deletes all RootWindows. 250 // This also deletes all RootWindows.
266 display_controller_.reset(); 251 display_controller_.reset();
267 screen_position_controller_.reset(); 252 screen_position_controller_.reset();
268 253
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 254 // Delete the activation controller after other controllers and launcher
277 // because they might have registered ActivationChangeObserver. 255 // because they might have registered ActivationChangeObserver.
278 activation_controller_.reset(); 256 activation_controller_.reset();
279 257
280 DCHECK(instance_ == this); 258 DCHECK(instance_ == this);
281 instance_ = NULL; 259 instance_ = NULL;
282 260
283 #if defined(OS_CHROMEOS) 261 #if defined(OS_CHROMEOS)
284 output_configurator_->RemoveObserver(output_configurator_animation_.get()); 262 output_configurator_->RemoveObserver(output_configurator_animation_.get());
285 base::MessagePumpAuraX11::Current()->RemoveDispatcherForRootWindow( 263 base::MessagePumpAuraX11::Current()->RemoveDispatcherForRootWindow(
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 327
350 // static 328 // static
351 std::vector<aura::Window*> Shell::GetAllContainers(int container_id) { 329 std::vector<aura::Window*> Shell::GetAllContainers(int container_id) {
352 std::vector<aura::Window*> containers; 330 std::vector<aura::Window*> containers;
353 aura::Window* container = GetPrimaryRootWindow()->GetChildById(container_id); 331 aura::Window* container = GetPrimaryRootWindow()->GetChildById(container_id);
354 if (container) 332 if (container)
355 containers.push_back(container); 333 containers.push_back(container);
356 return containers; 334 return containers;
357 } 335 }
358 336
337 // static
338 bool Shell::IsMultipleLaunchersEnabled() {
339 CommandLine* command_line = CommandLine::ForCurrentProcess();
340 return command_line->HasSwitch(switches::kAshMultipleLaunchers);
341 }
342
359 void Shell::Init() { 343 void Shell::Init() {
360 // Install the custom factory first so that views::FocusManagers for Tray, 344 // Install the custom factory first so that views::FocusManagers for Tray,
361 // Launcher, and WallPaper could be created by the factory. 345 // Launcher, and WallPaper could be created by the factory.
362 views::FocusManagerFactory::Install(new AshFocusManagerFactory); 346 views::FocusManagerFactory::Install(new AshFocusManagerFactory);
363 347
364 env_filter_.reset(new aura::shared::CompoundEventFilter); 348 env_filter_.reset(new aura::shared::CompoundEventFilter);
365 AddEnvEventFilter(env_filter_.get()); 349 AddEnvEventFilter(env_filter_.get());
366 350
367 cursor_manager_.set_delegate(this); 351 cursor_manager_.set_delegate(this);
368 352
369 focus_manager_.reset(new aura::FocusManager); 353 focus_manager_.reset(new aura::FocusManager);
370 activation_controller_.reset( 354 activation_controller_.reset(
371 new internal::ActivationController(focus_manager_.get())); 355 new internal::ActivationController(focus_manager_.get()));
372 356
357 focus_cycler_.reset(new internal::FocusCycler());
358
373 screen_position_controller_.reset(new internal::ScreenPositionController); 359 screen_position_controller_.reset(new internal::ScreenPositionController);
374 display_controller_.reset(new DisplayController); 360 display_controller_.reset(new DisplayController);
375 display_controller_->InitPrimaryDisplay(); 361 display_controller_->InitPrimaryDisplay();
376 aura::RootWindow* root_window = display_controller_->GetPrimaryRootWindow(); 362 aura::RootWindow* root_window = display_controller_->GetPrimaryRootWindow();
377 active_root_window_ = root_window; 363 active_root_window_ = root_window;
378 364
379 cursor_manager_.SetDeviceScaleFactor( 365 cursor_manager_.SetDeviceScaleFactor(
380 root_window->AsRootWindowHostDelegate()->GetDeviceScaleFactor()); 366 root_window->AsRootWindowHostDelegate()->GetDeviceScaleFactor());
381 367
382 #if !defined(OS_MACOSX) 368 #if !defined(OS_MACOSX)
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 445
460 // Launcher must be created after secondary displays are initialized. 446 // Launcher must be created after secondary displays are initialized.
461 display_controller_->InitSecondaryDisplays(); 447 display_controller_->InitSecondaryDisplays();
462 448
463 // StatusAreaWidget uses Shell's CapsLockDelegate. 449 // StatusAreaWidget uses Shell's CapsLockDelegate.
464 if (delegate_.get()) 450 if (delegate_.get())
465 caps_lock_delegate_.reset(delegate_->CreateCapsLockDelegate()); 451 caps_lock_delegate_.reset(delegate_->CreateCapsLockDelegate());
466 else 452 else
467 caps_lock_delegate_.reset(new CapsLockDelegateStub); 453 caps_lock_delegate_.reset(new CapsLockDelegateStub);
468 454
469 // Initialize Primary RootWindow specific items.
470 status_area_widget_ = new internal::StatusAreaWidget();
471 status_area_widget_->CreateTrayViews(delegate_.get());
472 // Login screen manages status area visibility by itself.
473 if (delegate_.get() && delegate_->IsSessionStarted())
474 status_area_widget_->Show();
475
476 focus_cycler_.reset(new internal::FocusCycler());
477 focus_cycler_->AddWidget(status_area_widget_);
478
479 InitLayoutManagersForPrimaryDisplay(root_window_controller);
480
481 if (!command_line->HasSwitch(switches::kAuraNoShadows)) { 455 if (!command_line->HasSwitch(switches::kAuraNoShadows)) {
482 resize_shadow_controller_.reset(new internal::ResizeShadowController()); 456 resize_shadow_controller_.reset(new internal::ResizeShadowController());
483 shadow_controller_.reset(new internal::ShadowController()); 457 shadow_controller_.reset(new internal::ShadowController());
484 } 458 }
485 459
486 if (!delegate_.get() || delegate_->IsUserLoggedIn()) 460 root_window_controller->InitForPrimaryDisplay();
487 CreateLauncher();
488 461
489 // Force Layout 462 // Force Layout
490 root_window_controller->root_window_layout()->OnWindowResized(); 463 root_window_controller->root_window_layout()->OnWindowResized();
491 464
492 // It needs to be created after OnWindowResized has been called, otherwise the 465 // It needs to be created after OnWindowResized has been called, otherwise the
493 // widget will not paint when restoring after a browser crash. Also it needs 466 // widget will not paint when restoring after a browser crash. Also it needs
494 // to be created after InitSecondaryDisplays() to initialize the wallpapers in 467 // to be created after InitSecondaryDisplays() to initialize the wallpapers in
495 // the correct size. 468 // the correct size.
496 user_wallpaper_delegate_->InitializeWallpaper(); 469 user_wallpaper_delegate_->InitializeWallpaper();
497 470
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 562
590 void Shell::OnAppTerminating() { 563 void Shell::OnAppTerminating() {
591 FOR_EACH_OBSERVER(ShellObserver, observers_, OnAppTerminating()); 564 FOR_EACH_OBSERVER(ShellObserver, observers_, OnAppTerminating());
592 } 565 }
593 566
594 void Shell::OnLockStateChanged(bool locked) { 567 void Shell::OnLockStateChanged(bool locked) {
595 FOR_EACH_OBSERVER(ShellObserver, observers_, OnLockStateChanged(locked)); 568 FOR_EACH_OBSERVER(ShellObserver, observers_, OnLockStateChanged(locked));
596 } 569 }
597 570
598 void Shell::CreateLauncher() { 571 void Shell::CreateLauncher() {
599 if (launcher_.get()) 572 GetPrimaryRootWindowController()->CreateLauncher();
600 return;
601
602 aura::Window* default_container =
603 GetPrimaryRootWindowController()->
604 GetContainer(internal::kShellWindowId_DefaultContainer);
605 launcher_.reset(new Launcher(default_container, shelf_));
606
607 launcher_->SetFocusCycler(focus_cycler_.get());
608 shelf_->SetLauncher(launcher_.get());
609 if (panel_layout_manager_)
610 panel_layout_manager_->SetLauncher(launcher_.get());
611
612 if (delegate())
613 launcher_->SetVisible(delegate()->IsSessionStarted());
614 launcher_->widget()->Show();
615 } 573 }
616 574
617 void Shell::ShowLauncher() { 575 void Shell::ShowLauncher() {
618 if (!launcher_.get()) 576 GetPrimaryRootWindowController()->ShowLauncher();
619 return;
620 launcher_->SetVisible(true);
621 } 577 }
622 578
623 void Shell::AddShellObserver(ShellObserver* observer) { 579 void Shell::AddShellObserver(ShellObserver* observer) {
624 observers_.AddObserver(observer); 580 observers_.AddObserver(observer);
625 } 581 }
626 582
627 void Shell::RemoveShellObserver(ShellObserver* observer) { 583 void Shell::RemoveShellObserver(ShellObserver* observer) {
628 observers_.RemoveObserver(observer); 584 observers_.RemoveObserver(observer);
629 } 585 }
630 586
587 Launcher* Shell::launcher() {
588 return GetPrimaryRootWindowController()->launcher();
589 }
590
631 void Shell::UpdateShelfVisibility() { 591 void Shell::UpdateShelfVisibility() {
632 shelf_->UpdateVisibilityState(); 592 GetPrimaryRootWindowController()->UpdateShelfVisibility();
633 } 593 }
634 594
635 void Shell::SetShelfAutoHideBehavior(ShelfAutoHideBehavior behavior) { 595 void Shell::SetShelfAutoHideBehavior(ShelfAutoHideBehavior behavior) {
636 shelf_->SetAutoHideBehavior(behavior); 596 GetPrimaryRootWindowController()->SetShelfAutoHideBehavior(behavior);
637 } 597 }
638 598
639 ShelfAutoHideBehavior Shell::GetShelfAutoHideBehavior() const { 599 ShelfAutoHideBehavior Shell::GetShelfAutoHideBehavior() const {
640 return shelf_->auto_hide_behavior(); 600 return GetPrimaryRootWindowController()->GetShelfAutoHideBehavior();
641 } 601 }
642 602
643 void Shell::SetShelfAlignment(ShelfAlignment alignment) { 603 void Shell::SetShelfAlignment(ShelfAlignment alignment) {
644 if (!shelf_->SetAlignment(alignment)) 604 if (GetPrimaryRootWindowController()->SetShelfAlignment(alignment)) {
645 return; 605 FOR_EACH_OBSERVER(ShellObserver, observers_, OnShelfAlignmentChanged());
646 FOR_EACH_OBSERVER(ShellObserver, observers_, OnShelfAlignmentChanged()); 606 }
647 } 607 }
648 608
649 ShelfAlignment Shell::GetShelfAlignment() { 609 ShelfAlignment Shell::GetShelfAlignment() {
650 return shelf_->alignment(); 610 return GetPrimaryRootWindowController()->GetShelfAlignment();
651 } 611 }
652 612
653 void Shell::SetDimming(bool should_dim) { 613 void Shell::SetDimming(bool should_dim) {
654 RootWindowControllerList controllers = GetAllRootWindowControllers(); 614 RootWindowControllerList controllers = GetAllRootWindowControllers();
655 for (RootWindowControllerList::iterator iter = controllers.begin(); 615 for (RootWindowControllerList::iterator iter = controllers.begin();
656 iter != controllers.end(); ++iter) 616 iter != controllers.end(); ++iter)
657 (*iter)->screen_dimmer()->SetDimming(should_dim); 617 (*iter)->screen_dimmer()->SetDimming(should_dim);
658 } 618 }
659 619
660 void Shell::CreateModalBackground() { 620 void Shell::CreateModalBackground() {
(...skipping 17 matching lines...) Expand all
678 } 638 }
679 if (!activated) { 639 if (!activated) {
680 RemoveEnvEventFilter(modality_filter_.get()); 640 RemoveEnvEventFilter(modality_filter_.get());
681 modality_filter_.reset(); 641 modality_filter_.reset();
682 for (RootWindowControllerList::iterator iter = controllers.begin(); 642 for (RootWindowControllerList::iterator iter = controllers.begin();
683 iter != controllers.end(); ++iter) 643 iter != controllers.end(); ++iter)
684 (*iter)->GetSystemModalLayoutManager()->DestroyModalBackground(); 644 (*iter)->GetSystemModalLayoutManager()->DestroyModalBackground();
685 } 645 }
686 } 646 }
687 647
648 internal::ShelfLayoutManager* Shell::shelf() const {
649 return GetPrimaryRootWindowController()->shelf();
650 }
651
652 internal::StatusAreaWidget* Shell::status_area_widget() const {
653 return GetPrimaryRootWindowController()->status_area_widget();
654 }
655
688 SystemTrayDelegate* Shell::tray_delegate() { 656 SystemTrayDelegate* Shell::tray_delegate() {
689 return status_area_widget_->system_tray_delegate(); 657 return status_area_widget()->system_tray_delegate();
690 } 658 }
691 659
692 SystemTray* Shell::system_tray() { 660 SystemTray* Shell::system_tray() {
693 return status_area_widget_->system_tray(); 661 return status_area_widget()->system_tray();
694 } 662 }
695 663
696 void Shell::InitRootWindowForSecondaryDisplay(aura::RootWindow* root) { 664 void Shell::InitRootWindowForSecondaryDisplay(aura::RootWindow* root) {
697 root->set_focus_manager(focus_manager_.get()); 665 root->set_focus_manager(focus_manager_.get());
698 internal::RootWindowController* controller = 666 internal::RootWindowController* controller =
699 new internal::RootWindowController(root); 667 new internal::RootWindowController(root);
700 controller->CreateContainers(); 668 controller->CreateContainers();
701 InitRootWindowController(controller); 669 InitRootWindowController(controller);
702 controller->root_window_layout()->OnWindowResized(); 670 controller->root_window_layout()->OnWindowResized();
703 desktop_background_controller_->OnRootWindowAdded(root); 671 desktop_background_controller_->OnRootWindowAdded(root);
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
755 has_modal_background()) { 723 has_modal_background()) {
756 controller->GetSystemModalLayoutManager()->CreateModalBackground(); 724 controller->GetSystemModalLayoutManager()->CreateModalBackground();
757 } 725 }
758 726
759 window_cycle_controller_->OnRootWindowAdded(root_window); 727 window_cycle_controller_->OnRootWindowAdded(root_window);
760 } 728 }
761 729
762 //////////////////////////////////////////////////////////////////////////////// 730 ////////////////////////////////////////////////////////////////////////////////
763 // Shell, private: 731 // Shell, private:
764 732
765 void Shell::InitLayoutManagersForPrimaryDisplay(
766 internal::RootWindowController* controller) {
767 DCHECK(status_area_widget_);
768
769 internal::ShelfLayoutManager* shelf_layout_manager =
770 new internal::ShelfLayoutManager(status_area_widget_);
771 controller->GetContainer(internal::kShellWindowId_LauncherContainer)->
772 SetLayoutManager(shelf_layout_manager);
773 shelf_ = shelf_layout_manager;
774
775 internal::StatusAreaLayoutManager* status_area_layout_manager =
776 new internal::StatusAreaLayoutManager(shelf_layout_manager);
777 controller->GetContainer(internal::kShellWindowId_StatusContainer)->
778 SetLayoutManager(status_area_layout_manager);
779
780 shelf_layout_manager->set_workspace_controller(
781 controller->workspace_controller());
782
783 // TODO(oshima): Support multiple displays.
784 controller->workspace_controller()->SetShelf(shelf());
785
786 // Create Panel layout manager
787 aura::Window* panel_container = GetContainer(
788 GetPrimaryRootWindow(),
789 internal::kShellWindowId_PanelContainer);
790 panel_layout_manager_ =
791 new internal::PanelLayoutManager(panel_container);
792 panel_container->SetEventFilter(
793 new internal::PanelWindowEventFilter(
794 panel_container, panel_layout_manager_));
795 panel_container->SetLayoutManager(panel_layout_manager_);
796 }
797
798 void Shell::SetCursor(gfx::NativeCursor cursor) { 733 void Shell::SetCursor(gfx::NativeCursor cursor) {
799 RootWindowList root_windows = GetAllRootWindows(); 734 RootWindowList root_windows = GetAllRootWindows();
800 for (RootWindowList::iterator iter = root_windows.begin(); 735 for (RootWindowList::iterator iter = root_windows.begin();
801 iter != root_windows.end(); ++iter) 736 iter != root_windows.end(); ++iter)
802 (*iter)->SetCursor(cursor); 737 (*iter)->SetCursor(cursor);
803 } 738 }
804 739
805 void Shell::ShowCursor(bool visible) { 740 void Shell::ShowCursor(bool visible) {
806 RootWindowList root_windows = GetAllRootWindows(); 741 RootWindowList root_windows = GetAllRootWindows();
807 for (RootWindowList::iterator iter = root_windows.begin(); 742 for (RootWindowList::iterator iter = root_windows.begin();
808 iter != root_windows.end(); ++iter) 743 iter != root_windows.end(); ++iter)
809 (*iter)->ShowCursor(visible); 744 (*iter)->ShowCursor(visible);
810 } 745 }
811 746
812 bool Shell::CanWindowReceiveEvents(aura::Window* window) { 747 bool Shell::CanWindowReceiveEvents(aura::Window* window) {
813 RootWindowControllerList controllers = GetAllRootWindowControllers(); 748 RootWindowControllerList controllers = GetAllRootWindowControllers();
814 for (RootWindowControllerList::iterator iter = controllers.begin(); 749 for (RootWindowControllerList::iterator iter = controllers.begin();
815 iter != controllers.end(); ++iter) { 750 iter != controllers.end(); ++iter) {
816 if ((*iter)->GetSystemModalLayoutManager()-> 751 if ((*iter)->GetSystemModalLayoutManager()->
817 CanWindowReceiveEvents(window)) { 752 CanWindowReceiveEvents(window)) {
818 return true; 753 return true;
819 } 754 }
820 } 755 }
821 return false; 756 return false;
822 } 757 }
823 758
824 } // namespace ash 759 } // namespace ash
OLDNEW
« ash/shell.h ('K') | « ash/shell.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698