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

Side by Side Diff: ash/wm/base_layout_manager.cc

Issue 11201002: Removes worskpace 1 code. Will rename next. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove constants and add back kDisableLoginAnimations Created 8 years, 2 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
« no previous file with comments | « ash/wm/base_layout_manager.h ('k') | ash/wm/frame_painter.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/wm/base_layout_manager.h" 5 #include "ash/wm/base_layout_manager.h"
6 6
7 #include "ash/ash_switches.h"
8 #include "ash/screen_ash.h" 7 #include "ash/screen_ash.h"
9 #include "ash/shell.h" 8 #include "ash/shell.h"
10 #include "ash/wm/shelf_layout_manager.h" 9 #include "ash/wm/shelf_layout_manager.h"
11 #include "ash/wm/window_animations.h" 10 #include "ash/wm/window_animations.h"
12 #include "ash/wm/window_properties.h" 11 #include "ash/wm/window_properties.h"
13 #include "ash/wm/window_util.h" 12 #include "ash/wm/window_util.h"
14 #include "ash/wm/workspace_controller.h"
15 #include "ash/wm/workspace/workspace_window_resizer.h" 13 #include "ash/wm/workspace/workspace_window_resizer.h"
16 #include "base/command_line.h"
17 #include "ui/aura/client/aura_constants.h" 14 #include "ui/aura/client/aura_constants.h"
18 #include "ui/aura/root_window.h" 15 #include "ui/aura/root_window.h"
19 #include "ui/aura/window.h" 16 #include "ui/aura/window.h"
20 #include "ui/base/ui_base_types.h" 17 #include "ui/base/ui_base_types.h"
21 #include "ui/compositor/layer.h" 18 #include "ui/compositor/layer.h"
22 #include "ui/gfx/screen.h" 19 #include "ui/gfx/screen.h"
23 20
24 namespace ash { 21 namespace ash {
25 namespace internal { 22 namespace internal {
26 23
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 61
65 void BaseLayoutManager::OnWindowResized() { 62 void BaseLayoutManager::OnWindowResized() {
66 } 63 }
67 64
68 void BaseLayoutManager::OnWindowAddedToLayout(aura::Window* child) { 65 void BaseLayoutManager::OnWindowAddedToLayout(aura::Window* child) {
69 windows_.insert(child); 66 windows_.insert(child);
70 child->AddObserver(this); 67 child->AddObserver(this);
71 // Only update the bounds if the window has a show state that depends on the 68 // Only update the bounds if the window has a show state that depends on the
72 // workspace area. 69 // workspace area.
73 if (wm::IsWindowMaximized(child) || wm::IsWindowFullscreen(child)) 70 if (wm::IsWindowMaximized(child) || wm::IsWindowFullscreen(child))
74 UpdateBoundsFromShowState(child, false); 71 UpdateBoundsFromShowState(child);
75 } 72 }
76 73
77 void BaseLayoutManager::OnWillRemoveWindowFromLayout(aura::Window* child) { 74 void BaseLayoutManager::OnWillRemoveWindowFromLayout(aura::Window* child) {
78 windows_.erase(child); 75 windows_.erase(child);
79 child->RemoveObserver(this); 76 child->RemoveObserver(this);
80 } 77 }
81 78
82 void BaseLayoutManager::OnWindowRemovedFromLayout(aura::Window* child) { 79 void BaseLayoutManager::OnWindowRemovedFromLayout(aura::Window* child) {
83 } 80 }
84 81
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 ui::WindowShowState new_state = 126 ui::WindowShowState new_state =
130 window->GetProperty(aura::client::kShowStateKey); 127 window->GetProperty(aura::client::kShowStateKey);
131 if (old_state != new_state && old_state != ui::SHOW_STATE_MINIMIZED && 128 if (old_state != new_state && old_state != ui::SHOW_STATE_MINIMIZED &&
132 !GetRestoreBoundsInScreen(window) && 129 !GetRestoreBoundsInScreen(window) &&
133 ((new_state == ui::SHOW_STATE_MAXIMIZED && 130 ((new_state == ui::SHOW_STATE_MAXIMIZED &&
134 old_state != ui::SHOW_STATE_FULLSCREEN) || 131 old_state != ui::SHOW_STATE_FULLSCREEN) ||
135 (new_state == ui::SHOW_STATE_FULLSCREEN && 132 (new_state == ui::SHOW_STATE_FULLSCREEN &&
136 old_state != ui::SHOW_STATE_MAXIMIZED))) { 133 old_state != ui::SHOW_STATE_MAXIMIZED))) {
137 SetRestoreBoundsInParent(window, window->bounds()); 134 SetRestoreBoundsInParent(window, window->bounds());
138 } 135 }
139 // Minimized state handles its own animations. 136 UpdateBoundsFromShowState(window);
140 // TODO(sky): get animations to work with Workspace2.
141 bool animate = (old_state != ui::SHOW_STATE_MINIMIZED) &&
142 !WorkspaceController::IsWorkspace2Enabled();
143 UpdateBoundsFromShowState(window, animate);
144 ShowStateChanged(window, old_state); 137 ShowStateChanged(window, old_state);
145 } 138 }
146 } 139 }
147 140
148 void BaseLayoutManager::OnWindowDestroying(aura::Window* window) { 141 void BaseLayoutManager::OnWindowDestroying(aura::Window* window) {
149 if (root_window_ == window) { 142 if (root_window_ == window) {
150 root_window_->RemoveObserver(this); 143 root_window_->RemoveObserver(this);
151 root_window_ = NULL; 144 root_window_ = NULL;
152 } 145 }
153 } 146 }
(...skipping 16 matching lines...) Expand all
170 wm::DeactivateWindow(window); 163 wm::DeactivateWindow(window);
171 } else if ((window->TargetVisibility() || 164 } else if ((window->TargetVisibility() ||
172 last_show_state == ui::SHOW_STATE_MINIMIZED) && 165 last_show_state == ui::SHOW_STATE_MINIMIZED) &&
173 !window->layer()->visible()) { 166 !window->layer()->visible()) {
174 // The layer may be hidden if the window was previously minimized. Make 167 // The layer may be hidden if the window was previously minimized. Make
175 // sure it's visible. 168 // sure it's visible.
176 window->Show(); 169 window->Show();
177 } 170 }
178 } 171 }
179 172
180 void BaseLayoutManager::UpdateBoundsFromShowState(aura::Window* window, 173 void BaseLayoutManager::UpdateBoundsFromShowState(aura::Window* window) {
181 bool animate) {
182 switch (window->GetProperty(aura::client::kShowStateKey)) { 174 switch (window->GetProperty(aura::client::kShowStateKey)) {
183 case ui::SHOW_STATE_DEFAULT: 175 case ui::SHOW_STATE_DEFAULT:
184 case ui::SHOW_STATE_NORMAL: { 176 case ui::SHOW_STATE_NORMAL: {
185 const gfx::Rect* restore = GetRestoreBoundsInScreen(window); 177 const gfx::Rect* restore = GetRestoreBoundsInScreen(window);
186 if (restore) { 178 if (restore) {
187 gfx::Rect bounds_in_parent = 179 gfx::Rect bounds_in_parent =
188 ScreenAsh::ConvertRectFromScreen(window->parent(), *restore); 180 ScreenAsh::ConvertRectFromScreen(window->parent(), *restore);
189 MaybeAnimateToBounds(window, 181 SetChildBoundsDirect(window,
190 animate,
191 BoundsWithScreenEdgeVisible(window, 182 BoundsWithScreenEdgeVisible(window,
192 bounds_in_parent)); 183 bounds_in_parent));
193 } 184 }
194 window->ClearProperty(aura::client::kRestoreBoundsKey); 185 window->ClearProperty(aura::client::kRestoreBoundsKey);
195 break; 186 break;
196 } 187 }
197 188
198 case ui::SHOW_STATE_MAXIMIZED: 189 case ui::SHOW_STATE_MAXIMIZED:
199 MaybeAnimateToBounds(window, 190 SetChildBoundsDirect(window,
200 animate,
201 ScreenAsh::GetMaximizedWindowBoundsInParent(window)); 191 ScreenAsh::GetMaximizedWindowBoundsInParent(window));
202 break; 192 break;
203 193
204 case ui::SHOW_STATE_FULLSCREEN: 194 case ui::SHOW_STATE_FULLSCREEN:
205 // Don't animate the full-screen window transition. 195 // Don't animate the full-screen window transition.
206 // TODO(jamescook): Use animation here. Be sure the lock screen works. 196 // TODO(jamescook): Use animation here. Be sure the lock screen works.
207 SetChildBoundsDirect( 197 SetChildBoundsDirect(
208 window, ScreenAsh::GetDisplayBoundsInParent(window)); 198 window, ScreenAsh::GetDisplayBoundsInParent(window));
209 break; 199 break;
210 200
211 default: 201 default:
212 break; 202 break;
213 } 203 }
214 } 204 }
215 205
216 void BaseLayoutManager::MaybeAnimateToBounds(aura::Window* window,
217 bool animate,
218 const gfx::Rect& new_bounds) {
219 // Only animate visible windows.
220 if (animate &&
221 window->TargetVisibility() &&
222 !window->GetProperty(aura::client::kAnimationsDisabledKey) &&
223 !CommandLine::ForCurrentProcess()->HasSwitch(
224 ash::switches::kAshWindowAnimationsDisabled)) {
225 CrossFadeToBounds(window, new_bounds);
226 return;
227 }
228 SetChildBoundsDirect(window, new_bounds);
229 }
230
231 void BaseLayoutManager::AdjustWindowSizesForScreenChange() { 206 void BaseLayoutManager::AdjustWindowSizesForScreenChange() {
232 // If a user plugs an external display into a laptop running Aura the 207 // If a user plugs an external display into a laptop running Aura the
233 // display size will change. Maximized windows need to resize to match. 208 // display size will change. Maximized windows need to resize to match.
234 // We also do this when developers running Aura on a desktop manually resize 209 // We also do this when developers running Aura on a desktop manually resize
235 // the host window. 210 // the host window.
236 // We also need to do this when the work area insets changes. 211 // We also need to do this when the work area insets changes.
237 for (WindowSet::const_iterator it = windows_.begin(); 212 for (WindowSet::const_iterator it = windows_.begin();
238 it != windows_.end(); 213 it != windows_.end();
239 ++it) { 214 ++it) {
240 aura::Window* window = *it; 215 aura::Window* window = *it;
241 if (wm::IsWindowMaximized(window)) { 216 if (wm::IsWindowMaximized(window)) {
242 SetChildBoundsDirect( 217 SetChildBoundsDirect(
243 window, ScreenAsh::GetMaximizedWindowBoundsInParent(window)); 218 window, ScreenAsh::GetMaximizedWindowBoundsInParent(window));
244 } else if (wm::IsWindowFullscreen(window)) { 219 } else if (wm::IsWindowFullscreen(window)) {
245 SetChildBoundsDirect( 220 SetChildBoundsDirect(
246 window, ScreenAsh::GetDisplayBoundsInParent(window)); 221 window, ScreenAsh::GetDisplayBoundsInParent(window));
247 } else { 222 } else {
248 // The work area may be smaller than the full screen. 223 // The work area may be smaller than the full screen.
249 gfx::Rect display_rect = 224 gfx::Rect display_rect =
250 ScreenAsh::GetDisplayWorkAreaBoundsInParent(window); 225 ScreenAsh::GetDisplayWorkAreaBoundsInParent(window);
251 // Put as much of the window as possible within the display area. 226 // Put as much of the window as possible within the display area.
252 window->SetBounds(window->bounds().AdjustToFit(display_rect)); 227 window->SetBounds(window->bounds().AdjustToFit(display_rect));
253 } 228 }
254 } 229 }
255 } 230 }
256 231
257 } // namespace internal 232 } // namespace internal
258 } // namespace ash 233 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/base_layout_manager.h ('k') | ash/wm/frame_painter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698