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 787884 - g-s-d is not properly setting the display property on touchscreen inputdevs, causing the coordinates to not get tranformed when rotation the display
g-s-d is not properly setting the display property on touchscreen inputdevs, ...
Status: RESOLVED FIXED
Product: gnome-settings-daemon
Classification: Core
Component: wacom
3.26.x
Other Linux
: Normal normal
: ---
Assigned To: Carlos Garnacho
gnome-settings-daemon-maint
Depends on:
Blocks:
 
 
Reported: 2017-09-19 10:30 UTC by Hans de Goede
Modified: 2017-10-03 13:31 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
wacom: Use GTK+ skeleton (774 bytes, patch)
2017-09-22 15:58 UTC, Carlos Garnacho
committed Details | Review
wacom: Add both tablet and touchscreen devices on initial iteration (2.25 KB, patch)
2017-09-22 15:58 UTC, Carlos Garnacho
committed Details | Review
common: Ignore (pure) keyboard devices on GsdDeviceManager (2.28 KB, patch)
2017-09-24 11:43 UTC, Carlos Garnacho
rejected Details | Review
common: Ignore (pure) keyboard devices on GsdDeviceManager (2.58 KB, patch)
2017-09-29 15:00 UTC, Hans de Goede
committed Details | Review
common: Fix touchscreen vs display orientation mismatch under gdm (865 bytes, patch)
2017-09-29 15:01 UTC, Hans de Goede
committed Details | Review

Description Hans de Goede 2017-09-19 10:30:13 UTC
g-s-d's wacom plugin should set a display property with "vendor", "model", "serial" strings in there on the touchscreen inputdev, so that mutter can find the matching displau and when it is rotating the display it can transform the touchscreen coordinates to match.

I've added a g_warning to debug this to mutter and currently it gets "", "", "" as display value from the gsettings for the touchscreen.

I've seen this on multiple Bay and Cherry Trail tablets running Fedora 27 / GNOME 3.26. I think I may be able to reproduce it on older GNOME versions too, but I've done all the debugging on 3.26, so I'm sure it is broken there.
Comment 1 Carlos Garnacho 2017-09-22 15:58:10 UTC
Created attachment 360269 [details] [review]
wacom: Use GTK+ skeleton

The wacom module uses GDK resources indirectly through GsdDeviceMapper,
which turn out NULL when this object tries to attach itself to a
GdkScreen.
Comment 2 Carlos Garnacho 2017-09-22 15:58:16 UTC
Created attachment 360270 [details] [review]
wacom: Add both tablet and touchscreen devices on initial iteration

The GsdDeviceManager::device-added callback would observe both
display-attached tablets and touchscreens, but only the former were
added in the initial loop.

This made touchscreens not properly mapped to outputs, as touchscreens
are usually built into the device.
Comment 3 Rui Matos 2017-09-22 16:00:33 UTC
Review of attachment 360269 [details] [review]:

sure
Comment 4 Rui Matos 2017-09-22 16:03:13 UTC
Review of attachment 360270 [details] [review]:

makes sense
Comment 5 Carlos Garnacho 2017-09-22 17:58:28 UTC
Thanks! Pushed to master. I see gnome-3-26 is not branched yet, and this
does not apply to gnome-3-24, so we're good here.

Attachment 360269 [details] pushed as 0fb1b96 - wacom: Use GTK+ skeleton
Attachment 360270 [details] pushed as 08424fb - wacom: Add both tablet and touchscreen devices on initial iteration
Comment 6 Hans de Goede 2017-09-24 10:14:44 UTC
Carlos,

Thank you for looking into this, unfortunately the fix is not complete. Starting with 4.14 the kernel has support for the capacitive home-button found on some
goodix touchscreens (on some x86 tablets the windows logo on the front is a capacitive button), so now the touchscreen is both a touchscreen and a keyboard.

xf86-input-libinput deals with this by splitting the /dev/input/event# node into 2 Xi2 devices, but plugins/common/gsd-device-manager-x11.c checks for duplicate devices based on the device path returned by xdevice_get_device_node which is the same /dev/input/event# node for both the keyboard and touchscreen Xi2 devices which xf86-input-libinput creates for the touchscreen.

