| 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_view.h" | 5 #include "ash/desktop_background/desktop_background_view.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "ash/ash_export.h" | 9 #include "ash/ash_export.h" |
| 10 #include "ash/desktop_background/desktop_background_controller.h" | 10 #include "ash/desktop_background/desktop_background_controller.h" |
| 11 #include "ash/desktop_background/desktop_background_widget_controller.h" |
| 11 #include "ash/shell.h" | 12 #include "ash/shell.h" |
| 12 #include "ash/shell_window_ids.h" | 13 #include "ash/shell_window_ids.h" |
| 13 #include "ash/wm/window_animations.h" | 14 #include "ash/wm/window_animations.h" |
| 14 #include "base/message_loop.h" | 15 #include "base/message_loop.h" |
| 15 #include "base/utf_string_conversions.h" | 16 #include "base/utf_string_conversions.h" |
| 16 #include "grit/ui_resources.h" | 17 #include "grit/ui_resources.h" |
| 17 #include "ui/aura/root_window.h" | 18 #include "ui/aura/root_window.h" |
| 18 #include "ui/base/resource/resource_bundle.h" | 19 #include "ui/base/resource/resource_bundle.h" |
| 19 #include "ui/compositor/layer.h" | 20 #include "ui/compositor/layer.h" |
| 20 #include "ui/compositor/layer_animation_observer.h" | 21 #include "ui/compositor/layer_animation_observer.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 36 container_id_(container_id), | 37 container_id_(container_id), |
| 37 desktop_widget_(desktop_widget) { | 38 desktop_widget_(desktop_widget) { |
| 38 } | 39 } |
| 39 | 40 |
| 40 virtual ~ShowWallpaperAnimationObserver() { | 41 virtual ~ShowWallpaperAnimationObserver() { |
| 41 } | 42 } |
| 42 | 43 |
| 43 private: | 44 private: |
| 44 // Overridden from ui::ImplicitAnimationObserver: | 45 // Overridden from ui::ImplicitAnimationObserver: |
| 45 virtual void OnImplicitAnimationsCompleted() OVERRIDE { | 46 virtual void OnImplicitAnimationsCompleted() OVERRIDE { |
| 46 ash::Shell::GetInstance()-> | 47 ash::Shell* shell = ash::Shell::GetInstance(); |
| 47 user_wallpaper_delegate()->OnWallpaperAnimationFinished(); | 48 shell->user_wallpaper_delegate()->OnWallpaperAnimationFinished(); |
| 49 // Only removes old component when wallpaper animation finished. If we |
| 50 // remove the old one too early, there will be a white flash during |
| 51 // animation. |
| 52 internal::DesktopBackgroundWidgetController* component = |
| 53 root_window_->GetProperty(kComponentWrapper)->component(); |
| 54 root_window_->SetProperty(kWindowDesktopComponent, component); |
| 48 | 55 |
| 49 MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 56 MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
| 50 } | 57 } |
| 51 | 58 |
| 52 aura::RootWindow* root_window_; | 59 aura::RootWindow* root_window_; |
| 53 int container_id_; | 60 int container_id_; |
| 54 views::Widget* desktop_widget_; | 61 views::Widget* desktop_widget_; |
| 55 | 62 |
| 56 DISALLOW_COPY_AND_ASSIGN(ShowWallpaperAnimationObserver); | 63 DISALLOW_COPY_AND_ASSIGN(ShowWallpaperAnimationObserver); |
| 57 }; | 64 }; |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 params.delegate = view; | 153 params.delegate = view; |
| 147 if (controller->GetWallpaper().empty()) | 154 if (controller->GetWallpaper().empty()) |
| 148 params.transparent = true; | 155 params.transparent = true; |
| 149 params.parent = root_window->GetChildById(container_id); | 156 params.parent = root_window->GetChildById(container_id); |
| 150 desktop_widget->Init(params); | 157 desktop_widget->Init(params); |
| 151 desktop_widget->SetContentsView(view); | 158 desktop_widget->SetContentsView(view); |
| 152 ash::WindowVisibilityAnimationType animation_type = | 159 ash::WindowVisibilityAnimationType animation_type = |
| 153 ash::Shell::GetInstance()->user_wallpaper_delegate()->GetAnimationType(); | 160 ash::Shell::GetInstance()->user_wallpaper_delegate()->GetAnimationType(); |
| 154 ash::SetWindowVisibilityAnimationType(desktop_widget->GetNativeView(), | 161 ash::SetWindowVisibilityAnimationType(desktop_widget->GetNativeView(), |
| 155 animation_type); | 162 animation_type); |
| 156 ash::SetWindowVisibilityAnimationTransition(desktop_widget->GetNativeView(), | 163 // Disable animation when creating the first widget. Otherwise, wallpaper |
| 157 ash::ANIMATE_SHOW); | 164 // will animate from a white screen. Note that boot animation is different. |
| 165 // It animates from a white background. |
| 166 if (animation_type == ash::WINDOW_VISIBILITY_ANIMATION_TYPE_FADE && |
| 167 NULL == root_window->GetProperty(internal::kWindowDesktopComponent)) { |
| 168 ash::SetWindowVisibilityAnimationTransition(desktop_widget->GetNativeView(), |
| 169 ash::ANIMATE_NONE); |
| 170 } else { |
| 171 ash::SetWindowVisibilityAnimationTransition(desktop_widget->GetNativeView(), |
| 172 ash::ANIMATE_SHOW); |
| 173 } |
| 158 desktop_widget->SetBounds(params.parent->bounds()); | 174 desktop_widget->SetBounds(params.parent->bounds()); |
| 159 ui::ScopedLayerAnimationSettings settings( | 175 ui::ScopedLayerAnimationSettings settings( |
| 160 desktop_widget->GetNativeView()->layer()->GetAnimator()); | 176 desktop_widget->GetNativeView()->layer()->GetAnimator()); |
| 161 settings.SetPreemptionStrategy(ui::LayerAnimator::ENQUEUE_NEW_ANIMATION); | 177 settings.SetPreemptionStrategy(ui::LayerAnimator::ENQUEUE_NEW_ANIMATION); |
| 162 settings.AddObserver(new ShowWallpaperAnimationObserver(root_window, | 178 settings.AddObserver(new ShowWallpaperAnimationObserver(root_window, |
| 163 container_id, | 179 container_id, |
| 164 desktop_widget)); | 180 desktop_widget)); |
| 165 desktop_widget->Show(); | 181 desktop_widget->Show(); |
| 166 desktop_widget->GetNativeView()->SetName("DesktopBackgroundView"); | 182 desktop_widget->GetNativeView()->SetName("DesktopBackgroundView"); |
| 167 return desktop_widget; | 183 return desktop_widget; |
| 168 } | 184 } |
| 169 | 185 |
| 170 } // namespace internal | 186 } // namespace internal |
| 171 } // namespace ash | 187 } // namespace ash |
| OLD | NEW |