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..178987582133fa63fed49fb01ad8983064cf5153 100644 |
--- a/ash/wm/workspace/two_step_edge_cycler.cc |
+++ b/ash/wm/workspace/two_step_edge_cycler.cc |
@@ -12,20 +12,28 @@ 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. |
+// again in the preferred direction from the last paused location for at least |
+// |kMaxPixelsAfterPause| (horizontal distance). |
pkotwicz
2015/05/11 17:32:41
Nit: "(horizontal distance)" -> "horizontal pixels
varkha
2015/05/11 20:19:38
Done.
|
// . The mouse moves |kMaxPixels| horizontal pixels. |
-// . The mouse is moved |kMaxMoves| times. |
-const int kMaxDelay = 500; |
+// . The mouse is moved |kMaxMoves| times since the last pause. If mouse was |
+// paused at least once then this movement needs to be in the preferred |
+// direction. |
+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,12 +43,24 @@ void TwoStepEdgeCycler::OnMove(const gfx::Point& location) { |
if (second_mode_) |
return; |
pkotwicz
2015/05/11 17:32:41
I would be tempted to do something like this:
if
pkotwicz
2015/05/11 17:35:06
Correction:
I would be tempted to do something li
varkha
2015/05/11 20:19:38
Done.
|
- ++num_moves_; |
- second_mode_ = |
- (base::TimeTicks::Now() - time_last_move_).InMilliseconds() > |
- kMaxDelay || |
- std::abs(location.x() - start_x_) >= kMaxPixels || |
- num_moves_ >= kMaxMoves; |
+ if (!paused_ || |
+ (direction_ == DIRECTION_RIGHT && location.x() >= paused_x_) || |
+ (direction_ == DIRECTION_LEFT && location.x() <= paused_x_)) { |
+ ++num_moves_; |
+ } |
+ 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_ && ((direction_ == DIRECTION_RIGHT && |
+ (location.x() - paused_x_) >= kMaxPixelsAfterPause) || |
+ (direction_ == DIRECTION_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(); |
} |