Touch Events on Windows 10 using msys2/python
Steps to reproduce
- setup msys2 with mingw64 and python 3.8.2 on Win 10
- install gtk using pacman
- run the script and use a touch screen on the window
import gi
gi.require_version('Gdk', '3.0')
gi.require_version('Gtk', '3.0')
from gi.repository import Gdk
from gi.repository import Gtk
def on_touch_event(drawing_area):
print('touch event')
if __name__ == '__main__':
sequences = {}
w = Gtk.Window()
w.set_support_multidevice(True)
w.connect('delete-event', lambda *_: Gtk.main_quit())
a = Gtk.DrawingArea(visible=True)
a.set_size_request(500,500)
w.add_events(
Gdk.EventMask.TOUCH_MASK
| Gdk.EventMask.SMOOTH_SCROLL_MASK
| Gdk.EventMask.TABLET_PAD_MASK
)
w.add(a)
a.connect('touch_event', on_touch_event)
display = w.get_display()
w.present()
Gdk.set_show_events(True)
Gtk.main()
Current behavior
The latest version of the msys2 packages doesn't support touch events. The code above should print the message "touch event", but it doesn't.
Expected outcome
I would expect that the python script (see above) should print the message "touch event" if the touch screen is used.
Version information
I used:
- Win10
- msys2
- MinGW 64
- python 3.8.2
- https://packages.msys2.org/package/mingw-w64-x86_64-gtk3, https://repo.msys2.org/mingw/x86_64/mingw-w64-x86_64-gtk3-3.24.23-1-any.pkg.tar.zst
Additional information
I called Gdk.set_show_events(True). Some events seem to be triggered, but the connected function is not called. An exemplary output is:
WM_NCHITTEST 0000000011d814c2 0 0x29b01af DefWindowProcW => 15
WM_SETCURSOR 0000000011d814c2 0x11d814c2 0x200000f 0xf 0x200 DefWindowProcW => 1
WM_NCMOUSEMOVE 0000000011d814c2 0xf 0x29b01af (431,667) DefWindowProcW => 0
WM_MOUSELEAVE 0000000011d814c2 0 0 0 (431,667)
WM_NCHITTEST 0000000011d814c2 0 0x29b01af DefWindowProcW => 15
===> GDK_LEAVE_NOTIFY 0000000011d814c2 @ 549302046ms 0000000000000000 (293,506) (431,667) NORMAL ANCESTOR => 0
WM_NCMOUSELEAVE 0000000011d814c2 0 0 DefWindowProcW => 0
WM_NCHITTEST 0000000011d814c2 0 0x277025e DefWindowProcW => 1
WM_NCHITTEST 0000000011d814c2 0 0x277025e DefWindowProcW => 1
unk-0x249 0000000011d814c2 0x6017013b 0x277025e DefWindowProcW => 0
unk-0x246 0000000011d814c2 0x6017013b 0x277025e DefWindowProcW
unk-0x2cc 0000000011d814c2 0 0x277025e DefWindowProcW
WM_NCHITTEST 0000000011d814c2 0 0x277025e DefWindowProcW => 1 => 0
unk-0x11a 0000000011d814c2 0 0x61cd10 DefWindowProcW => 0 => 0
unk-0x245 0000000011d814c2 0x6016013b 0x277025e DefWindowProcW => 0
unk-0x245 0000000011d814c2 0x6016013b 0x277025e DefWindowProcW => 0
unk-0x245 0000000011d814c2 0x6016013b 0x277025e DefWindowProcW => 0
unk-0x245 0000000011d814c2 0x6016013b 0x277025e DefWindowProcW => 0
Some events are known and named, others are not. Checking the windows "winuser.h" macros suggests that "newer" event IDs are unknown:
#define WM_DROPFILES 0x0233
#define WM_MDIREFRESHMENU 0x0234
#if WINVER >= 0x0602
#define WM_POINTERDEVICECHANGE 0x238
#define WM_POINTERDEVICEINRANGE 0x239
#define WM_POINTERDEVICEOUTOFRANGE 0x23a
#endif
#if WINVER >= 0x0601
#define WM_TOUCH 0x0240
#endif
#if WINVER >= 0x0602
#define WM_NCPOINTERUPDATE 0x0241
#define WM_NCPOINTERDOWN 0x0242
#define WM_NCPOINTERUP 0x0243
#define WM_POINTERUPDATE 0x0245
#define WM_POINTERDOWN 0x0246
#define WM_POINTERUP 0x0247
#define WM_POINTERENTER 0x0249
#define WM_POINTERLEAVE 0x024a
#define WM_POINTERACTIVATE 0x024b
#define WM_POINTERCAPTURECHANGED 0x024c
#define WM_TOUCHHITTESTING 0x024d
#define WM_POINTERWHEEL 0x024e
#define WM_POINTERHWHEEL 0x024f
#endif
I assume that the show_events messages should have descriptions also for newer events.