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_view.h" | 5 #include "ash/common/wallpaper/wallpaper_view.h" |
6 | 6 |
7 #include "ash/aura/wm_window_aura.h" | |
8 #include "ash/common/session/session_state_delegate.h" | 7 #include "ash/common/session/session_state_delegate.h" |
| 8 #include "ash/common/wallpaper/wallpaper_controller.h" |
9 #include "ash/common/wallpaper/wallpaper_delegate.h" | 9 #include "ash/common/wallpaper/wallpaper_delegate.h" |
| 10 #include "ash/common/wallpaper/wallpaper_widget_controller.h" |
10 #include "ash/common/wm/overview/window_selector_controller.h" | 11 #include "ash/common/wm/overview/window_selector_controller.h" |
11 #include "ash/common/wm_lookup.h" | 12 #include "ash/common/wm_lookup.h" |
| 13 #include "ash/common/wm_root_window_controller.h" |
12 #include "ash/common/wm_shell.h" | 14 #include "ash/common/wm_shell.h" |
13 #include "ash/root_window_controller.h" | 15 #include "ash/common/wm_window.h" |
14 #include "ash/shell.h" | |
15 #include "ash/wallpaper/wallpaper_controller.h" | |
16 #include "ash/wallpaper/wallpaper_widget_controller.h" | |
17 #include "ui/display/display.h" | 16 #include "ui/display/display.h" |
18 #include "ui/display/manager/managed_display_info.h" | 17 #include "ui/display/manager/managed_display_info.h" |
19 #include "ui/display/screen.h" | 18 #include "ui/display/screen.h" |
20 #include "ui/gfx/canvas.h" | 19 #include "ui/gfx/canvas.h" |
21 #include "ui/gfx/geometry/safe_integer_conversions.h" | 20 #include "ui/gfx/geometry/safe_integer_conversions.h" |
22 #include "ui/gfx/geometry/size_conversions.h" | 21 #include "ui/gfx/geometry/size_conversions.h" |
23 #include "ui/gfx/transform.h" | 22 #include "ui/gfx/transform.h" |
24 #include "ui/views/widget/widget.h" | 23 #include "ui/views/widget/widget.h" |
25 | 24 |
26 namespace ash { | 25 namespace ash { |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 } | 114 } |
116 | 115 |
117 //////////////////////////////////////////////////////////////////////////////// | 116 //////////////////////////////////////////////////////////////////////////////// |
118 // WallpaperView, views::View overrides: | 117 // WallpaperView, views::View overrides: |
119 | 118 |
120 void WallpaperView::OnPaint(gfx::Canvas* canvas) { | 119 void WallpaperView::OnPaint(gfx::Canvas* canvas) { |
121 // Scale the image while maintaining the aspect ratio, cropping as necessary | 120 // Scale the image while maintaining the aspect ratio, cropping as necessary |
122 // to fill the wallpaper. Ideally the image should be larger than the largest | 121 // to fill the wallpaper. Ideally the image should be larger than the largest |
123 // display supported, if not we will scale and center it if the layout is | 122 // display supported, if not we will scale and center it if the layout is |
124 // wallpaper::WALLPAPER_LAYOUT_CENTER_CROPPED. | 123 // wallpaper::WALLPAPER_LAYOUT_CENTER_CROPPED. |
125 WallpaperController* controller = | 124 WallpaperController* controller = WmShell::Get()->wallpaper_controller(); |
126 Shell::GetInstance()->wallpaper_controller(); | |
127 gfx::ImageSkia wallpaper = controller->GetWallpaper(); | 125 gfx::ImageSkia wallpaper = controller->GetWallpaper(); |
128 wallpaper::WallpaperLayout layout = controller->GetWallpaperLayout(); | 126 wallpaper::WallpaperLayout layout = controller->GetWallpaperLayout(); |
129 | 127 |
130 // Wallpapers with png format could be partially transparent. Fill the canvas | 128 // Wallpapers with png format could be partially transparent. Fill the canvas |
131 // with black to make it opaque before painting the wallpaper. | 129 // with black to make it opaque before painting the wallpaper. |
132 canvas->FillRect(GetLocalBounds(), SK_ColorBLACK); | 130 canvas->FillRect(GetLocalBounds(), SK_ColorBLACK); |
133 | 131 |
134 if (wallpaper.isNull()) | 132 if (wallpaper.isNull()) |
135 return; | 133 return; |
136 | 134 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 return true; | 180 return true; |
183 } | 181 } |
184 | 182 |
185 void WallpaperView::ShowContextMenuForView(views::View* source, | 183 void WallpaperView::ShowContextMenuForView(views::View* source, |
186 const gfx::Point& point, | 184 const gfx::Point& point, |
187 ui::MenuSourceType source_type) { | 185 ui::MenuSourceType source_type) { |
188 WmShell::Get()->ShowContextMenu(point, source_type); | 186 WmShell::Get()->ShowContextMenu(point, source_type); |
189 } | 187 } |
190 | 188 |
191 views::Widget* CreateWallpaper(WmWindow* root_window, int container_id) { | 189 views::Widget* CreateWallpaper(WmWindow* root_window, int container_id) { |
192 aura::Window* aura_root_window = WmWindowAura::GetAuraWindow(root_window); | 190 WallpaperController* controller = WmShell::Get()->wallpaper_controller(); |
193 WallpaperController* controller = | |
194 Shell::GetInstance()->wallpaper_controller(); | |
195 WallpaperDelegate* wallpaper_delegate = WmShell::Get()->wallpaper_delegate(); | 191 WallpaperDelegate* wallpaper_delegate = WmShell::Get()->wallpaper_delegate(); |
196 | 192 |
197 views::Widget* wallpaper_widget = new views::Widget; | 193 views::Widget* wallpaper_widget = new views::Widget; |
198 views::Widget::InitParams params( | 194 views::Widget::InitParams params( |
199 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); | 195 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); |
200 params.name = "WallpaperView"; | 196 params.name = "WallpaperView"; |
201 if (controller->GetWallpaper().isNull()) | 197 if (controller->GetWallpaper().isNull()) |
202 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; | 198 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; |
203 params.parent = aura_root_window->GetChildById(container_id); | 199 root_window->GetRootWindowController()->ConfigureWidgetInitParamsForContainer( |
| 200 wallpaper_widget, container_id, ¶ms); |
204 wallpaper_widget->Init(params); | 201 wallpaper_widget->Init(params); |
205 wallpaper_widget->SetContentsView(new LayerControlView(new WallpaperView())); | 202 wallpaper_widget->SetContentsView(new LayerControlView(new WallpaperView())); |
206 int animation_type = wallpaper_delegate->GetAnimationType(); | 203 int animation_type = wallpaper_delegate->GetAnimationType(); |
207 WmWindow* wallpaper_window = | 204 WmWindow* wallpaper_window = |
208 WmLookup::Get()->GetWindowForWidget(wallpaper_widget); | 205 WmLookup::Get()->GetWindowForWidget(wallpaper_widget); |
209 wallpaper_window->SetVisibilityAnimationType(animation_type); | 206 wallpaper_window->SetVisibilityAnimationType(animation_type); |
210 | 207 |
211 RootWindowController* root_window_controller = | 208 WmRootWindowController* root_window_controller = |
212 GetRootWindowController(aura_root_window); | 209 root_window->GetRootWindowController(); |
213 | 210 |
214 // Enable wallpaper transition for the following cases: | 211 // Enable wallpaper transition for the following cases: |
215 // 1. Initial(OOBE) wallpaper animation. | 212 // 1. Initial(OOBE) wallpaper animation. |
216 // 2. Wallpaper fades in from a non empty background. | 213 // 2. Wallpaper fades in from a non empty background. |
217 // 3. From an empty background, chrome transit to a logged in user session. | 214 // 3. From an empty background, chrome transit to a logged in user session. |
218 // 4. From an empty background, guest user logged in. | 215 // 4. From an empty background, guest user logged in. |
219 if (wallpaper_delegate->ShouldShowInitialAnimation() || | 216 if (wallpaper_delegate->ShouldShowInitialAnimation() || |
220 root_window_controller->animating_wallpaper_widget_controller() || | 217 root_window_controller->animating_wallpaper_widget_controller() || |
221 WmShell::Get()->GetSessionStateDelegate()->NumberOfLoggedInUsers()) { | 218 WmShell::Get()->GetSessionStateDelegate()->NumberOfLoggedInUsers()) { |
222 wallpaper_window->SetVisibilityAnimationTransition(::wm::ANIMATE_SHOW); | 219 wallpaper_window->SetVisibilityAnimationTransition(::wm::ANIMATE_SHOW); |
223 int duration_override = wallpaper_delegate->GetAnimationDurationOverride(); | 220 int duration_override = wallpaper_delegate->GetAnimationDurationOverride(); |
224 if (duration_override) { | 221 if (duration_override) { |
225 wallpaper_window->SetVisibilityAnimationDuration( | 222 wallpaper_window->SetVisibilityAnimationDuration( |
226 base::TimeDelta::FromMilliseconds(duration_override)); | 223 base::TimeDelta::FromMilliseconds(duration_override)); |
227 } | 224 } |
228 } else { | 225 } else { |
229 // Disable animation if transition to login screen from an empty background. | 226 // Disable animation if transition to login screen from an empty background. |
230 wallpaper_window->SetVisibilityAnimationTransition(::wm::ANIMATE_NONE); | 227 wallpaper_window->SetVisibilityAnimationTransition(::wm::ANIMATE_NONE); |
231 } | 228 } |
232 | 229 |
233 wallpaper_widget->SetBounds(params.parent->bounds()); | 230 WmWindow* container = root_window->GetChildByShellWindowId(container_id); |
| 231 wallpaper_widget->SetBounds(container->GetBounds()); |
234 return wallpaper_widget; | 232 return wallpaper_widget; |
235 } | 233 } |
236 | 234 |
237 } // namespace ash | 235 } // namespace ash |
OLD | NEW |