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