diff options
author | varunjain@chromium.org <varunjain@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-07 05:56:15 +0000 |
---|---|---|
committer | varunjain@chromium.org <varunjain@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-07 05:56:15 +0000 |
commit | a702758968507f0eabb01651c8a98d240934144b (patch) | |
tree | 37b3db611c163ec2372c825dc30f8c2d1c72d4ee /ui | |
parent | 6b87e6ca65abbb08e15430fd3b2af0bda68de83a (diff) | |
download | chromium_src-a702758968507f0eabb01651c8a98d240934144b.zip chromium_src-a702758968507f0eabb01651c8a98d240934144b.tar.gz chromium_src-a702758968507f0eabb01651c8a98d240934144b.tar.bz2 |
Fix TAP_DOWN gesture event:
1. GESTURE_TAP_DOWN should be sent only on the first TOUCH_PRESSED.
2. New gesture GESTURE_BEGIN shuold be sent on all TOUCH_PRESSED.
3. Rename GESTURE_TAP_UP to GESTURE_END.
BUG=131007
TEST=manual
Review URL: https://chromiumcodereview.appspot.com/10533029
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@140967 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r-- | ui/aura/gestures/gesture_recognizer_unittest.cc | 74 | ||||
-rw-r--r-- | ui/aura/root_window_unittest.cc | 23 | ||||
-rw-r--r-- | ui/aura/window_unittest.cc | 9 | ||||
-rw-r--r-- | ui/base/events.h | 5 | ||||
-rw-r--r-- | ui/base/gestures/gesture_sequence.cc | 22 | ||||
-rw-r--r-- | ui/base/gestures/gesture_sequence.h | 3 | ||||
-rw-r--r-- | ui/views/view_unittest.cc | 2 | ||||
-rw-r--r-- | ui/views/widget/root_view.cc | 2 | ||||
-rw-r--r-- | ui/views/widget/widget.cc | 8 |
9 files changed, 116 insertions, 32 deletions
diff --git a/ui/aura/gestures/gesture_recognizer_unittest.cc b/ui/aura/gestures/gesture_recognizer_unittest.cc index 84ef01c..2621d54 100644 --- a/ui/aura/gestures/gesture_recognizer_unittest.cc +++ b/ui/aura/gestures/gesture_recognizer_unittest.cc @@ -36,7 +36,8 @@ class GestureEventConsumeDelegate : public TestWindowDelegate { GestureEventConsumeDelegate() : tap_(false), tap_down_(false), - tap_up_(false), + begin_(false), + end_(false), double_tap_(false), scroll_begin_(false), scroll_update_(false), @@ -60,7 +61,8 @@ class GestureEventConsumeDelegate : public TestWindowDelegate { void Reset() { tap_ = false; tap_down_ = false; - tap_up_ = false; + begin_ = false; + end_ = false; double_tap_ = false; scroll_begin_ = false; scroll_update_ = false; @@ -85,7 +87,8 @@ class GestureEventConsumeDelegate : public TestWindowDelegate { bool tap() const { return tap_; } bool tap_down() const { return tap_down_; } - bool tap_up() const { return tap_up_; } + bool begin() const { return begin_; } + bool end() const { return end_; } bool double_tap() const { return double_tap_; } bool scroll_begin() const { return scroll_begin_; } bool scroll_update() const { return scroll_update_; } @@ -124,8 +127,11 @@ class GestureEventConsumeDelegate : public TestWindowDelegate { case ui::ET_GESTURE_TAP_DOWN: tap_down_ = true; break; - case ui::ET_GESTURE_TAP_UP: - tap_up_ = true; + case ui::ET_GESTURE_BEGIN: + begin_ = true; + break; + case ui::ET_GESTURE_END: + end_ = true; break; case ui::ET_GESTURE_DOUBLE_TAP: double_tap_ = true; @@ -173,7 +179,8 @@ class GestureEventConsumeDelegate : public TestWindowDelegate { private: bool tap_; bool tap_down_; - bool tap_up_; + bool begin_; + bool end_; bool double_tap_; bool scroll_begin_; bool scroll_update_; @@ -403,6 +410,7 @@ TEST_F(GestureRecognizerTest, GestureEventTap) { root_window()->DispatchTouchEvent(&press); EXPECT_FALSE(delegate->tap()); EXPECT_TRUE(delegate->tap_down()); + EXPECT_TRUE(delegate->begin()); EXPECT_FALSE(delegate->double_tap()); EXPECT_FALSE(delegate->scroll_begin()); EXPECT_FALSE(delegate->scroll_update()); @@ -419,6 +427,8 @@ TEST_F(GestureRecognizerTest, GestureEventTap) { root_window()->DispatchTouchEvent(&release); EXPECT_TRUE(delegate->tap()); EXPECT_FALSE(delegate->tap_down()); + EXPECT_FALSE(delegate->begin()); + EXPECT_TRUE(delegate->end()); EXPECT_FALSE(delegate->double_tap()); EXPECT_FALSE(delegate->scroll_begin()); EXPECT_FALSE(delegate->scroll_update()); @@ -447,6 +457,7 @@ TEST_F(GestureRecognizerTest, GestureEventTapRegion) { root_window()->DispatchTouchEvent(&press); EXPECT_FALSE(delegate->tap()); EXPECT_TRUE(delegate->tap_down()); + EXPECT_TRUE(delegate->begin()); EXPECT_FALSE(delegate->double_tap()); EXPECT_FALSE(delegate->scroll_begin()); EXPECT_FALSE(delegate->scroll_update()); @@ -465,6 +476,8 @@ TEST_F(GestureRecognizerTest, GestureEventTapRegion) { root_window()->DispatchTouchEvent(&release); EXPECT_TRUE(delegate->tap()); EXPECT_FALSE(delegate->tap_down()); + EXPECT_FALSE(delegate->begin()); + EXPECT_TRUE(delegate->end()); EXPECT_FALSE(delegate->double_tap()); EXPECT_FALSE(delegate->scroll_begin()); EXPECT_FALSE(delegate->scroll_update()); @@ -487,6 +500,7 @@ TEST_F(GestureRecognizerTest, GestureEventTapRegion) { root_window()->DispatchTouchEvent(&press); EXPECT_FALSE(delegate->tap()); EXPECT_TRUE(delegate->tap_down()); + EXPECT_TRUE(delegate->begin()); EXPECT_FALSE(delegate->double_tap()); EXPECT_FALSE(delegate->scroll_begin()); EXPECT_FALSE(delegate->scroll_update()); @@ -503,6 +517,8 @@ TEST_F(GestureRecognizerTest, GestureEventTapRegion) { root_window()->DispatchTouchEvent(&release); EXPECT_TRUE(delegate->tap()); EXPECT_FALSE(delegate->tap_down()); + EXPECT_FALSE(delegate->begin()); + EXPECT_TRUE(delegate->end()); EXPECT_FALSE(delegate->double_tap()); EXPECT_FALSE(delegate->scroll_begin()); EXPECT_FALSE(delegate->scroll_update()); @@ -525,6 +541,7 @@ TEST_F(GestureRecognizerTest, GestureEventTapRegion) { root_window()->DispatchTouchEvent(&press); EXPECT_FALSE(delegate->tap()); EXPECT_TRUE(delegate->tap_down()); + EXPECT_TRUE(delegate->begin()); EXPECT_FALSE(delegate->double_tap()); EXPECT_FALSE(delegate->scroll_begin()); EXPECT_FALSE(delegate->scroll_update()); @@ -540,6 +557,7 @@ TEST_F(GestureRecognizerTest, GestureEventTapRegion) { root_window()->DispatchTouchEvent(&move); EXPECT_FALSE(delegate->tap()); EXPECT_FALSE(delegate->tap_down()); + EXPECT_FALSE(delegate->begin()); EXPECT_FALSE(delegate->double_tap()); EXPECT_FALSE(delegate->scroll_begin()); EXPECT_FALSE(delegate->scroll_update()); @@ -556,6 +574,8 @@ TEST_F(GestureRecognizerTest, GestureEventTapRegion) { root_window()->DispatchTouchEvent(&release); EXPECT_TRUE(delegate->tap()); EXPECT_FALSE(delegate->tap_down()); + EXPECT_FALSE(delegate->begin()); + EXPECT_TRUE(delegate->end()); EXPECT_FALSE(delegate->double_tap()); EXPECT_FALSE(delegate->scroll_begin()); EXPECT_FALSE(delegate->scroll_update()); @@ -578,6 +598,7 @@ TEST_F(GestureRecognizerTest, GestureEventTapRegion) { root_window()->DispatchTouchEvent(&press); EXPECT_FALSE(delegate->tap()); EXPECT_TRUE(delegate->tap_down()); + EXPECT_TRUE(delegate->begin()); EXPECT_FALSE(delegate->double_tap()); EXPECT_FALSE(delegate->scroll_begin()); EXPECT_FALSE(delegate->scroll_update()); @@ -593,6 +614,7 @@ TEST_F(GestureRecognizerTest, GestureEventTapRegion) { root_window()->DispatchTouchEvent(&move); EXPECT_FALSE(delegate->tap()); EXPECT_FALSE(delegate->tap_down()); + EXPECT_FALSE(delegate->begin()); EXPECT_FALSE(delegate->double_tap()); EXPECT_FALSE(delegate->scroll_begin()); EXPECT_FALSE(delegate->scroll_update()); @@ -608,6 +630,7 @@ TEST_F(GestureRecognizerTest, GestureEventTapRegion) { root_window()->DispatchTouchEvent(&move1); EXPECT_FALSE(delegate->tap()); EXPECT_FALSE(delegate->tap_down()); + EXPECT_FALSE(delegate->begin()); EXPECT_FALSE(delegate->double_tap()); EXPECT_FALSE(delegate->scroll_begin()); EXPECT_FALSE(delegate->scroll_update()); @@ -623,6 +646,7 @@ TEST_F(GestureRecognizerTest, GestureEventTapRegion) { root_window()->DispatchTouchEvent(&move2); EXPECT_FALSE(delegate->tap()); EXPECT_FALSE(delegate->tap_down()); + EXPECT_FALSE(delegate->begin()); EXPECT_FALSE(delegate->double_tap()); EXPECT_FALSE(delegate->scroll_begin()); EXPECT_FALSE(delegate->scroll_update()); @@ -639,6 +663,8 @@ TEST_F(GestureRecognizerTest, GestureEventTapRegion) { root_window()->DispatchTouchEvent(&release); EXPECT_TRUE(delegate->tap()); EXPECT_FALSE(delegate->tap_down()); + EXPECT_FALSE(delegate->begin()); + EXPECT_TRUE(delegate->end()); EXPECT_FALSE(delegate->double_tap()); EXPECT_FALSE(delegate->scroll_begin()); EXPECT_FALSE(delegate->scroll_update()); @@ -669,6 +695,7 @@ TEST_F(GestureRecognizerTest, GestureEventScroll) { root_window()->DispatchTouchEvent(&press); EXPECT_FALSE(delegate->tap()); EXPECT_TRUE(delegate->tap_down()); + EXPECT_TRUE(delegate->begin()); EXPECT_FALSE(delegate->double_tap()); EXPECT_FALSE(delegate->scroll_begin()); EXPECT_FALSE(delegate->scroll_update()); @@ -681,6 +708,7 @@ TEST_F(GestureRecognizerTest, GestureEventScroll) { SendScrollEvent(root_window(), 130, 230, kTouchId, delegate.get()); EXPECT_FALSE(delegate->tap()); EXPECT_FALSE(delegate->tap_down()); + EXPECT_FALSE(delegate->begin()); EXPECT_FALSE(delegate->double_tap()); EXPECT_TRUE(delegate->scroll_begin()); EXPECT_TRUE(delegate->scroll_update()); @@ -694,6 +722,7 @@ TEST_F(GestureRecognizerTest, GestureEventScroll) { SendScrollEvent(root_window(), 110, 211, kTouchId, delegate.get()); EXPECT_FALSE(delegate->tap()); EXPECT_FALSE(delegate->tap_down()); + EXPECT_FALSE(delegate->begin()); EXPECT_FALSE(delegate->double_tap()); EXPECT_FALSE(delegate->scroll_begin()); EXPECT_TRUE(delegate->scroll_update()); @@ -704,6 +733,7 @@ TEST_F(GestureRecognizerTest, GestureEventScroll) { SendScrollEvent(root_window(), 140, 215, kTouchId, delegate.get()); EXPECT_FALSE(delegate->tap()); EXPECT_FALSE(delegate->tap_down()); + EXPECT_FALSE(delegate->begin()); EXPECT_FALSE(delegate->double_tap()); EXPECT_FALSE(delegate->scroll_begin()); EXPECT_TRUE(delegate->scroll_update()); @@ -719,6 +749,8 @@ TEST_F(GestureRecognizerTest, GestureEventScroll) { root_window()->DispatchTouchEvent(&release); EXPECT_FALSE(delegate->tap()); EXPECT_FALSE(delegate->tap_down()); + EXPECT_FALSE(delegate->begin()); + EXPECT_TRUE(delegate->end()); EXPECT_FALSE(delegate->double_tap()); EXPECT_FALSE(delegate->scroll_begin()); EXPECT_FALSE(delegate->scroll_update()); @@ -856,6 +888,7 @@ TEST_F(GestureRecognizerTest, GestureEventLongPress) { kTouchId, GetTime()); root_window()->DispatchTouchEvent(&press1); EXPECT_TRUE(delegate->tap_down()); + EXPECT_TRUE(delegate->begin()); // We haven't pressed long enough for a long press to occur EXPECT_FALSE(delegate->long_press()); @@ -939,6 +972,7 @@ TEST_F(GestureRecognizerTest, GestureEventLongPressCancelledBySecondTap) { kTouchId1, GetTime()); root_window()->DispatchTouchEvent(&press); EXPECT_TRUE(delegate->tap_down()); + EXPECT_TRUE(delegate->begin()); // We haven't pressed long enough for a long press to occur EXPECT_FALSE(delegate->long_press()); @@ -949,6 +983,7 @@ TEST_F(GestureRecognizerTest, GestureEventLongPressCancelledBySecondTap) { kTouchId2, GetTime()); root_window()->DispatchTouchEvent(&press2); EXPECT_FALSE(delegate->tap_down()); // no touch down for second tap. + EXPECT_TRUE(delegate->begin()); // Wait until the timer runs out gesture_sequence->ForceTimeout(); @@ -1212,6 +1247,7 @@ TEST_F(GestureRecognizerTest, AsynchronousGestureRecognition) { root_window()->DispatchTouchEvent(&press); EXPECT_FALSE(queued_delegate->tap()); EXPECT_FALSE(queued_delegate->tap_down()); + EXPECT_FALSE(queued_delegate->begin()); EXPECT_FALSE(queued_delegate->double_tap()); EXPECT_FALSE(queued_delegate->scroll_begin()); EXPECT_FALSE(queued_delegate->scroll_update()); @@ -1226,6 +1262,8 @@ TEST_F(GestureRecognizerTest, AsynchronousGestureRecognition) { root_window()->DispatchTouchEvent(&release); EXPECT_FALSE(queued_delegate->tap()); EXPECT_FALSE(queued_delegate->tap_down()); + EXPECT_FALSE(queued_delegate->begin()); + EXPECT_FALSE(queued_delegate->end()); EXPECT_FALSE(queued_delegate->double_tap()); EXPECT_FALSE(queued_delegate->scroll_begin()); EXPECT_FALSE(queued_delegate->scroll_update()); @@ -1243,6 +1281,8 @@ TEST_F(GestureRecognizerTest, AsynchronousGestureRecognition) { root_window()->DispatchTouchEvent(&press2); EXPECT_FALSE(delegate->tap()); EXPECT_TRUE(delegate->tap_down()); + EXPECT_FALSE(queued_delegate->begin()); + EXPECT_FALSE(queued_delegate->end()); EXPECT_FALSE(delegate->double_tap()); EXPECT_FALSE(delegate->scroll_begin()); EXPECT_FALSE(delegate->scroll_update()); @@ -1257,6 +1297,8 @@ TEST_F(GestureRecognizerTest, AsynchronousGestureRecognition) { queued_delegate->ReceivedAck(); EXPECT_FALSE(queued_delegate->tap()); EXPECT_TRUE(queued_delegate->tap_down()); + EXPECT_TRUE(queued_delegate->begin()); + EXPECT_FALSE(queued_delegate->end()); EXPECT_FALSE(queued_delegate->double_tap()); EXPECT_FALSE(queued_delegate->scroll_begin()); EXPECT_FALSE(queued_delegate->scroll_update()); @@ -1267,6 +1309,8 @@ TEST_F(GestureRecognizerTest, AsynchronousGestureRecognition) { queued_delegate->ReceivedAck(); EXPECT_TRUE(queued_delegate->tap()); EXPECT_FALSE(queued_delegate->tap_down()); + EXPECT_FALSE(queued_delegate->begin()); + EXPECT_TRUE(queued_delegate->end()); EXPECT_FALSE(queued_delegate->double_tap()); EXPECT_FALSE(queued_delegate->scroll_begin()); EXPECT_FALSE(queued_delegate->scroll_update()); @@ -1280,6 +1324,10 @@ TEST_F(GestureRecognizerTest, AsynchronousGestureRecognition) { root_window()->DispatchTouchEvent(&press3); EXPECT_FALSE(queued_delegate->tap()); EXPECT_FALSE(queued_delegate->tap_down()); + EXPECT_FALSE(queued_delegate->begin()); + EXPECT_FALSE(queued_delegate->end()); + EXPECT_FALSE(queued_delegate->begin()); + EXPECT_FALSE(queued_delegate->end()); EXPECT_FALSE(queued_delegate->double_tap()); EXPECT_FALSE(queued_delegate->scroll_begin()); EXPECT_FALSE(queued_delegate->scroll_update()); @@ -1292,12 +1340,16 @@ TEST_F(GestureRecognizerTest, AsynchronousGestureRecognition) { root_window()->DispatchTouchEvent(&press4); EXPECT_FALSE(delegate->tap()); EXPECT_FALSE(delegate->tap_down()); + EXPECT_FALSE(delegate->begin()); + EXPECT_FALSE(delegate->end()); EXPECT_FALSE(delegate->double_tap()); EXPECT_FALSE(delegate->scroll_begin()); EXPECT_FALSE(delegate->scroll_update()); EXPECT_FALSE(delegate->scroll_end()); EXPECT_FALSE(queued_delegate->tap()); EXPECT_FALSE(queued_delegate->tap_down()); + EXPECT_FALSE(queued_delegate->begin()); + EXPECT_FALSE(queued_delegate->end()); EXPECT_FALSE(queued_delegate->double_tap()); EXPECT_FALSE(queued_delegate->scroll_begin()); EXPECT_FALSE(queued_delegate->scroll_update()); @@ -1313,12 +1365,14 @@ TEST_F(GestureRecognizerTest, AsynchronousGestureRecognition) { root_window()->DispatchTouchEvent(&move); EXPECT_FALSE(delegate->tap()); EXPECT_FALSE(delegate->tap_down()); + EXPECT_FALSE(delegate->begin()); EXPECT_FALSE(delegate->double_tap()); EXPECT_FALSE(delegate->scroll_begin()); EXPECT_FALSE(delegate->scroll_update()); EXPECT_FALSE(delegate->scroll_end()); EXPECT_FALSE(queued_delegate->tap()); EXPECT_FALSE(queued_delegate->tap_down()); + EXPECT_FALSE(queued_delegate->begin()); EXPECT_FALSE(queued_delegate->double_tap()); EXPECT_FALSE(queued_delegate->scroll_begin()); EXPECT_FALSE(queued_delegate->scroll_update()); @@ -1328,6 +1382,8 @@ TEST_F(GestureRecognizerTest, AsynchronousGestureRecognition) { queued_delegate->ReceivedAck(); EXPECT_FALSE(queued_delegate->tap()); EXPECT_TRUE(queued_delegate->tap_down()); + EXPECT_TRUE(queued_delegate->begin()); + EXPECT_FALSE(queued_delegate->end()); EXPECT_FALSE(queued_delegate->double_tap()); EXPECT_FALSE(queued_delegate->scroll_begin()); EXPECT_FALSE(queued_delegate->scroll_update()); @@ -1337,6 +1393,8 @@ TEST_F(GestureRecognizerTest, AsynchronousGestureRecognition) { queued_delegate->ReceivedAck(); EXPECT_FALSE(queued_delegate->tap()); EXPECT_FALSE(queued_delegate->tap_down()); // no touch down for second tap. + EXPECT_TRUE(queued_delegate->begin()); + EXPECT_FALSE(queued_delegate->end()); EXPECT_FALSE(queued_delegate->double_tap()); EXPECT_FALSE(queued_delegate->scroll_begin()); EXPECT_FALSE(queued_delegate->scroll_update()); @@ -1349,6 +1407,8 @@ TEST_F(GestureRecognizerTest, AsynchronousGestureRecognition) { queued_delegate->ReceivedAck(); EXPECT_FALSE(queued_delegate->tap()); EXPECT_FALSE(queued_delegate->tap_down()); + EXPECT_FALSE(queued_delegate->begin()); + EXPECT_FALSE(queued_delegate->end()); EXPECT_FALSE(queued_delegate->double_tap()); EXPECT_TRUE(queued_delegate->scroll_begin()); EXPECT_FALSE(queued_delegate->scroll_update()); @@ -1782,7 +1842,7 @@ TEST_F(GestureRecognizerTest, CaptureSendsTapUp) { capture->SetCapture(); RunAllPendingInMessageLoop(); - EXPECT_TRUE(delegate->tap_up()); + EXPECT_TRUE(delegate->end()); } TEST_F(GestureRecognizerTest, TwoFingerTap) { diff --git a/ui/aura/root_window_unittest.cc b/ui/aura/root_window_unittest.cc index f1c456b..1b8c804 100644 --- a/ui/aura/root_window_unittest.cc +++ b/ui/aura/root_window_unittest.cc @@ -425,8 +425,11 @@ std::string EventTypeToString(ui::EventType type) { case ui::ET_GESTURE_TAP_DOWN: return "GESTURE_TAP_DOWN"; - case ui::ET_GESTURE_TAP_UP: - return "GESTURE_TAP_UP"; + case ui::ET_GESTURE_BEGIN: + return "GESTURE_BEGIN"; + + case ui::ET_GESTURE_END: + return "GESTURE_END"; case ui::ET_GESTURE_DOUBLE_TAP: return "GESTURE_DOUBLE_TAP"; @@ -470,9 +473,9 @@ TEST_F(RootWindowTest, GestureToMouseEventTest) { base::TimeDelta::FromMilliseconds(time_ms)); root_window()->DispatchTouchEvent(&touch_pressed_event); root_window()->DispatchTouchEvent(&touch_released_event); - EXPECT_EQ("TOUCH_PRESSED GESTURE_TAP_DOWN TOUCH_RELEASED GESTURE_TAP " - "MOUSE_ENTERED MOUSE_MOVED MOUSE_PRESSED MOUSE_RELEASED " - "GESTURE_TAP_UP", + EXPECT_EQ("TOUCH_PRESSED GESTURE_BEGIN GESTURE_TAP_DOWN TOUCH_RELEASED " + "GESTURE_TAP MOUSE_ENTERED MOUSE_MOVED MOUSE_PRESSED " + "MOUSE_RELEASED GESTURE_END", EventTypesToString(filter->events())); filter->events().clear(); } @@ -482,7 +485,7 @@ TEST_F(RootWindowTest, GestureToMouseEventTest) { TouchEvent touch_event(ui::ET_TOUCH_PRESSED, gfx::Point(100, 101), 1, base::TimeDelta()); root_window()->DispatchTouchEvent(&touch_event); - EXPECT_EQ("TOUCH_PRESSED GESTURE_TAP_DOWN", + EXPECT_EQ("TOUCH_PRESSED GESTURE_BEGIN GESTURE_TAP_DOWN", EventTypesToString(filter->events())); filter->events().clear(); } @@ -518,7 +521,7 @@ TEST_F(RootWindowTest, GestureToMouseEventTest) { base::TimeDelta()); root_window()->DispatchTouchEvent(&touch_event); EXPECT_EQ("TOUCH_RELEASED GESTURE_SCROLL_END MOUSE_DRAGGED MOUSE_RELEASED " - "GESTURE_TAP_UP", + "GESTURE_END", EventTypesToString(filter->events())); filter->events().clear(); } @@ -556,9 +559,9 @@ TEST_F(RootWindowTest, MouseMoveThenTouch) { base::TimeDelta::FromMilliseconds(time_ms)); root_window()->DispatchTouchEvent(&touch_pressed_event); root_window()->DispatchTouchEvent(&touch_released_event); - EXPECT_EQ("TOUCH_PRESSED GESTURE_TAP_DOWN TOUCH_RELEASED GESTURE_TAP " - "MOUSE_EXITED MOUSE_ENTERED MOUSE_MOVED MOUSE_PRESSED " - "MOUSE_RELEASED GESTURE_TAP_UP", + EXPECT_EQ("TOUCH_PRESSED GESTURE_BEGIN GESTURE_TAP_DOWN TOUCH_RELEASED " + "GESTURE_TAP MOUSE_EXITED MOUSE_ENTERED MOUSE_MOVED " + "MOUSE_PRESSED MOUSE_RELEASED GESTURE_END", EventTypesToString(filter->events())); filter->events().clear(); } diff --git a/ui/aura/window_unittest.cc b/ui/aura/window_unittest.cc index 9252097..2b9a68a 100644 --- a/ui/aura/window_unittest.cc +++ b/ui/aura/window_unittest.cc @@ -626,7 +626,8 @@ TEST_F(WindowTest, TouchCaptureCancelsOtherTouches) { TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), 0, getTime()); root_window()->DispatchTouchEvent(&press); - EXPECT_EQ(1, delegate1.gesture_event_count()); + // We will get both GESTURE_BEGIN and GESTURE_TAP_DOWN. + EXPECT_EQ(2, delegate1.gesture_event_count()); delegate1.ResetCounts(); w2->SetCapture(); @@ -658,7 +659,8 @@ TEST_F(WindowTest, TouchCaptureCancelsOtherTouches) { gfx::Point(10, 10), 0, getTime()); root_window()->DispatchTouchEvent(&press2); EXPECT_EQ(0, delegate1.gesture_event_count()); - EXPECT_EQ(1, delegate2.gesture_event_count()); + // We will get both GESTURE_BEGIN and GESTURE_TAP_DOWN. + EXPECT_EQ(2, delegate2.gesture_event_count()); } TEST_F(WindowTest, TouchCaptureDoesntCancelCapturedTouches) { @@ -670,7 +672,8 @@ TEST_F(WindowTest, TouchCaptureDoesntCancelCapturedTouches) { gfx::Point(10, 10), 0, getTime()); root_window()->DispatchTouchEvent(&press); - EXPECT_EQ(1, delegate.gesture_event_count()); + // We will get both GESTURE_BEGIN and GESTURE_TAP_DOWN. + EXPECT_EQ(2, delegate.gesture_event_count()); delegate.ResetCounts(); window->SetCapture(); diff --git a/ui/base/events.h b/ui/base/events.h index 6712b19..1d8b2d6 100644 --- a/ui/base/events.h +++ b/ui/base/events.h @@ -52,8 +52,9 @@ enum EventType { ET_GESTURE_SCROLL_END, ET_GESTURE_SCROLL_UPDATE, ET_GESTURE_TAP, - ET_GESTURE_TAP_DOWN, // Sent before any other gesture types. - ET_GESTURE_TAP_UP, // Sent after any other gestures. + ET_GESTURE_TAP_DOWN, + ET_GESTURE_BEGIN, // Sent before any other gesture types. + ET_GESTURE_END, // Sent after any other gestures. ET_GESTURE_DOUBLE_TAP, ET_GESTURE_TWO_FINGER_TAP, ET_GESTURE_PINCH_BEGIN, diff --git a/ui/base/gestures/gesture_sequence.cc b/ui/base/gestures/gesture_sequence.cc index f11d5d1..7e3302c 100644 --- a/ui/base/gestures/gesture_sequence.cc +++ b/ui/base/gestures/gesture_sequence.cc @@ -248,6 +248,11 @@ GestureSequence::Gestures* GestureSequence::ProcessTouchEventForGesture( const int point_id = points_[event.GetTouchId()].point_id(); if (point_id < 0) return NULL; + + // Send GESTURE_BEGIN for any touch pressed. + if (event.GetEventType() == ui::ET_TOUCH_PRESSED) + AppendBeginGestureEvent(point, gestures.get()); + switch (Signature(state_, point_id, event.GetEventType(), false)) { case GST_NO_GESTURE_FIRST_PRESSED: TouchDown(event, point, gestures.get()); @@ -351,7 +356,6 @@ GestureSequence::Gestures* GestureSequence::ProcessTouchEventForGesture( case GST_PINCH_THIRD_PRESSED: case GST_PINCH_FOURTH_PRESSED: case GST_PINCH_FIFTH_PRESSED: - AppendTapDownGestureEvent(point, gestures.get()); pinch_distance_current_ = BoundingBoxDiagonal(bounding_box_); pinch_distance_start_ = pinch_distance_current_; break; @@ -359,7 +363,7 @@ GestureSequence::Gestures* GestureSequence::ProcessTouchEventForGesture( if (event.GetEventType() == ui::ET_TOUCH_RELEASED || event.GetEventType() == ui::ET_TOUCH_CANCELLED) - AppendTapUpGestureEvent(point, gestures.get()); + AppendEndGestureEvent(point, gestures.get()); if (state_ != last_state) DVLOG(4) << "Gesture Sequence" @@ -476,13 +480,23 @@ void GestureSequence::AppendTapDownGestureEvent(const GesturePoint& point, point.first_touch_position(), flags_, base::Time::FromDoubleT(point.last_touch_time()), + 0, 0.f, 1 << point.touch_id())); +} + +void GestureSequence::AppendBeginGestureEvent(const GesturePoint& point, + Gestures* gestures) { + gestures->push_back(helper_->CreateGestureEvent( + ui::ET_GESTURE_BEGIN, + point.first_touch_position(), + flags_, + base::Time::FromDoubleT(point.last_touch_time()), point_count_, 0.f, 1 << point.touch_id())); } -void GestureSequence::AppendTapUpGestureEvent(const GesturePoint& point, +void GestureSequence::AppendEndGestureEvent(const GesturePoint& point, Gestures* gestures) { gestures->push_back(helper_->CreateGestureEvent( - ui::ET_GESTURE_TAP_UP, + ui::ET_GESTURE_END, point.first_touch_position(), flags_, base::Time::FromDoubleT(point.last_touch_time()), diff --git a/ui/base/gestures/gesture_sequence.h b/ui/base/gestures/gesture_sequence.h index b976bb3..07d8cc4 100644 --- a/ui/base/gestures/gesture_sequence.h +++ b/ui/base/gestures/gesture_sequence.h @@ -78,7 +78,8 @@ class UI_EXPORT GestureSequence { // Tap gestures. void AppendTapDownGestureEvent(const GesturePoint& point, Gestures* gestures); - void AppendTapUpGestureEvent(const GesturePoint& point, Gestures* gestures); + void AppendBeginGestureEvent(const GesturePoint& point, Gestures* gestures); + void AppendEndGestureEvent(const GesturePoint& point, Gestures* gestures); void AppendClickGestureEvent(const GesturePoint& point, Gestures* gestures); void AppendDoubleClickGestureEvent(const GesturePoint& point, Gestures* gestures); diff --git a/ui/views/view_unittest.cc b/ui/views/view_unittest.cc index 70e6cee..3b6099d 100644 --- a/ui/views/view_unittest.cc +++ b/ui/views/view_unittest.cc @@ -603,7 +603,7 @@ TEST_F(ViewTest, GestureEvent) { EXPECT_EQ(ui::ET_UNKNOWN, v1->last_gesture_event_type_); // Simulate an up so that RootView is no longer targetting |v3|. - GestureEventForTest g1_up(ui::ET_GESTURE_TAP_UP, 110, 110, 0); + GestureEventForTest g1_up(ui::ET_GESTURE_END, 110, 110, 0); root->OnGestureEvent(g1_up); v1->Reset(); diff --git a/ui/views/widget/root_view.cc b/ui/views/widget/root_view.cc index 6b6c14b..f10bd5b 100644 --- a/ui/views/widget/root_view.cc +++ b/ui/views/widget/root_view.cc @@ -450,7 +450,7 @@ ui::GestureStatus RootView::OnGestureEvent(const GestureEvent& event) { View* handler = gesture_handler_; GestureEvent handler_event(event, this, gesture_handler_); // TODO: should only do this for the last touch id that goes up. - if (event.type() == ui::ET_GESTURE_TAP_UP) + if (event.type() == ui::ET_GESTURE_END) gesture_handler_ = NULL; return handler->OnGestureEvent(handler_event); } diff --git a/ui/views/widget/widget.cc b/ui/views/widget/widget.cc index 7626e96..2231378 100644 --- a/ui/views/widget/widget.cc +++ b/ui/views/widget/widget.cc @@ -1116,9 +1116,11 @@ ui::GestureStatus Widget::OnGestureEvent(const GestureEvent& event) { // dragging) may explicitly capture. break; - case ui::ET_GESTURE_TAP_UP: - is_touch_down_ = false; - ReleaseCapture(); + case ui::ET_GESTURE_END: + if (event.delta_x() == 1) { + is_touch_down_ = false; + ReleaseCapture(); + } break; default: |