Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(207)

Side by Side Diff: ash/common/wallpaper/wallpaper_view.cc

Issue 2726823003: Remove WmLookup. (Closed)
Patch Set: Clean up include and modify comment. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_lookup.h"
13 #include "ash/common/wm_shell.h" 12 #include "ash/common/wm_shell.h"
14 #include "ash/common/wm_window.h" 13 #include "ash/common/wm_window.h"
15 #include "ash/root_window_controller.h" 14 #include "ash/root_window_controller.h"
16 #include "ui/display/display.h" 15 #include "ui/display/display.h"
17 #include "ui/display/manager/managed_display_info.h" 16 #include "ui/display/manager/managed_display_info.h"
18 #include "ui/display/screen.h" 17 #include "ui/display/screen.h"
19 #include "ui/gfx/canvas.h" 18 #include "ui/gfx/canvas.h"
20 #include "ui/gfx/geometry/safe_integer_conversions.h" 19 #include "ui/gfx/geometry/safe_integer_conversions.h"
21 #include "ui/gfx/geometry/size_conversions.h" 20 #include "ui/gfx/geometry/size_conversions.h"
22 #include "ui/gfx/transform.h" 21 #include "ui/gfx/transform.h"
23 #include "ui/views/widget/widget.h" 22 #include "ui/views/widget/widget.h"
24 23
25 namespace ash { 24 namespace ash {
26 namespace { 25 namespace {
27 26
28 // A view that controls the child view's layer so that the layer always has the 27 // 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 28 // 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 29 // 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 30 // scaling the image at painting time, then scaling it back to the screen size
32 // in the compositor. 31 // in the compositor.
33 class LayerControlView : public views::View { 32 class LayerControlView : public views::View {
34 public: 33 public:
35 explicit LayerControlView(views::View* view) { 34 explicit LayerControlView(views::View* view) {
36 AddChildView(view); 35 AddChildView(view);
37 view->SetPaintToLayer(); 36 view->SetPaintToLayer();
38 } 37 }
39 38
40 // Overrides views::View. 39 // Overrides views::View.
41 void Layout() override { 40 void Layout() override {
42 WmWindow* window = WmLookup::Get()->GetWindowForWidget(GetWidget()); 41 WmWindow* window = WmWindow::Get(GetWidget()->GetNativeWindow());
43 // Keep |this| at the bottom since there may be other windows on top of the 42 // Keep |this| at the bottom since there may be other windows on top of the
44 // wallpaper view such as an overview mode shield. 43 // wallpaper view such as an overview mode shield.
45 window->GetParent()->StackChildAtBottom(window); 44 window->GetParent()->StackChildAtBottom(window);
46 display::Display display = window->GetDisplayNearestWindow(); 45 display::Display display = window->GetDisplayNearestWindow();
47 46
48 // TODO(mash): Mash returns a fake ManagedDisplayInfo. crbug.com/622480 47 // TODO(mash): Mash returns a fake ManagedDisplayInfo. crbug.com/622480
49 float ui_scale = 1.f; 48 float ui_scale = 1.f;
50 display::ManagedDisplayInfo info = 49 display::ManagedDisplayInfo info =
51 WmShell::Get()->GetDisplayInfo(display.id()); 50 WmShell::Get()->GetDisplayInfo(display.id());
52 if (info.id() == display.id()) 51 if (info.id() == display.id())
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); 199 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
201 params.name = "WallpaperView"; 200 params.name = "WallpaperView";
202 if (controller->GetWallpaper().isNull()) 201 if (controller->GetWallpaper().isNull())
203 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; 202 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW;
204 root_window->GetRootWindowController()->ConfigureWidgetInitParamsForContainer( 203 root_window->GetRootWindowController()->ConfigureWidgetInitParamsForContainer(
205 wallpaper_widget, container_id, &params); 204 wallpaper_widget, container_id, &params);
206 wallpaper_widget->Init(params); 205 wallpaper_widget->Init(params);
207 wallpaper_widget->SetContentsView(new LayerControlView(new WallpaperView())); 206 wallpaper_widget->SetContentsView(new LayerControlView(new WallpaperView()));
208 int animation_type = wallpaper_delegate->GetAnimationType(); 207 int animation_type = wallpaper_delegate->GetAnimationType();
209 WmWindow* wallpaper_window = 208 WmWindow* wallpaper_window =
210 WmLookup::Get()->GetWindowForWidget(wallpaper_widget); 209 WmWindow::Get(wallpaper_widget->GetNativeWindow());
211 wallpaper_window->SetVisibilityAnimationType(animation_type); 210 wallpaper_window->SetVisibilityAnimationType(animation_type);
212 211
213 RootWindowController* root_window_controller = 212 RootWindowController* root_window_controller =
214 root_window->GetRootWindowController(); 213 root_window->GetRootWindowController();
215 214
216 // Enable wallpaper transition for the following cases: 215 // Enable wallpaper transition for the following cases:
217 // 1. Initial(OOBE) wallpaper animation. 216 // 1. Initial(OOBE) wallpaper animation.
218 // 2. Wallpaper fades in from a non empty background. 217 // 2. Wallpaper fades in from a non empty background.
219 // 3. From an empty background, chrome transit to a logged in user session. 218 // 3. From an empty background, chrome transit to a logged in user session.
220 // 4. From an empty background, guest user logged in. 219 // 4. From an empty background, guest user logged in.
(...skipping 10 matching lines...) Expand all
231 // Disable animation if transition to login screen from an empty background. 230 // Disable animation if transition to login screen from an empty background.
232 wallpaper_window->SetVisibilityAnimationTransition(::wm::ANIMATE_NONE); 231 wallpaper_window->SetVisibilityAnimationTransition(::wm::ANIMATE_NONE);
233 } 232 }
234 233
235 WmWindow* container = root_window->GetChildByShellWindowId(container_id); 234 WmWindow* container = root_window->GetChildByShellWindowId(container_id);
236 wallpaper_widget->SetBounds(container->GetBounds()); 235 wallpaper_widget->SetBounds(container->GetBounds());
237 return wallpaper_widget; 236 return wallpaper_widget;
238 } 237 }
239 238
240 } // namespace ash 239 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/system/web_notification/web_notification_tray.cc ('k') | ash/common/wallpaper/wallpaper_widget_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698