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