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

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

Issue 1127133003: Adjusts dragging logic to be less likely to trigger false positive switch from snapping to docking (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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 924 matching lines...) Expand 10 before | Expand all | Expand 10 after
935 snap_type_ = GetSnapType(location); 935 snap_type_ = GetSnapType(location);
936 } 936 }
937 const bool can_snap = snap_type_ != SNAP_NONE && window_state()->CanSnap(); 937 const bool can_snap = snap_type_ != SNAP_NONE && window_state()->CanSnap();
938 if (!can_snap && !can_dock) { 938 if (!can_snap && !can_dock) {
939 snap_type_ = SNAP_NONE; 939 snap_type_ = SNAP_NONE;
940 snap_phantom_window_controller_.reset(); 940 snap_phantom_window_controller_.reset();
941 edge_cycler_.reset(); 941 edge_cycler_.reset();
942 return; 942 return;
943 } 943 }
944 if (!edge_cycler_) 944 if (!edge_cycler_)
945 edge_cycler_.reset(new TwoStepEdgeCycler(location)); 945 edge_cycler_.reset(new TwoStepEdgeCycler(location, snap_type_));
946 else 946 else
947 edge_cycler_->OnMove(location); 947 edge_cycler_->OnMove(location);
948 948
949 // Update phantom window with snapped or docked guide bounds. 949 // Update phantom window with snapped or docked guide bounds.
950 // Windows that cannot be snapped or are less wide than kMaxDockWidth can get 950 // Windows that cannot be snapped or are less wide than kMaxDockWidth can get
951 // docked without going through a snapping sequence. 951 // docked without going through a snapping sequence.
952 gfx::Rect phantom_bounds; 952 gfx::Rect phantom_bounds;
953 const bool should_dock = can_dock && 953 const bool should_dock = can_dock &&
954 (!can_snap || 954 (!can_snap ||
955 GetTarget()->bounds().width() <= 955 GetTarget()->bounds().width() <=
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
998 parent->StackChildAtTop(map.rbegin()->second); 998 parent->StackChildAtTop(map.rbegin()->second);
999 for (IndexToWindowMap::const_reverse_iterator i = map.rbegin(); 999 for (IndexToWindowMap::const_reverse_iterator i = map.rbegin();
1000 i != map.rend(); ) { 1000 i != map.rend(); ) {
1001 aura::Window* window = i->second; 1001 aura::Window* window = i->second;
1002 ++i; 1002 ++i;
1003 if (i != map.rend()) 1003 if (i != map.rend())
1004 parent->StackChildBelow(i->second, window); 1004 parent->StackChildBelow(i->second, window);
1005 } 1005 }
1006 } 1006 }
1007 1007
1008 WorkspaceWindowResizer::SnapType WorkspaceWindowResizer::GetSnapType( 1008 SnapType WorkspaceWindowResizer::GetSnapType(const gfx::Point& location) const {
1009 const gfx::Point& location) const {
1010 // TODO: this likely only wants total display area, not the area of a single 1009 // TODO: this likely only wants total display area, not the area of a single
1011 // display. 1010 // display.
1012 gfx::Rect area(ScreenUtil::GetDisplayWorkAreaBoundsInParent(GetTarget())); 1011 gfx::Rect area(ScreenUtil::GetDisplayWorkAreaBoundsInParent(GetTarget()));
1013 if (details().source == aura::client::WINDOW_MOVE_SOURCE_TOUCH) { 1012 if (details().source == aura::client::WINDOW_MOVE_SOURCE_TOUCH) {
1014 // Increase tolerance for touch-snapping near the screen edges. This is only 1013 // Increase tolerance for touch-snapping near the screen edges. This is only
1015 // necessary when the work area left or right edge is same as screen edge. 1014 // necessary when the work area left or right edge is same as screen edge.
1016 gfx::Rect display_bounds(ScreenUtil::GetDisplayBoundsInParent(GetTarget())); 1015 gfx::Rect display_bounds(ScreenUtil::GetDisplayBoundsInParent(GetTarget()));
1017 int inset_left = 0; 1016 int inset_left = 0;
1018 if (area.x() == display_bounds.x()) 1017 if (area.x() == display_bounds.x())
1019 inset_left = kScreenEdgeInsetForTouchDrag; 1018 inset_left = kScreenEdgeInsetForTouchDrag;
(...skipping 30 matching lines...) Expand all
1050 snapped_type == wm::WINDOW_STATE_TYPE_RIGHT_SNAPPED); 1049 snapped_type == wm::WINDOW_STATE_TYPE_RIGHT_SNAPPED);
1051 gfx::Rect snapped_bounds = ScreenUtil::GetDisplayWorkAreaBoundsInParent( 1050 gfx::Rect snapped_bounds = ScreenUtil::GetDisplayWorkAreaBoundsInParent(
1052 GetTarget()); 1051 GetTarget());
1053 if (snapped_type == wm::WINDOW_STATE_TYPE_RIGHT_SNAPPED) 1052 if (snapped_type == wm::WINDOW_STATE_TYPE_RIGHT_SNAPPED)
1054 snapped_bounds.set_x(snapped_bounds.right() - bounds_in_parent.width()); 1053 snapped_bounds.set_x(snapped_bounds.right() - bounds_in_parent.width());
1055 snapped_bounds.set_width(bounds_in_parent.width()); 1054 snapped_bounds.set_width(bounds_in_parent.width());
1056 return bounds_in_parent == snapped_bounds; 1055 return bounds_in_parent == snapped_bounds;
1057 } 1056 }
1058 1057
1059 } // namespace ash 1058 } // namespace ash
OLDNEW
« ash/wm/workspace/two_step_edge_cycler.cc ('K') | « ash/wm/workspace/workspace_window_resizer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698