After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 723552 - Handle touch events, even if minimally
Handle touch events, even if minimally
Product: mutter
Classification: Core
Component: general
git master
Other Linux
: Normal normal
: ---
Assigned To: mutter-maint
: 727491 (view as bug list)
Depends on:
Reported: 2014-02-03 19:10 UTC by Carlos Garnacho
Modified: 2014-07-08 15:09 UTC
See Also:
GNOME target: ---
GNOME version: ---

patch (10.07 KB, patch)
2014-02-03 19:10 UTC, Carlos Garnacho
reviewed Details | Review
core: Add minimal handling of touch events (11.30 KB, patch)
2014-03-10 19:31 UTC, Carlos Garnacho
committed Details | Review

Description Carlos Garnacho 2014-02-03 19:10:00 UTC
Created attachment 267994 [details] [review]

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().
Comment 1 Matthias Clasen 2014-03-07 04:50:05 UTC
this would be great to have in 3.12 (I just got a touchscreen, so some self-interest here...)
Comment 2 Jasper St. Pierre (not reading bugmail) 2014-03-07 14:16:29 UTC
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?
Comment 3 Carlos Garnacho 2014-03-10 19:31:40 UTC
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.
Comment 4 Jasper St. Pierre (not reading bugmail) 2014-03-10 19:44:37 UTC
Review of attachment 271467 [details] [review]:

Comment 5 Matthias Clasen 2014-03-14 22:09:54 UTC
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
Comment 6 Florian Müllner 2014-04-02 13:38:58 UTC
*** Bug 727491 has been marked as a duplicate of this bug. ***