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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/two_step_edge_cycler.h" 5 #include "ash/wm/workspace/two_step_edge_cycler.h"
6 6
7 #include <cstdlib> 7 #include <cstdlib>
8 8
9 namespace ash { 9 namespace ash {
10 namespace { 10 namespace {
11 11
12 // We cycle to the second mode if any of the following happens while the mouse 12 // We cycle to the second mode if any of the following happens while the mouse
13 // is on the edge of the workspace: 13 // is on the edge of the workspace:
14 // . The user stops moving the mouse for |kMaxDelay| and then moves the mouse 14 // . The user stops moving the mouse for |kMaxDelay| and then moves the mouse
15 // again. 15 // again in the preferred direction from the last paused location for at least
16 // . The mouse moves |kMaxPixels| horizontal pixels. 16 // |kMaxPixelsAfterPause| horizontal pixels.
17 // . The mouse is moved |kMaxMoves| times. 17 // . The mouse moves |kMaxPixels| horizontal pixels in the preferred direction.
18 const int kMaxDelay = 500; 18 // . The mouse is moved |kMaxMoves| times since the last pause.
19 const int kMaxDelay = 400;
19 const int kMaxPixels = 100; 20 const int kMaxPixels = 100;
21 const int kMaxPixelsAfterPause = 10;
20 const int kMaxMoves = 25; 22 const int kMaxMoves = 25;
21 23
22 } // namespace 24 } // namespace
23 25
24 TwoStepEdgeCycler::TwoStepEdgeCycler(const gfx::Point& start) 26 TwoStepEdgeCycler::TwoStepEdgeCycler(const gfx::Point& start,
27 TwoStepEdgeCycler::Direction direction)
25 : second_mode_(false), 28 : second_mode_(false),
26 time_last_move_(base::TimeTicks::Now()), 29 time_last_move_(base::TimeTicks::Now()),
27 num_moves_(0), 30 num_moves_(0),
28 start_x_(start.x()) { 31 start_x_(start.x()),
32 paused_x_(start.x()),
33 paused_(false),
34 direction_(direction) {
29 } 35 }
30 36
31 TwoStepEdgeCycler::~TwoStepEdgeCycler() { 37 TwoStepEdgeCycler::~TwoStepEdgeCycler() {
32 } 38 }
33 39
34 void TwoStepEdgeCycler::OnMove(const gfx::Point& location) { 40 void TwoStepEdgeCycler::OnMove(const gfx::Point& location) {
35 if (second_mode_) 41 if (second_mode_)
36 return; 42 return;
37 43
44 if ((base::TimeTicks::Now() - time_last_move_).InMilliseconds() > kMaxDelay) {
45 paused_ = true;
46 paused_x_ = location.x();
47 num_moves_ = 0;
48 }
49 time_last_move_ = base::TimeTicks::Now();
50
51 int compare_x = paused_ ? paused_x_ : start_x_;
52 if (location.x() != compare_x &&
53 (location.x() < compare_x) != (direction_ == DIRECTION_LEFT)) {
54 return;
55 }
56
38 ++num_moves_; 57 ++num_moves_;
39 second_mode_ = 58 bool moved_in_the_same_direction_after_pause =
40 (base::TimeTicks::Now() - time_last_move_).InMilliseconds() > 59 paused_ && std::abs(location.x() - paused_x_) >= kMaxPixelsAfterPause;
41 kMaxDelay || 60 second_mode_ = moved_in_the_same_direction_after_pause ||
42 std::abs(location.x() - start_x_) >= kMaxPixels || 61 std::abs(location.x() - start_x_) >= kMaxPixels ||
43 num_moves_ >= kMaxMoves; 62 num_moves_ >= kMaxMoves;
44 time_last_move_ = base::TimeTicks::Now();
45 } 63 }
46 64
47 } // namespace ash 65 } // namespace ash
OLDNEW
« 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