GNOME Bugzilla – Bug 731371
Gtk gets confused by wayland touch events
Last modified: 2014-06-12 10:36:19 UTC
When using a touchscreen under weston, Gtk+ sometimes seems to get confused about its inputs. E.g. when running gtk3-demo, scrolling in the demo list with the touchscreen causes mouse events to be ignored afterwards. Some digging revealed that this is due to weston numbering its touch events sequence from 0 and gdks wayland backend simply using GUINT_TO_POINTER to set the touch.sequence field. This causes gdk_event_get_touch_sequence to return NULL which confuses other parts of Gdk/Gtk.
Created attachment 278100 [details] [review] Ensure GdkEvent has a non-null touch sequence for touch events
Created attachment 278104 [details] [review] Compared to previous fix casting warning
Comment on attachment 278104 [details] [review] Compared to previous fix casting warning Thanks Sjoerd for the patch! having slot id=0 is indeed possible on wayland... I would however find more convenient to have the event sequence tied somehow to the slot ID (say id+1), that'd be helpful for debugging situations above GDK, although eventually there should maybe be a gdk_wayland_event_sequence_get_slot(). The way weston/mutter make use of mtdev should ensure slot is kept between 0..max_dev_touches-1, if a compositor for some reason implements this as a counter, it could overflow to 0 at some point, but it wouldn't be worse than X11 in that regard...
I forgot to mention, IMO it's fine to push after that change
committed: commit 5b118a9fd768f752f3e770d7734596e239de942d Author: Sjoerd Simons <sjoerd.simons@collabora.co.uk> Date: Sun Jun 8 17:21:14 2014 +0200 wayland: Ensure the touch sequence pointer value is non-null Weston numbers its touch sequences ids starting from 0, thus simply setting the GtkEvents touch.sequence to the touch id value typically causes gdk_event_get_event_sequence to return NULL. Unfortunately this confuses other parts of GDK. As both weston & mutter keep the sequence id between 0..max_dev_touches -1 simply use + 1 to keep the id > 0. While this isn't entirely correct (compositor could send -1 as the touch id), this keeps the touch id in gtk tied to the touch id from weston which is useful for debugging. A more thorough solution could be done when it turns out this is an issue in practise https://bugzilla.gnome.org/show_bug.cgi?id=731371