So now depending on which get enumerated first (and my testing has shown that the enumeration order is random) either only the Touchscreen Xi2 dev gets seen by plugins/common/gsd-device-manager-x11.c; or only the keyboard Xi2 dev. The former is fine as g-s-d does not need to be aware of the keyboard Xi2 dev, if however the keybaord Xi2 dev gets enumerated g-s-d never sees the touchscreen and the mapping of the touchscreen to a monitor does not happen.

I believe the easiest way to fix this is for g-s-d to ignore the keyboard Xi2 devices for /dev/input/event# nodes which are both a touch device and a keyboard, note xf86-input-libinput calls these devices sub-devices. I see 2 ways for g-s-d to ignore these sub-devices:

1) Have xf86-input-libinput not set the XI_PROP_DEVICE_NODE property on sub-devices so that xdevice_get_device_node returns NULL as it already does for the 
"Virtual core XTEST pointer/keyboard"

2) Have xf86-input-libinput set a new XI_PROP_LIBINPUT_SUBDEV property on sub-devs which g-s-d can then test to ignore these.

1. Has the advantage that it requires no changes in g-s-d, but I'm not sure if that may have any bad side-effects.

I will send Peter Hutterer a mail about this, asking him to reply here in bugzilla.

Regards,

Hans
Comment 7 Carlos Garnacho 2017-09-24 11:41:31 UTC
(In reply to Hans de Goede from comment #6)
> Carlos,
> 
> Thank you for looking into this, unfortunately the fix is not complete.
> Starting with 4.14 the kernel has support for the capacitive home-button
> found on some
> goodix touchscreens (on some x86 tablets the windows logo on the front is a
> capacitive button), so now the touchscreen is both a touchscreen and a
> keyboard.

Ouch, I see... I have no tablets with such button, so will leave testing to you :).

> 
> xf86-input-libinput deals with this by splitting the /dev/input/event# node
> into 2 Xi2 devices, but plugins/common/gsd-device-manager-x11.c checks for
> duplicate devices based on the device path returned by
> xdevice_get_device_node which is the same /dev/input/event# node for both
> the keyboard and touchscreen Xi2 devices which xf86-input-libinput creates
> for the touchscreen.
> 
> So now depending on which get enumerated first (and my testing has shown
> that the enumeration order is random) either only the Touchscreen Xi2 dev
> gets seen by plugins/common/gsd-device-manager-x11.c; or only the keyboard
> Xi2 dev. The former is fine as g-s-d does not need to be aware of the
> keyboard Xi2 dev, if however the keybaord Xi2 dev gets enumerated g-s-d
> never sees the touchscreen and the mapping of the touchscreen to a monitor
> does not happen.
> 
> I believe the easiest way to fix this is for g-s-d to ignore the keyboard
> Xi2 devices for /dev/input/event# nodes which are both a touch device and a
> keyboard, note xf86-input-libinput calls these devices sub-devices. I see 2
> ways for g-s-d to ignore these sub-devices:

IMHO there's no need to complicate this much from the g-s-d perspective. GsdDeviceManager is only used together with GsdDeviceMapper, so just devices with ABS axes are essential here. I think it's entirely safe to ignore all keyboards here.

Also, a heads up that this output mapping policy will be folded into mutter. There we have a less ad-hoc input device abstraction, so whatever we come up with here might not be needed after all.

Regardless of Peter considering this a xf86-input-libinput inconsistency or not, I'm attaching an untested patch to ignore keyboards on g-s-d.
Comment 8 Carlos Garnacho 2017-09-24 11:43:25 UTC
Created attachment 360314 [details] [review]
common: Ignore (pure) keyboard devices on GsdDeviceManager

They are not needed for GsdDeviceMapper purposes, and can cause misbehavior
if the keyboard device "shares" the input node with a device we do need
mapping.

Fixes spotty touchscreen detection with those touchscreens that have a
capacitive menu/windows button.
Comment 9 Rui Matos 2017-09-25 13:07:31 UTC
Review of attachment 360314 [details] [review]:

