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

Unified Diff: ash/wm/gestures/overview_gesture_handler.cc

Issue 2667293002: [ash-md] Adds support for gesture to move selection in overview mode (Closed)
Patch Set: [ash-md] Adds support for gesture to move selection in overview mode (no skipping 1st) Created 3 years, 10 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/gestures/overview_gesture_handler.h ('k') | ash/wm/gestures/overview_gesture_handler_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/wm/gestures/overview_gesture_handler.cc
diff --git a/ash/wm/gestures/overview_gesture_handler.cc b/ash/wm/gestures/overview_gesture_handler.cc
index 2b94b9eefe3bc64cc952241ac2f3a8434de651a7..8d84fee41eb4d863ae45e812088c7ec33e7d08db 100644
--- a/ash/wm/gestures/overview_gesture_handler.cc
+++ b/ash/wm/gestures/overview_gesture_handler.cc
@@ -10,13 +10,13 @@
#include "ui/events/event_constants.h"
namespace ash {
-namespace {
-// The threshold before engaging overview on a three finger swipe on the
-// touchpad.
-const float kSwipeThresholdPixels = 300;
+// The threshold before engaging overview with a touchpad three-finger scroll.
+const float OverviewGestureHandler::vertical_threshold_pixels_ = 300;
-} // namespace
+// The threshold before moving selector horizontally when using a touchpad
+// three-finger scroll.
+const float OverviewGestureHandler::horizontal_threshold_pixels_ = 330;
OverviewGestureHandler::OverviewGestureHandler() : scroll_x_(0), scroll_y_(0) {}
@@ -32,31 +32,44 @@ bool OverviewGestureHandler::ProcessScrollEvent(const ui::ScrollEvent& event) {
scroll_x_ += event.x_offset();
scroll_y_ += event.y_offset();
- // Horizontal swiping is ignored.
+ WindowSelectorController* window_selector_controller =
+ WmShell::Get()->window_selector_controller();
+
+ // Horizontal 3-finger scroll moves selection when already in overview mode.
if (std::fabs(scroll_x_) >= std::fabs(scroll_y_)) {
+ if (!window_selector_controller->IsSelecting()) {
+ scroll_x_ = scroll_y_ = 0;
+ return false;
+ }
+ if (std::fabs(scroll_x_) < horizontal_threshold_pixels_)
+ return false;
+
+ const int increment = scroll_x_ > 0 ? 1 : -1;
scroll_x_ = scroll_y_ = 0;
- return false;
+ window_selector_controller->IncrementSelection(increment);
+ return true;
}
- // Only allow swipe up to enter overview, down to exit. Ignore extra swiping
- // in the wrong direction.
- WindowSelectorController* window_selector_controller =
- WmShell::Get()->window_selector_controller();
+ // Use vertical 3-finger scroll gesture up to enter overview, down to exit.
if (window_selector_controller->IsSelecting()) {
if (scroll_y_ < 0)
scroll_x_ = scroll_y_ = 0;
- if (scroll_y_ < kSwipeThresholdPixels)
+ if (scroll_y_ < vertical_threshold_pixels_)
return false;
} else {
if (scroll_y_ > 0)
scroll_x_ = scroll_y_ = 0;
- if (scroll_y_ > -kSwipeThresholdPixels)
+ if (scroll_y_ > -vertical_threshold_pixels_)
return false;
}
// Reset scroll amount on toggling.
scroll_x_ = scroll_y_ = 0;
WmShell::Get()->RecordUserMetricsAction(UMA_TOUCHPAD_GESTURE_OVERVIEW);
+ if (window_selector_controller->IsSelecting() &&
+ window_selector_controller->AcceptSelection()) {
+ return true;
+ }
window_selector_controller->ToggleOverview();
return true;
}
« no previous file with comments | « ash/wm/gestures/overview_gesture_handler.h ('k') | ash/wm/gestures/overview_gesture_handler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698