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_widget_controller.h" | 5 #include "ash/wallpaper/wallpaper_widget_controller.h" |
6 | 6 |
7 #include "ash/ash_export.h" | 7 #include "ash/ash_export.h" |
8 #include "ash/root_window_controller.h" | 8 #include "ash/root_window_controller.h" |
9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
10 #include "ash/wallpaper/wallpaper_delegate.h" | 10 #include "ash/wallpaper/wallpaper_delegate.h" |
11 #include "ash/wm_window.h" | 11 #include "ui/aura/window.h" |
12 #include "ui/compositor/layer_animation_observer.h" | 12 #include "ui/compositor/layer_animation_observer.h" |
13 #include "ui/compositor/scoped_layer_animation_settings.h" | 13 #include "ui/compositor/scoped_layer_animation_settings.h" |
14 #include "ui/views/widget/widget.h" | 14 #include "ui/views/widget/widget.h" |
15 | 15 |
16 namespace ash { | 16 namespace ash { |
17 namespace { | 17 namespace { |
18 | 18 |
19 class ShowWallpaperAnimationObserver : public ui::ImplicitAnimationObserver, | 19 class ShowWallpaperAnimationObserver : public ui::ImplicitAnimationObserver, |
20 public views::WidgetObserver { | 20 public views::WidgetObserver { |
21 public: | 21 public: |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 | 55 |
56 // Is this object observing the initial brightness/grayscale animation? | 56 // Is this object observing the initial brightness/grayscale animation? |
57 const bool is_initial_animation_; | 57 const bool is_initial_animation_; |
58 | 58 |
59 DISALLOW_COPY_AND_ASSIGN(ShowWallpaperAnimationObserver); | 59 DISALLOW_COPY_AND_ASSIGN(ShowWallpaperAnimationObserver); |
60 }; | 60 }; |
61 | 61 |
62 } // namespace | 62 } // namespace |
63 | 63 |
64 WallpaperWidgetController::WallpaperWidgetController(views::Widget* widget) | 64 WallpaperWidgetController::WallpaperWidgetController(views::Widget* widget) |
65 : widget_(widget), | 65 : widget_(widget), widget_parent_(widget->GetNativeWindow()->parent()) { |
66 widget_parent_(WmWindow::Get(widget->GetNativeWindow())->GetParent()) { | |
67 DCHECK(widget_); | 66 DCHECK(widget_); |
68 widget_->AddObserver(this); | 67 widget_->AddObserver(this); |
69 widget_parent_->aura_window()->AddObserver(this); | 68 widget_parent_->AddObserver(this); |
70 } | 69 } |
71 | 70 |
72 WallpaperWidgetController::~WallpaperWidgetController() { | 71 WallpaperWidgetController::~WallpaperWidgetController() { |
73 if (widget_) { | 72 if (widget_) { |
74 views::Widget* widget = widget_; | 73 views::Widget* widget = widget_; |
75 RemoveObservers(); | 74 RemoveObservers(); |
76 widget->CloseNow(); | 75 widget->CloseNow(); |
77 } | 76 } |
78 } | 77 } |
79 | 78 |
80 void WallpaperWidgetController::OnWidgetDestroying(views::Widget* widget) { | 79 void WallpaperWidgetController::OnWidgetDestroying(views::Widget* widget) { |
81 RemoveObservers(); | 80 RemoveObservers(); |
82 } | 81 } |
83 | 82 |
84 void WallpaperWidgetController::SetBounds(const gfx::Rect& bounds) { | 83 void WallpaperWidgetController::SetBounds(const gfx::Rect& bounds) { |
85 if (widget_) | 84 if (widget_) |
86 widget_->SetBounds(bounds); | 85 widget_->SetBounds(bounds); |
87 } | 86 } |
88 | 87 |
89 bool WallpaperWidgetController::Reparent(WmWindow* root_window, int container) { | 88 bool WallpaperWidgetController::Reparent(aura::Window* root_window, |
| 89 int container) { |
90 if (widget_) { | 90 if (widget_) { |
91 widget_parent_->aura_window()->RemoveObserver(this); | 91 widget_parent_->RemoveObserver(this); |
92 WmWindow* window = WmWindow::Get(widget_->GetNativeWindow()); | 92 aura::Window* window = widget_->GetNativeWindow(); |
93 root_window->GetChildByShellWindowId(container)->AddChild(window); | 93 root_window->GetChildById(container)->AddChild(window); |
94 widget_parent_ = WmWindow::Get(widget_->GetNativeWindow())->GetParent(); | 94 widget_parent_ = widget_->GetNativeWindow()->parent(); |
95 widget_parent_->aura_window()->AddObserver(this); | 95 widget_parent_->AddObserver(this); |
96 return true; | 96 return true; |
97 } | 97 } |
98 // Nothing to reparent. | 98 // Nothing to reparent. |
99 return false; | 99 return false; |
100 } | 100 } |
101 | 101 |
102 void WallpaperWidgetController::RemoveObservers() { | 102 void WallpaperWidgetController::RemoveObservers() { |
103 widget_parent_->aura_window()->RemoveObserver(this); | 103 widget_parent_->RemoveObserver(this); |
104 widget_->RemoveObserver(this); | 104 widget_->RemoveObserver(this); |
105 widget_ = nullptr; | 105 widget_ = nullptr; |
106 } | 106 } |
107 | 107 |
108 void WallpaperWidgetController::OnWindowBoundsChanged( | 108 void WallpaperWidgetController::OnWindowBoundsChanged( |
109 aura::Window* window, | 109 aura::Window* window, |
110 const gfx::Rect& old_bounds, | 110 const gfx::Rect& old_bounds, |
111 const gfx::Rect& new_bounds) { | 111 const gfx::Rect& new_bounds) { |
112 SetBounds(new_bounds); | 112 SetBounds(new_bounds); |
113 } | 113 } |
(...skipping 26 matching lines...) Expand all Loading... |
140 } | 140 } |
141 | 141 |
142 WallpaperWidgetController* AnimatingWallpaperWidgetController::GetController( | 142 WallpaperWidgetController* AnimatingWallpaperWidgetController::GetController( |
143 bool pass_ownership) { | 143 bool pass_ownership) { |
144 if (pass_ownership) | 144 if (pass_ownership) |
145 return controller_.release(); | 145 return controller_.release(); |
146 return controller_.get(); | 146 return controller_.get(); |
147 } | 147 } |
148 | 148 |
149 } // namespace ash | 149 } // namespace ash |
OLD | NEW |