| 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/wallpaper/wallpaper_view.h" |
| 6 | 6 |
| 7 #include "ash/root_window_controller.h" | 7 #include "ash/root_window_controller.h" |
| 8 #include "ash/session/session_controller.h" | 8 #include "ash/session/session_controller.h" |
| 9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 10 #include "ash/shell_port.h" | 10 #include "ash/shell_port.h" |
| 11 #include "ash/wallpaper/wallpaper_controller.h" | 11 #include "ash/wallpaper/wallpaper_controller.h" |
| 12 #include "ash/wallpaper/wallpaper_delegate.h" | 12 #include "ash/wallpaper/wallpaper_delegate.h" |
| 13 #include "ash/wallpaper/wallpaper_widget_controller.h" | 13 #include "ash/wallpaper/wallpaper_widget_controller.h" |
| 14 #include "ash/wm/overview/window_selector_controller.h" | 14 #include "ash/wm/overview/window_selector_controller.h" |
| 15 #include "ash/wm_window.h" | 15 #include "ui/aura/window.h" |
| 16 #include "ui/display/display.h" | 16 #include "ui/display/display.h" |
| 17 #include "ui/display/manager/managed_display_info.h" | 17 #include "ui/display/manager/managed_display_info.h" |
| 18 #include "ui/display/screen.h" | 18 #include "ui/display/screen.h" |
| 19 #include "ui/gfx/canvas.h" | 19 #include "ui/gfx/canvas.h" |
| 20 #include "ui/gfx/geometry/safe_integer_conversions.h" | 20 #include "ui/gfx/geometry/safe_integer_conversions.h" |
| 21 #include "ui/gfx/geometry/size_conversions.h" | 21 #include "ui/gfx/geometry/size_conversions.h" |
| 22 #include "ui/gfx/transform.h" | 22 #include "ui/gfx/transform.h" |
| 23 #include "ui/views/widget/widget.h" | 23 #include "ui/views/widget/widget.h" |
| 24 #include "ui/wm/core/window_animations.h" |
| 24 | 25 |
| 25 namespace ash { | 26 namespace ash { |
| 26 namespace { | 27 namespace { |
| 27 | 28 |
| 28 // A view that controls the child view's layer so that the layer always has the | 29 // A view that controls the child view's layer so that the layer always has the |
| 29 // same size as the display's original, un-scaled size in DIP. The layer is then | 30 // same size as the display's original, un-scaled size in DIP. The layer is then |
| 30 // transformed to fit to the virtual screen size when laid-out. This is to avoid | 31 // transformed to fit to the virtual screen size when laid-out. This is to avoid |
| 31 // scaling the image at painting time, then scaling it back to the screen size | 32 // scaling the image at painting time, then scaling it back to the screen size |
| 32 // in the compositor. | 33 // in the compositor. |
| 33 class LayerControlView : public views::View { | 34 class LayerControlView : public views::View { |
| 34 public: | 35 public: |
| 35 explicit LayerControlView(views::View* view) { | 36 explicit LayerControlView(views::View* view) { |
| 36 AddChildView(view); | 37 AddChildView(view); |
| 37 view->SetPaintToLayer(); | 38 view->SetPaintToLayer(); |
| 38 } | 39 } |
| 39 | 40 |
| 40 // Overrides views::View. | 41 // Overrides views::View. |
| 41 void Layout() override { | 42 void Layout() override { |
| 42 WmWindow* window = WmWindow::Get(GetWidget()->GetNativeWindow()); | 43 aura::Window* window = GetWidget()->GetNativeWindow(); |
| 43 // Keep |this| at the bottom since there may be other windows on top of the | 44 // Keep |this| at the bottom since there may be other windows on top of the |
| 44 // wallpaper view such as an overview mode shield. | 45 // wallpaper view such as an overview mode shield. |
| 45 window->GetParent()->StackChildAtBottom(window); | 46 window->parent()->StackChildAtBottom(window); |
| 46 display::Display display = window->GetDisplayNearestWindow(); | 47 display::Display display = |
| 48 display::Screen::GetScreen()->GetDisplayNearestWindow(window); |
| 47 | 49 |
| 48 // TODO(mash): Mash returns a fake ManagedDisplayInfo. crbug.com/622480 | 50 // TODO(mash): Mash returns a fake ManagedDisplayInfo. crbug.com/622480 |
| 49 float ui_scale = 1.f; | 51 float ui_scale = 1.f; |
| 50 display::ManagedDisplayInfo info = | 52 display::ManagedDisplayInfo info = |
| 51 ShellPort::Get()->GetDisplayInfo(display.id()); | 53 ShellPort::Get()->GetDisplayInfo(display.id()); |
| 52 if (info.id() == display.id()) | 54 if (info.id() == display.id()) |
| 53 ui_scale = info.GetEffectiveUIScale(); | 55 ui_scale = info.GetEffectiveUIScale(); |
| 54 | 56 |
| 55 gfx::Size rounded_size = | 57 gfx::Size rounded_size = |
| 56 gfx::ScaleToFlooredSize(display.size(), 1.f / ui_scale); | 58 gfx::ScaleToFlooredSize(display.size(), 1.f / ui_scale); |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 bool WallpaperView::OnMousePressed(const ui::MouseEvent& event) { | 186 bool WallpaperView::OnMousePressed(const ui::MouseEvent& event) { |
| 185 return true; | 187 return true; |
| 186 } | 188 } |
| 187 | 189 |
| 188 void WallpaperView::ShowContextMenuForView(views::View* source, | 190 void WallpaperView::ShowContextMenuForView(views::View* source, |
| 189 const gfx::Point& point, | 191 const gfx::Point& point, |
| 190 ui::MenuSourceType source_type) { | 192 ui::MenuSourceType source_type) { |
| 191 ShellPort::Get()->ShowContextMenu(point, source_type); | 193 ShellPort::Get()->ShowContextMenu(point, source_type); |
| 192 } | 194 } |
| 193 | 195 |
| 194 views::Widget* CreateWallpaper(WmWindow* root_window, int container_id) { | 196 views::Widget* CreateWallpaper(aura::Window* root_window, int container_id) { |
| 195 WallpaperController* controller = Shell::Get()->wallpaper_controller(); | 197 WallpaperController* controller = Shell::Get()->wallpaper_controller(); |
| 196 WallpaperDelegate* wallpaper_delegate = Shell::Get()->wallpaper_delegate(); | 198 WallpaperDelegate* wallpaper_delegate = Shell::Get()->wallpaper_delegate(); |
| 197 | 199 |
| 198 views::Widget* wallpaper_widget = new views::Widget; | 200 views::Widget* wallpaper_widget = new views::Widget; |
| 199 views::Widget::InitParams params( | 201 views::Widget::InitParams params( |
| 200 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); | 202 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); |
| 201 params.name = "WallpaperView"; | 203 params.name = "WallpaperView"; |
| 202 if (controller->GetWallpaper().isNull()) | 204 if (controller->GetWallpaper().isNull()) |
| 203 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; | 205 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; |
| 204 root_window->GetRootWindowController()->ConfigureWidgetInitParamsForContainer( | 206 RootWindowController* root_window_controller = |
| 207 RootWindowController::ForWindow(root_window); |
| 208 root_window_controller->ConfigureWidgetInitParamsForContainer( |
| 205 wallpaper_widget, container_id, ¶ms); | 209 wallpaper_widget, container_id, ¶ms); |
| 206 wallpaper_widget->Init(params); | 210 wallpaper_widget->Init(params); |
| 207 wallpaper_widget->SetContentsView(new LayerControlView(new WallpaperView())); | 211 wallpaper_widget->SetContentsView(new LayerControlView(new WallpaperView())); |
| 208 int animation_type = wallpaper_delegate->GetAnimationType(); | 212 int animation_type = wallpaper_delegate->GetAnimationType(); |
| 209 WmWindow* wallpaper_window = | 213 aura::Window* wallpaper_window = wallpaper_widget->GetNativeWindow(); |
| 210 WmWindow::Get(wallpaper_widget->GetNativeWindow()); | 214 ::wm::SetWindowVisibilityAnimationType(wallpaper_window, animation_type); |
| 211 wallpaper_window->SetVisibilityAnimationType(animation_type); | |
| 212 | |
| 213 RootWindowController* root_window_controller = | |
| 214 root_window->GetRootWindowController(); | |
| 215 | 215 |
| 216 // Enable wallpaper transition for the following cases: | 216 // Enable wallpaper transition for the following cases: |
| 217 // 1. Initial(OOBE) wallpaper animation. | 217 // 1. Initial(OOBE) wallpaper animation. |
| 218 // 2. Wallpaper fades in from a non empty background. | 218 // 2. Wallpaper fades in from a non empty background. |
| 219 // 3. From an empty background, chrome transit to a logged in user session. | 219 // 3. From an empty background, chrome transit to a logged in user session. |
| 220 // 4. From an empty background, guest user logged in. | 220 // 4. From an empty background, guest user logged in. |
| 221 if (wallpaper_delegate->ShouldShowInitialAnimation() || | 221 if (wallpaper_delegate->ShouldShowInitialAnimation() || |
| 222 root_window_controller->animating_wallpaper_widget_controller() || | 222 root_window_controller->animating_wallpaper_widget_controller() || |
| 223 Shell::Get()->session_controller()->NumberOfLoggedInUsers()) { | 223 Shell::Get()->session_controller()->NumberOfLoggedInUsers()) { |
| 224 wallpaper_window->SetVisibilityAnimationTransition(::wm::ANIMATE_SHOW); | 224 ::wm::SetWindowVisibilityAnimationTransition(wallpaper_window, |
| 225 ::wm::ANIMATE_SHOW); |
| 225 int duration_override = wallpaper_delegate->GetAnimationDurationOverride(); | 226 int duration_override = wallpaper_delegate->GetAnimationDurationOverride(); |
| 226 if (duration_override) { | 227 if (duration_override) { |
| 227 wallpaper_window->SetVisibilityAnimationDuration( | 228 ::wm::SetWindowVisibilityAnimationDuration( |
| 229 wallpaper_window, |
| 228 base::TimeDelta::FromMilliseconds(duration_override)); | 230 base::TimeDelta::FromMilliseconds(duration_override)); |
| 229 } | 231 } |
| 230 } else { | 232 } else { |
| 231 // Disable animation if transition to login screen from an empty background. | 233 // Disable animation if transition to login screen from an empty background. |
| 232 wallpaper_window->SetVisibilityAnimationTransition(::wm::ANIMATE_NONE); | 234 ::wm::SetWindowVisibilityAnimationTransition(wallpaper_window, |
| 235 ::wm::ANIMATE_NONE); |
| 233 } | 236 } |
| 234 | 237 |
| 235 WmWindow* container = root_window->GetChildByShellWindowId(container_id); | 238 aura::Window* container = root_window->GetChildById(container_id); |
| 236 wallpaper_widget->SetBounds(container->GetBounds()); | 239 wallpaper_widget->SetBounds(container->bounds()); |
| 237 return wallpaper_widget; | 240 return wallpaper_widget; |
| 238 } | 241 } |
| 239 | 242 |
| 240 } // namespace ash | 243 } // namespace ash |
| OLD | NEW |