| 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/wallpaper/wallpaper_controller.h" | 5 #include "ash/wallpaper/wallpaper_controller.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "ash/ash_switches.h" | 10 #include "ash/ash_switches.h" |
| 11 #include "ash/display/window_tree_host_manager.h" | 11 #include "ash/display/window_tree_host_manager.h" |
| 12 #include "ash/public/cpp/shell_window_ids.h" | 12 #include "ash/public/cpp/shell_window_ids.h" |
| 13 #include "ash/root_window_controller.h" | 13 #include "ash/root_window_controller.h" |
| 14 #include "ash/session/session_controller.h" | 14 #include "ash/session/session_controller.h" |
| 15 #include "ash/shell.h" | 15 #include "ash/shell.h" |
| 16 #include "ash/shell_port.h" | 16 #include "ash/shell_port.h" |
| 17 #include "ash/wallpaper/wallpaper_controller_observer.h" | 17 #include "ash/wallpaper/wallpaper_controller_observer.h" |
| 18 #include "ash/wallpaper/wallpaper_delegate.h" | 18 #include "ash/wallpaper/wallpaper_delegate.h" |
| 19 #include "ash/wallpaper/wallpaper_view.h" | 19 #include "ash/wallpaper/wallpaper_view.h" |
| 20 #include "ash/wallpaper/wallpaper_widget_controller.h" | 20 #include "ash/wallpaper/wallpaper_widget_controller.h" |
| 21 #include "ash/wm_window.h" | |
| 22 #include "base/bind.h" | 21 #include "base/bind.h" |
| 23 #include "base/command_line.h" | 22 #include "base/command_line.h" |
| 24 #include "base/logging.h" | 23 #include "base/logging.h" |
| 25 #include "base/task_runner.h" | 24 #include "base/task_runner.h" |
| 26 #include "components/wallpaper/wallpaper_color_calculator.h" | 25 #include "components/wallpaper/wallpaper_color_calculator.h" |
| 27 #include "components/wallpaper/wallpaper_resizer.h" | 26 #include "components/wallpaper/wallpaper_resizer.h" |
| 28 #include "ui/display/manager/managed_display_info.h" | 27 #include "ui/display/manager/managed_display_info.h" |
| 29 #include "ui/display/screen.h" | 28 #include "ui/display/screen.h" |
| 30 #include "ui/gfx/color_analysis.h" | 29 #include "ui/gfx/color_analysis.h" |
| 31 #include "ui/views/widget/widget.h" | 30 #include "ui/views/widget/widget.h" |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 timer_.Stop(); | 179 timer_.Stop(); |
| 181 GetInternalDisplayCompositorLock(); | 180 GetInternalDisplayCompositorLock(); |
| 182 timer_.Start(FROM_HERE, | 181 timer_.Start(FROM_HERE, |
| 183 base::TimeDelta::FromMilliseconds(wallpaper_reload_delay_), | 182 base::TimeDelta::FromMilliseconds(wallpaper_reload_delay_), |
| 184 base::Bind(&WallpaperController::UpdateWallpaper, | 183 base::Bind(&WallpaperController::UpdateWallpaper, |
| 185 base::Unretained(this), false /* clear cache */)); | 184 base::Unretained(this), false /* clear cache */)); |
| 186 } | 185 } |
| 187 } | 186 } |
| 188 } | 187 } |
| 189 | 188 |
| 190 void WallpaperController::OnRootWindowAdded(WmWindow* root_window) { | 189 void WallpaperController::OnRootWindowAdded(aura::Window* root_window) { |
| 191 // The wallpaper hasn't been set yet. | 190 // The wallpaper hasn't been set yet. |
| 192 if (wallpaper_mode_ == WALLPAPER_NONE) | 191 if (wallpaper_mode_ == WALLPAPER_NONE) |
| 193 return; | 192 return; |
| 194 | 193 |
| 195 // Handle resolution change for "built-in" images. | 194 // Handle resolution change for "built-in" images. |
| 196 gfx::Size max_display_size = GetMaxDisplaySizeInNative(); | 195 gfx::Size max_display_size = GetMaxDisplaySizeInNative(); |
| 197 if (current_max_display_size_ != max_display_size) { | 196 if (current_max_display_size_ != max_display_size) { |
| 198 current_max_display_size_ = max_display_size; | 197 current_max_display_size_ = max_display_size; |
| 199 if (wallpaper_mode_ == WALLPAPER_IMAGE && current_wallpaper_) | 198 if (wallpaper_mode_ == WALLPAPER_IMAGE && current_wallpaper_) |
| 200 UpdateWallpaper(true /* clear cache */); | 199 UpdateWallpaper(true /* clear cache */); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 CalculateWallpaperColors(); | 283 CalculateWallpaperColors(); |
| 285 compositor_lock_.reset(); | 284 compositor_lock_.reset(); |
| 286 } | 285 } |
| 287 | 286 |
| 288 void WallpaperController::OnColorCalculationComplete() { | 287 void WallpaperController::OnColorCalculationComplete() { |
| 289 const SkColor color = color_calculator_->prominent_color(); | 288 const SkColor color = color_calculator_->prominent_color(); |
| 290 color_calculator_.reset(); | 289 color_calculator_.reset(); |
| 291 SetProminentColor(color); | 290 SetProminentColor(color); |
| 292 } | 291 } |
| 293 | 292 |
| 294 void WallpaperController::InstallDesktopController(WmWindow* root_window) { | 293 void WallpaperController::InstallDesktopController(aura::Window* root_window) { |
| 295 WallpaperWidgetController* component = nullptr; | 294 WallpaperWidgetController* component = nullptr; |
| 296 int container_id = GetWallpaperContainerId(locked_); | 295 int container_id = GetWallpaperContainerId(locked_); |
| 297 | 296 |
| 298 switch (wallpaper_mode_) { | 297 switch (wallpaper_mode_) { |
| 299 case WALLPAPER_IMAGE: { | 298 case WALLPAPER_IMAGE: { |
| 300 component = new WallpaperWidgetController( | 299 component = new WallpaperWidgetController( |
| 301 CreateWallpaper(root_window, container_id)); | 300 CreateWallpaper(root_window, container_id)); |
| 302 break; | 301 break; |
| 303 } | 302 } |
| 304 case WALLPAPER_NONE: | 303 case WALLPAPER_NONE: |
| 305 NOTREACHED(); | 304 NOTREACHED(); |
| 306 return; | 305 return; |
| 307 } | 306 } |
| 308 | 307 |
| 309 RootWindowController* controller = root_window->GetRootWindowController(); | 308 RootWindowController* controller = |
| 309 RootWindowController::ForWindow(root_window); |
| 310 controller->SetAnimatingWallpaperWidgetController( | 310 controller->SetAnimatingWallpaperWidgetController( |
| 311 new AnimatingWallpaperWidgetController(component)); | 311 new AnimatingWallpaperWidgetController(component)); |
| 312 component->StartAnimating(controller); | 312 component->StartAnimating(controller); |
| 313 } | 313 } |
| 314 | 314 |
| 315 void WallpaperController::InstallDesktopControllerForAllWindows() { | 315 void WallpaperController::InstallDesktopControllerForAllWindows() { |
| 316 for (WmWindow* root : ShellPort::Get()->GetAllRootWindows()) | 316 for (aura::Window* root : Shell::GetAllRootWindows()) |
| 317 InstallDesktopController(root); | 317 InstallDesktopController(root); |
| 318 current_max_display_size_ = GetMaxDisplaySizeInNative(); | 318 current_max_display_size_ = GetMaxDisplaySizeInNative(); |
| 319 } | 319 } |
| 320 | 320 |
| 321 bool WallpaperController::ReparentWallpaper(int container) { | 321 bool WallpaperController::ReparentWallpaper(int container) { |
| 322 bool moved = false; | 322 bool moved = false; |
| 323 for (WmWindow* root_window : ShellPort::Get()->GetAllRootWindows()) { | 323 for (auto* root_window_controller : Shell::GetAllRootWindowControllers()) { |
| 324 RootWindowController* root_window_controller = | |
| 325 root_window->GetRootWindowController(); | |
| 326 // In the steady state (no animation playing) the wallpaper widget | 324 // In the steady state (no animation playing) the wallpaper widget |
| 327 // controller exists in the RootWindowController. | 325 // controller exists in the RootWindowController. |
| 328 WallpaperWidgetController* wallpaper_widget_controller = | 326 WallpaperWidgetController* wallpaper_widget_controller = |
| 329 root_window_controller->wallpaper_widget_controller(); | 327 root_window_controller->wallpaper_widget_controller(); |
| 330 if (wallpaper_widget_controller) { | 328 if (wallpaper_widget_controller) { |
| 331 moved |= wallpaper_widget_controller->Reparent( | 329 moved |= wallpaper_widget_controller->Reparent( |
| 332 root_window_controller->GetWindow(), container); | 330 root_window_controller->GetWindow(), container); |
| 333 } | 331 } |
| 334 // During wallpaper show animations the controller lives in | 332 // During wallpaper show animations the controller lives in |
| 335 // AnimatingWallpaperWidgetController owned by RootWindowController. | 333 // AnimatingWallpaperWidgetController owned by RootWindowController. |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 426 base::TimeDelta::FromMilliseconds(kCompositorLockTimeoutMs)); | 424 base::TimeDelta::FromMilliseconds(kCompositorLockTimeoutMs)); |
| 427 } | 425 } |
| 428 } | 426 } |
| 429 } | 427 } |
| 430 | 428 |
| 431 void WallpaperController::CompositorLockTimedOut() { | 429 void WallpaperController::CompositorLockTimedOut() { |
| 432 compositor_lock_.reset(); | 430 compositor_lock_.reset(); |
| 433 } | 431 } |
| 434 | 432 |
| 435 } // namespace ash | 433 } // namespace ash |
| OLD | NEW |