Chromium Code Reviews| 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..395a7953d166edbe2fe462c0018eef382b8b6af3 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. |
| +float OverviewGestureHandler::vertical_threshold_pixels_ = 300; |
| -} // namespace |
| +// The threshold before moving selector horizontally when using a touchpad |
| +// two or three-finger scroll. |
| +float OverviewGestureHandler::horizontal_threshold_pixels_ = 150; |
| OverviewGestureHandler::OverviewGestureHandler() : scroll_x_(0), scroll_y_(0) {} |
| @@ -24,7 +24,8 @@ OverviewGestureHandler::~OverviewGestureHandler() {} |
| bool OverviewGestureHandler::ProcessScrollEvent(const ui::ScrollEvent& event) { |
| if (event.type() == ui::ET_SCROLL_FLING_START || |
| - event.type() == ui::ET_SCROLL_FLING_CANCEL || event.finger_count() != 3) { |
| + event.type() == ui::ET_SCROLL_FLING_CANCEL || |
| + (event.finger_count() != 2 && event.finger_count() != 3)) { |
|
tdanderson
2017/02/08 23:14:19
If you're going to start permitting two-finger scr
varkha
2017/02/09 21:54:42
Convinced - going back to requiring 3-finger gestu
|
| scroll_x_ = scroll_y_ = 0; |
| return false; |
| } |
| @@ -32,31 +33,51 @@ bool OverviewGestureHandler::ProcessScrollEvent(const ui::ScrollEvent& event) { |
| scroll_x_ += event.x_offset(); |
| scroll_y_ += event.y_offset(); |
| - // Horizontal swiping is ignored. |
| + // Only allow swipe up to enter overview, down to exit. Ignore extra swiping |
|
tdanderson
2017/02/08 23:14:19
nit: update documentation and probably just merge
varkha
2017/02/09 21:54:42
Done.
|
| + // in the wrong direction. |
| + WindowSelectorController* window_selector_controller = |
| + WmShell::Get()->window_selector_controller(); |
| + |
| + // Horizontal 2 or 3 finger scroll moves selection when 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; |
|
tdanderson
2017/02/08 23:14:19
nit: newline
varkha
2017/02/09 21:54:42
Done.
|
| + window_selector_controller->IncrementSelection( |
| + scroll_x_ / horizontal_threshold_pixels_); |
| + scroll_x_ = scroll_y_ = 0; |
| + return true; |
| + } |
| + |
| + // For the vertical scroll 3 fingers are required. |
| + if (event.finger_count() != 3) { |
| scroll_x_ = scroll_y_ = 0; |
| return false; |
| } |
| - // 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(); |
| 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; |
| } |