| 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 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 : root_filter_(new internal::RootWindowEventFilter), | 208 : root_filter_(new internal::RootWindowEventFilter), |
| 209 ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)), | 209 ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)), |
| 210 #if !defined(OS_MACOSX) | 210 #if !defined(OS_MACOSX) |
| 211 nested_dispatcher_controller_(new NestedDispatcherController), | 211 nested_dispatcher_controller_(new NestedDispatcherController), |
| 212 accelerator_controller_(new AcceleratorController), | 212 accelerator_controller_(new AcceleratorController), |
| 213 #endif | 213 #endif |
| 214 delegate_(delegate), | 214 delegate_(delegate), |
| 215 shelf_(NULL), | 215 shelf_(NULL), |
| 216 dynamic_window_mode_(false), | 216 dynamic_window_mode_(false), |
| 217 window_mode_(MODE_OVERLAPPING), | 217 window_mode_(MODE_OVERLAPPING), |
| 218 desktop_background_mode_(BACKGROUND_IMAGE), |
| 218 root_window_layout_(NULL), | 219 root_window_layout_(NULL), |
| 219 status_widget_(NULL) { | 220 status_widget_(NULL) { |
| 220 // Pass ownership of the filter to the root window. | 221 // Pass ownership of the filter to the root window. |
| 221 aura::RootWindow::GetInstance()->SetEventFilter(root_filter_); | 222 aura::RootWindow::GetInstance()->SetEventFilter(root_filter_); |
| 222 } | 223 } |
| 223 | 224 |
| 224 Shell::~Shell() { | 225 Shell::~Shell() { |
| 225 RemoveRootWindowEventFilter(partial_screenshot_filter_.get()); | 226 RemoveRootWindowEventFilter(partial_screenshot_filter_.get()); |
| 226 RemoveRootWindowEventFilter(input_method_filter_.get()); | 227 RemoveRootWindowEventFilter(input_method_filter_.get()); |
| 227 RemoveRootWindowEventFilter(window_modality_controller_.get()); | 228 RemoveRootWindowEventFilter(window_modality_controller_.get()); |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 453 | 454 |
| 454 void Shell::SetWindowModeForMonitorSize(const gfx::Size& monitor_size) { | 455 void Shell::SetWindowModeForMonitorSize(const gfx::Size& monitor_size) { |
| 455 // If we're running on a device, a resolution change means the user plugged in | 456 // If we're running on a device, a resolution change means the user plugged in |
| 456 // or unplugged an external monitor. Change window mode to be appropriate for | 457 // or unplugged an external monitor. Change window mode to be appropriate for |
| 457 // the new screen resolution. | 458 // the new screen resolution. |
| 458 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 459 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 459 WindowMode new_mode = ComputeWindowMode(monitor_size, command_line); | 460 WindowMode new_mode = ComputeWindowMode(monitor_size, command_line); |
| 460 ChangeWindowMode(new_mode); | 461 ChangeWindowMode(new_mode); |
| 461 } | 462 } |
| 462 | 463 |
| 464 void Shell::SetDesktopBackgroundMode(BackgroundMode mode) { |
| 465 if (mode == BACKGROUND_SOLID_COLOR) { |
| 466 // Set a solid black background. |
| 467 // TODO(derat): Remove this in favor of having the compositor only clear the |
| 468 // viewport when there are regions not covered by a layer: |
| 469 // http://crbug.com/113445 |
| 470 ui::Layer* background_layer = new ui::Layer(ui::Layer::LAYER_SOLID_COLOR); |
| 471 background_layer->SetColor(SK_ColorBLACK); |
| 472 GetContainer(internal::kShellWindowId_DesktopBackgroundContainer)-> |
| 473 layer()->Add(background_layer); |
| 474 root_window_layout_->SetBackgroundLayer(background_layer); |
| 475 root_window_layout_->SetBackgroundWidget(NULL); |
| 476 } else { |
| 477 // Create the desktop background image. |
| 478 root_window_layout_->SetBackgroundLayer(NULL); |
| 479 root_window_layout_->SetBackgroundWidget( |
| 480 internal::CreateDesktopBackground()); |
| 481 } |
| 482 desktop_background_mode_ = mode; |
| 483 } |
| 484 |
| 463 bool Shell::IsScreenLocked() const { | 485 bool Shell::IsScreenLocked() const { |
| 464 const aura::Window* lock_screen_container = GetContainer( | 486 const aura::Window* lock_screen_container = GetContainer( |
| 465 internal::kShellWindowId_LockScreenContainer); | 487 internal::kShellWindowId_LockScreenContainer); |
| 466 return lock_screen_container->StopsEventPropagation(); | 488 return lock_screen_container->StopsEventPropagation(); |
| 467 } | 489 } |
| 468 | 490 |
| 469 bool Shell::IsModalWindowOpen() const { | 491 bool Shell::IsModalWindowOpen() const { |
| 470 aura::Window* modal_container = | 492 aura::Window* modal_container = |
| 471 ash::Shell::GetInstance()->GetContainer( | 493 ash::Shell::GetInstance()->GetContainer( |
| 472 internal::kShellWindowId_SystemModalContainer); | 494 internal::kShellWindowId_SystemModalContainer); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 534 default_container->SetLayoutManager(compact_layout_manager); | 556 default_container->SetLayoutManager(compact_layout_manager); |
| 535 | 557 |
| 536 // Keep the launcher for its data model, but hide it. Do this before | 558 // Keep the launcher for its data model, but hide it. Do this before |
| 537 // maximizing the windows so the work area is the right size. | 559 // maximizing the windows so the work area is the right size. |
| 538 launcher_->widget()->Hide(); | 560 launcher_->widget()->Hide(); |
| 539 | 561 |
| 540 // Maximize all the windows, using the new layout manager. | 562 // Maximize all the windows, using the new layout manager. |
| 541 MaximizeWindows(default_container); | 563 MaximizeWindows(default_container); |
| 542 | 564 |
| 543 // Set a solid black background. | 565 // Set a solid black background. |
| 544 // TODO(derat): Remove this in favor of having the compositor only clear the | 566 SetDesktopBackgroundMode(BACKGROUND_SOLID_COLOR); |
| 545 // viewport when there are regions not covered by a layer: | |
| 546 // http://crbug.com/113445 | |
| 547 ui::Layer* background_layer = new ui::Layer(ui::Layer::LAYER_SOLID_COLOR); | |
| 548 background_layer->SetColor(SK_ColorBLACK); | |
| 549 GetContainer(internal::kShellWindowId_DesktopBackgroundContainer)-> | |
| 550 layer()->Add(background_layer); | |
| 551 root_window_layout_->SetBackgroundLayer(background_layer); | |
| 552 root_window_layout_->SetBackgroundWidget(NULL); | |
| 553 } | 567 } |
| 554 | 568 |
| 555 void Shell::SetupNonCompactWindowMode() { | 569 void Shell::SetupNonCompactWindowMode() { |
| 556 DCHECK(root_window_layout_); | 570 DCHECK(root_window_layout_); |
| 557 DCHECK(status_widget_); | 571 DCHECK(status_widget_); |
| 558 | 572 |
| 559 // Clean out the old layout managers before we start. | 573 // Clean out the old layout managers before we start. |
| 560 ResetLayoutManager(internal::kShellWindowId_DefaultContainer); | 574 ResetLayoutManager(internal::kShellWindowId_DefaultContainer); |
| 561 ResetLayoutManager(internal::kShellWindowId_LauncherContainer); | 575 ResetLayoutManager(internal::kShellWindowId_LauncherContainer); |
| 562 ResetLayoutManager(internal::kShellWindowId_StatusContainer); | 576 ResetLayoutManager(internal::kShellWindowId_StatusContainer); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 590 } | 604 } |
| 591 // Ensure launcher is visible. | 605 // Ensure launcher is visible. |
| 592 launcher_->widget()->Show(); | 606 launcher_->widget()->Show(); |
| 593 | 607 |
| 594 // Restore all maximized windows. Don't change full screen windows, as we | 608 // Restore all maximized windows. Don't change full screen windows, as we |
| 595 // don't want to disrupt a user trying to plug in an external monitor to | 609 // don't want to disrupt a user trying to plug in an external monitor to |
| 596 // give a presentation. | 610 // give a presentation. |
| 597 RestoreMaximizedWindows(default_container); | 611 RestoreMaximizedWindows(default_container); |
| 598 | 612 |
| 599 // Create the desktop background image. | 613 // Create the desktop background image. |
| 600 root_window_layout_->SetBackgroundWidget(internal::CreateDesktopBackground()); | 614 SetDesktopBackgroundMode(BACKGROUND_IMAGE); |
| 601 root_window_layout_->SetBackgroundLayer(NULL); | |
| 602 } | 615 } |
| 603 | 616 |
| 604 void Shell::ResetLayoutManager(int container_id) { | 617 void Shell::ResetLayoutManager(int container_id) { |
| 605 GetContainer(container_id)->SetLayoutManager(NULL); | 618 GetContainer(container_id)->SetLayoutManager(NULL); |
| 606 } | 619 } |
| 607 | 620 |
| 608 } // namespace ash | 621 } // namespace ash |
| OLD | NEW |