Index: ash/desktop_background/desktop_background_widget_controller.cc |
diff --git a/ash/desktop_background/desktop_background_widget_controller.cc b/ash/desktop_background/desktop_background_widget_controller.cc |
index e4c2afa5df326e67750ae531c60df20326bff509..ae8f0cfc00e672c74995eb24cc576f23f7dd5e33 100644 |
--- a/ash/desktop_background/desktop_background_widget_controller.cc |
+++ b/ash/desktop_background/desktop_background_widget_controller.cc |
@@ -5,9 +5,12 @@ |
#include "ash/desktop_background/desktop_background_widget_controller.h" |
#include "ash/ash_export.h" |
+#include "ash/common/wm/wm_lookup.h" |
+#include "ash/common/wm/wm_window.h" |
#include "ash/desktop_background/user_wallpaper_delegate.h" |
#include "ash/root_window_controller.h" |
#include "ash/shell.h" |
+#include "ui/aura/window.h" |
#include "ui/aura/window_event_dispatcher.h" |
#include "ui/compositor/layer_animation_observer.h" |
#include "ui/compositor/scoped_layer_animation_settings.h" |
@@ -65,26 +68,29 @@ class ShowWallpaperAnimationObserver : public ui::ImplicitAnimationObserver, |
} // namespace |
DesktopBackgroundWidgetController::DesktopBackgroundWidgetController( |
- views::Widget* widget) : widget_(widget) { |
+ views::Widget* widget) |
+ : widget_(widget), |
+ widget_parent_( |
+ wm::WmLookup::Get()->GetWindowForWidget(widget)->GetParent()) { |
DCHECK(widget_); |
widget_->AddObserver(this); |
+ widget_parent_->AddObserver(this); |
} |
DesktopBackgroundWidgetController::~DesktopBackgroundWidgetController() { |
if (widget_) { |
- widget_->RemoveObserver(this); |
- widget_->CloseNow(); |
- widget_ = NULL; |
+ views::Widget* widget = widget_; |
+ RemoveObservers(); |
+ widget->CloseNow(); |
} |
} |
void DesktopBackgroundWidgetController::OnWidgetDestroying( |
views::Widget* widget) { |
- widget_->RemoveObserver(this); |
- widget_ = NULL; |
+ RemoveObservers(); |
} |
-void DesktopBackgroundWidgetController::SetBounds(gfx::Rect bounds) { |
+void DesktopBackgroundWidgetController::SetBounds(const gfx::Rect& bounds) { |
if (widget_) |
widget_->SetBounds(bounds); |
} |
@@ -93,14 +99,31 @@ bool DesktopBackgroundWidgetController::Reparent(aura::Window* root_window, |
int src_container, |
int dest_container) { |
if (widget_) { |
+ widget_parent_->RemoveObserver(this); |
views::Widget::ReparentNativeView(widget_->GetNativeView(), |
root_window->GetChildById(dest_container)); |
+ widget_parent_ = |
+ wm::WmLookup::Get()->GetWindowForWidget(widget_)->GetParent(); |
+ widget_parent_->AddObserver(this); |
return true; |
} |
// Nothing to reparent. |
return false; |
} |
+void DesktopBackgroundWidgetController::RemoveObservers() { |
+ widget_parent_->RemoveObserver(this); |
+ widget_->RemoveObserver(this); |
+ widget_ = nullptr; |
+} |
+ |
+void DesktopBackgroundWidgetController::OnWindowBoundsChanged( |
+ wm::WmWindow* window, |
+ const gfx::Rect& old_bounds, |
+ const gfx::Rect& new_bounds) { |
+ SetBounds(new_bounds); |
+} |
+ |
void DesktopBackgroundWidgetController::StartAnimating( |
RootWindowController* root_window_controller) { |
if (widget_) { |