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

Unified Diff: ash/wm/workspace/two_step_edge_cycler.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 side-by-side diff with in-line comments
Download patch
Index: ash/wm/workspace/two_step_edge_cycler.cc
diff --git a/ash/wm/workspace/two_step_edge_cycler.cc b/ash/wm/workspace/two_step_edge_cycler.cc
index 45bedebe3c947d16e7a9ea96526c036b2ec16fef..8c9ddcf41ff9f5288d71be4eb382e010cc2c5b07 100644
--- a/ash/wm/workspace/two_step_edge_cycler.cc
+++ b/ash/wm/workspace/two_step_edge_cycler.cc
@@ -15,17 +15,22 @@ namespace {
// again.
// . The mouse moves |kMaxPixels| horizontal pixels.
// . The mouse is moved |kMaxMoves| times.
pkotwicz 2015/05/07 17:10:28 Can you please update this comment?
varkha 2015/05/07 20:27:28 Done.
-const int kMaxDelay = 500;
+const int kMaxDelay = 400;
const int kMaxPixels = 100;
+const int kMaxPixelsAfterPause = 20;
const int kMaxMoves = 25;
} // namespace
-TwoStepEdgeCycler::TwoStepEdgeCycler(const gfx::Point& start)
+TwoStepEdgeCycler::TwoStepEdgeCycler(const gfx::Point& start,
+ SnapType snap_type)
: second_mode_(false),
time_last_move_(base::TimeTicks::Now()),
num_moves_(0),
- start_x_(start.x()) {
+ start_x_(start.x()),
+ paused_x_(start.x()),
+ paused_(false),
+ snap_type_(snap_type) {
}
TwoStepEdgeCycler::~TwoStepEdgeCycler() {
@@ -36,11 +41,19 @@ void TwoStepEdgeCycler::OnMove(const gfx::Point& location) {
return;
++num_moves_;
- second_mode_ =
- (base::TimeTicks::Now() - time_last_move_).InMilliseconds() >
- kMaxDelay ||
- std::abs(location.x() - start_x_) >= kMaxPixels ||
- num_moves_ >= kMaxMoves;
+ if ((base::TimeTicks::Now() - time_last_move_).InMilliseconds() > kMaxDelay) {
+ paused_ = true;
+ paused_x_ = location.x();
+ num_moves_ = 0;
+ }
+ bool moved_in_the_same_direction_after_pause =
+ paused_ && ((snap_type_ == SNAP_RIGHT &&
+ (location.x() - paused_x_) >= kMaxPixelsAfterPause) ||
+ (snap_type_ == SNAP_LEFT &&
+ (paused_x_ - location.x()) >= kMaxPixelsAfterPause));
+ second_mode_ = moved_in_the_same_direction_after_pause ||
+ std::abs(location.x() - start_x_) >= kMaxPixels ||
+ num_moves_ >= kMaxMoves;
time_last_move_ = base::TimeTicks::Now();
}

Powered by Google App Engine
This is Rietveld 408576698