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 | 8 |
9 #include "ash/app_list/app_list.h" | 9 #include "ash/app_list/app_list.h" |
10 #include "ash/ash_switches.h" | 10 #include "ash/ash_switches.h" |
| 11 #include "ash/desktop_background/desktop_background_controller.h" |
| 12 #include "ash/desktop_background/desktop_background_resources.h" |
| 13 #include "ash/desktop_background/desktop_background_view.h" |
11 #include "ash/drag_drop/drag_drop_controller.h" | 14 #include "ash/drag_drop/drag_drop_controller.h" |
12 #include "ash/focus_cycler.h" | 15 #include "ash/focus_cycler.h" |
13 #include "ash/ime/input_method_event_filter.h" | 16 #include "ash/ime/input_method_event_filter.h" |
14 #include "ash/launcher/launcher.h" | 17 #include "ash/launcher/launcher.h" |
15 #include "ash/screen_ash.h" | 18 #include "ash/screen_ash.h" |
16 #include "ash/shell_delegate.h" | 19 #include "ash/shell_delegate.h" |
17 #include "ash/shell_factory.h" | 20 #include "ash/shell_factory.h" |
18 #include "ash/shell_window_ids.h" | 21 #include "ash/shell_window_ids.h" |
19 #include "ash/system/audio/tray_volume.h" | 22 #include "ash/system/audio/tray_volume.h" |
20 #include "ash/system/brightness/tray_brightness.h" | 23 #include "ash/system/brightness/tray_brightness.h" |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 | 337 |
335 //////////////////////////////////////////////////////////////////////////////// | 338 //////////////////////////////////////////////////////////////////////////////// |
336 // Shell, public: | 339 // Shell, public: |
337 | 340 |
338 Shell::Shell(ShellDelegate* delegate) | 341 Shell::Shell(ShellDelegate* delegate) |
339 : root_window_(new aura::RootWindow), | 342 : root_window_(new aura::RootWindow), |
340 screen_(new ScreenAsh(root_window_.get())), | 343 screen_(new ScreenAsh(root_window_.get())), |
341 root_filter_(NULL), | 344 root_filter_(NULL), |
342 delegate_(delegate), | 345 delegate_(delegate), |
343 shelf_(NULL), | 346 shelf_(NULL), |
344 desktop_background_mode_(BACKGROUND_IMAGE), | |
345 root_window_layout_(NULL), | 347 root_window_layout_(NULL), |
346 status_widget_(NULL) { | 348 status_widget_(NULL) { |
347 aura::Env::GetInstance()->SetMonitorManager( | 349 aura::Env::GetInstance()->SetMonitorManager( |
348 aura::CreateSingleMonitorManager(root_window_.get())); | 350 aura::CreateSingleMonitorManager(root_window_.get())); |
349 gfx::Screen::SetInstance(screen_); | 351 gfx::Screen::SetInstance(screen_); |
350 } | 352 } |
351 | 353 |
352 Shell::~Shell() { | 354 Shell::~Shell() { |
353 RemoveRootWindowEventFilter(partial_screenshot_filter_.get()); | 355 RemoveRootWindowEventFilter(partial_screenshot_filter_.get()); |
354 RemoveRootWindowEventFilter(input_method_filter_.get()); | 356 RemoveRootWindowEventFilter(input_method_filter_.get()); |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
510 tray_->AddTrayItem(tray_brightness); | 512 tray_->AddTrayItem(tray_brightness); |
511 tray_->AddTrayItem(new internal::TraySettings()); | 513 tray_->AddTrayItem(new internal::TraySettings()); |
512 } | 514 } |
513 if (!status_widget_) | 515 if (!status_widget_) |
514 status_widget_ = internal::CreateStatusArea(tray_.get()); | 516 status_widget_ = internal::CreateStatusArea(tray_.get()); |
515 | 517 |
516 aura::Window* default_container = | 518 aura::Window* default_container = |
517 GetContainer(internal::kShellWindowId_DefaultContainer); | 519 GetContainer(internal::kShellWindowId_DefaultContainer); |
518 launcher_.reset(new Launcher(default_container)); | 520 launcher_.reset(new Launcher(default_container)); |
519 | 521 |
| 522 // This controller needs to be set before SetupManagedWindowMode. |
| 523 desktop_background_controller_.reset(new DesktopBackgroundController); |
| 524 |
520 InitLayoutManagers(); | 525 InitLayoutManagers(); |
521 | 526 |
522 if (!command_line->HasSwitch(switches::kAuraNoShadows)) | 527 if (!command_line->HasSwitch(switches::kAuraNoShadows)) |
523 shadow_controller_.reset(new internal::ShadowController()); | 528 shadow_controller_.reset(new internal::ShadowController()); |
524 | 529 |
525 focus_cycler_.reset(new internal::FocusCycler()); | 530 focus_cycler_.reset(new internal::FocusCycler()); |
526 focus_cycler_->AddWidget(status_widget_); | 531 focus_cycler_->AddWidget(status_widget_); |
527 focus_cycler_->AddWidget(launcher_->widget()); | 532 focus_cycler_->AddWidget(launcher_->widget()); |
528 launcher_->SetFocusCycler(focus_cycler_.get()); | 533 launcher_->SetFocusCycler(focus_cycler_.get()); |
529 | 534 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
573 if (workspace_controller_.get()) | 578 if (workspace_controller_.get()) |
574 workspace_controller_->ShowMenu(widget, location); | 579 workspace_controller_->ShowMenu(widget, location); |
575 } | 580 } |
576 | 581 |
577 void Shell::ToggleAppList() { | 582 void Shell::ToggleAppList() { |
578 if (!app_list_.get()) | 583 if (!app_list_.get()) |
579 app_list_.reset(new internal::AppList); | 584 app_list_.reset(new internal::AppList); |
580 app_list_->SetVisible(!app_list_->IsVisible()); | 585 app_list_->SetVisible(!app_list_->IsVisible()); |
581 } | 586 } |
582 | 587 |
583 void Shell::SetDesktopBackgroundMode(BackgroundMode mode) { | |
584 if (mode == BACKGROUND_SOLID_COLOR) { | |
585 // Set a solid black background. | |
586 // TODO(derat): Remove this in favor of having the compositor only clear the | |
587 // viewport when there are regions not covered by a layer: | |
588 // http://crbug.com/113445 | |
589 ui::Layer* background_layer = new ui::Layer(ui::Layer::LAYER_SOLID_COLOR); | |
590 background_layer->SetColor(SK_ColorBLACK); | |
591 GetContainer(internal::kShellWindowId_DesktopBackgroundContainer)-> | |
592 layer()->Add(background_layer); | |
593 root_window_layout_->SetBackgroundLayer(background_layer); | |
594 root_window_layout_->SetBackgroundWidget(NULL); | |
595 } else { | |
596 // Create the desktop background image. | |
597 root_window_layout_->SetBackgroundLayer(NULL); | |
598 root_window_layout_->SetBackgroundWidget( | |
599 internal::CreateDesktopBackground()); | |
600 } | |
601 desktop_background_mode_ = mode; | |
602 } | |
603 | |
604 bool Shell::IsScreenLocked() const { | 588 bool Shell::IsScreenLocked() const { |
605 const aura::Window* lock_screen_container = GetContainer( | 589 const aura::Window* lock_screen_container = GetContainer( |
606 internal::kShellWindowId_LockScreenContainer); | 590 internal::kShellWindowId_LockScreenContainer); |
607 return lock_screen_container->StopsEventPropagation(); | 591 return lock_screen_container->StopsEventPropagation(); |
608 } | 592 } |
609 | 593 |
610 bool Shell::IsModalWindowOpen() const { | 594 bool Shell::IsModalWindowOpen() const { |
611 const aura::Window* modal_container = GetContainer( | 595 const aura::Window* modal_container = GetContainer( |
612 internal::kShellWindowId_SystemModalContainer); | 596 internal::kShellWindowId_SystemModalContainer); |
613 return !modal_container->children().empty(); | 597 return !modal_container->children().empty(); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
676 GetContainer(internal::kShellWindowId_DefaultContainer); | 660 GetContainer(internal::kShellWindowId_DefaultContainer); |
677 // Workspace manager has its own layout managers. | 661 // Workspace manager has its own layout managers. |
678 workspace_controller_.reset( | 662 workspace_controller_.reset( |
679 new internal::WorkspaceController(default_container)); | 663 new internal::WorkspaceController(default_container)); |
680 workspace_controller_->workspace_manager()->set_shelf(shelf_layout_manager); | 664 workspace_controller_->workspace_manager()->set_shelf(shelf_layout_manager); |
681 | 665 |
682 // Ensure launcher is visible. | 666 // Ensure launcher is visible. |
683 launcher_->widget()->Show(); | 667 launcher_->widget()->Show(); |
684 | 668 |
685 // Create the desktop background image. | 669 // Create the desktop background image. |
686 SetDesktopBackgroundMode(BACKGROUND_IMAGE); | 670 desktop_background_controller_->SetDefaultDesktopBackgroundImage(); |
687 } | 671 } |
688 | 672 |
689 void Shell::DisableWorkspaceGridLayout() { | 673 void Shell::DisableWorkspaceGridLayout() { |
690 if (workspace_controller_.get()) | 674 if (workspace_controller_.get()) |
691 workspace_controller_->workspace_manager()->set_grid_size(0); | 675 workspace_controller_->workspace_manager()->set_grid_size(0); |
692 } | 676 } |
693 | 677 |
694 } // namespace ash | 678 } // namespace ash |
OLD | NEW |