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

Unified Diff: views/focus/accelerator_handler_touch.cc

Issue 7792094: touchui: support XInput2 MT (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: update patch set according to comment #12 Created 9 years, 3 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/focus/accelerator_handler_touch.cc
diff --git a/views/focus/accelerator_handler_touch.cc b/views/focus/accelerator_handler_touch.cc
index c76e8badbe38773b3d2fd21bf235ddc388c381af..de2b2ac144b5f26dc1afe4d1f4b8beadf193ee8f 100644
--- a/views/focus/accelerator_handler_touch.cc
+++ b/views/focus/accelerator_handler_touch.cc
@@ -47,6 +47,52 @@ bool DispatchX2Event(Widget* widget, XEvent* xev) {
// TODO(sad): We don't capture XInput2 events from keyboard yet.
break;
}
+#if defined(USE_XI2_MT)
+ case XI_TouchBegin:
+ case XI_TouchEnd:
+ case XI_TouchUpdate: {
+ Event::FromNativeEvent2 from_native;
+
+ // Hide the cursor when a touch event comes in.
+ TouchFactory::GetInstance()->SetCursorVisible(false, false);
+
+ // If the TouchEvent is processed by |widget|, then return.
+ TouchEvent touch(xev, from_native);
+ if (widget->OnTouchEvent(touch) != ui::TOUCH_STATUS_UNKNOWN)
+ return true;
+
+ // We do not want to generate a mouse event for an unprocessed touch
+ // event here. That is already done by the gesture manager in
+ // RootView::OnTouchEvent.
+ return false;
+ }
sadrul 2011/09/12 16:20:38 I think you should just #endif here, and let the e
ningxin.hu 2011/09/13 00:51:08 It's a good idea. Thanks for the comment. I used
+ case XI_ButtonPress:
+ case XI_ButtonRelease:
+ case XI_Motion: {
+ XIDeviceEvent* xievent = static_cast<XIDeviceEvent*>(cookie->data);
+ Event::FromNativeEvent2 from_native;
+
+ // Scrolling the wheel generates press/release events with button id's 4
+ // and 5. In case of a wheelscroll, we do not want to show the cursor.
+ if (xievent->detail == 4 || xievent->detail == 5) {
+ MouseWheelEvent wheelev(xev, from_native);
+ return widget->OnMouseEvent(wheelev);
+ }
+
+ MouseEvent mouseev(xev, from_native);
+
+ // Show the cursor. Start a timer to hide the cursor after a delay on
+ // move (not drag) events, or if the only button pressed is released.
+ bool start_timer = mouseev.type() == ui::ET_MOUSE_MOVED;
+ start_timer |= mouseev.type() == ui::ET_MOUSE_RELEASED &&
+ (mouseev.IsOnlyLeftMouseButton() ||
+ mouseev.IsOnlyMiddleMouseButton() ||
+ mouseev.IsOnlyRightMouseButton());
+ TouchFactory::GetInstance()->SetCursorVisible(true, start_timer);
+
+ return widget->OnMouseEvent(mouseev);
+ }
+#else
case XI_ButtonPress:
case XI_ButtonRelease:
case XI_Motion: {
@@ -72,8 +118,8 @@ bool DispatchX2Event(Widget* widget, XEvent* xev) {
cookie->evtype == XI_ButtonRelease)
return false;
- // If the TouchEvent is processed by |root|, then return. Otherwise let
- // it fall through so it can be used as a MouseEvent, if desired.
+ // If the TouchEvent is processed by |widget|, then return. Otherwise
+ // let it fall through so it can be used as a MouseEvent, if desired.
sadrul 2011/09/12 16:20:38 Thanks!
ningxin.hu 2011/09/13 00:51:08 My pleasure.
TouchEvent touch(xev, from_native);
if (widget->OnTouchEvent(touch) != ui::TOUCH_STATUS_UNKNOWN)
return true;
@@ -97,6 +143,7 @@ bool DispatchX2Event(Widget* widget, XEvent* xev) {
return widget->OnMouseEvent(mouseev);
}
}
+#endif // defined(USE_XI2_MT)
sadrul 2011/09/12 16:20:38 Two-blank spaces before '//' comments.
ningxin.hu 2011/09/13 00:51:08 Thanks. Will correct it.
}
return false;
}

Powered by Google App Engine
This is Rietveld 408576698