| 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/desktop_background/desktop_background_controller.h" | 5 #include "ash/desktop_background/desktop_background_controller.h" |
| 6 | 6 |
| 7 #include "ash/aura/wm_window_aura.h" | 7 #include "ash/aura/wm_window_aura.h" |
| 8 #include "ash/common/ash_switches.h" | 8 #include "ash/common/ash_switches.h" |
| 9 #include "ash/common/display/display_info.h" | 9 #include "ash/common/display/display_info.h" |
| 10 #include "ash/common/shell_window_ids.h" | 10 #include "ash/common/shell_window_ids.h" |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 | 94 |
| 95 if (WallpaperIsAlreadyLoaded(image, true /* compare_layouts */, layout)) { | 95 if (WallpaperIsAlreadyLoaded(image, true /* compare_layouts */, layout)) { |
| 96 VLOG(1) << "Wallpaper is already loaded"; | 96 VLOG(1) << "Wallpaper is already loaded"; |
| 97 return false; | 97 return false; |
| 98 } | 98 } |
| 99 | 99 |
| 100 current_wallpaper_.reset(new WallpaperResizer( | 100 current_wallpaper_.reset(new WallpaperResizer( |
| 101 image, GetMaxDisplaySizeInNative(), layout, blocking_pool_)); | 101 image, GetMaxDisplaySizeInNative(), layout, blocking_pool_)); |
| 102 current_wallpaper_->StartResize(); | 102 current_wallpaper_->StartResize(); |
| 103 | 103 |
| 104 FOR_EACH_OBSERVER(DesktopBackgroundControllerObserver, | 104 FOR_EACH_OBSERVER(DesktopBackgroundControllerObserver, observers_, |
| 105 observers_, | |
| 106 OnWallpaperDataChanged()); | 105 OnWallpaperDataChanged()); |
| 107 SetDesktopBackgroundImageMode(); | 106 SetDesktopBackgroundImageMode(); |
| 108 return true; | 107 return true; |
| 109 } | 108 } |
| 110 | 109 |
| 111 void DesktopBackgroundController::CreateEmptyWallpaper() { | 110 void DesktopBackgroundController::CreateEmptyWallpaper() { |
| 112 current_wallpaper_.reset(NULL); | 111 current_wallpaper_.reset(NULL); |
| 113 SetDesktopBackgroundImageMode(); | 112 SetDesktopBackgroundImageMode(); |
| 114 } | 113 } |
| 115 | 114 |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 case BACKGROUND_IMAGE: { | 218 case BACKGROUND_IMAGE: { |
| 220 views::Widget* widget = | 219 views::Widget* widget = |
| 221 CreateDesktopBackground(root_window, container_id); | 220 CreateDesktopBackground(root_window, container_id); |
| 222 component = new DesktopBackgroundWidgetController(widget); | 221 component = new DesktopBackgroundWidgetController(widget); |
| 223 break; | 222 break; |
| 224 } | 223 } |
| 225 case BACKGROUND_NONE: | 224 case BACKGROUND_NONE: |
| 226 NOTREACHED(); | 225 NOTREACHED(); |
| 227 return; | 226 return; |
| 228 } | 227 } |
| 229 GetRootWindowController(root_window)->SetAnimatingWallpaperController( | 228 GetRootWindowController(root_window) |
| 230 new AnimatingDesktopController(component)); | 229 ->SetAnimatingWallpaperController( |
| 230 new AnimatingDesktopController(component)); |
| 231 | 231 |
| 232 component->StartAnimating(GetRootWindowController(root_window)); | 232 component->StartAnimating(GetRootWindowController(root_window)); |
| 233 } | 233 } |
| 234 | 234 |
| 235 void DesktopBackgroundController::InstallDesktopControllerForAllWindows() { | 235 void DesktopBackgroundController::InstallDesktopControllerForAllWindows() { |
| 236 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 236 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| 237 for (aura::Window::Windows::iterator iter = root_windows.begin(); | 237 for (aura::Window::Windows::iterator iter = root_windows.begin(); |
| 238 iter != root_windows.end(); ++iter) { | 238 iter != root_windows.end(); ++iter) { |
| 239 InstallDesktopController(*iter); | 239 InstallDesktopController(*iter); |
| 240 } | 240 } |
| 241 current_max_display_size_ = GetMaxDisplaySizeInNative(); | 241 current_max_display_size_ = GetMaxDisplaySizeInNative(); |
| 242 } | 242 } |
| 243 | 243 |
| 244 bool DesktopBackgroundController::ReparentBackgroundWidgets(int src_container, | 244 bool DesktopBackgroundController::ReparentBackgroundWidgets(int src_container, |
| 245 int dst_container) { | 245 int dst_container) { |
| 246 bool moved = false; | 246 bool moved = false; |
| 247 Shell::RootWindowControllerList controllers = | 247 Shell::RootWindowControllerList controllers = |
| 248 Shell::GetAllRootWindowControllers(); | 248 Shell::GetAllRootWindowControllers(); |
| 249 for (Shell::RootWindowControllerList::iterator iter = controllers.begin(); | 249 for (Shell::RootWindowControllerList::iterator iter = controllers.begin(); |
| 250 iter != controllers.end(); ++iter) { | 250 iter != controllers.end(); ++iter) { |
| 251 RootWindowController* root_window_controller = *iter; | 251 RootWindowController* root_window_controller = *iter; |
| 252 // In the steady state (no animation playing) the background widget | 252 // In the steady state (no animation playing) the background widget |
| 253 // controller exists in the RootWindowController. | 253 // controller exists in the RootWindowController. |
| 254 DesktopBackgroundWidgetController* desktop_controller = | 254 DesktopBackgroundWidgetController* desktop_controller = |
| 255 root_window_controller->wallpaper_controller(); | 255 root_window_controller->wallpaper_controller(); |
| 256 if (desktop_controller) { | 256 if (desktop_controller) { |
| 257 moved |= | 257 moved |= |
| 258 desktop_controller->Reparent(root_window_controller->GetRootWindow(), | 258 desktop_controller->Reparent(root_window_controller->GetRootWindow(), |
| 259 src_container, | 259 src_container, dst_container); |
| 260 dst_container); | |
| 261 } | 260 } |
| 262 // During desktop show animations the controller lives in | 261 // During desktop show animations the controller lives in |
| 263 // AnimatingDesktopController owned by RootWindowController. | 262 // AnimatingDesktopController owned by RootWindowController. |
| 264 // NOTE: If a wallpaper load happens during a desktop show animation there | 263 // NOTE: If a wallpaper load happens during a desktop show animation there |
| 265 // can temporarily be two desktop background widgets. We must reparent | 264 // can temporarily be two desktop background widgets. We must reparent |
| 266 // both of them - one above and one here. | 265 // both of them - one above and one here. |
| 267 DesktopBackgroundWidgetController* animating_controller = | 266 DesktopBackgroundWidgetController* animating_controller = |
| 268 root_window_controller->animating_wallpaper_controller() ? | 267 root_window_controller->animating_wallpaper_controller() |
| 269 root_window_controller->animating_wallpaper_controller()-> | 268 ? root_window_controller->animating_wallpaper_controller() |
| 270 GetController(false) : | 269 ->GetController(false) |
| 271 NULL; | 270 : NULL; |
| 272 if (animating_controller) { | 271 if (animating_controller) { |
| 273 moved |= animating_controller->Reparent( | 272 moved |= animating_controller->Reparent( |
| 274 root_window_controller->GetRootWindow(), | 273 root_window_controller->GetRootWindow(), src_container, |
| 275 src_container, | |
| 276 dst_container); | 274 dst_container); |
| 277 } | 275 } |
| 278 } | 276 } |
| 279 return moved; | 277 return moved; |
| 280 } | 278 } |
| 281 | 279 |
| 282 int DesktopBackgroundController::GetBackgroundContainerId(bool locked) { | 280 int DesktopBackgroundController::GetBackgroundContainerId(bool locked) { |
| 283 return locked ? kShellWindowId_LockScreenBackgroundContainer | 281 return locked ? kShellWindowId_LockScreenBackgroundContainer |
| 284 : kShellWindowId_DesktopBackgroundContainer; | 282 : kShellWindowId_DesktopBackgroundContainer; |
| 285 } | 283 } |
| 286 | 284 |
| 287 void DesktopBackgroundController::UpdateWallpaper(bool clear_cache) { | 285 void DesktopBackgroundController::UpdateWallpaper(bool clear_cache) { |
| 288 current_wallpaper_.reset(NULL); | 286 current_wallpaper_.reset(NULL); |
| 289 ash::Shell::GetInstance()->user_wallpaper_delegate()->UpdateWallpaper( | 287 ash::Shell::GetInstance()->user_wallpaper_delegate()->UpdateWallpaper( |
| 290 clear_cache); | 288 clear_cache); |
| 291 } | 289 } |
| 292 | 290 |
| 293 } // namespace ash | 291 } // namespace ash |
| OLD | NEW |