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_window_resizer.h" | 5 #include "ash/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 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
436 const wm::WMEvent event(snap_type_ == SNAP_LEFT ? | 436 const wm::WMEvent event(snap_type_ == SNAP_LEFT ? |
437 wm::WM_EVENT_SNAP_LEFT : wm::WM_EVENT_SNAP_RIGHT); | 437 wm::WM_EVENT_SNAP_LEFT : wm::WM_EVENT_SNAP_RIGHT); |
438 window_state()->OnWMEvent(&event); | 438 window_state()->OnWMEvent(&event); |
439 metrics->RecordUserMetricsAction( | 439 metrics->RecordUserMetricsAction( |
440 snap_type_ == SNAP_LEFT ? | 440 snap_type_ == SNAP_LEFT ? |
441 UMA_DRAG_MAXIMIZE_LEFT : UMA_DRAG_MAXIMIZE_RIGHT); | 441 UMA_DRAG_MAXIMIZE_LEFT : UMA_DRAG_MAXIMIZE_RIGHT); |
442 snapped = true; | 442 snapped = true; |
443 } | 443 } |
444 } | 444 } |
445 | 445 |
446 if (!snapped && window_state()->IsSnapped()) { | 446 if (!snapped) { |
447 // Keep the window snapped if the user resizes the window such that the | 447 if (window_state()->IsSnapped()) { |
448 // window has valid bounds for a snapped window. Always unsnap the window | 448 // Keep the window snapped if the user resizes the window such that the |
449 // if the user dragged the window via the caption area because doing this is | 449 // window has valid bounds for a snapped window. Always unsnap the window |
450 // slightly less confusing. | 450 // if the user dragged the window via the caption area because doing this |
451 if (details().window_component == HTCAPTION || | 451 // is slightly less confusing. |
452 !AreBoundsValidSnappedBounds(window_state()->GetStateType(), | 452 if (details().window_component == HTCAPTION || |
453 GetTarget()->bounds())) { | 453 !AreBoundsValidSnappedBounds(window_state()->GetStateType(), |
454 // Set the window to WINDOW_STATE_TYPE_NORMAL but keep the | 454 GetTarget()->bounds())) { |
455 // window at the bounds that the user has moved/resized the | 455 // Set the window to WINDOW_STATE_TYPE_NORMAL but keep the |
456 // window to. ClearRestoreBounds() is used instead of | 456 // window at the bounds that the user has moved/resized the |
457 // SaveCurrentBoundsForRestore() because most of the restore | 457 // window to. ClearRestoreBounds() is used instead of |
458 // logic is skipped because we are still in the middle of a | 458 // SaveCurrentBoundsForRestore() because most of the restore |
459 // drag. TODO(pkotwicz): Fix this and use | 459 // logic is skipped because we are still in the middle of a |
460 // SaveCurrentBoundsForRestore(). | 460 // drag. TODO(pkotwicz): Fix this and use |
461 window_state()->ClearRestoreBounds(); | 461 // SaveCurrentBoundsForRestore(). |
462 window_state()->Restore(); | 462 window_state()->ClearRestoreBounds(); |
463 window_state()->Restore(); | |
464 } | |
465 } else { | |
466 // The window was not snapped and is not snapped. This is a user | |
467 // resize/drag and so the current bounds should be maintained, clearing | |
468 // any prior restore bounds. When the window is docked the restore bound | |
469 // must be kept so the docked state can be reverted properly. | |
470 if (!dock_layout_->is_dragged_window_docked()) { | |
varkha
2014/08/26 21:20:03
nit: Can be merged into an else if.
nit: The code
Peter Wen
2014/08/27 13:32:57
Done.
| |
471 window_state()->ClearRestoreBounds(); | |
472 } | |
463 } | 473 } |
464 } | 474 } |
465 } | 475 } |
466 | 476 |
467 void WorkspaceWindowResizer::RevertDrag() { | 477 void WorkspaceWindowResizer::RevertDrag() { |
468 window_state()->set_bounds_changed_by_user(initial_bounds_changed_by_user_); | 478 window_state()->set_bounds_changed_by_user(initial_bounds_changed_by_user_); |
469 snap_phantom_window_controller_.reset(); | 479 snap_phantom_window_controller_.reset(); |
470 | 480 |
471 if (!did_move_or_resize_) | 481 if (!did_move_or_resize_) |
472 return; | 482 return; |
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1038 snapped_type == wm::WINDOW_STATE_TYPE_RIGHT_SNAPPED); | 1048 snapped_type == wm::WINDOW_STATE_TYPE_RIGHT_SNAPPED); |
1039 gfx::Rect snapped_bounds = ScreenUtil::GetDisplayWorkAreaBoundsInParent( | 1049 gfx::Rect snapped_bounds = ScreenUtil::GetDisplayWorkAreaBoundsInParent( |
1040 GetTarget()); | 1050 GetTarget()); |
1041 if (snapped_type == wm::WINDOW_STATE_TYPE_RIGHT_SNAPPED) | 1051 if (snapped_type == wm::WINDOW_STATE_TYPE_RIGHT_SNAPPED) |
1042 snapped_bounds.set_x(snapped_bounds.right() - bounds_in_parent.width()); | 1052 snapped_bounds.set_x(snapped_bounds.right() - bounds_in_parent.width()); |
1043 snapped_bounds.set_width(bounds_in_parent.width()); | 1053 snapped_bounds.set_width(bounds_in_parent.width()); |
1044 return bounds_in_parent == snapped_bounds; | 1054 return bounds_in_parent == snapped_bounds; |
1045 } | 1055 } |
1046 | 1056 |
1047 } // namespace ash | 1057 } // namespace ash |
OLD | NEW |