Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(410)

Unified Diff: views/touchui/gesture_manager.cc

Issue 8364039: Initial views touchui GestureRecognizer support (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Event injection as per Robert comments Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: views/touchui/gesture_manager.cc
diff --git a/views/touchui/gesture_manager.cc b/views/touchui/gesture_manager.cc
index 723db77792244d63a4763b5bbb500ebeb69516d7..e47c25251deb67b29b06433c2c5394823632c963 100644
--- a/views/touchui/gesture_manager.cc
+++ b/views/touchui/gesture_manager.cc
@@ -28,42 +28,53 @@ bool GestureManager::ProcessTouchEventForGesture(const TouchEvent& event,
if (status != ui::TOUCH_STATUS_UNKNOWN)
return false; // The event was consumed by a touch sequence.
- // TODO(rjkroege): A realistic version of the GestureManager will
- // appear in a subsequent CL. This interim version permits verifying that the
- // event distribution code works by turning all touch inputs into
- // mouse approximations.
-
- // Conver the touch-event into a mouse-event. This mouse-event gets its
- // location information from the native-event, so it needs to convert the
- // coordinate to the target widget.
- MouseEvent mouseev(event);
- if (ViewsDelegate::views_delegate->GetDefaultParentView()) {
- // TODO(oshima): We may need to send the event back through
- // window manager to handle mouse capture correctly.
- Widget* desktop =
- ViewsDelegate::views_delegate->GetDefaultParentView()->GetWidget();
- Widget* source_widget = source->GetWidget();
- MouseEvent converted(
- mouseev, desktop->GetRootView(), source_widget->GetRootView());
- source_widget->OnMouseEvent(converted);
- } else {
- Widget* source_widget = source->GetWidget();
- Widget* top_widget = source_widget->GetTopLevelWidget();
- if (source_widget != top_widget) {
- // This is necessary as TYPE_CHILD widget is still NativeWidgetGtk.
- // Fix this once TYPE_CHILD is switched to NativeWidgetViews.
- MouseEvent converted(mouseev,
- top_widget->GetRootView(),
- source_widget->GetRootView());
- source_widget->OnMouseEvent(mouseev);
+ if (root_view_ == NULL || root_view_ == source->GetWidget()->GetRootView()) {
+ // Get the GestureEvent list processed from GestureManager.
+ scoped_ptr<Gestures> gestures;
+ gestures.reset(gesture_recognizer.ProcessTouchEventForGesture(converted,
+ false));
rjkroege 2011/10/24 17:41:09 indent 1 more
Gajen 2011/10/25 14:32:29 Done.
+ Widget* source_widget = NULL;
+ RootView* source_root_view = NULL;
+ RootView* target_root_view = NULL;
+ if (ViewsDelegate::views_delegate->GetDefaultParentView()) {
+ // TODO(oshima): We may need to send the event back through
+ // window manager to handle mouse capture correctly.
+ Widget* desktop =
+ ViewsDelegate::views_delegate->GetDefaultParentView()->GetWidget();
+ Widget* source_widget = source->GetWidget();
+ TouchEvent converted(
+ event, desktop->GetRootView(), source_widget->GetRootView());
+ source_root_view = desktop->GetRootView();
+ target_root_view = source_widget->GetRootView();
} else {
- source_widget->OnMouseEvent(mouseev);
+ Widget* source_widget = source->GetWidget();
+ Widget* top_widget = source_widget->GetTopLevelWidget();
+ if (source_widget != top_widget) {
+ // This is necessary as TYPE_CHILD widget is still NativeWidgetGtk.
+ // Fix this once TYPE_CHILD is switched to NativeWidgetViews.
+ source_root_view = top_widget->GetRootView();
+ target_root_view = source_widget->GetRootView();
+ }
}
+ for (int i = 0; i < gestures->size(); i++) {
+ // Convert GestureEvent w.r.t new source and target.
+ GestureEvent converted(*(gestures->at(i).GestureEvent()),
+ source_root_view, target_root_view);
+ source_widget->OnGestureEvent(converted);
rjkroege 2011/10/24 17:41:09 you can modify the code in RootView to contain the
Gajen 2011/10/25 14:32:29 Done temporarily, but would required changes when
+ }
+ return true;
+ } else {
+ // Reset GestureRecognizer state.
+ // TODO(Gajen): Do we need to support Gesture across different RootViews
rjkroege 2011/10/24 17:41:09 no. you'll see that the RootView owns a private GM
Gajen 2011/10/25 14:32:29 But, GM is singleton, so would be same across all
+ // except where TYPE_CHILD widget is still NativeWidgetGtk.
+ gesture_recognizer.Reset();
+ root_view_ = NULL;
+ return false;
}
- return true;
}
-GestureManager::GestureManager() {
+GestureManager::GestureManager()
+ : root_view_(NULL) {
}
} // namespace views

Powered by Google App Engine
This is Rietveld 408576698