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

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: Adjusts docking dragging logic to be more tolerant (nits) 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
« no previous file with comments | « ash/wm/workspace/two_step_edge_cycler.h ('k') | ash/wm/workspace/workspace_window_resizer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..7f1ba4745dcde80739921e92c0b6f93054e3bb6b 100644
--- a/ash/wm/workspace/two_step_edge_cycler.cc
+++ b/ash/wm/workspace/two_step_edge_cycler.cc
@@ -12,20 +12,26 @@ namespace {
// We cycle to the second mode if any of the following happens while the mouse
// is on the edge of the workspace:
// . The user stops moving the mouse for |kMaxDelay| and then moves the mouse
-// again.
-// . The mouse moves |kMaxPixels| horizontal pixels.
-// . The mouse is moved |kMaxMoves| times.
-const int kMaxDelay = 500;
+// again in the preferred direction from the last paused location for at least
+// |kMaxPixelsAfterPause| horizontal pixels.
+// . The mouse moves |kMaxPixels| horizontal pixels in the preferred direction.
+// . The mouse is moved |kMaxMoves| times since the last pause.
+const int kMaxDelay = 400;
const int kMaxPixels = 100;
+const int kMaxPixelsAfterPause = 10;
const int kMaxMoves = 25;
} // namespace
-TwoStepEdgeCycler::TwoStepEdgeCycler(const gfx::Point& start)
+TwoStepEdgeCycler::TwoStepEdgeCycler(const gfx::Point& start,
+ TwoStepEdgeCycler::Direction direction)
: 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),
+ direction_(direction) {
}
TwoStepEdgeCycler::~TwoStepEdgeCycler() {
@@ -35,13 +41,25 @@ void TwoStepEdgeCycler::OnMove(const gfx::Point& location) {
if (second_mode_)
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;
+ }
time_last_move_ = base::TimeTicks::Now();
+
+ int compare_x = paused_ ? paused_x_ : start_x_;
+ if (location.x() != compare_x &&
+ (location.x() < compare_x) != (direction_ == DIRECTION_LEFT)) {
+ return;
+ }
+
+ ++num_moves_;
+ bool moved_in_the_same_direction_after_pause =
+ paused_ && std::abs(location.x() - paused_x_) >= kMaxPixelsAfterPause;
+ second_mode_ = moved_in_the_same_direction_after_pause ||
+ std::abs(location.x() - start_x_) >= kMaxPixels ||
+ num_moves_ >= kMaxMoves;
}
} // namespace ash
« no previous file with comments | « ash/wm/workspace/two_step_edge_cycler.h ('k') | ash/wm/workspace/workspace_window_resizer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698