Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(24)

Side by Side Diff: ash/wm/workspace/workspace_window_resizer.cc

Issue 477823003: Clear restore bounds for user resize/drag actions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 // SaveCurrentBoundsForRestore().
462 window_state()->ClearRestoreBounds();
463 window_state()->Restore();
464 }
465 } else if (!dock_layout_->is_dragged_window_docked()) {
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.
461 window_state()->ClearRestoreBounds(); 470 window_state()->ClearRestoreBounds();
462 window_state()->Restore();
463 } 471 }
464 } 472 }
465 } 473 }
466 474
467 void WorkspaceWindowResizer::RevertDrag() { 475 void WorkspaceWindowResizer::RevertDrag() {
468 window_state()->set_bounds_changed_by_user(initial_bounds_changed_by_user_); 476 window_state()->set_bounds_changed_by_user(initial_bounds_changed_by_user_);
469 snap_phantom_window_controller_.reset(); 477 snap_phantom_window_controller_.reset();
470 478
471 if (!did_move_or_resize_) 479 if (!did_move_or_resize_)
472 return; 480 return;
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after
1038 snapped_type == wm::WINDOW_STATE_TYPE_RIGHT_SNAPPED); 1046 snapped_type == wm::WINDOW_STATE_TYPE_RIGHT_SNAPPED);
1039 gfx::Rect snapped_bounds = ScreenUtil::GetDisplayWorkAreaBoundsInParent( 1047 gfx::Rect snapped_bounds = ScreenUtil::GetDisplayWorkAreaBoundsInParent(
1040 GetTarget()); 1048 GetTarget());
1041 if (snapped_type == wm::WINDOW_STATE_TYPE_RIGHT_SNAPPED) 1049 if (snapped_type == wm::WINDOW_STATE_TYPE_RIGHT_SNAPPED)
1042 snapped_bounds.set_x(snapped_bounds.right() - bounds_in_parent.width()); 1050 snapped_bounds.set_x(snapped_bounds.right() - bounds_in_parent.width());
1043 snapped_bounds.set_width(bounds_in_parent.width()); 1051 snapped_bounds.set_width(bounds_in_parent.width());
1044 return bounds_in_parent == snapped_bounds; 1052 return bounds_in_parent == snapped_bounds;
1045 } 1053 }
1046 1054
1047 } // namespace ash 1055 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/workspace/workspace_layout_manager.cc ('k') | ash/wm/workspace/workspace_window_resizer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698