| 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/desktop_background/desktop_background_view.h" | 7 #include "ash/desktop_background/desktop_background_view.h" |
| 8 #include "ash/desktop_background/desktop_background_widget_controller.h" | 8 #include "ash/desktop_background/desktop_background_widget_controller.h" |
| 9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 10 #include "ash/shell_factory.h" | 10 #include "ash/shell_factory.h" |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 for (Shell::RootWindowList::iterator iter = root_windows.begin(); | 230 for (Shell::RootWindowList::iterator iter = root_windows.begin(); |
| 231 iter != root_windows.end(); ++iter) { | 231 iter != root_windows.end(); ++iter) { |
| 232 gfx::Size root_window_size = (*iter)->GetHostSize(); | 232 gfx::Size root_window_size = (*iter)->GetHostSize(); |
| 233 if (root_window_size.width() > kSmallWallpaperMaxWidth || | 233 if (root_window_size.width() > kSmallWallpaperMaxWidth || |
| 234 root_window_size.height() > kSmallWallpaperMaxHeight) | 234 root_window_size.height() > kSmallWallpaperMaxHeight) |
| 235 resolution = LARGE; | 235 resolution = LARGE; |
| 236 } | 236 } |
| 237 return resolution; | 237 return resolution; |
| 238 } | 238 } |
| 239 | 239 |
| 240 void DesktopBackgroundController::MoveDesktopToLockedContainer() { | 240 bool DesktopBackgroundController::MoveDesktopToLockedContainer() { |
| 241 if (locked_) | 241 if (locked_) |
| 242 return; | 242 return false; |
| 243 locked_ = true; | 243 locked_ = true; |
| 244 ReparentBackgroundWidgets(GetBackgroundContainerId(false), | 244 return ReparentBackgroundWidgets(GetBackgroundContainerId(false), |
| 245 GetBackgroundContainerId(true)); | 245 GetBackgroundContainerId(true)); |
| 246 } | 246 } |
| 247 | 247 |
| 248 void DesktopBackgroundController::MoveDesktopToUnlockedContainer() { | 248 bool DesktopBackgroundController::MoveDesktopToUnlockedContainer() { |
| 249 if (!locked_) | 249 if (!locked_) |
| 250 return; | 250 return false; |
| 251 locked_ = false; | 251 locked_ = false; |
| 252 ReparentBackgroundWidgets(GetBackgroundContainerId(true), | 252 return ReparentBackgroundWidgets(GetBackgroundContainerId(true), |
| 253 GetBackgroundContainerId(false)); | 253 GetBackgroundContainerId(false)); |
| 254 } | 254 } |
| 255 | 255 |
| 256 void DesktopBackgroundController::OnWindowDestroying(aura::Window* window) { | 256 void DesktopBackgroundController::OnWindowDestroying(aura::Window* window) { |
| 257 window->SetProperty(internal::kWindowDesktopComponent, | 257 window->SetProperty(internal::kWindowDesktopComponent, |
| 258 static_cast<internal::DesktopBackgroundWidgetController*>(NULL)); | 258 static_cast<internal::DesktopBackgroundWidgetController*>(NULL)); |
| 259 window->SetProperty(internal::kComponentWrapper, | 259 window->SetProperty(internal::kComponentWrapper, |
| 260 static_cast<internal::ComponentWrapper*>(NULL)); | 260 static_cast<internal::ComponentWrapper*>(NULL)); |
| 261 } | 261 } |
| 262 | 262 |
| 263 void DesktopBackgroundController::SetDesktopBackgroundImageMode() { | 263 void DesktopBackgroundController::SetDesktopBackgroundImageMode() { |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 } | 329 } |
| 330 | 330 |
| 331 void DesktopBackgroundController::InstallComponentForAllWindows() { | 331 void DesktopBackgroundController::InstallComponentForAllWindows() { |
| 332 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | 332 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
| 333 for (Shell::RootWindowList::iterator iter = root_windows.begin(); | 333 for (Shell::RootWindowList::iterator iter = root_windows.begin(); |
| 334 iter != root_windows.end(); ++iter) { | 334 iter != root_windows.end(); ++iter) { |
| 335 InstallComponent(*iter); | 335 InstallComponent(*iter); |
| 336 } | 336 } |
| 337 } | 337 } |
| 338 | 338 |
| 339 void DesktopBackgroundController::ReparentBackgroundWidgets(int src_container, | 339 bool DesktopBackgroundController::ReparentBackgroundWidgets(int src_container, |
| 340 int dst_container) { | 340 int dst_container) { |
| 341 bool moved = false; |
| 341 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | 342 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
| 342 for (Shell::RootWindowList::iterator iter = root_windows.begin(); | 343 for (Shell::RootWindowList::iterator iter = root_windows.begin(); |
| 343 iter != root_windows.end(); ++iter) { | 344 iter != root_windows.end(); ++iter) { |
| 344 aura::RootWindow* root_window = *iter; | 345 aura::RootWindow* root_window = *iter; |
| 345 if (root_window->GetProperty(internal::kComponentWrapper)) { | 346 if (root_window->GetProperty(internal::kComponentWrapper)) { |
| 346 internal::DesktopBackgroundWidgetController* component = root_window-> | 347 internal::DesktopBackgroundWidgetController* component = root_window-> |
| 347 GetProperty(internal::kWindowDesktopComponent); | 348 GetProperty(internal::kWindowDesktopComponent); |
| 348 // Wallpaper animation may not finish at this point. Try to get component | 349 // Wallpaper animation may not finish at this point. Try to get component |
| 349 // from kComponentWrapper instead. | 350 // from kComponentWrapper instead. |
| 350 if (!component) { | 351 if (!component) { |
| 351 component = root_window->GetProperty(internal::kComponentWrapper)-> | 352 component = root_window->GetProperty(internal::kComponentWrapper)-> |
| 352 GetComponent(false); | 353 GetComponent(false); |
| 353 } | 354 } |
| 354 DCHECK(component); | 355 DCHECK(component); |
| 355 component->Reparent(root_window, | 356 moved = moved || component->Reparent(root_window, |
| 356 src_container, | 357 src_container, |
| 357 dst_container); | 358 dst_container); |
| 358 } | 359 } |
| 359 } | 360 } |
| 361 return moved; |
| 360 } | 362 } |
| 361 | 363 |
| 362 int DesktopBackgroundController::GetBackgroundContainerId(bool locked) { | 364 int DesktopBackgroundController::GetBackgroundContainerId(bool locked) { |
| 363 return locked ? internal::kShellWindowId_LockScreenBackgroundContainer : | 365 return locked ? internal::kShellWindowId_LockScreenBackgroundContainer : |
| 364 internal::kShellWindowId_DesktopBackgroundContainer; | 366 internal::kShellWindowId_DesktopBackgroundContainer; |
| 365 } | 367 } |
| 366 | 368 |
| 367 } // namespace ash | 369 } // namespace ash |
| OLD | NEW |