summaryrefslogtreecommitdiffstats
path: root/ui/base
diff options
context:
space:
mode:
authorsadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-07 21:06:59 +0000
committersadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-07 21:06:59 +0000
commit3057393e317509831e09b3cb81d2555cbae2e083 (patch)
treeb0f11163ffecced884037b5b12c77fb0a6946429 /ui/base
parentf98d573dea5090e90271b2ea44a5e2685c5189b9 (diff)
downloadchromium_src-3057393e317509831e09b3cb81d2555cbae2e083.zip
chromium_src-3057393e317509831e09b3cb81d2555cbae2e083.tar.gz
chromium_src-3057393e317509831e09b3cb81d2555cbae2e083.tar.bz2
gesture recognizer: Make sure the pinch/scroll only when the finger is moved for real.
Change in the radius for any of the touch-points changes the bounding box of the points, but in such cases, we do not want to trigger either scroll or pinch updates. BUG=none TBR=ben@chromium.org Review URL: https://chromiumcodereview.appspot.com/10837107 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@150400 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/base')
-rw-r--r--ui/base/gestures/gesture_sequence.cc20
1 files changed, 18 insertions, 2 deletions
diff --git a/ui/base/gestures/gesture_sequence.cc b/ui/base/gestures/gesture_sequence.cc
index 42c19b3..b52babb 100644
--- a/ui/base/gestures/gesture_sequence.cc
+++ b/ui/base/gestures/gesture_sequence.cc
@@ -675,12 +675,12 @@ void GestureSequence::AppendScrollGestureUpdate(const GesturePoint& point,
gfx::Point current_center = bounding_box_.CenterPoint();
int dx = current_center.x() - bounding_box_last_center_.x();
int dy = current_center.y() - bounding_box_last_center_.y();
- if (dx == 0 && dy == 0)
- return;
if (scroll_type_ == ST_HORIZONTAL)
dy = 0;
else if (scroll_type_ == ST_VERTICAL)
dx = 0;
+ if (dx == 0 && dy == 0)
+ return;
gestures->push_back(CreateGestureEvent(
GestureEventDetails(ui::ET_GESTURE_SCROLL_UPDATE, dx, dy),
@@ -908,6 +908,22 @@ bool GestureSequence::PinchUpdate(const TouchEvent& event,
const GesturePoint& point, Gestures* gestures) {
DCHECK(state_ == GS_PINCH);
+ // It is possible that the none of the touch-points changed their position,
+ // but their radii changed, and that caused the bounding box to also change.
+ // But in such cases, we do not want to either pinch or scroll.
+ // To avoid small jiggles, it is also necessary to make sure that at least one
+ // of the fingers moved enough before a pinch or scroll update is created.
+ bool did_scroll = false;
+ for (int i = 0; i < kMaxGesturePoints; ++i) {
+ if (!points_[i].in_use() || !points_[i].DidScroll(event, 2))
+ continue;
+ did_scroll = true;
+ break;
+ }
+
+ if (!did_scroll)
+ return false;
+
float distance = BoundingBoxDiagonal(bounding_box_);
if (abs(distance - pinch_distance_current_) >=