| 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/common/wallpaper/wallpaper_view.h" | 5 #include "ash/common/wallpaper/wallpaper_view.h" |
| 6 | 6 |
| 7 #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" | 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/wallpaper/wallpaper_widget_controller.h" |
| 11 #include "ash/common/wm/overview/window_selector_controller.h" | 11 #include "ash/common/wm/overview/window_selector_controller.h" |
| 12 #include "ash/common/wm_shell.h" | 12 #include "ash/common/wm_shell.h" |
| 13 #include "ash/common/wm_window.h" | 13 #include "ash/common/wm_window.h" |
| 14 #include "ash/root_window_controller.h" | 14 #include "ash/root_window_controller.h" |
| 15 #include "ash/shell.h" |
| 15 #include "ui/display/display.h" | 16 #include "ui/display/display.h" |
| 16 #include "ui/display/manager/managed_display_info.h" | 17 #include "ui/display/manager/managed_display_info.h" |
| 17 #include "ui/display/screen.h" | 18 #include "ui/display/screen.h" |
| 18 #include "ui/gfx/canvas.h" | 19 #include "ui/gfx/canvas.h" |
| 19 #include "ui/gfx/geometry/safe_integer_conversions.h" | 20 #include "ui/gfx/geometry/safe_integer_conversions.h" |
| 20 #include "ui/gfx/geometry/size_conversions.h" | 21 #include "ui/gfx/geometry/size_conversions.h" |
| 21 #include "ui/gfx/transform.h" | 22 #include "ui/gfx/transform.h" |
| 22 #include "ui/views/widget/widget.h" | 23 #include "ui/views/widget/widget.h" |
| 23 | 24 |
| 24 namespace ash { | 25 namespace ash { |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 } | 119 } |
| 119 | 120 |
| 120 //////////////////////////////////////////////////////////////////////////////// | 121 //////////////////////////////////////////////////////////////////////////////// |
| 121 // WallpaperView, views::View overrides: | 122 // WallpaperView, views::View overrides: |
| 122 | 123 |
| 123 void WallpaperView::OnPaint(gfx::Canvas* canvas) { | 124 void WallpaperView::OnPaint(gfx::Canvas* canvas) { |
| 124 // Scale the image while maintaining the aspect ratio, cropping as necessary | 125 // Scale the image while maintaining the aspect ratio, cropping as necessary |
| 125 // to fill the wallpaper. Ideally the image should be larger than the largest | 126 // to fill the wallpaper. Ideally the image should be larger than the largest |
| 126 // display supported, if not we will scale and center it if the layout is | 127 // display supported, if not we will scale and center it if the layout is |
| 127 // wallpaper::WALLPAPER_LAYOUT_CENTER_CROPPED. | 128 // wallpaper::WALLPAPER_LAYOUT_CENTER_CROPPED. |
| 128 WallpaperController* controller = WmShell::Get()->wallpaper_controller(); | 129 WallpaperController* controller = |
| 130 Shell::GetInstance()->wallpaper_controller(); |
| 129 gfx::ImageSkia wallpaper = controller->GetWallpaper(); | 131 gfx::ImageSkia wallpaper = controller->GetWallpaper(); |
| 130 wallpaper::WallpaperLayout layout = controller->GetWallpaperLayout(); | 132 wallpaper::WallpaperLayout layout = controller->GetWallpaperLayout(); |
| 131 | 133 |
| 132 // Wallpapers with png format could be partially transparent. Fill the canvas | 134 // Wallpapers with png format could be partially transparent. Fill the canvas |
| 133 // with black to make it opaque before painting the wallpaper. | 135 // with black to make it opaque before painting the wallpaper. |
| 134 canvas->FillRect(GetLocalBounds(), SK_ColorBLACK); | 136 canvas->FillRect(GetLocalBounds(), SK_ColorBLACK); |
| 135 | 137 |
| 136 if (wallpaper.isNull()) | 138 if (wallpaper.isNull()) |
| 137 return; | 139 return; |
| 138 | 140 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 return true; | 186 return true; |
| 185 } | 187 } |
| 186 | 188 |
| 187 void WallpaperView::ShowContextMenuForView(views::View* source, | 189 void WallpaperView::ShowContextMenuForView(views::View* source, |
| 188 const gfx::Point& point, | 190 const gfx::Point& point, |
| 189 ui::MenuSourceType source_type) { | 191 ui::MenuSourceType source_type) { |
| 190 WmShell::Get()->ShowContextMenu(point, source_type); | 192 WmShell::Get()->ShowContextMenu(point, source_type); |
| 191 } | 193 } |
| 192 | 194 |
| 193 views::Widget* CreateWallpaper(WmWindow* root_window, int container_id) { | 195 views::Widget* CreateWallpaper(WmWindow* root_window, int container_id) { |
| 194 WallpaperController* controller = WmShell::Get()->wallpaper_controller(); | 196 WallpaperController* controller = |
| 197 Shell::GetInstance()->wallpaper_controller(); |
| 195 WallpaperDelegate* wallpaper_delegate = WmShell::Get()->wallpaper_delegate(); | 198 WallpaperDelegate* wallpaper_delegate = WmShell::Get()->wallpaper_delegate(); |
| 196 | 199 |
| 197 views::Widget* wallpaper_widget = new views::Widget; | 200 views::Widget* wallpaper_widget = new views::Widget; |
| 198 views::Widget::InitParams params( | 201 views::Widget::InitParams params( |
| 199 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); | 202 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); |
| 200 params.name = "WallpaperView"; | 203 params.name = "WallpaperView"; |
| 201 if (controller->GetWallpaper().isNull()) | 204 if (controller->GetWallpaper().isNull()) |
| 202 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; | 205 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; |
| 203 root_window->GetRootWindowController()->ConfigureWidgetInitParamsForContainer( | 206 root_window->GetRootWindowController()->ConfigureWidgetInitParamsForContainer( |
| 204 wallpaper_widget, container_id, ¶ms); | 207 wallpaper_widget, container_id, ¶ms); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 230 // Disable animation if transition to login screen from an empty background. | 233 // Disable animation if transition to login screen from an empty background. |
| 231 wallpaper_window->SetVisibilityAnimationTransition(::wm::ANIMATE_NONE); | 234 wallpaper_window->SetVisibilityAnimationTransition(::wm::ANIMATE_NONE); |
| 232 } | 235 } |
| 233 | 236 |
| 234 WmWindow* container = root_window->GetChildByShellWindowId(container_id); | 237 WmWindow* container = root_window->GetChildByShellWindowId(container_id); |
| 235 wallpaper_widget->SetBounds(container->GetBounds()); | 238 wallpaper_widget->SetBounds(container->GetBounds()); |
| 236 return wallpaper_widget; | 239 return wallpaper_widget; |
| 237 } | 240 } |
| 238 | 241 |
| 239 } // namespace ash | 242 } // namespace ash |
| OLD | NEW |