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/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 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 for (WindowSet::const_iterator it = windows_.begin(); | 309 for (WindowSet::const_iterator it = windows_.begin(); |
310 it != windows_.end(); | 310 it != windows_.end(); |
311 ++it) { | 311 ++it) { |
312 AdjustWindowSizeForScreenChange(*it, reason); | 312 AdjustWindowSizeForScreenChange(*it, reason); |
313 } | 313 } |
314 } | 314 } |
315 | 315 |
316 void WorkspaceLayoutManager::AdjustWindowSizeForScreenChange( | 316 void WorkspaceLayoutManager::AdjustWindowSizeForScreenChange( |
317 Window* window, | 317 Window* window, |
318 AdjustWindowReason reason) { | 318 AdjustWindowReason reason) { |
319 if (GetTrackedByWorkspace(window) && | 319 if (!GetTrackedByWorkspace(window)) |
320 !SetMaximizedOrFullscreenBounds(window)) { | 320 return; |
321 if (reason == ADJUST_WINDOW_SCREEN_SIZE_CHANGED) { | 321 |
322 // The work area may be smaller than the full screen. Put as much of the | 322 // Use cross fade transition for the maximized window if the adjustment |
323 // window as possible within the display area. | 323 // happens due to the shelf's visibility change. Otherwise the background |
324 gfx::Rect bounds = window->bounds(); | 324 // can be seen slightly between the bottom edge of resized-window and |
325 bounds.AdjustToFit(work_area_); | 325 // the animating shelf. |
326 window->SetBounds(bounds); | 326 // TODO(mukai): this cause slight blur at the window frame because of the |
327 } else if (reason == ADJUST_WINDOW_DISPLAY_INSETS_CHANGED) { | 327 // cross fade. I think this is better, but should reconsider if someone |
328 gfx::Rect bounds = window->bounds(); | 328 // raises voice for this. |
329 ash::wm::AdjustBoundsToEnsureMinimumWindowVisibility(work_area_, &bounds); | 329 if (wm::IsWindowMaximized(window) && |
330 if (window->bounds() != bounds) | 330 reason == ADJUST_WINDOW_DISPLAY_INSETS_CHANGED) { |
331 window->SetBounds(bounds); | 331 CrossFadeToBounds(window, ScreenAsh::GetMaximizedWindowBoundsInParent( |
332 } else if (reason == ADJUST_WINDOW_WINDOW_ADDED) { | 332 window->parent()->parent())); |
333 gfx::Rect bounds = window->bounds(); | 333 return; |
334 int min_width = bounds.width() * kMinimumPercentOnScreenArea; | |
335 int min_height = bounds.height() * kMinimumPercentOnScreenArea; | |
336 ash::wm::AdjustBoundsToEnsureWindowVisibility( | |
337 work_area_, min_width, min_height, &bounds); | |
338 if (window->bounds() != bounds) | |
339 window->SetBounds(bounds); | |
340 } | |
341 } | 334 } |
| 335 |
| 336 if (SetMaximizedOrFullscreenBounds(window)) |
| 337 return; |
| 338 |
| 339 gfx::Rect bounds = window->bounds(); |
| 340 if (reason == ADJUST_WINDOW_SCREEN_SIZE_CHANGED) { |
| 341 // The work area may be smaller than the full screen. Put as much of the |
| 342 // window as possible within the display area. |
| 343 bounds.AdjustToFit(work_area_); |
| 344 } else if (reason == ADJUST_WINDOW_DISPLAY_INSETS_CHANGED) { |
| 345 ash::wm::AdjustBoundsToEnsureMinimumWindowVisibility(work_area_, &bounds); |
| 346 } else if (reason == ADJUST_WINDOW_WINDOW_ADDED) { |
| 347 int min_width = bounds.width() * kMinimumPercentOnScreenArea; |
| 348 int min_height = bounds.height() * kMinimumPercentOnScreenArea; |
| 349 ash::wm::AdjustBoundsToEnsureWindowVisibility( |
| 350 work_area_, min_width, min_height, &bounds); |
| 351 } |
| 352 if (window->bounds() != bounds) |
| 353 window->SetBounds(bounds); |
342 } | 354 } |
343 | 355 |
344 void WorkspaceLayoutManager::UpdateBoundsFromShowState(Window* window) { | 356 void WorkspaceLayoutManager::UpdateBoundsFromShowState(Window* window) { |
345 // See comment in SetMaximizedOrFullscreenBounds() as to why we use parent in | 357 // See comment in SetMaximizedOrFullscreenBounds() as to why we use parent in |
346 // these calculation. | 358 // these calculation. |
347 switch (window->GetProperty(aura::client::kShowStateKey)) { | 359 switch (window->GetProperty(aura::client::kShowStateKey)) { |
348 case ui::SHOW_STATE_DEFAULT: | 360 case ui::SHOW_STATE_DEFAULT: |
349 case ui::SHOW_STATE_NORMAL: { | 361 case ui::SHOW_STATE_NORMAL: { |
350 const gfx::Rect* restore = GetRestoreBoundsInScreen(window); | 362 const gfx::Rect* restore = GetRestoreBoundsInScreen(window); |
351 if (restore) { | 363 if (restore) { |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 } | 409 } |
398 return false; | 410 return false; |
399 } | 411 } |
400 | 412 |
401 WorkspaceManager* WorkspaceLayoutManager::workspace_manager() { | 413 WorkspaceManager* WorkspaceLayoutManager::workspace_manager() { |
402 return workspace_->workspace_manager(); | 414 return workspace_->workspace_manager(); |
403 } | 415 } |
404 | 416 |
405 } // namespace internal | 417 } // namespace internal |
406 } // namespace ash | 418 } // namespace ash |
OLD | NEW |