| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/default_state.h" | 5 #include "ash/wm/default_state.h" |
| 6 | 6 |
| 7 #include "ash/display/display_controller.h" | 7 #include "ash/display/display_controller.h" |
| 8 #include "ash/screen_util.h" | 8 #include "ash/screen_util.h" |
| 9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 10 #include "ash/shell_window_ids.h" | 10 #include "ash/shell_window_ids.h" |
| (...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 504 case WINDOW_STATE_TYPE_LEFT_SNAPPED: | 504 case WINDOW_STATE_TYPE_LEFT_SNAPPED: |
| 505 case WINDOW_STATE_TYPE_RIGHT_SNAPPED: | 505 case WINDOW_STATE_TYPE_RIGHT_SNAPPED: |
| 506 bounds_in_parent = state_type_ == WINDOW_STATE_TYPE_LEFT_SNAPPED ? | 506 bounds_in_parent = state_type_ == WINDOW_STATE_TYPE_LEFT_SNAPPED ? |
| 507 GetDefaultLeftSnappedWindowBoundsInParent(window_state->window()) : | 507 GetDefaultLeftSnappedWindowBoundsInParent(window_state->window()) : |
| 508 GetDefaultRightSnappedWindowBoundsInParent(window_state->window()); | 508 GetDefaultRightSnappedWindowBoundsInParent(window_state->window()); |
| 509 break; | 509 break; |
| 510 case WINDOW_STATE_TYPE_DEFAULT: | 510 case WINDOW_STATE_TYPE_DEFAULT: |
| 511 case WINDOW_STATE_TYPE_NORMAL: { | 511 case WINDOW_STATE_TYPE_NORMAL: { |
| 512 gfx::Rect work_area_in_parent = | 512 gfx::Rect work_area_in_parent = |
| 513 ScreenUtil::GetDisplayWorkAreaBoundsInParent(window_state->window()); | 513 ScreenUtil::GetDisplayWorkAreaBoundsInParent(window_state->window()); |
| 514 if (window_state->HasRestoreBounds()) | 514 if (window_state->HasRestoreBounds()) { |
| 515 bounds_in_parent = window_state->GetRestoreBoundsInParent(); | 515 bounds_in_parent = window_state->GetRestoreBoundsInParent(); |
| 516 else | 516 // Check if the |window|'s restored size is bigger than the working area |
| 517 // This may happen if a window was resized to maximized bounds or if the |
| 518 // display resolution changed while the window was maximized. |
| 519 if (previous_state_type == WINDOW_STATE_TYPE_MAXIMIZED && |
| 520 bounds_in_parent.width() >= work_area_in_parent.width() && |
| 521 bounds_in_parent.height() >= work_area_in_parent.height()) { |
| 522 // Inset the bounds slightly so that they are not exactly same as |
| 523 // the work area bounds and it is easier to resize the window. |
| 524 bounds_in_parent = work_area_in_parent; |
| 525 bounds_in_parent.Inset(10, 10, 10, 10); |
| 526 } |
| 527 } else { |
| 517 bounds_in_parent = window->bounds(); | 528 bounds_in_parent = window->bounds(); |
| 529 } |
| 518 // Make sure that part of the window is always visible. | 530 // Make sure that part of the window is always visible. |
| 519 AdjustBoundsToEnsureMinimumWindowVisibility( | 531 AdjustBoundsToEnsureMinimumWindowVisibility( |
| 520 work_area_in_parent, &bounds_in_parent); | 532 work_area_in_parent, &bounds_in_parent); |
| 521 break; | 533 break; |
| 522 } | 534 } |
| 523 case WINDOW_STATE_TYPE_MAXIMIZED: | 535 case WINDOW_STATE_TYPE_MAXIMIZED: |
| 524 bounds_in_parent = ScreenUtil::GetMaximizedWindowBoundsInParent(window); | 536 bounds_in_parent = ScreenUtil::GetMaximizedWindowBoundsInParent(window); |
| 525 break; | 537 break; |
| 526 | 538 |
| 527 case WINDOW_STATE_TYPE_FULLSCREEN: | 539 case WINDOW_STATE_TYPE_FULLSCREEN: |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 597 ScreenUtil::GetDisplayWorkAreaBoundsInParent(window); | 609 ScreenUtil::GetDisplayWorkAreaBoundsInParent(window); |
| 598 center_in_parent.ClampToCenteredSize(window->bounds().size()); | 610 center_in_parent.ClampToCenteredSize(window->bounds().size()); |
| 599 window_state->SetBoundsDirectAnimated(center_in_parent); | 611 window_state->SetBoundsDirectAnimated(center_in_parent); |
| 600 } | 612 } |
| 601 // Centering window is treated as if a user moved and resized the window. | 613 // Centering window is treated as if a user moved and resized the window. |
| 602 window_state->set_bounds_changed_by_user(true); | 614 window_state->set_bounds_changed_by_user(true); |
| 603 } | 615 } |
| 604 | 616 |
| 605 } // namespace wm | 617 } // namespace wm |
| 606 } // namespace ash | 618 } // namespace ash |
| OLD | NEW |