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" |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 SkBitmap null_image_; | 241 SkBitmap null_image_; |
242 | 242 |
243 DISALLOW_COPY_AND_ASSIGN(DummySystemTrayDelegate); | 243 DISALLOW_COPY_AND_ASSIGN(DummySystemTrayDelegate); |
244 }; | 244 }; |
245 | 245 |
246 } // namespace | 246 } // namespace |
247 | 247 |
248 // static | 248 // static |
249 Shell* Shell::instance_ = NULL; | 249 Shell* Shell::instance_ = NULL; |
250 // static | 250 // static |
251 bool Shell::compact_window_mode_for_test_ = false; | |
252 // static | |
253 bool Shell::initially_hide_cursor_ = false; | 251 bool Shell::initially_hide_cursor_ = false; |
254 | 252 |
255 //////////////////////////////////////////////////////////////////////////////// | 253 //////////////////////////////////////////////////////////////////////////////// |
256 // Shell::TestApi | 254 // Shell::TestApi |
257 | 255 |
258 Shell::TestApi::TestApi(Shell* shell) : shell_(shell) {} | 256 Shell::TestApi::TestApi(Shell* shell) : shell_(shell) {} |
259 | 257 |
260 Shell::WindowMode Shell::TestApi::ComputeWindowMode(CommandLine* cmd) const { | 258 Shell::WindowMode Shell::TestApi::ComputeWindowMode(CommandLine* cmd) const { |
261 return shell_->ComputeWindowMode(cmd); | 259 return shell_->ComputeWindowMode(cmd); |
262 } | 260 } |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 if (!status_widget_) | 443 if (!status_widget_) |
446 status_widget_ = internal::CreateStatusArea(tray_.get()); | 444 status_widget_ = internal::CreateStatusArea(tray_.get()); |
447 | 445 |
448 aura::Window* default_container = | 446 aura::Window* default_container = |
449 GetContainer(internal::kShellWindowId_DefaultContainer); | 447 GetContainer(internal::kShellWindowId_DefaultContainer); |
450 launcher_.reset(new Launcher(default_container)); | 448 launcher_.reset(new Launcher(default_container)); |
451 | 449 |
452 if (window_mode_ == MODE_COMPACT) | 450 if (window_mode_ == MODE_COMPACT) |
453 SetupCompactWindowMode(); | 451 SetupCompactWindowMode(); |
454 else | 452 else |
455 SetupNonCompactWindowMode(); | 453 SetupManagedWindowMode(); |
456 | 454 |
457 if (!command_line->HasSwitch(switches::kAuraNoShadows)) | 455 if (!command_line->HasSwitch(switches::kAuraNoShadows)) |
458 shadow_controller_.reset(new internal::ShadowController()); | 456 shadow_controller_.reset(new internal::ShadowController()); |
459 | 457 |
460 focus_cycler_.reset(new internal::FocusCycler()); | 458 focus_cycler_.reset(new internal::FocusCycler()); |
461 focus_cycler_->AddWidget(status_widget_); | 459 focus_cycler_->AddWidget(status_widget_); |
462 focus_cycler_->AddWidget(launcher_->widget()); | 460 focus_cycler_->AddWidget(launcher_->widget()); |
463 launcher_->SetFocusCycler(focus_cycler_.get()); | 461 launcher_->SetFocusCycler(focus_cycler_.get()); |
464 | 462 |
465 // Force a layout. | 463 // Force a layout. |
466 root_window->layout_manager()->OnWindowResized(); | 464 root_window->layout_manager()->OnWindowResized(); |
467 | 465 |
468 window_modality_controller_.reset(new internal::WindowModalityController); | 466 window_modality_controller_.reset(new internal::WindowModalityController); |
469 AddRootWindowEventFilter(window_modality_controller_.get()); | 467 AddRootWindowEventFilter(window_modality_controller_.get()); |
470 | 468 |
471 visibility_controller_.reset(new internal::VisibilityController); | 469 visibility_controller_.reset(new internal::VisibilityController); |
472 | 470 |
473 tooltip_controller_.reset(new internal::TooltipController); | 471 tooltip_controller_.reset(new internal::TooltipController); |
474 AddRootWindowEventFilter(tooltip_controller_.get()); | 472 AddRootWindowEventFilter(tooltip_controller_.get()); |
475 | 473 |
476 drag_drop_controller_.reset(new internal::DragDropController); | 474 drag_drop_controller_.reset(new internal::DragDropController); |
477 power_button_controller_.reset(new PowerButtonController); | 475 power_button_controller_.reset(new PowerButtonController); |
478 video_detector_.reset(new VideoDetector); | 476 video_detector_.reset(new VideoDetector); |
479 window_cycle_controller_.reset(new WindowCycleController); | 477 window_cycle_controller_.reset(new WindowCycleController); |
480 } | 478 } |
481 | 479 |
482 Shell::WindowMode Shell::ComputeWindowMode(CommandLine* command_line) const { | 480 Shell::WindowMode Shell::ComputeWindowMode(CommandLine* command_line) const { |
483 if (compact_window_mode_for_test_) | |
484 return MODE_COMPACT; | |
485 | |
486 // Some devices don't perform well with overlapping windows. | 481 // Some devices don't perform well with overlapping windows. |
487 if (command_line->HasSwitch(switches::kAuraForceCompactWindowMode)) | 482 if (command_line->HasSwitch(switches::kAuraForceCompactWindowMode)) |
488 return MODE_COMPACT; | 483 return MODE_COMPACT; |
489 | 484 |
490 // If user set the flag, use their desired behavior. | 485 // If user set the flag, use their desired behavior. |
491 if (command_line->HasSwitch(switches::kAuraWindowMode)) { | 486 if (command_line->HasSwitch(switches::kAuraWindowMode)) { |
492 std::string mode = | 487 std::string mode = |
493 command_line->GetSwitchValueASCII(switches::kAuraWindowMode); | 488 command_line->GetSwitchValueASCII(switches::kAuraWindowMode); |
494 if (mode == switches::kAuraWindowModeCompact) | 489 if (mode == switches::kAuraWindowModeCompact) |
495 return MODE_COMPACT; | 490 return MODE_COMPACT; |
496 if (mode == switches::kAuraWindowModeManaged) | 491 if (mode == switches::kAuraWindowModeManaged) |
497 return MODE_MANAGED; | 492 return MODE_MANAGED; |
498 if (mode == switches::kAuraWindowModeOverlapping) | |
499 return MODE_OVERLAPPING; | |
500 } | 493 } |
501 | 494 |
502 // Managed is the default. | 495 // Managed is the default. |
503 return Shell::MODE_MANAGED; | 496 return Shell::MODE_MANAGED; |
504 } | 497 } |
505 | 498 |
506 aura::Window* Shell::GetContainer(int container_id) { | 499 aura::Window* Shell::GetContainer(int container_id) { |
507 return const_cast<aura::Window*>( | 500 return const_cast<aura::Window*>( |
508 const_cast<const Shell*>(this)->GetContainer(container_id)); | 501 const_cast<const Shell*>(this)->GetContainer(container_id)); |
509 } | 502 } |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
626 default_container->SetLayoutManager(compact_layout_manager); | 619 default_container->SetLayoutManager(compact_layout_manager); |
627 | 620 |
628 // Keep the launcher for its data model, but hide it. Do this before | 621 // Keep the launcher for its data model, but hide it. Do this before |
629 // maximizing the windows so the work area is the right size. | 622 // maximizing the windows so the work area is the right size. |
630 launcher_->widget()->Hide(); | 623 launcher_->widget()->Hide(); |
631 | 624 |
632 // Set a solid black background. | 625 // Set a solid black background. |
633 SetDesktopBackgroundMode(BACKGROUND_SOLID_COLOR); | 626 SetDesktopBackgroundMode(BACKGROUND_SOLID_COLOR); |
634 } | 627 } |
635 | 628 |
636 void Shell::SetupNonCompactWindowMode() { | 629 void Shell::SetupManagedWindowMode() { |
637 DCHECK(root_window_layout_); | 630 DCHECK(root_window_layout_); |
638 DCHECK(status_widget_); | 631 DCHECK(status_widget_); |
639 | 632 |
640 internal::ShelfLayoutManager* shelf_layout_manager = | 633 internal::ShelfLayoutManager* shelf_layout_manager = |
641 new internal::ShelfLayoutManager(launcher_->widget(), status_widget_); | 634 new internal::ShelfLayoutManager(launcher_->widget(), status_widget_); |
642 GetContainer(internal::kShellWindowId_LauncherContainer)-> | 635 GetContainer(internal::kShellWindowId_LauncherContainer)-> |
643 SetLayoutManager(shelf_layout_manager); | 636 SetLayoutManager(shelf_layout_manager); |
644 shelf_ = shelf_layout_manager; | 637 shelf_ = shelf_layout_manager; |
645 | 638 |
646 internal::StatusAreaLayoutManager* status_area_layout_manager = | 639 internal::StatusAreaLayoutManager* status_area_layout_manager = |
647 new internal::StatusAreaLayoutManager(shelf_layout_manager); | 640 new internal::StatusAreaLayoutManager(shelf_layout_manager); |
648 GetContainer(internal::kShellWindowId_StatusContainer)-> | 641 GetContainer(internal::kShellWindowId_StatusContainer)-> |
649 SetLayoutManager(status_area_layout_manager); | 642 SetLayoutManager(status_area_layout_manager); |
650 | 643 |
651 aura::Window* default_container = | 644 aura::Window* default_container = |
652 GetContainer(internal::kShellWindowId_DefaultContainer); | 645 GetContainer(internal::kShellWindowId_DefaultContainer); |
653 if (window_mode_ == MODE_MANAGED) { | 646 // Workspace manager has its own layout managers. |
654 // Workspace manager has its own layout managers. | 647 workspace_controller_.reset( |
655 workspace_controller_.reset( | 648 new internal::WorkspaceController(default_container)); |
656 new internal::WorkspaceController(default_container)); | 649 workspace_controller_->workspace_manager()->set_shelf(shelf_layout_manager); |
657 workspace_controller_->workspace_manager()->set_shelf(shelf_layout_manager); | 650 |
658 } else { | |
659 // Default layout manager. | |
660 internal::ToplevelLayoutManager* toplevel_layout_manager = | |
661 new internal::ToplevelLayoutManager(); | |
662 toplevel_layout_manager->set_shelf(shelf_layout_manager); | |
663 default_container->SetLayoutManager(toplevel_layout_manager); | |
664 default_container->SetEventFilter( | |
665 new ToplevelWindowEventFilter(default_container)); | |
666 } | |
667 // Ensure launcher is visible. | 651 // Ensure launcher is visible. |
668 launcher_->widget()->Show(); | 652 launcher_->widget()->Show(); |
669 | 653 |
670 // Create the desktop background image. | 654 // Create the desktop background image. |
671 SetDesktopBackgroundMode(BACKGROUND_IMAGE); | 655 SetDesktopBackgroundMode(BACKGROUND_IMAGE); |
672 } | 656 } |
673 | 657 |
674 void Shell::ResetLayoutManager(int container_id) { | 658 void Shell::ResetLayoutManager(int container_id) { |
675 GetContainer(container_id)->SetLayoutManager(NULL); | 659 GetContainer(container_id)->SetLayoutManager(NULL); |
676 } | 660 } |
677 | 661 |
678 void Shell::DisableWorkspaceGridLayout() { | 662 void Shell::DisableWorkspaceGridLayout() { |
679 if (workspace_controller_.get()) | 663 if (workspace_controller_.get()) |
680 workspace_controller_->workspace_manager()->set_grid_size(0); | 664 workspace_controller_->workspace_manager()->set_grid_size(0); |
681 } | 665 } |
682 | 666 |
683 } // namespace ash | 667 } // namespace ash |
OLD | NEW |