Search code examples
ubuntueventstcltk-toolkitwacom

Why are X-input events not processed any longer by Tk event callbacks (Ubuntu 22.04, Tk 8.6.12)?


I have a Tcl/Tk program (C and script) which processes X-input events from a graphics tablet (Wacom). XSelectExtensionEvent() is called such that the X server reports these events (like pen motion), and Tk_CreateGenericHandler() is used to register a handler function (which then invokes a Tcl proc).

Everything was working fine up to Ubuntu 20.04 with Tk 8.6.10, but the callback function is not called any longer for these events (like motion events of the pen) in Ubuntu 22.04 with Tk 8.6.12. However, if I use XNextEvent() to get the events directly, I see the motion events. xev also sees the events, so it doesn't seem to be a driver problem.

However, I need to use the Tk event handling to integrate the events into the Tcl/Tk script, so using XNextEvent() is not a solution.

Does anyone know whether the event handling was changed in Tk lately? Or any other idea what could have changed? Thanks a lot!


Solution

  • I might have found the issue. Since commit 3682b41 (Feb 5, 2020), all X-input events with a type greater than MappingNotify are ignored. However, this also ignores some/all events of the X input extension, since the extension event types are not constants as described in X Input Device Extension Library:

    Extension event types are not constants. Instead, they are dynamically allocated by the extension's request to the X server when the extension is initialized.

    Accordingly, the problem could be solved by adjusting the following condition in tk/unix/tkUnixEvent.c and (re)compiling Tk.

    if (event.type > MappingNotify) {
        continue;
    }
    

    This is possibly a bug and will (hopefully) be fixed in a future version of Tk.