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

Side by Side Diff: ash/desktop_background/desktop_background_view.cc

Issue 10829173: Revert 149869 because it broke ash_unittests on win_aura and linux_chromeos. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 4 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 | Annotate | Revision Log
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/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/shell.h" 11 #include "ash/shell.h"
12 #include "ash/shell_window_ids.h" 12 #include "ash/shell_window_ids.h"
13 #include "ash/wm/root_window_layout_manager.h"
13 #include "ash/wm/window_animations.h" 14 #include "ash/wm/window_animations.h"
14 #include "base/message_loop.h" 15 #include "base/message_loop.h"
15 #include "base/utf_string_conversions.h" 16 #include "base/utf_string_conversions.h"
16 #include "grit/ui_resources.h" 17 #include "grit/ui_resources.h"
17 #include "ui/aura/root_window.h" 18 #include "ui/aura/root_window.h"
18 #include "ui/base/resource/resource_bundle.h" 19 #include "ui/base/resource/resource_bundle.h"
19 #include "ui/compositor/layer.h" 20 #include "ui/compositor/layer.h"
20 #include "ui/compositor/layer_animation_observer.h" 21 #include "ui/compositor/layer_animation_observer.h"
21 #include "ui/compositor/scoped_layer_animation_settings.h" 22 #include "ui/compositor/scoped_layer_animation_settings.h"
22 #include "ui/gfx/canvas.h" 23 #include "ui/gfx/canvas.h"
23 #include "ui/gfx/image/image.h" 24 #include "ui/gfx/image/image.h"
24 #include "ui/views/widget/widget.h" 25 #include "ui/views/widget/widget.h"
25 26
26 namespace ash { 27 namespace ash {
27 namespace internal { 28 namespace internal {
28 namespace { 29 namespace {
29 30
30 class ShowWallpaperAnimationObserver : public ui::ImplicitAnimationObserver { 31 class ShowWallpaperAnimationObserver : public ui::ImplicitAnimationObserver {
31 public: 32 public:
32 ShowWallpaperAnimationObserver(aura::RootWindow* root_window, 33 ShowWallpaperAnimationObserver(aura::RootWindow* root_window,
33 int container_id,
34 views::Widget* desktop_widget) 34 views::Widget* desktop_widget)
35 : root_window_(root_window), 35 : root_window_(root_window),
36 container_id_(container_id),
37 desktop_widget_(desktop_widget) { 36 desktop_widget_(desktop_widget) {
38 } 37 }
39 38
40 virtual ~ShowWallpaperAnimationObserver() { 39 virtual ~ShowWallpaperAnimationObserver() {
41 } 40 }
42 41
43 private: 42 private:
44 // Overridden from ui::ImplicitAnimationObserver: 43 // Overridden from ui::ImplicitAnimationObserver:
45 virtual void OnImplicitAnimationsCompleted() OVERRIDE { 44 virtual void OnImplicitAnimationsCompleted() OVERRIDE {
45 internal::RootWindowLayoutManager* root_window_layout =
46 static_cast<internal::RootWindowLayoutManager*>(
47 root_window_->layout_manager());
48 root_window_layout->SetBackgroundWidget(desktop_widget_);
49
46 ash::Shell::GetInstance()-> 50 ash::Shell::GetInstance()->
47 user_wallpaper_delegate()->OnWallpaperAnimationFinished(); 51 user_wallpaper_delegate()->OnWallpaperAnimationFinished();
48 52
49 MessageLoop::current()->DeleteSoon(FROM_HERE, this); 53 MessageLoop::current()->DeleteSoon(FROM_HERE, this);
50 } 54 }
51 55
52 aura::RootWindow* root_window_; 56 aura::RootWindow* root_window_;
53 int container_id_;
54 views::Widget* desktop_widget_; 57 views::Widget* desktop_widget_;
55 58
56 DISALLOW_COPY_AND_ASSIGN(ShowWallpaperAnimationObserver); 59 DISALLOW_COPY_AND_ASSIGN(ShowWallpaperAnimationObserver);
57 }; 60 };
58 61
59 } // namespace 62 } // namespace
60 63
61 // For our scaling ratios we need to round positive numbers. 64 // For our scaling ratios we need to round positive numbers.
62 static int RoundPositive(double x) { 65 static int RoundPositive(double x) {
63 return static_cast<int>(floor(x + 0.5)); 66 return static_cast<int>(floor(x + 0.5));
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 131
129 bool DesktopBackgroundView::OnMousePressed(const views::MouseEvent& event) { 132 bool DesktopBackgroundView::OnMousePressed(const views::MouseEvent& event) {
130 return true; 133 return true;
131 } 134 }
132 135
133 void DesktopBackgroundView::ShowContextMenuForView(views::View* source, 136 void DesktopBackgroundView::ShowContextMenuForView(views::View* source,
134 const gfx::Point& point) { 137 const gfx::Point& point) {
135 Shell::GetInstance()->ShowBackgroundMenu(GetWidget(), point); 138 Shell::GetInstance()->ShowBackgroundMenu(GetWidget(), point);
136 } 139 }
137 140
138 views::Widget* CreateDesktopBackground(aura::RootWindow* root_window, 141 void CreateDesktopBackground(aura::RootWindow* root_window) {
139 int container_id) {
140 DesktopBackgroundController* controller = ash::Shell::GetInstance()-> 142 DesktopBackgroundController* controller = ash::Shell::GetInstance()->
141 desktop_background_controller(); 143 desktop_background_controller();
142 views::Widget* desktop_widget = new views::Widget; 144 views::Widget* desktop_widget = new views::Widget;
143 views::Widget::InitParams params( 145 views::Widget::InitParams params(
144 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); 146 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
145 DesktopBackgroundView* view = new DesktopBackgroundView(); 147 DesktopBackgroundView* view = new DesktopBackgroundView();
146 params.delegate = view; 148 params.delegate = view;
147 if (controller->GetWallpaper().empty()) 149 if (controller->GetWallpaper().empty())
148 params.transparent = true; 150 params.transparent = true;
149 params.parent = root_window->GetChildById(container_id); 151 params.parent = root_window->GetChildById(
152 ash::internal::kShellWindowId_DesktopBackgroundContainer);
150 desktop_widget->Init(params); 153 desktop_widget->Init(params);
151 desktop_widget->SetContentsView(view); 154 desktop_widget->SetContentsView(view);
152 ash::WindowVisibilityAnimationType animation_type = 155 ash::WindowVisibilityAnimationType animation_type =
153 ash::Shell::GetInstance()->user_wallpaper_delegate()->GetAnimationType(); 156 ash::Shell::GetInstance()->user_wallpaper_delegate()->GetAnimationType();
154 ash::SetWindowVisibilityAnimationType(desktop_widget->GetNativeView(), 157 ash::SetWindowVisibilityAnimationType(desktop_widget->GetNativeView(),
155 animation_type); 158 animation_type);
156 ash::SetWindowVisibilityAnimationTransition(desktop_widget->GetNativeView(), 159 ash::SetWindowVisibilityAnimationTransition(desktop_widget->GetNativeView(),
157 ash::ANIMATE_SHOW); 160 ash::ANIMATE_SHOW);
158 desktop_widget->SetBounds(params.parent->bounds()); 161 desktop_widget->SetBounds(params.parent->bounds());
159 ui::ScopedLayerAnimationSettings settings( 162 ui::ScopedLayerAnimationSettings settings(
160 desktop_widget->GetNativeView()->layer()->GetAnimator()); 163 desktop_widget->GetNativeView()->layer()->GetAnimator());
161 settings.SetPreemptionStrategy(ui::LayerAnimator::ENQUEUE_NEW_ANIMATION); 164 settings.SetPreemptionStrategy(ui::LayerAnimator::ENQUEUE_NEW_ANIMATION);
162 settings.AddObserver(new ShowWallpaperAnimationObserver(root_window, 165 settings.AddObserver(new ShowWallpaperAnimationObserver(root_window,
163 container_id,
164 desktop_widget)); 166 desktop_widget));
165 desktop_widget->Show(); 167 desktop_widget->Show();
166 desktop_widget->GetNativeView()->SetName("DesktopBackgroundView"); 168 desktop_widget->GetNativeView()->SetName("DesktopBackgroundView");
167 return desktop_widget;
168 } 169 }
169 170
170 } // namespace internal 171 } // namespace internal
171 } // namespace ash 172 } // namespace ash
OLDNEW
« no previous file with comments | « ash/desktop_background/desktop_background_controller.cc ('k') | ash/desktop_background/desktop_background_widget_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698