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; |
+ } |
+ 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. |
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) |
} |
return false; |
} |