GNOME Bugzilla – Bug 723552
Handle touch events, even if minimally
Last modified: 2014-07-08 15:09:45 UTC
Created attachment 267994 [details] [review] patch For pointer events, mutter seems to do a great deal for not letting those go through GDK, instead handling those internally and later letting upper layers take the event with gtk_main_do_event(). For touch events, it is not as thorough unfortunately, XI_TouchBegin is ignored by mutter, but handled in GDK, which updates internal grab states and translates it to a button press event. This event does trigger a meta_display_begin_grab_op(), XIGrabDevice() is called with an evmask that ignores touch events in favor of emulated pointer events, so GDK will never know about this touch again, leaving stuck implicit grabs internally. This makes any future touch operation redirect to the first grabbed window. I'm attaching a patch that adds very minimal touch event handling, so GDK is kept ignorant of touch events as equally as pointer events. In order to perform one-finger window dragging, only XI_TouchBegin needs to be handled, so a button press event is emulated within mutter, and all other events are safely converted by the grab mask into pointer events without leaving inconsistent states. In the future, if multitouch gestures are devised for window management, the device grab should include all 3 touch events in the mask ,and XI_TouchUpdate/End would need handling in event_callback().
this would be great to have in 3.12 (I just got a touchscreen, so some self-interest here...)
Review of attachment 267994 [details] [review]: Can you add the three new event types to the events logging function, even if minimally? ::: src/core/display.c @@ +2688,3 @@ + /* Currently unhandled, if any grab_op is started through XI_TouchBegin, + * the XIGrabDevice() evmask drops touch events, so only emulated + * XI_Motions and XI_ButtonRelease will follow. Perhaps we should have a g_assert_not_reached then? Or could we drop the grab by some other means and then see a TouchUpdate / TouchEnd in practice?
Created attachment 271467 [details] [review] core: Add minimal handling of touch events Currently touch events are ignored in the core event handler, and hence dealt with within GDK. If those touch events were emulating pointer events, GDK would attempt to convert back those events to pointer events as the frame GdkWindow doesn't have the GDK_TOUCH_MASK set. This results in XI_TouchBegin events being initially processed by GDK, converted to button events, and triggering a grab op that subverts touch events into pointer events, so the touch is never ever seen again by GDK. This leaves GDK in an inconsistent internal state wrt pointer grabs, so future pointer-emulating touches will refer to the same window forever. Fix this by handling touch events minimally, just enough to convert XI_TouchBegin to GDK_BUTTON_PRESS within mutter, so GDK is bypassed for every touch event just like it is for pointer events. This, and the XIGrabDevice() that keeps coercing pointer events when the grab operation starts, are enough to fix window drag and drop on touch devices.
Review of attachment 271467 [details] [review]: OK.
Comment on attachment 271467 [details] [review] core: Add minimal handling of touch events pushed to master. bug still open for porting to the wayland branch
*** Bug 727491 has been marked as a duplicate of this bug. ***