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/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" |
(...skipping 13 matching lines...) Expand all Loading... |
24 #include "ui/gfx/image/image.h" | 24 #include "ui/gfx/image/image.h" |
25 #include "ui/views/widget/widget.h" | 25 #include "ui/views/widget/widget.h" |
26 | 26 |
27 namespace ash { | 27 namespace ash { |
28 namespace internal { | 28 namespace internal { |
29 namespace { | 29 namespace { |
30 | 30 |
31 class ShowWallpaperAnimationObserver : public ui::ImplicitAnimationObserver { | 31 class ShowWallpaperAnimationObserver : public ui::ImplicitAnimationObserver { |
32 public: | 32 public: |
33 ShowWallpaperAnimationObserver(aura::RootWindow* root_window, | 33 ShowWallpaperAnimationObserver(aura::RootWindow* root_window, |
| 34 int container_id, |
34 views::Widget* desktop_widget) | 35 views::Widget* desktop_widget) |
35 : root_window_(root_window), | 36 : root_window_(root_window), |
| 37 container_id_(container_id), |
36 desktop_widget_(desktop_widget) { | 38 desktop_widget_(desktop_widget) { |
37 } | 39 } |
38 | 40 |
39 virtual ~ShowWallpaperAnimationObserver() { | 41 virtual ~ShowWallpaperAnimationObserver() { |
40 } | 42 } |
41 | 43 |
42 private: | 44 private: |
43 // Overridden from ui::ImplicitAnimationObserver: | 45 // Overridden from ui::ImplicitAnimationObserver: |
44 virtual void OnImplicitAnimationsCompleted() OVERRIDE { | 46 virtual void OnImplicitAnimationsCompleted() OVERRIDE { |
45 internal::RootWindowLayoutManager* root_window_layout = | 47 internal::RootWindowLayoutManager* root_window_layout = |
46 static_cast<internal::RootWindowLayoutManager*>( | 48 static_cast<internal::RootWindowLayoutManager*>( |
47 root_window_->layout_manager()); | 49 root_window_->layout_manager()); |
48 root_window_layout->SetBackgroundWidget(desktop_widget_); | 50 root_window_layout->SetBackgroundWidget(desktop_widget_, container_id_); |
49 | 51 |
50 ash::Shell::GetInstance()-> | 52 ash::Shell::GetInstance()-> |
51 user_wallpaper_delegate()->OnWallpaperAnimationFinished(); | 53 user_wallpaper_delegate()->OnWallpaperAnimationFinished(); |
52 | 54 |
53 MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 55 MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
54 } | 56 } |
55 | 57 |
56 aura::RootWindow* root_window_; | 58 aura::RootWindow* root_window_; |
| 59 int container_id_; |
57 views::Widget* desktop_widget_; | 60 views::Widget* desktop_widget_; |
58 | 61 |
59 DISALLOW_COPY_AND_ASSIGN(ShowWallpaperAnimationObserver); | 62 DISALLOW_COPY_AND_ASSIGN(ShowWallpaperAnimationObserver); |
60 }; | 63 }; |
61 | 64 |
62 } // namespace | 65 } // namespace |
63 | 66 |
64 // For our scaling ratios we need to round positive numbers. | 67 // For our scaling ratios we need to round positive numbers. |
65 static int RoundPositive(double x) { | 68 static int RoundPositive(double x) { |
66 return static_cast<int>(floor(x + 0.5)); | 69 return static_cast<int>(floor(x + 0.5)); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 | 134 |
132 bool DesktopBackgroundView::OnMousePressed(const views::MouseEvent& event) { | 135 bool DesktopBackgroundView::OnMousePressed(const views::MouseEvent& event) { |
133 return true; | 136 return true; |
134 } | 137 } |
135 | 138 |
136 void DesktopBackgroundView::ShowContextMenuForView(views::View* source, | 139 void DesktopBackgroundView::ShowContextMenuForView(views::View* source, |
137 const gfx::Point& point) { | 140 const gfx::Point& point) { |
138 Shell::GetInstance()->ShowBackgroundMenu(GetWidget(), point); | 141 Shell::GetInstance()->ShowBackgroundMenu(GetWidget(), point); |
139 } | 142 } |
140 | 143 |
141 void CreateDesktopBackground(aura::RootWindow* root_window) { | 144 void CreateDesktopBackground(aura::RootWindow* root_window, int container_id) { |
142 DesktopBackgroundController* controller = ash::Shell::GetInstance()-> | 145 DesktopBackgroundController* controller = ash::Shell::GetInstance()-> |
143 desktop_background_controller(); | 146 desktop_background_controller(); |
144 views::Widget* desktop_widget = new views::Widget; | 147 views::Widget* desktop_widget = new views::Widget; |
145 views::Widget::InitParams params( | 148 views::Widget::InitParams params( |
146 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); | 149 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); |
147 DesktopBackgroundView* view = new DesktopBackgroundView(); | 150 DesktopBackgroundView* view = new DesktopBackgroundView(); |
148 params.delegate = view; | 151 params.delegate = view; |
149 if (controller->GetWallpaper().empty()) | 152 if (controller->GetWallpaper().empty()) |
150 params.transparent = true; | 153 params.transparent = true; |
151 params.parent = root_window->GetChildById( | 154 params.parent = root_window->GetChildById(container_id); |
152 ash::internal::kShellWindowId_DesktopBackgroundContainer); | |
153 desktop_widget->Init(params); | 155 desktop_widget->Init(params); |
154 desktop_widget->SetContentsView(view); | 156 desktop_widget->SetContentsView(view); |
155 ash::SetWindowVisibilityAnimationType( | 157 ash::SetWindowVisibilityAnimationType( |
156 desktop_widget->GetNativeView(), | 158 desktop_widget->GetNativeView(), |
157 ash::WINDOW_VISIBILITY_ANIMATION_TYPE_FADE); | 159 ash::WINDOW_VISIBILITY_ANIMATION_TYPE_FADE); |
158 ash::SetWindowVisibilityAnimationTransition( | 160 ash::SetWindowVisibilityAnimationTransition( |
159 desktop_widget->GetNativeView(), | 161 desktop_widget->GetNativeView(), |
160 ash::ANIMATE_SHOW); | 162 ash::ANIMATE_SHOW); |
161 desktop_widget->SetBounds(params.parent->bounds()); | 163 desktop_widget->SetBounds(params.parent->bounds()); |
162 ui::ScopedLayerAnimationSettings settings(desktop_widget->GetNativeView()-> | 164 ui::ScopedLayerAnimationSettings settings(desktop_widget->GetNativeView()-> |
163 layer()->GetAnimator()); | 165 layer()->GetAnimator()); |
164 settings.SetPreemptionStrategy(ui::LayerAnimator::ENQUEUE_NEW_ANIMATION); | 166 settings.SetPreemptionStrategy(ui::LayerAnimator::ENQUEUE_NEW_ANIMATION); |
165 settings.AddObserver(new ShowWallpaperAnimationObserver(root_window, | 167 settings.AddObserver(new ShowWallpaperAnimationObserver(root_window, |
| 168 container_id, |
166 desktop_widget)); | 169 desktop_widget)); |
167 desktop_widget->Show(); | 170 desktop_widget->Show(); |
168 desktop_widget->GetNativeView()->SetName("DesktopBackgroundView"); | 171 desktop_widget->GetNativeView()->SetName("DesktopBackgroundView"); |
169 } | 172 } |
170 | 173 |
171 } // namespace internal | 174 } // namespace internal |
172 } // namespace ash | 175 } // namespace ash |
OLD | NEW |