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/root_window_controller.h" | 5 #include "ash/root_window_controller.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
| 9 #include "ash/ash_switches.h" |
9 #include "ash/desktop_background/desktop_background_widget_controller.h" | 10 #include "ash/desktop_background/desktop_background_widget_controller.h" |
10 #include "ash/display/display_controller.h" | 11 #include "ash/display/display_controller.h" |
11 #include "ash/display/multi_display_manager.h" | 12 #include "ash/display/multi_display_manager.h" |
12 #include "ash/focus_cycler.h" | 13 #include "ash/focus_cycler.h" |
13 #include "ash/shell.h" | 14 #include "ash/shell.h" |
14 #include "ash/shell_delegate.h" | 15 #include "ash/shell_delegate.h" |
15 #include "ash/shell_factory.h" | 16 #include "ash/shell_factory.h" |
16 #include "ash/shell_window_ids.h" | 17 #include "ash/shell_window_ids.h" |
17 #include "ash/system/status_area_widget.h" | 18 #include "ash/system/status_area_widget.h" |
18 #include "ash/system/tray/system_tray_delegate.h" | 19 #include "ash/system/tray/system_tray_delegate.h" |
19 #include "ash/wm/base_layout_manager.h" | 20 #include "ash/wm/base_layout_manager.h" |
20 #include "ash/wm/panel_layout_manager.h" | 21 #include "ash/wm/panel_layout_manager.h" |
21 #include "ash/wm/panel_window_event_filter.h" | 22 #include "ash/wm/panel_window_event_filter.h" |
22 #include "ash/wm/property_util.h" | 23 #include "ash/wm/property_util.h" |
23 #include "ash/wm/root_window_layout_manager.h" | 24 #include "ash/wm/root_window_layout_manager.h" |
24 #include "ash/wm/screen_dimmer.h" | 25 #include "ash/wm/screen_dimmer.h" |
25 #include "ash/wm/shelf_layout_manager.h" | 26 #include "ash/wm/shelf_layout_manager.h" |
26 #include "ash/wm/shelf_types.h" | 27 #include "ash/wm/shelf_types.h" |
27 #include "ash/wm/status_area_layout_manager.h" | 28 #include "ash/wm/status_area_layout_manager.h" |
| 29 #include "ash/wm/system_background_controller.h" |
28 #include "ash/wm/system_modal_container_layout_manager.h" | 30 #include "ash/wm/system_modal_container_layout_manager.h" |
29 #include "ash/wm/toplevel_window_event_handler.h" | 31 #include "ash/wm/toplevel_window_event_handler.h" |
30 #include "ash/wm/visibility_controller.h" | 32 #include "ash/wm/visibility_controller.h" |
31 #include "ash/wm/window_properties.h" | 33 #include "ash/wm/window_properties.h" |
32 #include "ash/wm/workspace/colored_window_controller.h" | |
33 #include "ash/wm/workspace_controller.h" | 34 #include "ash/wm/workspace_controller.h" |
| 35 #include "base/command_line.h" |
34 #include "ui/aura/client/activation_client.h" | 36 #include "ui/aura/client/activation_client.h" |
35 #include "ui/aura/client/aura_constants.h" | 37 #include "ui/aura/client/aura_constants.h" |
36 #include "ui/aura/client/capture_client.h" | 38 #include "ui/aura/client/capture_client.h" |
37 #include "ui/aura/client/tooltip_client.h" | 39 #include "ui/aura/client/tooltip_client.h" |
38 #include "ui/aura/focus_manager.h" | 40 #include "ui/aura/focus_manager.h" |
39 #include "ui/aura/root_window.h" | 41 #include "ui/aura/root_window.h" |
40 #include "ui/aura/window.h" | 42 #include "ui/aura/window.h" |
41 #include "ui/aura/window_observer.h" | 43 #include "ui/aura/window_observer.h" |
42 #include "ui/aura/window_tracker.h" | 44 #include "ui/aura/window_tracker.h" |
43 #include "ui/base/models/menu_model.h" | 45 #include "ui/base/models/menu_model.h" |
44 #include "ui/gfx/display.h" | 46 #include "ui/gfx/display.h" |
45 #include "ui/gfx/screen.h" | 47 #include "ui/gfx/screen.h" |
46 #include "ui/views/controls/menu/menu_model_adapter.h" | 48 #include "ui/views/controls/menu/menu_model_adapter.h" |
47 #include "ui/views/controls/menu/menu_runner.h" | 49 #include "ui/views/controls/menu/menu_runner.h" |
48 #include "ui/views/view_model.h" | 50 #include "ui/views/view_model.h" |
49 #include "ui/views/view_model_utils.h" | 51 #include "ui/views/view_model_utils.h" |
50 | 52 |
51 namespace ash { | 53 namespace ash { |
52 namespace { | 54 namespace { |
53 | 55 |
54 #if defined(OS_CHROMEOS) | |
55 // Color initially used for the system background after the system has first | |
56 // booted. | |
57 const SkColor kBootSystemBackgroundColor = 0xFFFEFEFE; | |
58 #endif | |
59 | |
60 // Creates a new window for use as a container. | 56 // Creates a new window for use as a container. |
61 aura::Window* CreateContainer(int window_id, | 57 aura::Window* CreateContainer(int window_id, |
62 const char* name, | 58 const char* name, |
63 aura::Window* parent) { | 59 aura::Window* parent) { |
64 aura::Window* container = new aura::Window(NULL); | 60 aura::Window* container = new aura::Window(NULL); |
65 container->set_id(window_id); | 61 container->set_id(window_id); |
66 container->SetName(name); | 62 container->SetName(name); |
67 container->Init(ui::LAYER_NOT_DRAWN); | 63 container->Init(ui::LAYER_NOT_DRAWN); |
68 parent->AddChild(container); | 64 parent->AddChild(container); |
69 if (window_id != internal::kShellWindowId_UnparentedControlContainer) | 65 if (window_id != internal::kShellWindowId_UnparentedControlContainer) |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 if (!delegate || delegate->IsUserLoggedIn()) | 282 if (!delegate || delegate->IsUserLoggedIn()) |
287 CreateLauncher(); | 283 CreateLauncher(); |
288 } | 284 } |
289 | 285 |
290 void RootWindowController::CreateContainers() { | 286 void RootWindowController::CreateContainers() { |
291 CreateContainersInRootWindow(root_window_.get()); | 287 CreateContainersInRootWindow(root_window_.get()); |
292 } | 288 } |
293 | 289 |
294 void RootWindowController::CreateSystemBackground( | 290 void RootWindowController::CreateSystemBackground( |
295 bool is_first_run_after_boot) { | 291 bool is_first_run_after_boot) { |
296 SkColor color = SK_ColorBLACK; | 292 SystemBackgroundController::Content initial_content = |
| 293 SystemBackgroundController::CONTENT_BLACK; |
297 #if defined(OS_CHROMEOS) | 294 #if defined(OS_CHROMEOS) |
298 if (is_first_run_after_boot) | 295 if (is_first_run_after_boot) { |
299 color = kBootSystemBackgroundColor; | 296 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 297 switches::kAshCopyHostBackgroundAtBoot)) { |
| 298 initial_content = SystemBackgroundController::CONTENT_COPY_FROM_HOST; |
| 299 } else { |
| 300 initial_content = |
| 301 SystemBackgroundController::CONTENT_CHROME_OS_BOOT_COLOR; |
| 302 } |
| 303 } |
300 #endif | 304 #endif |
301 background_.reset(new ColoredWindowController( | 305 system_background_.reset( |
302 root_window_->GetChildById(kShellWindowId_SystemBackgroundContainer), | 306 new SystemBackgroundController(root_window_.get(), initial_content)); |
303 "SystemBackground")); | |
304 background_->SetColor(color); | |
305 background_->GetWidget()->Show(); | |
306 } | 307 } |
307 | 308 |
308 void RootWindowController::CreateLauncher() { | 309 void RootWindowController::CreateLauncher() { |
309 if (launcher_.get()) | 310 if (launcher_.get()) |
310 return; | 311 return; |
311 | 312 |
312 aura::Window* default_container = | 313 aura::Window* default_container = |
313 GetContainer(internal::kShellWindowId_DefaultContainer); | 314 GetContainer(internal::kShellWindowId_DefaultContainer); |
314 launcher_.reset(new Launcher(default_container, shelf_)); | 315 launcher_.reset(new Launcher(default_container, shelf_)); |
315 | 316 |
(...skipping 22 matching lines...) Expand all Loading... |
338 shelf_->UpdateVisibilityState(); | 339 shelf_->UpdateVisibilityState(); |
339 } | 340 } |
340 | 341 |
341 void RootWindowController::UpdateAfterLoginStatusChange( | 342 void RootWindowController::UpdateAfterLoginStatusChange( |
342 user::LoginStatus status) { | 343 user::LoginStatus status) { |
343 if (status_area_widget_) | 344 if (status_area_widget_) |
344 status_area_widget_->UpdateAfterLoginStatusChange(status); | 345 status_area_widget_->UpdateAfterLoginStatusChange(status); |
345 } | 346 } |
346 | 347 |
347 void RootWindowController::HandleDesktopBackgroundVisible() { | 348 void RootWindowController::HandleDesktopBackgroundVisible() { |
348 if (background_.get()) | 349 system_background_->SetContent(SystemBackgroundController::CONTENT_BLACK); |
349 background_->SetColor(SK_ColorBLACK); | |
350 } | 350 } |
351 | 351 |
352 void RootWindowController::CloseChildWindows() { | 352 void RootWindowController::CloseChildWindows() { |
353 // The status area needs to be shut down before the windows are destroyed. | 353 // The status area needs to be shut down before the windows are destroyed. |
354 if (status_area_widget_) { | 354 if (status_area_widget_) { |
355 status_area_widget_->Shutdown(); | 355 status_area_widget_->Shutdown(); |
356 status_area_widget_ = NULL; | 356 status_area_widget_ = NULL; |
357 } | 357 } |
358 | 358 |
359 // Closing the windows frees the workspace controller. | 359 // Closing the windows frees the workspace controller. |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
465 | 465 |
466 //////////////////////////////////////////////////////////////////////////////// | 466 //////////////////////////////////////////////////////////////////////////////// |
467 // RootWindowController, private: | 467 // RootWindowController, private: |
468 | 468 |
469 void RootWindowController::CreateContainersInRootWindow( | 469 void RootWindowController::CreateContainersInRootWindow( |
470 aura::RootWindow* root_window) { | 470 aura::RootWindow* root_window) { |
471 // These containers are just used by PowerButtonController to animate groups | 471 // These containers are just used by PowerButtonController to animate groups |
472 // of containers simultaneously without messing up the current transformations | 472 // of containers simultaneously without messing up the current transformations |
473 // on those containers. These are direct children of the root window; all of | 473 // on those containers. These are direct children of the root window; all of |
474 // the other containers are their children. | 474 // the other containers are their children. |
475 // Desktop and lock screen background containers are not part of the | 475 |
476 // lock animation so they are not included in those animate groups. | 476 // The desktop background container is not part of the lock animation, so it |
| 477 // is not included in those animate groups. |
477 // When screen is locked desktop background is moved to lock screen background | 478 // When screen is locked desktop background is moved to lock screen background |
478 // container (moved back on unlock). We want to make sure that there's an | 479 // container (moved back on unlock). We want to make sure that there's an |
479 // opaque layer occluding the non-lock-screen layers. | 480 // opaque layer occluding the non-lock-screen layers. |
480 | 481 aura::Window* desktop_background_container = CreateContainer( |
481 CreateContainer(kShellWindowId_SystemBackgroundContainer, | |
482 "SystemBackgroundContainer", root_window); | |
483 | |
484 aura::Window* desktop_background_containers = CreateContainer( | |
485 kShellWindowId_DesktopBackgroundContainer, | 482 kShellWindowId_DesktopBackgroundContainer, |
486 "DesktopBackgroundContainer", | 483 "DesktopBackgroundContainer", |
487 root_window); | 484 root_window); |
488 SetChildWindowVisibilityChangesAnimated(desktop_background_containers); | 485 SetChildWindowVisibilityChangesAnimated(desktop_background_container); |
489 | 486 |
490 aura::Window* non_lock_screen_containers = CreateContainer( | 487 aura::Window* non_lock_screen_containers = CreateContainer( |
491 kShellWindowId_NonLockScreenContainersContainer, | 488 kShellWindowId_NonLockScreenContainersContainer, |
492 "NonLockScreenContainersContainer", | 489 "NonLockScreenContainersContainer", |
493 root_window); | 490 root_window); |
494 | 491 |
495 aura::Window* lock_background_containers = CreateContainer( | 492 aura::Window* lock_background_containers = CreateContainer( |
496 kShellWindowId_LockScreenBackgroundContainer, | 493 kShellWindowId_LockScreenBackgroundContainer, |
497 "LockScreenBackgroundContainer", | 494 "LockScreenBackgroundContainer", |
498 root_window); | 495 root_window); |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
616 "OverlayContainer", | 613 "OverlayContainer", |
617 lock_screen_related_containers); | 614 lock_screen_related_containers); |
618 SetUsesScreenCoordinates(overlay_container); | 615 SetUsesScreenCoordinates(overlay_container); |
619 | 616 |
620 CreateContainer(kShellWindowId_PowerButtonAnimationContainer, | 617 CreateContainer(kShellWindowId_PowerButtonAnimationContainer, |
621 "PowerButtonAnimationContainer", root_window) ; | 618 "PowerButtonAnimationContainer", root_window) ; |
622 } | 619 } |
623 | 620 |
624 } // namespace internal | 621 } // namespace internal |
625 } // namespace ash | 622 } // namespace ash |
OLD | NEW |