makes sense, push if testing passes
Comment 10 Peter Hutterer 2017-09-26 05:06:49 UTC
bit late with the reply, sorry.

(In reply to Hans de Goede from comment #6)
> 1) Have xf86-input-libinput not set the XI_PROP_DEVICE_NODE property on
> sub-devices so that xdevice_get_device_node returns NULL as it already does
> for the 
> "Virtual core XTEST pointer/keyboard"
> 
> 2) Have xf86-input-libinput set a new XI_PROP_LIBINPUT_SUBDEV property on
> sub-devs which g-s-d can then test to ignore these.
 
sorry, both of these aren't really acceptable for the libinput driver which is doing the right thing here. The concept of multiple X devices per event node has been around for a while (wacom driver) so this is simply a bug in g-s-d.
Comment 11 Hans de Goede 2017-09-29 13:22:07 UTC
Peter, thank you for the feedback,

Carlos, sorry for the slow response, testing your patch now. First thing which stands out:

gsd-device-manager-udev.c: In function ‘create_device’:
gsd-device-manager-udev.c:95:3: warning: ‘return’ with no value, in function returning non-void
   return;
   ^~~~~~
gsd-device-manager-udev.c:82:1: note: declared here
 create_device (GUdevDevice *udev_device)
 ^~~~~~~~~~~~~

Fixed this with this diff on top:

--- a/plugins/common/gsd-device-manager-udev.c
+++ b/plugins/common/gsd-device-manager-udev.c
@@ -92,7 +92,7 @@ create_device (GUdevDevice *udev_device)
         */
        device_type = udev_device_get_device_type (udev_device);
        if (device_type == GSD_DEVICE_TYPE_KEYBOARD)
-               return;
+               return NULL;
 
        parent = g_udev_device_get_parent (udev_device);
        g_assert (parent != NULL);
@@ -137,6 +137,9 @@ add_device (GsdUdevDeviceManager *manager,
                return;
 
        device = create_device (udev_device);
+       if (!device)
+               return;
+
        g_hash_table_insert (manager->devices, g_object_ref (udev_device), device);
        g_signal_emit_by_name (manager, "device-added", device);
 }
Comment 12 Hans de Goede 2017-09-29 13:24:52 UTC
Carlos' patch with my fixup works for a GNOME3 on Xorg session, but gsd-wacom seems to be using gsd-device-manager-x11.c under wayland and seeing the xwayland devices ?

Debugging this further.
Comment 13 Hans de Goede 2017-09-29 14:41:57 UTC
Ok, so my remark about using gsd-device-manager-x11.c probably is a red herring. The problem seems to be that plugins/common/daemon-skeleton-gtk.h should_run returns false for gsd-wacom under gdm an I was using gdm to test things under Wayland (and a normal session for testing the Xorg paths).
Comment 14 Hans de Goede 2017-09-29 15:00:20 UTC
Created attachment 360668 [details] [review]
common: Ignore (pure) keyboard devices on GsdDeviceManager

New, fixed version of Carlos' patch.
Comment 15 Hans de Goede 2017-09-29 15:01:08 UTC
Created attachment 360669 [details] [review]
common: Fix touchscreen vs display orientation mismatch under gdm

This fixes gsd-wacom not being active under gdm.
Comment 16 Hans de Goede 2017-09-29 15:01:33 UTC
Ok, with these 2 patches everything works as it should.
Comment 17 Rui Matos 2017-10-03 13:28:00 UTC
Review of attachment 360314 [details] [review]:

oops
Comment 18 Rui Matos 2017-10-03 13:28:41 UTC
Review of attachment 360668 [details] [review]:

thanks, this seems fine
Comment 19 Rui Matos 2017-10-03 13:29:20 UTC
Review of attachment 360669 [details] [review]:

ok, makes sense
Comment 20 Rui Matos 2017-10-03 13:31:34 UTC
Attachment 360668 [details] pushed as 36ed918 - common: Ignore (pure) keyboard devices on GsdDeviceManager
Attachment 360669 [details] pushed as cf5b5fb - common: Fix touchscreen vs display orientation mismatch under gdm