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 // Keep the window snapped if the user resizes the window such that the |
448 // window has valid bounds for a snapped window. Always unsnap the window | 448 // window has valid bounds for a snapped window. Always unsnap the window |
449 // if the user dragged the window via the caption area because doing this is | 449 // if the user dragged the window via the caption area because doing this |
450 // slightly less confusing. | 450 // is slightly less confusing. |
451 if (details().window_component == HTCAPTION || | 451 if (window_state()->IsSnapped()) { |
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 // SaveCurrentBoundsForRestore(). | |
462 window_state()->ClearRestoreBounds(); | |
463 window_state()->Restore(); | |
464 } | |
465 // The window was not snapped and is not snapped. This is a user | |
466 // resize/drag and so the current bounds should be maintained, clearing | |
467 // any prior restore bounds. When the window is docked the restore bound | |
468 // must be kept so the docked state can be reverted properly. | |
469 } else if (!dock_layout_->is_dragged_window_docked()) | |
varkha
2014/08/27 14:55:27
nit: Now that the code is changed it should follow
| |
461 window_state()->ClearRestoreBounds(); | 470 window_state()->ClearRestoreBounds(); |
462 window_state()->Restore(); | |
463 } | |
464 } | 471 } |
465 } | 472 } |
466 | 473 |
467 void WorkspaceWindowResizer::RevertDrag() { | 474 void WorkspaceWindowResizer::RevertDrag() { |
468 window_state()->set_bounds_changed_by_user(initial_bounds_changed_by_user_); | 475 window_state()->set_bounds_changed_by_user(initial_bounds_changed_by_user_); |
469 snap_phantom_window_controller_.reset(); | 476 snap_phantom_window_controller_.reset(); |
470 | 477 |
471 if (!did_move_or_resize_) | 478 if (!did_move_or_resize_) |
472 return; | 479 return; |
473 | 480 |
(...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1038 snapped_type == wm::WINDOW_STATE_TYPE_RIGHT_SNAPPED); | 1045 snapped_type == wm::WINDOW_STATE_TYPE_RIGHT_SNAPPED); |
1039 gfx::Rect snapped_bounds = ScreenUtil::GetDisplayWorkAreaBoundsInParent( | 1046 gfx::Rect snapped_bounds = ScreenUtil::GetDisplayWorkAreaBoundsInParent( |
1040 GetTarget()); | 1047 GetTarget()); |
1041 if (snapped_type == wm::WINDOW_STATE_TYPE_RIGHT_SNAPPED) | 1048 if (snapped_type == wm::WINDOW_STATE_TYPE_RIGHT_SNAPPED) |
1042 snapped_bounds.set_x(snapped_bounds.right() - bounds_in_parent.width()); | 1049 snapped_bounds.set_x(snapped_bounds.right() - bounds_in_parent.width()); |
1043 snapped_bounds.set_width(bounds_in_parent.width()); | 1050 snapped_bounds.set_width(bounds_in_parent.width()); |
1044 return bounds_in_parent == snapped_bounds; | 1051 return bounds_in_parent == snapped_bounds; |
1045 } | 1052 } |
1046 | 1053 |
1047 } // namespace ash | 1054 } // namespace ash |
OLD | NEW |