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 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
471 | 474 |
472 window_modality_controller_.reset(new internal::WindowModalityController); | 475 window_modality_controller_.reset(new internal::WindowModalityController); |
473 AddRootWindowEventFilter(window_modality_controller_.get()); | 476 AddRootWindowEventFilter(window_modality_controller_.get()); |
474 | 477 |
475 visibility_controller_.reset(new internal::VisibilityController); | 478 visibility_controller_.reset(new internal::VisibilityController); |
476 | 479 |
477 tooltip_controller_.reset(new internal::TooltipController); | 480 tooltip_controller_.reset(new internal::TooltipController); |
478 AddRootWindowEventFilter(tooltip_controller_.get()); | 481 AddRootWindowEventFilter(tooltip_controller_.get()); |
479 | 482 |
480 drag_drop_controller_.reset(new internal::DragDropController); | 483 drag_drop_controller_.reset(new internal::DragDropController); |
484 desktop_background_controller_.reset(new DesktopBackgroundController); | |
481 power_button_controller_.reset(new PowerButtonController); | 485 power_button_controller_.reset(new PowerButtonController); |
482 video_detector_.reset(new VideoDetector); | 486 video_detector_.reset(new VideoDetector); |
483 window_cycle_controller_.reset(new WindowCycleController); | 487 window_cycle_controller_.reset(new WindowCycleController); |
484 } | 488 } |
485 | 489 |
486 Shell::WindowMode Shell::ComputeWindowMode(CommandLine* command_line) const { | 490 Shell::WindowMode Shell::ComputeWindowMode(CommandLine* command_line) const { |
487 // Some devices don't perform well with overlapping windows. | 491 // Some devices don't perform well with overlapping windows. |
488 if (command_line->HasSwitch(switches::kAuraForceCompactWindowMode)) | 492 if (command_line->HasSwitch(switches::kAuraForceCompactWindowMode)) |
489 return MODE_COMPACT; | 493 return MODE_COMPACT; |
490 | 494 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
531 if (workspace_controller_.get()) | 535 if (workspace_controller_.get()) |
532 workspace_controller_->ShowMenu(widget, location); | 536 workspace_controller_->ShowMenu(widget, location); |
533 } | 537 } |
534 | 538 |
535 void Shell::ToggleAppList() { | 539 void Shell::ToggleAppList() { |
536 if (!app_list_.get()) | 540 if (!app_list_.get()) |
537 app_list_.reset(new internal::AppList); | 541 app_list_.reset(new internal::AppList); |
538 app_list_->SetVisible(!app_list_->IsVisible()); | 542 app_list_->SetVisible(!app_list_->IsVisible()); |
539 } | 543 } |
540 | 544 |
541 void Shell::SetDesktopBackgroundMode(BackgroundMode mode) { | 545 void Shell::SetDesktopBackgroundWallpaper(const SkBitmap& wallpaper) { |
542 if (mode == BACKGROUND_SOLID_COLOR) { | 546 if (desktop_background_mode_ == BACKGROUND_SOLID_COLOR) |
543 // Set a solid black background. | 547 return; |
544 // TODO(derat): Remove this in favor of having the compositor only clear the | 548 |
545 // viewport when there are regions not covered by a layer: | 549 DCHECK(root_window_layout_->background_widget()); |
546 // http://crbug.com/113445 | 550 static_cast<internal::DesktopBackgroundView*>( |
547 ui::Layer* background_layer = new ui::Layer(ui::Layer::LAYER_SOLID_COLOR); | 551 root_window_layout_->background_widget()->widget_delegate())-> |
548 background_layer->SetColor(SK_ColorBLACK); | 552 SetWallpaper(wallpaper); |
549 GetContainer(internal::kShellWindowId_DesktopBackgroundContainer)-> | 553 } |
550 layer()->Add(background_layer); | 554 |
551 root_window_layout_->SetBackgroundLayer(background_layer); | 555 void Shell::SetDesktopBackgroundImageMode(const SkBitmap& wallpaper) { |
552 root_window_layout_->SetBackgroundWidget(NULL); | 556 root_window_layout_->SetBackgroundLayer(NULL); |
553 } else { | 557 root_window_layout_->SetBackgroundWidget( |
554 // Create the desktop background image. | 558 internal::CreateDesktopBackground(wallpaper)); |
555 root_window_layout_->SetBackgroundLayer(NULL); | 559 desktop_background_mode_ = BACKGROUND_IMAGE; |
556 root_window_layout_->SetBackgroundWidget( | 560 } |
557 internal::CreateDesktopBackground()); | 561 |
558 } | 562 void Shell::SetDesktopBackgroundSolidColorMode() { |
559 desktop_background_mode_ = mode; | 563 // Set a solid black background. |
564 // TODO(derat): Remove this in favor of having the compositor only clear the | |
565 // viewport when there are regions not covered by a layer: | |
566 // http://crbug.com/113445 | |
567 ui::Layer* background_layer = new ui::Layer(ui::Layer::LAYER_SOLID_COLOR); | |
568 background_layer->SetColor(SK_ColorBLACK); | |
569 GetContainer(internal::kShellWindowId_DesktopBackgroundContainer)-> | |
570 layer()->Add(background_layer); | |
571 root_window_layout_->SetBackgroundLayer(background_layer); | |
572 root_window_layout_->SetBackgroundWidget(NULL); | |
573 desktop_background_mode_ = BACKGROUND_SOLID_COLOR; | |
560 } | 574 } |
561 | 575 |
562 bool Shell::IsScreenLocked() const { | 576 bool Shell::IsScreenLocked() const { |
563 const aura::Window* lock_screen_container = GetContainer( | 577 const aura::Window* lock_screen_container = GetContainer( |
564 internal::kShellWindowId_LockScreenContainer); | 578 internal::kShellWindowId_LockScreenContainer); |
565 return lock_screen_container->StopsEventPropagation(); | 579 return lock_screen_container->StopsEventPropagation(); |
566 } | 580 } |
567 | 581 |
568 bool Shell::IsModalWindowOpen() const { | 582 bool Shell::IsModalWindowOpen() const { |
569 const aura::Window* modal_container = GetContainer( | 583 const aura::Window* modal_container = GetContainer( |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
628 new internal::CompactStatusAreaLayoutManager(status_widget_); | 642 new internal::CompactStatusAreaLayoutManager(status_widget_); |
629 GetContainer(internal::kShellWindowId_StatusContainer)-> | 643 GetContainer(internal::kShellWindowId_StatusContainer)-> |
630 SetLayoutManager(status_area_layout_manager); | 644 SetLayoutManager(status_area_layout_manager); |
631 default_container->SetLayoutManager(compact_layout_manager); | 645 default_container->SetLayoutManager(compact_layout_manager); |
632 | 646 |
633 // Keep the launcher for its data model, but hide it. Do this before | 647 // Keep the launcher for its data model, but hide it. Do this before |
634 // maximizing the windows so the work area is the right size. | 648 // maximizing the windows so the work area is the right size. |
635 launcher_->widget()->Hide(); | 649 launcher_->widget()->Hide(); |
636 | 650 |
637 // Set a solid black background. | 651 // Set a solid black background. |
638 SetDesktopBackgroundMode(BACKGROUND_SOLID_COLOR); | 652 SetDesktopBackgroundSolidColorMode(); |
639 } | 653 } |
640 | 654 |
641 void Shell::SetupManagedWindowMode() { | 655 void Shell::SetupManagedWindowMode() { |
642 DCHECK(root_window_layout_); | 656 DCHECK(root_window_layout_); |
643 DCHECK(status_widget_); | 657 DCHECK(status_widget_); |
644 | 658 |
645 internal::ShelfLayoutManager* shelf_layout_manager = | 659 internal::ShelfLayoutManager* shelf_layout_manager = |
646 new internal::ShelfLayoutManager(launcher_->widget(), status_widget_); | 660 new internal::ShelfLayoutManager(launcher_->widget(), status_widget_); |
647 GetContainer(internal::kShellWindowId_LauncherContainer)-> | 661 GetContainer(internal::kShellWindowId_LauncherContainer)-> |
648 SetLayoutManager(shelf_layout_manager); | 662 SetLayoutManager(shelf_layout_manager); |
649 shelf_ = shelf_layout_manager; | 663 shelf_ = shelf_layout_manager; |
650 | 664 |
651 internal::StatusAreaLayoutManager* status_area_layout_manager = | 665 internal::StatusAreaLayoutManager* status_area_layout_manager = |
652 new internal::StatusAreaLayoutManager(shelf_layout_manager); | 666 new internal::StatusAreaLayoutManager(shelf_layout_manager); |
653 GetContainer(internal::kShellWindowId_StatusContainer)-> | 667 GetContainer(internal::kShellWindowId_StatusContainer)-> |
654 SetLayoutManager(status_area_layout_manager); | 668 SetLayoutManager(status_area_layout_manager); |
655 | 669 |
656 aura::Window* default_container = | 670 aura::Window* default_container = |
657 GetContainer(internal::kShellWindowId_DefaultContainer); | 671 GetContainer(internal::kShellWindowId_DefaultContainer); |
658 // Workspace manager has its own layout managers. | 672 // Workspace manager has its own layout managers. |
659 workspace_controller_.reset( | 673 workspace_controller_.reset( |
660 new internal::WorkspaceController(default_container)); | 674 new internal::WorkspaceController(default_container)); |
661 workspace_controller_->workspace_manager()->set_shelf(shelf_layout_manager); | 675 workspace_controller_->workspace_manager()->set_shelf(shelf_layout_manager); |
662 | 676 |
663 // Ensure launcher is visible. | 677 // Ensure launcher is visible. |
664 launcher_->widget()->Show(); | 678 launcher_->widget()->Show(); |
665 | 679 |
666 // Create the desktop background image. | 680 // Create the desktop background image. |
667 SetDesktopBackgroundMode(BACKGROUND_IMAGE); | 681 SetDesktopBackgroundImageMode(desktop_background_controller_-> |
682 GetPresetWallpaper()); | |
flackr
2012/03/08 01:19:59
Indent 4 more spaces as this isn't another argumen
bshe
2012/03/08 03:19:24
Done.
| |
668 } | 683 } |
669 | 684 |
670 void Shell::ResetLayoutManager(int container_id) { | 685 void Shell::ResetLayoutManager(int container_id) { |
671 GetContainer(container_id)->SetLayoutManager(NULL); | 686 GetContainer(container_id)->SetLayoutManager(NULL); |
672 } | 687 } |
673 | 688 |
674 void Shell::DisableWorkspaceGridLayout() { | 689 void Shell::DisableWorkspaceGridLayout() { |
675 if (workspace_controller_.get()) | 690 if (workspace_controller_.get()) |
676 workspace_controller_->workspace_manager()->set_grid_size(0); | 691 workspace_controller_->workspace_manager()->set_grid_size(0); |
677 } | 692 } |
678 | 693 |
679 } // namespace ash | 694 } // namespace ash |
OLD | NEW |