| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/gestures/overview_gesture_handler.h" | 5 #include "ash/wm/gestures/overview_gesture_handler.h" |
| 6 | 6 |
| 7 #include "ash/common/wm/overview/window_selector_controller.h" | 7 #include "ash/common/wm/overview/window_selector_controller.h" |
| 8 #include "ash/common/wm_shell.h" | 8 #include "ash/common/wm_shell.h" |
| 9 #include "ui/events/event.h" | 9 #include "ui/events/event.h" |
| 10 #include "ui/events/event_constants.h" | 10 #include "ui/events/event_constants.h" |
| 11 | 11 |
| 12 namespace ash { | 12 namespace ash { |
| 13 namespace { | 13 namespace { |
| 14 | 14 |
| 15 // The threshold before engaging overview on a three finger swipe on the | 15 // The threshold before engaging overview on a three finger swipe on the |
| 16 // touchpad. | 16 // touchpad. |
| 17 const float kSwipeThresholdPixels = 300; | 17 const float kSwipeThresholdPixels = 300; |
| 18 | 18 |
| 19 } // namespace | 19 } // namespace |
| 20 | 20 |
| 21 OverviewGestureHandler::OverviewGestureHandler() : scroll_x_(0), scroll_y_(0) {} | 21 OverviewGestureHandler::OverviewGestureHandler() : scroll_x_(0), scroll_y_(0) {} |
| 22 | 22 |
| 23 OverviewGestureHandler::~OverviewGestureHandler() { | 23 OverviewGestureHandler::~OverviewGestureHandler() {} |
| 24 } | |
| 25 | 24 |
| 26 bool OverviewGestureHandler::ProcessScrollEvent(const ui::ScrollEvent& event) { | 25 bool OverviewGestureHandler::ProcessScrollEvent(const ui::ScrollEvent& event) { |
| 27 if (event.type() == ui::ET_SCROLL_FLING_START || | 26 if (event.type() == ui::ET_SCROLL_FLING_START || |
| 28 event.type() == ui::ET_SCROLL_FLING_CANCEL || | 27 event.type() == ui::ET_SCROLL_FLING_CANCEL || event.finger_count() != 3) { |
| 29 event.finger_count() != 3) { | |
| 30 scroll_x_ = scroll_y_ = 0; | 28 scroll_x_ = scroll_y_ = 0; |
| 31 return false; | 29 return false; |
| 32 } | 30 } |
| 33 | 31 |
| 34 scroll_x_ += event.x_offset(); | 32 scroll_x_ += event.x_offset(); |
| 35 scroll_y_ += event.y_offset(); | 33 scroll_y_ += event.y_offset(); |
| 36 | 34 |
| 37 // Horizontal swiping is ignored. | 35 // Horizontal swiping is ignored. |
| 38 if (std::fabs(scroll_x_) >= std::fabs(scroll_y_)) { | 36 if (std::fabs(scroll_x_) >= std::fabs(scroll_y_)) { |
| 39 scroll_x_ = scroll_y_ = 0; | 37 scroll_x_ = scroll_y_ = 0; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 57 } | 55 } |
| 58 | 56 |
| 59 // Reset scroll amount on toggling. | 57 // Reset scroll amount on toggling. |
| 60 scroll_x_ = scroll_y_ = 0; | 58 scroll_x_ = scroll_y_ = 0; |
| 61 WmShell::Get()->RecordUserMetricsAction(UMA_TOUCHPAD_GESTURE_OVERVIEW); | 59 WmShell::Get()->RecordUserMetricsAction(UMA_TOUCHPAD_GESTURE_OVERVIEW); |
| 62 window_selector_controller->ToggleOverview(); | 60 window_selector_controller->ToggleOverview(); |
| 63 return true; | 61 return true; |
| 64 } | 62 } |
| 65 | 63 |
| 66 } // namespace ash | 64 } // namespace ash |
| OLD | NEW |