summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordpranke <dpranke@chromium.org>2015-05-11 17:55:16 -0700
committerCommit bot <commit-bot@chromium.org>2015-05-12 00:55:37 +0000
commit0d4f7d597774f7415f1aff374db498c8fbe88a9a (patch)
treede9d74a05e9202be3af02df17a53fa22b8f688e3
parent3d47587f1458d6ef27f0b233f92012267718de5d (diff)
downloadchromium_src-0d4f7d597774f7415f1aff374db498c8fbe88a9a.zip
chromium_src-0d4f7d597774f7415f1aff374db498c8fbe88a9a.tar.gz
chromium_src-0d4f7d597774f7415f1aff374db498c8fbe88a9a.tar.bz2
Revert of Adjusts dragging logic to be less likely to trigger false positive switch from snapping to docking (patchset #5 id:90001 of https://codereview.chromium.org/1127133003/)
Reason for revert: I suspect this is causing a browser_tests failure on the bots: http://build.chromium.org/p/chromium.chromiumos/builders/Linux%20ChromiumOS%20Tests%20%28dbg%29%281%29/builds/2069 https://build.chromium.org/p/chromium.webkit/builders/Linux%20ChromiumOS%20Tests%20%28dbg%29%281%29/builds/1913 Sorry! Original issue's description: > Adjusts dragging logic to be less likely to trigger false positive switch from > snapping to docking. > > This CL adjusts the logic which selects whether a window will be snapped to > half of the workspace width or will be docked at the end of the drag when the > window is dragged to the edge of the workspace in the special case of the dock > being visible. The CL makes it easier to snap a window to half the workspace > width in this special case (and harder to inadvertently dock the window) > > BUG=484877 > TEST=None > > Committed: https://crrev.com/988c697aff35b3fd347dec35f2f2ac159c8328a9 > Cr-Commit-Position: refs/heads/master@{#329268} TBR=pkotwicz@chromium.org,varkha@chromium.org NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=484877 Review URL: https://codereview.chromium.org/1128933005 Cr-Commit-Position: refs/heads/master@{#329301}
-rw-r--r--ash/wm/workspace/two_step_edge_cycler.cc42
-rw-r--r--ash/wm/workspace/two_step_edge_cycler.h14
-rw-r--r--ash/wm/workspace/workspace_window_resizer.cc10
-rw-r--r--ash/wm/workspace/workspace_window_resizer.h13
4 files changed, 25 insertions, 54 deletions
diff --git a/ash/wm/workspace/two_step_edge_cycler.cc b/ash/wm/workspace/two_step_edge_cycler.cc
index 7f1ba474..45bedeb 100644
--- a/ash/wm/workspace/two_step_edge_cycler.cc
+++ b/ash/wm/workspace/two_step_edge_cycler.cc
@@ -12,26 +12,20 @@ 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 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;
+// again.
+// . The mouse moves |kMaxPixels| horizontal pixels.
+// . The mouse is moved |kMaxMoves| times.
+const int kMaxDelay = 500;
const int kMaxPixels = 100;
-const int kMaxPixelsAfterPause = 10;
const int kMaxMoves = 25;
} // namespace
-TwoStepEdgeCycler::TwoStepEdgeCycler(const gfx::Point& start,
- TwoStepEdgeCycler::Direction direction)
+TwoStepEdgeCycler::TwoStepEdgeCycler(const gfx::Point& start)
: second_mode_(false),
time_last_move_(base::TimeTicks::Now()),
num_moves_(0),
- start_x_(start.x()),
- paused_x_(start.x()),
- paused_(false),
- direction_(direction) {
+ start_x_(start.x()) {
}
TwoStepEdgeCycler::~TwoStepEdgeCycler() {
@@ -41,25 +35,13 @@ void TwoStepEdgeCycler::OnMove(const gfx::Point& location) {
if (second_mode_)
return;
- 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;
+ second_mode_ =
+ (base::TimeTicks::Now() - time_last_move_).InMilliseconds() >
+ kMaxDelay ||
+ std::abs(location.x() - start_x_) >= kMaxPixels ||
+ num_moves_ >= kMaxMoves;
+ time_last_move_ = base::TimeTicks::Now();
}
} // namespace ash
diff --git a/ash/wm/workspace/two_step_edge_cycler.h b/ash/wm/workspace/two_step_edge_cycler.h
index 3254cfd..01ca086 100644
--- a/ash/wm/workspace/two_step_edge_cycler.h
+++ b/ash/wm/workspace/two_step_edge_cycler.h
@@ -19,10 +19,7 @@ namespace ash {
// the workspace.
class ASH_EXPORT TwoStepEdgeCycler {
public:
- // The direction in which a mouse should travel to switch mode.
- enum Direction { DIRECTION_LEFT, DIRECTION_RIGHT };
-
- explicit TwoStepEdgeCycler(const gfx::Point& start, Direction direction);
+ explicit TwoStepEdgeCycler(const gfx::Point& start);
~TwoStepEdgeCycler();
// Update which mode should be used as a result of a mouse / touch move.
@@ -44,15 +41,6 @@ class ASH_EXPORT TwoStepEdgeCycler {
// Initial x-coordinate.
int start_x_;
- // x-coordinate when paused.
- int paused_x_;
-
- // Whether the movement was paused.
- bool paused_;
-
- // Determines a preferred movement direction that we are watching.
- Direction direction_;
-
DISALLOW_COPY_AND_ASSIGN(TwoStepEdgeCycler);
};
diff --git a/ash/wm/workspace/workspace_window_resizer.cc b/ash/wm/workspace/workspace_window_resizer.cc
index 73ba6fb..bd1ef25 100644
--- a/ash/wm/workspace/workspace_window_resizer.cc
+++ b/ash/wm/workspace/workspace_window_resizer.cc
@@ -941,14 +941,10 @@ void WorkspaceWindowResizer::UpdateSnapPhantomWindow(const gfx::Point& location,
edge_cycler_.reset();
return;
}
- if (!edge_cycler_) {
- edge_cycler_.reset(new TwoStepEdgeCycler(
- location, snap_type_ == SNAP_LEFT
- ? TwoStepEdgeCycler::DIRECTION_LEFT
- : TwoStepEdgeCycler::DIRECTION_RIGHT));
- } else {
+ if (!edge_cycler_)
+ edge_cycler_.reset(new TwoStepEdgeCycler(location));
+ else
edge_cycler_->OnMove(location);
- }
// Update phantom window with snapped or docked guide bounds.
// Windows that cannot be snapped or are less wide than kMaxDockWidth can get
diff --git a/ash/wm/workspace/workspace_window_resizer.h b/ash/wm/workspace/workspace_window_resizer.h
index 8bf0657..a05039b 100644
--- a/ash/wm/workspace/workspace_window_resizer.h
+++ b/ash/wm/workspace/workspace_window_resizer.h
@@ -61,13 +61,18 @@ class ASH_EXPORT WorkspaceWindowResizer : public WindowResizer {
void RevertDrag() override;
private:
+ WorkspaceWindowResizer(wm::WindowState* window_state,
+ const std::vector<aura::Window*>& attached_windows);
+
+ private:
friend class WorkspaceWindowResizerTest;
// The edge to which the window should be snapped at the end of the drag.
- enum SnapType { SNAP_LEFT, SNAP_RIGHT, SNAP_NONE };
-
- WorkspaceWindowResizer(wm::WindowState* window_state,
- const std::vector<aura::Window*>& attached_windows);
+ enum SnapType {
+ SNAP_LEFT,
+ SNAP_RIGHT,
+ SNAP_NONE
+ };
// Lays out the attached windows. |bounds| is the bounds of the main window.
void LayoutAttachedWindows(gfx::Rect* bounds);