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

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

Issue 2032613002: Converts RootWindowLayoutManager to common types (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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/desktop_background/desktop_background_widget_controller.h" 5 #include "ash/desktop_background/desktop_background_widget_controller.h"
6 6
7 #include "ash/ash_export.h" 7 #include "ash/ash_export.h"
8 #include "ash/common/wm/wm_lookup.h"
9 #include "ash/common/wm/wm_window.h"
8 #include "ash/desktop_background/user_wallpaper_delegate.h" 10 #include "ash/desktop_background/user_wallpaper_delegate.h"
9 #include "ash/root_window_controller.h" 11 #include "ash/root_window_controller.h"
10 #include "ash/shell.h" 12 #include "ash/shell.h"
13 #include "ui/aura/window.h"
11 #include "ui/aura/window_event_dispatcher.h" 14 #include "ui/aura/window_event_dispatcher.h"
12 #include "ui/compositor/layer_animation_observer.h" 15 #include "ui/compositor/layer_animation_observer.h"
13 #include "ui/compositor/scoped_layer_animation_settings.h" 16 #include "ui/compositor/scoped_layer_animation_settings.h"
14 #include "ui/views/widget/widget.h" 17 #include "ui/views/widget/widget.h"
15 #include "ui/views/widget/widget_observer.h" 18 #include "ui/views/widget/widget_observer.h"
16 19
17 namespace ash { 20 namespace ash {
18 namespace { 21 namespace {
19 22
20 class ShowWallpaperAnimationObserver : public ui::ImplicitAnimationObserver, 23 class ShowWallpaperAnimationObserver : public ui::ImplicitAnimationObserver,
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 61
59 // Is this object observing the initial brightness/grayscale animation? 62 // Is this object observing the initial brightness/grayscale animation?
60 const bool is_initial_animation_; 63 const bool is_initial_animation_;
61 64
62 DISALLOW_COPY_AND_ASSIGN(ShowWallpaperAnimationObserver); 65 DISALLOW_COPY_AND_ASSIGN(ShowWallpaperAnimationObserver);
63 }; 66 };
64 67
65 } // namespace 68 } // namespace
66 69
67 DesktopBackgroundWidgetController::DesktopBackgroundWidgetController( 70 DesktopBackgroundWidgetController::DesktopBackgroundWidgetController(
68 views::Widget* widget) : widget_(widget) { 71 views::Widget* widget)
72 : widget_(widget),
73 widget_parent_(
74 wm::WmLookup::Get()->GetWindowForWidget(widget)->GetParent()) {
69 DCHECK(widget_); 75 DCHECK(widget_);
70 widget_->AddObserver(this); 76 widget_->AddObserver(this);
77 widget_parent_->AddObserver(this);
71 } 78 }
72 79
73 DesktopBackgroundWidgetController::~DesktopBackgroundWidgetController() { 80 DesktopBackgroundWidgetController::~DesktopBackgroundWidgetController() {
74 if (widget_) { 81 if (widget_) {
75 widget_->RemoveObserver(this); 82 views::Widget* widget = widget_;
76 widget_->CloseNow(); 83 RemoveObservers();
77 widget_ = NULL; 84 widget->CloseNow();
78 } 85 }
79 } 86 }
80 87
81 void DesktopBackgroundWidgetController::OnWidgetDestroying( 88 void DesktopBackgroundWidgetController::OnWidgetDestroying(
82 views::Widget* widget) { 89 views::Widget* widget) {
83 widget_->RemoveObserver(this); 90 RemoveObservers();
84 widget_ = NULL;
85 } 91 }
86 92
87 void DesktopBackgroundWidgetController::SetBounds(gfx::Rect bounds) { 93 void DesktopBackgroundWidgetController::SetBounds(const gfx::Rect& bounds) {
88 if (widget_) 94 if (widget_)
89 widget_->SetBounds(bounds); 95 widget_->SetBounds(bounds);
90 } 96 }
91 97
92 bool DesktopBackgroundWidgetController::Reparent(aura::Window* root_window, 98 bool DesktopBackgroundWidgetController::Reparent(aura::Window* root_window,
93 int src_container, 99 int src_container,
94 int dest_container) { 100 int dest_container) {
95 if (widget_) { 101 if (widget_) {
102 widget_parent_->RemoveObserver(this);
96 views::Widget::ReparentNativeView(widget_->GetNativeView(), 103 views::Widget::ReparentNativeView(widget_->GetNativeView(),
97 root_window->GetChildById(dest_container)); 104 root_window->GetChildById(dest_container));
105 widget_parent_ =
106 wm::WmLookup::Get()->GetWindowForWidget(widget_)->GetParent();
107 widget_parent_->AddObserver(this);
98 return true; 108 return true;
99 } 109 }
100 // Nothing to reparent. 110 // Nothing to reparent.
101 return false; 111 return false;
102 } 112 }
103 113
114 void DesktopBackgroundWidgetController::RemoveObservers() {
115 widget_parent_->RemoveObserver(this);
116 widget_->RemoveObserver(this);
117 widget_ = nullptr;
118 }
119
120 void DesktopBackgroundWidgetController::OnWindowBoundsChanged(
121 wm::WmWindow* window,
122 const gfx::Rect& old_bounds,
123 const gfx::Rect& new_bounds) {
124 SetBounds(new_bounds);
125 }
126
104 void DesktopBackgroundWidgetController::StartAnimating( 127 void DesktopBackgroundWidgetController::StartAnimating(
105 RootWindowController* root_window_controller) { 128 RootWindowController* root_window_controller) {
106 if (widget_) { 129 if (widget_) {
107 ui::ScopedLayerAnimationSettings settings( 130 ui::ScopedLayerAnimationSettings settings(
108 widget_->GetNativeView()->layer()->GetAnimator()); 131 widget_->GetNativeView()->layer()->GetAnimator());
109 settings.AddObserver(new ShowWallpaperAnimationObserver( 132 settings.AddObserver(new ShowWallpaperAnimationObserver(
110 root_window_controller, widget_, 133 root_window_controller, widget_,
111 Shell::GetInstance()->user_wallpaper_delegate()-> 134 Shell::GetInstance()->user_wallpaper_delegate()->
112 ShouldShowInitialAnimation())); 135 ShouldShowInitialAnimation()));
113 // When |widget_| shows, AnimateShowWindowCommon() is called to do the 136 // When |widget_| shows, AnimateShowWindowCommon() is called to do the
(...skipping 20 matching lines...) Expand all
134 } 157 }
135 158
136 DesktopBackgroundWidgetController* AnimatingDesktopController::GetController( 159 DesktopBackgroundWidgetController* AnimatingDesktopController::GetController(
137 bool pass_ownership) { 160 bool pass_ownership) {
138 if (pass_ownership) 161 if (pass_ownership)
139 return controller_.release(); 162 return controller_.release();
140 return controller_.get(); 163 return controller_.get();
141 } 164 }
142 165
143 } // namespace ash 166 } // namespace ash
OLDNEW
« no previous file with comments | « ash/desktop_background/desktop_background_widget_controller.h ('k') | ash/root_window_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698