| 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/shell_delegate.h" | 18 #include "ash/shell_delegate.h" |
| 16 #include "ash/shell_factory.h" | 19 #include "ash/shell_factory.h" |
| 17 #include "ash/shell_window_ids.h" | 20 #include "ash/shell_window_ids.h" |
| 18 #include "ash/system/audio/tray_volume.h" | 21 #include "ash/system/audio/tray_volume.h" |
| 19 #include "ash/system/brightness/tray_brightness.h" | 22 #include "ash/system/brightness/tray_brightness.h" |
| 20 #include "ash/system/settings/tray_settings.h" | 23 #include "ash/system/settings/tray_settings.h" |
| (...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 468 tray_->AddTrayItem(tray_brightness); | 471 tray_->AddTrayItem(tray_brightness); |
| 469 tray_->AddTrayItem(new internal::TraySettings()); | 472 tray_->AddTrayItem(new internal::TraySettings()); |
| 470 } | 473 } |
| 471 if (!status_widget_) | 474 if (!status_widget_) |
| 472 status_widget_ = internal::CreateStatusArea(tray_.get()); | 475 status_widget_ = internal::CreateStatusArea(tray_.get()); |
| 473 | 476 |
| 474 aura::Window* default_container = | 477 aura::Window* default_container = |
| 475 GetContainer(internal::kShellWindowId_DefaultContainer); | 478 GetContainer(internal::kShellWindowId_DefaultContainer); |
| 476 launcher_.reset(new Launcher(default_container)); | 479 launcher_.reset(new Launcher(default_container)); |
| 477 | 480 |
| 481 // This controller needs to be set before SetupManagedWindowMode. |
| 482 desktop_background_controller_.reset(new DesktopBackgroundController); |
| 483 |
| 478 InitLayoutManagers(); | 484 InitLayoutManagers(); |
| 479 | 485 |
| 480 if (!command_line->HasSwitch(switches::kAuraNoShadows)) | 486 if (!command_line->HasSwitch(switches::kAuraNoShadows)) |
| 481 shadow_controller_.reset(new internal::ShadowController()); | 487 shadow_controller_.reset(new internal::ShadowController()); |
| 482 | 488 |
| 483 focus_cycler_.reset(new internal::FocusCycler()); | 489 focus_cycler_.reset(new internal::FocusCycler()); |
| 484 focus_cycler_->AddWidget(status_widget_); | 490 focus_cycler_->AddWidget(status_widget_); |
| 485 focus_cycler_->AddWidget(launcher_->widget()); | 491 focus_cycler_->AddWidget(launcher_->widget()); |
| 486 launcher_->SetFocusCycler(focus_cycler_.get()); | 492 launcher_->SetFocusCycler(focus_cycler_.get()); |
| 487 | 493 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 531 if (workspace_controller_.get()) | 537 if (workspace_controller_.get()) |
| 532 workspace_controller_->ShowMenu(widget, location); | 538 workspace_controller_->ShowMenu(widget, location); |
| 533 } | 539 } |
| 534 | 540 |
| 535 void Shell::ToggleAppList() { | 541 void Shell::ToggleAppList() { |
| 536 if (!app_list_.get()) | 542 if (!app_list_.get()) |
| 537 app_list_.reset(new internal::AppList); | 543 app_list_.reset(new internal::AppList); |
| 538 app_list_->SetVisible(!app_list_->IsVisible()); | 544 app_list_->SetVisible(!app_list_->IsVisible()); |
| 539 } | 545 } |
| 540 | 546 |
| 541 void Shell::SetDesktopBackgroundMode(BackgroundMode mode) { | 547 void Shell::SetDesktopBackgroundWallpaper(const SkBitmap& wallpaper) { |
| 542 if (mode == BACKGROUND_SOLID_COLOR) { | 548 if (desktop_background_mode_ == BACKGROUND_SOLID_COLOR) |
| 543 // Set a solid black background. | 549 return; |
| 544 // TODO(derat): Remove this in favor of having the compositor only clear the | 550 |
| 545 // viewport when there are regions not covered by a layer: | 551 DCHECK(root_window_layout_->background_widget()); |
| 546 // http://crbug.com/113445 | 552 static_cast<internal::DesktopBackgroundView*>( |
| 547 ui::Layer* background_layer = new ui::Layer(ui::Layer::LAYER_SOLID_COLOR); | 553 root_window_layout_->background_widget()->widget_delegate())-> |
| 548 background_layer->SetColor(SK_ColorBLACK); | 554 SetWallpaper(wallpaper); |
| 549 GetContainer(internal::kShellWindowId_DesktopBackgroundContainer)-> | 555 } |
| 550 layer()->Add(background_layer); | 556 |
| 551 root_window_layout_->SetBackgroundLayer(background_layer); | 557 void Shell::SetDesktopBackgroundImageMode(const SkBitmap& wallpaper) { |
| 552 root_window_layout_->SetBackgroundWidget(NULL); | 558 root_window_layout_->SetBackgroundLayer(NULL); |
| 553 } else { | 559 root_window_layout_->SetBackgroundWidget( |
| 554 // Create the desktop background image. | 560 internal::CreateDesktopBackground(wallpaper)); |
| 555 root_window_layout_->SetBackgroundLayer(NULL); | 561 desktop_background_mode_ = BACKGROUND_IMAGE; |
| 556 root_window_layout_->SetBackgroundWidget( | 562 } |
| 557 internal::CreateDesktopBackground()); | 563 |
| 558 } | 564 void Shell::SetDesktopBackgroundSolidColorMode() { |
| 559 desktop_background_mode_ = mode; | 565 // Set a solid black background. |
| 566 // TODO(derat): Remove this in favor of having the compositor only clear the |
| 567 // viewport when there are regions not covered by a layer: |
| 568 // http://crbug.com/113445 |
| 569 ui::Layer* background_layer = new ui::Layer(ui::Layer::LAYER_SOLID_COLOR); |
| 570 background_layer->SetColor(SK_ColorBLACK); |
| 571 GetContainer(internal::kShellWindowId_DesktopBackgroundContainer)-> |
| 572 layer()->Add(background_layer); |
| 573 root_window_layout_->SetBackgroundLayer(background_layer); |
| 574 root_window_layout_->SetBackgroundWidget(NULL); |
| 575 desktop_background_mode_ = BACKGROUND_SOLID_COLOR; |
| 560 } | 576 } |
| 561 | 577 |
| 562 bool Shell::IsScreenLocked() const { | 578 bool Shell::IsScreenLocked() const { |
| 563 const aura::Window* lock_screen_container = GetContainer( | 579 const aura::Window* lock_screen_container = GetContainer( |
| 564 internal::kShellWindowId_LockScreenContainer); | 580 internal::kShellWindowId_LockScreenContainer); |
| 565 return lock_screen_container->StopsEventPropagation(); | 581 return lock_screen_container->StopsEventPropagation(); |
| 566 } | 582 } |
| 567 | 583 |
| 568 bool Shell::IsModalWindowOpen() const { | 584 bool Shell::IsModalWindowOpen() const { |
| 569 const aura::Window* modal_container = GetContainer( | 585 const aura::Window* modal_container = GetContainer( |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 611 GetContainer(internal::kShellWindowId_DefaultContainer); | 627 GetContainer(internal::kShellWindowId_DefaultContainer); |
| 612 // Workspace manager has its own layout managers. | 628 // Workspace manager has its own layout managers. |
| 613 workspace_controller_.reset( | 629 workspace_controller_.reset( |
| 614 new internal::WorkspaceController(default_container)); | 630 new internal::WorkspaceController(default_container)); |
| 615 workspace_controller_->workspace_manager()->set_shelf(shelf_layout_manager); | 631 workspace_controller_->workspace_manager()->set_shelf(shelf_layout_manager); |
| 616 | 632 |
| 617 // Ensure launcher is visible. | 633 // Ensure launcher is visible. |
| 618 launcher_->widget()->Show(); | 634 launcher_->widget()->Show(); |
| 619 | 635 |
| 620 // Create the desktop background image. | 636 // Create the desktop background image. |
| 621 SetDesktopBackgroundMode(BACKGROUND_IMAGE); | 637 SetDesktopBackgroundImageMode(desktop_background_controller_-> |
| 638 GetPresetWallpaper()); |
| 622 } | 639 } |
| 623 | 640 |
| 624 void Shell::DisableWorkspaceGridLayout() { | 641 void Shell::DisableWorkspaceGridLayout() { |
| 625 if (workspace_controller_.get()) | 642 if (workspace_controller_.get()) |
| 626 workspace_controller_->workspace_manager()->set_grid_size(0); | 643 workspace_controller_->workspace_manager()->set_grid_size(0); |
| 627 } | 644 } |
| 628 | 645 |
| 629 } // namespace ash | 646 } // namespace ash |
| OLD | NEW |