diff options
author | sadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-18 19:08:01 +0000 |
---|---|---|
committer | sadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-18 19:08:01 +0000 |
commit | 2839e0061402c2f6d9d409e67850e9e708defa8d (patch) | |
tree | ed7090ef4e9bdcfa295b64aea49be5180d11b5d7 /views/widget | |
parent | da7abbb92e3cb6774f91ab37571bca6aaaa7b41a (diff) | |
download | chromium_src-2839e0061402c2f6d9d409e67850e9e708defa8d.zip chromium_src-2839e0061402c2f6d9d409e67850e9e708defa8d.tar.gz chromium_src-2839e0061402c2f6d9d409e67850e9e708defa8d.tar.bz2 |
touch: Return an enum from OnTouchEvent.
The enum returned from OnTouchEvent reflects the current status of the touch-sequence. This can be used by the RootView to determine when the touch-event-handler should be reset.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/6347002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@71677 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/widget')
-rw-r--r-- | views/widget/root_view.cc | 23 | ||||
-rw-r--r-- | views/widget/root_view.h | 2 |
2 files changed, 18 insertions, 7 deletions
diff --git a/views/widget/root_view.cc b/views/widget/root_view.cc index 143b23a..a124e60 100644 --- a/views/widget/root_view.cc +++ b/views/widget/root_view.cc @@ -306,16 +306,19 @@ void RootView::SetFocusOnMousePressed(bool f) { } #if defined(TOUCH_UI) -bool RootView::OnTouchEvent(const TouchEvent& e) { +View::TouchStatus RootView::OnTouchEvent(const TouchEvent& e) { // If touch_pressed_handler_ is non null, we are currently processing // a touch down on the screen situation. In that case we send the // event to touch_pressed_handler_ + View::TouchStatus status = TOUCH_STATUS_UNKNOWN; if (touch_pressed_handler_) { TouchEvent touch_event(e, this, touch_pressed_handler_); - touch_pressed_handler_->ProcessTouchEvent(touch_event); + status = touch_pressed_handler_->ProcessTouchEvent(touch_event); gesture_manager_->ProcessTouchEventForGesture(e, this, true); - return true; + if (status == TOUCH_STATUS_END) + touch_pressed_handler_ = NULL; + return status; } bool handled = false; @@ -327,12 +330,20 @@ bool RootView::OnTouchEvent(const TouchEvent& e) { // Disabled views eat events but are treated as not handled by the // the GestureManager. handled = false; + status = TOUCH_STATUS_UNKNOWN; break; } // See if this view wants to handle the touch TouchEvent touch_event(e, this, touch_pressed_handler_); - handled = touch_pressed_handler_->ProcessTouchEvent(touch_event); + status = touch_pressed_handler_->ProcessTouchEvent(touch_event); + + // If the touch didn't initiate a touch-sequence, then reset the touch event + // handler. + if (status != TOUCH_STATUS_START) + touch_pressed_handler_ = NULL; + + handled = status != TOUCH_STATUS_UNKNOWN; // The view could have removed itself from the tree when handling // OnTouchEvent(). So handle as per OnMousePressed. NB: we @@ -348,7 +359,7 @@ bool RootView::OnTouchEvent(const TouchEvent& e) { // forwarded to that view. if (handled) { gesture_manager_->ProcessTouchEventForGesture(e, this, handled); - return true; + return status; } } @@ -357,7 +368,7 @@ bool RootView::OnTouchEvent(const TouchEvent& e) { // Give the touch event to the gesture manager. gesture_manager_->ProcessTouchEventForGesture(e, this, handled); - return handled; + return status; } #endif diff --git a/views/widget/root_view.h b/views/widget/root_view.h index bf47c42..0bbdea8 100644 --- a/views/widget/root_view.h +++ b/views/widget/root_view.h @@ -98,7 +98,7 @@ class RootView : public View, virtual void OnMouseMoved(const MouseEvent& e); virtual void SetMouseHandler(View* new_mouse_handler); #if defined(TOUCH_UI) - virtual bool OnTouchEvent(const TouchEvent& e); + virtual TouchStatus OnTouchEvent(const TouchEvent& e); #endif // Invoked By the Widget if the mouse drag is interrupted by |