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

Side by Side Diff: ash/wm/workspace/workspace_layout_manager.cc

Issue 19460014: Do not create workspace for fullscreen. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 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
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/workspace/workspace_layout_manager.h" 5 #include "ash/wm/workspace/workspace_layout_manager.h"
6 6
7 #include "ash/root_window_controller.h" 7 #include "ash/root_window_controller.h"
8 #include "ash/screen_ash.h" 8 #include "ash/screen_ash.h"
9 #include "ash/session_state_delegate.h" 9 #include "ash/session_state_delegate.h"
10 #include "ash/shell.h" 10 #include "ash/shell.h"
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 gfx::Rect restore; 184 gfx::Rect restore;
185 if (old_state == ui::SHOW_STATE_MINIMIZED && 185 if (old_state == ui::SHOW_STATE_MINIMIZED &&
186 (new_state == ui::SHOW_STATE_NORMAL || 186 (new_state == ui::SHOW_STATE_NORMAL ||
187 new_state == ui::SHOW_STATE_DEFAULT) && 187 new_state == ui::SHOW_STATE_DEFAULT) &&
188 GetRestoreBoundsInScreen(window) && 188 GetRestoreBoundsInScreen(window) &&
189 !GetWindowAlwaysRestoresToRestoreBounds(window)) { 189 !GetWindowAlwaysRestoresToRestoreBounds(window)) {
190 restore = *GetRestoreBoundsInScreen(window); 190 restore = *GetRestoreBoundsInScreen(window);
191 SetRestoreBoundsInScreen(window, window->GetBoundsInScreen()); 191 SetRestoreBoundsInScreen(window, window->GetBoundsInScreen());
192 } 192 }
193 193
194 // If the new state requires |window| to be in a workspace, clone the layer.
195 // WorkspaceManager will use it (and take ownership of it) when animating.
196 // Ideally we could use that of BaseLayoutManager, but that proves
197 // problematic. In particular when restoring we need to animate on top of
198 // the workspace animating in.
199 ui::Layer* cloned_layer = NULL;
200 BoundsMap bounds_map;
201 if (wm::IsActiveWindow(window) &&
202 ((new_state == ui::SHOW_STATE_FULLSCREEN &&
203 wm::IsWindowStateNormal(old_state)) ||
204 (new_state != ui::SHOW_STATE_FULLSCREEN &&
205 old_state == ui::SHOW_STATE_FULLSCREEN &&
206 new_state != ui::SHOW_STATE_MINIMIZED))) {
207 BuildWindowBoundsMap(window, &bounds_map);
208 cloned_layer = views::corewm::RecreateWindowLayers(window, false);
209 // Constrained windows don't get their bounds reset when we update the
210 // window bounds. Leaving them empty is unexpected, so we reset them now.
211 ResetConstrainedWindowBoundsIfNecessary(bounds_map, window);
212 }
213 UpdateBoundsFromShowState(window); 194 UpdateBoundsFromShowState(window);
214 195 ShowStateChanged(window, old_state);
215 if (cloned_layer) {
216 // Even though we just set the bounds not all descendants may have valid
217 // bounds. For example, constrained windows don't resize with the parent.
218 // Ensure that all windows that had a bounds before we cloned the layer
219 // have a bounds now.
220 ResetBoundsIfNecessary(bounds_map, window);
221 }
222
223 ShowStateChanged(window, old_state, cloned_layer);
224 196
225 // Set the restore rectangle to the previously set restore rectangle. 197 // Set the restore rectangle to the previously set restore rectangle.
226 if (!restore.IsEmpty()) 198 if (!restore.IsEmpty())
227 SetRestoreBoundsInScreen(window, restore); 199 SetRestoreBoundsInScreen(window, restore);
228 } 200 }
229 201
230 if (key == internal::kWindowTrackedByWorkspaceKey && 202 if (key == internal::kWindowTrackedByWorkspaceKey &&
231 GetTrackedByWorkspace(window)) { 203 GetTrackedByWorkspace(window)) {
232 workspace_manager()->OnTrackedByWorkspaceChanged(workspace_, window); 204 workspace_manager()->OnTrackedByWorkspaceChanged(workspace_, window);
233 if (wm::IsWindowMaximized(window)) 205 SetMaximizedOrFullscreenBounds(window);
234 SetMaximizedOrFullscreenBounds(window);
235 } 206 }
236 207
237 if (key == aura::client::kAlwaysOnTopKey && 208 if (key == aura::client::kAlwaysOnTopKey &&
238 window->GetProperty(aura::client::kAlwaysOnTopKey)) { 209 window->GetProperty(aura::client::kAlwaysOnTopKey)) {
239 internal::AlwaysOnTopController* controller = 210 internal::AlwaysOnTopController* controller =
240 GetRootWindowController(window->GetRootWindow())-> 211 GetRootWindowController(window->GetRootWindow())->
241 always_on_top_controller(); 212 always_on_top_controller();
242 controller->GetContainer(window)->AddChild(window); 213 controller->GetContainer(window)->AddChild(window);
243 } 214 }
244 } 215 }
245 216
246 void WorkspaceLayoutManager::OnWindowDestroying(aura::Window* window) { 217 void WorkspaceLayoutManager::OnWindowDestroying(aura::Window* window) {
247 if (root_window_ == window) { 218 if (root_window_ == window) {
248 root_window_->RemoveObserver(this); 219 root_window_->RemoveObserver(this);
249 root_window_ = NULL; 220 root_window_ = NULL;
250 } 221 }
251 } 222 }
252 223
253 void WorkspaceLayoutManager::OnWindowBoundsChanged( 224 void WorkspaceLayoutManager::OnWindowBoundsChanged(
254 aura::Window* window, 225 aura::Window* window,
255 const gfx::Rect& old_bounds, 226 const gfx::Rect& old_bounds,
256 const gfx::Rect& new_bounds) { 227 const gfx::Rect& new_bounds) {
257 if (root_window_ == window) 228 if (root_window_ == window)
258 AdjustWindowSizesForScreenChange(ADJUST_WINDOW_SCREEN_SIZE_CHANGED); 229 AdjustWindowSizesForScreenChange(ADJUST_WINDOW_SCREEN_SIZE_CHANGED);
259 } 230 }
260 231
261 void WorkspaceLayoutManager::ShowStateChanged( 232 void WorkspaceLayoutManager::ShowStateChanged(
262 Window* window, 233 Window* window,
263 ui::WindowShowState last_show_state, 234 ui::WindowShowState last_show_state) {
264 ui::Layer* cloned_layer) {
265 if (wm::IsWindowMinimized(window)) { 235 if (wm::IsWindowMinimized(window)) {
266 DCHECK(!cloned_layer);
267 // Save the previous show state so that we can correctly restore it. 236 // Save the previous show state so that we can correctly restore it.
268 window->SetProperty(aura::client::kRestoreShowStateKey, last_show_state); 237 window->SetProperty(aura::client::kRestoreShowStateKey, last_show_state);
269 views::corewm::SetWindowVisibilityAnimationType( 238 views::corewm::SetWindowVisibilityAnimationType(
270 window, WINDOW_VISIBILITY_ANIMATION_TYPE_MINIMIZE); 239 window, WINDOW_VISIBILITY_ANIMATION_TYPE_MINIMIZE);
271 workspace_manager()->OnWorkspaceWindowShowStateChanged( 240 workspace_manager()->OnWorkspaceWindowShowStateChanged(
272 workspace_, window, last_show_state, NULL); 241 workspace_, window, last_show_state);
273 window->Hide(); 242 window->Hide();
274 if (wm::IsActiveWindow(window)) 243 if (wm::IsActiveWindow(window))
275 wm::DeactivateWindow(window); 244 wm::DeactivateWindow(window);
276 } else { 245 } else {
277 if ((window->TargetVisibility() || 246 if ((window->TargetVisibility() ||
278 last_show_state == ui::SHOW_STATE_MINIMIZED) && 247 last_show_state == ui::SHOW_STATE_MINIMIZED) &&
279 !window->layer()->visible()) { 248 !window->layer()->visible()) {
280 // The layer may be hidden if the window was previously minimized. Make 249 // The layer may be hidden if the window was previously minimized. Make
281 // sure it's visible. 250 // sure it's visible.
282 window->Show(); 251 window->Show();
283 } 252 }
284 if (last_show_state == ui::SHOW_STATE_MINIMIZED && 253 if (last_show_state == ui::SHOW_STATE_MINIMIZED &&
285 !wm::IsWindowMaximized(window) && 254 !wm::IsWindowMaximized(window) &&
286 !wm::IsWindowFullscreen(window)) { 255 !wm::IsWindowFullscreen(window)) {
287 window->ClearProperty(internal::kWindowRestoresToRestoreBounds); 256 window->ClearProperty(internal::kWindowRestoresToRestoreBounds);
288 } 257 }
289 workspace_manager()->OnWorkspaceWindowShowStateChanged( 258 workspace_manager()->OnWorkspaceWindowShowStateChanged(
290 workspace_, window, last_show_state, cloned_layer); 259 workspace_, window, last_show_state);
291 } 260 }
292 } 261 }
293 262
294 void WorkspaceLayoutManager::AdjustWindowSizesForScreenChange( 263 void WorkspaceLayoutManager::AdjustWindowSizesForScreenChange(
295 AdjustWindowReason reason) { 264 AdjustWindowReason reason) {
296 // Don't do any adjustments of the insets while we are in screen locked mode. 265 // Don't do any adjustments of the insets while we are in screen locked mode.
297 // This would happen if the launcher was auto hidden before the login screen 266 // This would happen if the launcher was auto hidden before the login screen
298 // was shown and then gets shown when the login screen gets presented. 267 // was shown and then gets shown when the login screen gets presented.
299 if (reason == ADJUST_WINDOW_DISPLAY_INSETS_CHANGED && 268 if (reason == ADJUST_WINDOW_DISPLAY_INSETS_CHANGED &&
300 Shell::GetInstance()->session_state_delegate()->IsScreenLocked()) 269 Shell::GetInstance()->session_state_delegate()->IsScreenLocked())
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 } 341 }
373 ClearRestoreBounds(window); 342 ClearRestoreBounds(window);
374 break; 343 break;
375 } 344 }
376 345
377 case ui::SHOW_STATE_MAXIMIZED: 346 case ui::SHOW_STATE_MAXIMIZED:
378 CrossFadeToBounds(window, ScreenAsh::GetMaximizedWindowBoundsInParent( 347 CrossFadeToBounds(window, ScreenAsh::GetMaximizedWindowBoundsInParent(
379 window->parent()->parent())); 348 window->parent()->parent()));
380 break; 349 break;
381 case ui::SHOW_STATE_FULLSCREEN: 350 case ui::SHOW_STATE_FULLSCREEN:
382 SetMaximizedOrFullscreenBounds(window); 351 CrossFadeToBounds(window, ScreenAsh::GetDisplayBoundsInParent(
352 window->parent()->parent()));
383 break; 353 break;
384 354
385 default: 355 default:
386 break; 356 break;
387 } 357 }
388 } 358 }
389 359
390 bool WorkspaceLayoutManager::SetMaximizedOrFullscreenBounds( 360 bool WorkspaceLayoutManager::SetMaximizedOrFullscreenBounds(
391 aura::Window* window) { 361 aura::Window* window) {
392 if (!GetTrackedByWorkspace(window)) 362 if (!GetTrackedByWorkspace(window))
(...skipping 16 matching lines...) Expand all
409 } 379 }
410 return false; 380 return false;
411 } 381 }
412 382
413 WorkspaceManager* WorkspaceLayoutManager::workspace_manager() { 383 WorkspaceManager* WorkspaceLayoutManager::workspace_manager() {
414 return workspace_->workspace_manager(); 384 return workspace_->workspace_manager();
415 } 385 }
416 386
417 } // namespace internal 387 } // namespace internal
418 } // namespace ash 388 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698