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 776572 - pressure pen / tablet devices aren't enumerated
pressure pen / tablet devices aren't enumerated
Status: RESOLVED OBSOLETE
Product: gtk+
Classification: Platform
Component: Backend: Win32
unspecified
Other Windows
: Normal normal
: ---
Assigned To: gtk-win32 maintainers
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2016-12-29 09:47 UTC by yzhang1985
Modified: 2018-05-02 17:55 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
split from 776568 (1.36 KB, patch)
2016-12-29 09:47 UTC, yzhang1985
accepted-commit_now Details | Review

Description yzhang1985 2016-12-29 09:47:56 UTC
Created attachment 342570 [details] [review]
split from 776568

I'm an Inkscape user who uses a Wacom AES pressure pen on a Lenovo P40 (and hopefully touchscreen as well - see bug 776568). Inkscape recently switched from GTK2 to GTK3 and the tablet devices are no longer work or are shown in the GUI.

I traced the problem and found for GTK3, Inkscape calls gdk_seat_get_slaves() instead of gdk_device_managers_list_devices().

It seems the calls in the wintab to associate master and slave devices are wrong.
Also, making the device as GDK_DEVICE_TYPE_FLOATING also causes gdk_seat_get_slaves to not return anything. As far as I can tell, the pen isn't floating because it clearly moves the mouse cursor - after using the pen and switching to mouse, the cursor is where the pen last was.

Can someone review this patch and check in?
thanks,
-Yale
Comment 1 Andrew Chadwick 2017-01-22 06:40:10 UTC
Possible downstream instance (Lenovo Yoga): https://github.com/mypaint/mypaint/issues/760

All I can test is that this doesn't break my Intuos (and some other tablets when I can stir myself to switch the drivers over).
Comment 2 LRN 2017-01-22 13:13:16 UTC
For reference, the original code was added in commit 24f9ca92ab36265aa486e52f456c20d91ad8135d by Alexander Larsson and has this in its commit message:
    We now have a proper MASTER/SLAVE input device split, where
    the masters are virtual core input devices and we add fake hw
    slave devices for the system pointer and real slave devices for
    wintab devices.

    We also set the proper source_device on the events so you can
    tell which device sent it and properly decode the axis info.

And i have absolutely no idea what this code does. Sorry.
Comment 3 Andrew Chadwick 2017-01-22 14:32:38 UTC
I can confirm that this code doesn't break tilt or pressure support for my Intuos 5, and it also appears to fix enumeration with gdk_device_manager_list_devices(). Seems it would be helpful for MyPaint - we currently learn about new devices there by examining each event as it comes in.

---------- unpatched gtk 3.22.7 ----------

testmonkey@win7test MINGW64 ~
$ python2 /e/lsdevices.py
['System Aggregated Keyboard', 'System Aggregated Pointer']

---------- patched gtk-git 3.22.7 at gaff4268 ----------

testmonkey@win7test MINGW64 ~
$ python2 /e/lsdevices.py
['System Aggregated Keyboard', 'System Aggregated Pointer', 'WACOM Tablet Pressure Stylus', 'WACOM Tablet Eraser  ']

---------- test code ----------

#!/usr/bin/env python2

import gi
gi.require_version('Gdk', '3.0')
from gi.repository import Gdk

disp = Gdk.Display.get_default()
mgr = disp.get_device_manager()
print [dev.get_name() for dev in mgr.list_devices(Gdk.DeviceType.SLAVE)]
Comment 4 Andrew Chadwick 2017-01-22 17:32:06 UTC
Debug builds from git containing this patch for current-MSYS2 and MyPaint v1.2.1 users: https://filebin.net/4fe2fekhy53wa0me

$ sha256sum gtk_debug_*
38ac88a44c0861d35746777be4692c4212eb07ccad42c9d26b90d38ebe879f57  gtk_debug_dlls_from_gtk3-git_3.22.7.30_gaff4268.zip
f8e389752ca71fcbd37ea330c04f866a549a2937fd4e382d19c647ed0a3eeab8  gtk_debug_packages_of_gtk3-git_3.22.7.30_gaff4268_for_current_msys2.zip
Comment 5 Andrew Chadwick 2017-01-22 19:44:14 UTC
Positive reports downstream about the patch:
https://github.com/mypaint/mypaint/issues/760#issuecomment-274350953
Comment 6 Carlos Garnacho 2017-01-23 11:22:39 UTC
Comment on attachment 342570 [details] [review]
split from 776568

The patch indeed makes sense, provided that the tablet takes over the pointer cursor, which IIRC win32 does.
Comment 7 yzhang1985 2017-01-23 12:21:28 UTC
Let me further explain my patch if it helps.

The master <--> slave association is wrong because
1. the parameter order is wrong (I compared this to how it's done on GNU/Linux)
2. system_pointer isn't a master device, but a fake slave device.

Then GTK 3 seems to have the seat concept which GTK 2 doesn't.
Inkscape with GTK 3 calls gdk_seat_get_slaves(), so if the pen isn't registered, it won't show up. Earlier, Inkscape for GTK2 used gdk_device_manager_list_devices(), which does report Wintab devices, even with the bug in GTK 3.
Comment 8 Carlos Garnacho 2017-01-23 13:45:44 UTC
(In reply to yzhang1985 from comment #7)
> Let me further explain my patch if it helps.
> 
> The master <--> slave association is wrong because
> 1. the parameter order is wrong (I compared this to how it's done on
> GNU/Linux)
> 2. system_pointer isn't a master device, but a fake slave device.

I agree. And I think it's the right fix to make the device a slave and relate it to a master device. 

My comment above was about whether it made sense to use core_pointer as the master pointer. Eg. in wayland tablets drive their own on-screen cursor, so the wayland gdk backend creates separate master devices to represent these. It is my understanding that wayland is the only platform that made this choice, and other platforms (incl. x11) just take over the single pointer cursor.

> 
> Then GTK 3 seems to have the seat concept which GTK 2 doesn't.
> Inkscape with GTK 3 calls gdk_seat_get_slaves(), so if the pen isn't
> registered, it won't show up. Earlier, Inkscape for GTK2 used
> gdk_device_manager_list_devices(), which does report Wintab devices, even
> with the bug in GTK 3.

Right, this is because GdkSeat only enumerates devices with type "master" or "slave". Floating devices are pretty much X11 specific, they have to be set up as such by the user, and it's pretty much XInput1 legacy, needless nowadays.
Comment 9 GNOME Infrastructure Team 2018-05-02 17:55:39 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/gtk/issues/730.