| 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/common/wm/workspace/workspace_window_resizer.h" | 5 #include "ash/common/wm/workspace/workspace_window_resizer.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 if (window_state()->IsSnapped()) { | 432 if (window_state()->IsSnapped()) { |
| 433 // Keep the window snapped if the user resizes the window such that the | 433 // Keep the window snapped if the user resizes the window such that the |
| 434 // window has valid bounds for a snapped window. Always unsnap the window | 434 // window has valid bounds for a snapped window. Always unsnap the window |
| 435 // if the user dragged the window via the caption area because doing this | 435 // if the user dragged the window via the caption area because doing this |
| 436 // is slightly less confusing. | 436 // is slightly less confusing. |
| 437 if (details().window_component == HTCAPTION || | 437 if (details().window_component == HTCAPTION || |
| 438 !AreBoundsValidSnappedBounds(window_state()->GetStateType(), | 438 !AreBoundsValidSnappedBounds(window_state()->GetStateType(), |
| 439 GetTarget()->GetBounds())) { | 439 GetTarget()->GetBounds())) { |
| 440 // Set the window to WINDOW_STATE_TYPE_NORMAL but keep the | 440 // Set the window to WINDOW_STATE_TYPE_NORMAL but keep the |
| 441 // window at the bounds that the user has moved/resized the | 441 // window at the bounds that the user has moved/resized the |
| 442 // window to. ClearRestoreBounds() is used instead of | 442 // window to. |
| 443 // SaveCurrentBoundsForRestore() because most of the restore | 443 window_state()->SaveCurrentBoundsForRestore(); |
| 444 // logic is skipped because we are still in the middle of a | |
| 445 // drag. TODO(pkotwicz): Fix this and use | |
| 446 // SaveCurrentBoundsForRestore(). | |
| 447 window_state()->ClearRestoreBounds(); | |
| 448 window_state()->Restore(); | 444 window_state()->Restore(); |
| 449 } | 445 } |
| 450 } else if (!dock_layout_->is_dragged_window_docked()) { | 446 } else if (!dock_layout_->is_dragged_window_docked()) { |
| 451 // The window was not snapped and is not snapped. This is a user | 447 // The window was not snapped and is not snapped. This is a user |
| 452 // resize/drag and so the current bounds should be maintained, clearing | 448 // resize/drag and so the current bounds should be maintained, clearing |
| 453 // any prior restore bounds. When the window is docked the restore bound | 449 // any prior restore bounds. When the window is docked the restore bound |
| 454 // must be kept so the docked state can be reverted properly. | 450 // must be kept so the docked state can be reverted properly. |
| 455 window_state()->ClearRestoreBounds(); | 451 window_state()->ClearRestoreBounds(); |
| 456 } | 452 } |
| 457 } | 453 } |
| (...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1015 DCHECK(snapped_type == wm::WINDOW_STATE_TYPE_LEFT_SNAPPED || | 1011 DCHECK(snapped_type == wm::WINDOW_STATE_TYPE_LEFT_SNAPPED || |
| 1016 snapped_type == wm::WINDOW_STATE_TYPE_RIGHT_SNAPPED); | 1012 snapped_type == wm::WINDOW_STATE_TYPE_RIGHT_SNAPPED); |
| 1017 gfx::Rect snapped_bounds = wm::GetDisplayWorkAreaBoundsInParent(GetTarget()); | 1013 gfx::Rect snapped_bounds = wm::GetDisplayWorkAreaBoundsInParent(GetTarget()); |
| 1018 if (snapped_type == wm::WINDOW_STATE_TYPE_RIGHT_SNAPPED) | 1014 if (snapped_type == wm::WINDOW_STATE_TYPE_RIGHT_SNAPPED) |
| 1019 snapped_bounds.set_x(snapped_bounds.right() - bounds_in_parent.width()); | 1015 snapped_bounds.set_x(snapped_bounds.right() - bounds_in_parent.width()); |
| 1020 snapped_bounds.set_width(bounds_in_parent.width()); | 1016 snapped_bounds.set_width(bounds_in_parent.width()); |
| 1021 return bounds_in_parent == snapped_bounds; | 1017 return bounds_in_parent == snapped_bounds; |
| 1022 } | 1018 } |
| 1023 | 1019 |
| 1024 } // namespace ash | 1020 } // namespace ash |
| OLD | NEW |