|
From: Kevin W. <kw...@co...> - 2025-08-31 22:04:11
|
A quick follow up...
As it turns out, my C code was plenty robust - in fact, I threw out a
lot of the modifications suggested by AI and went with a simple custom
event source as suggested at the Tcl wiki. There's even an example there
of Gtk event loop integration; it was trivial to swap the Gtk calls for
GLib.
Additional debugging showed that the event flood was happening on focus
events. After turning over every stone in the C code, I checked the
script-level implementation and found a {bind all <FocusIn>
::blah::blah::} that was intended for Windows. Turns out that was not
only unnecessary on X11, it was downright destructive. Limiting that
call to Windows seems to have fixed the problem.
This has been holding me up for weeks, and it turns out it's one line of
code at the script level! Never underestimate Tcl/Tk's power. :-)
I have more polishing and fine-tuning to do on the X11 accessibility
code, but now the foundation is solid. I'll be able to ask for review
and a TIP in the near future.
Brian, thanks for your input! It got me thinking about this in different
ways and I was able to find a solution.
All best,
Kevin
On 8/27/25 7:32 AM, Kevin Walzer wrote:
> Hi Brian,
>
> Thank you. I will take a closer look at your work here. Much appreciated!
>
> —Kevin
>
>> On Aug 27, 2025, at 1:03 AM, Brian Griffin <bri...@ea...>
>> wrote:
>>
>> Hi Kevin,
>>
>> I don't know anything about GLib event loop, but I did learn
>> something important when integrating the Qt event loop with Tcl. The
>> lesson learned is that there can only be one event loop master.
>> Everything else is just responding to the events when the master says
>> so.
>> Qt was interesting because it doesn't really have main loop per se,
>> but it still needed to know about *all* events. So, I put Tcl as the
>> top "loop"er (i.e. DoOneEvent). Then translated all Tcl events into
>> Qt events. Qt would handle it's own events directly, and the "tcl"
>> events were Qt events, but the callbacks went to Tcl for actual handling.
>> I ended up here because any other way lead to a hang or ignored events.
>>
>> Only one master loop!
>>
>> (Note: my work was before the switch to the new (epoll?) event loop
>> system.)
>>
>> I hope this gives you some insight.
>> -Brian
>>
>>> On Aug 26, 2025, at 20:09, Kevin Walzer <kw...@co...> wrote:
>>>
>>> Hi all,
>>>
>>> As you may be aware, for the past year I’ve been working on a
>>> project to introduce accessibility / screen reader support to Tk.
>>> I’m almost done, but there’s one obstacle I can’t seem to work
>>> through - integrating the Tcl and GLib event loops on Linux. This is
>>> required because the ATK accessibility API communicates with
>>> accessibility clients via the at-spi protocol, which is controlled
>>> by GLib.
>>>
>>> Put simply, Wish hangs. My latest commits take a bit longer, but
>>> eventually Wish freezes.
>>>
>>> Looking at the example of the gnocl project, I’ve created a custom
>>> Tcl event source that consumes events from GLib. It seems
>>> straightforward but is anything but.
>>>
>>> Here is my current code, based on a suggestion from one of the many
>>> AI assistants I’ve consulted:
>>> |/* Configure event loop. */ static void Atk_Event_Setup(ClientData
>>> clientData, int flags) { (void)clientData; static Tcl_Time
>>> block_time; if (!(flags & TCL_WINDOW_EVENTS)) { return; } /* Ask
>>> GLib how long it wants to sleep. */ gint timeout =
>>> g_main_context_iteration(NULL, FALSE); if (timeout > 0) {
>>> block_time.sec = timeout / 1000; block_time.usec = (timeout % 1000)
>>> * 1000; } else { /* If GLib has pending events, don't block. */
>>> block_time.sec = 0; block_time.usec = 0; }
>>> Tcl_SetMaxBlockTime(&block_time); } /* Check event queue. */ static
>>> void Atk_Event_Check(ClientData clientData, int flags) {
>>> (void)clientData; (void)flags; /* No-op. The real work is done in
>>> Atk_Event_Setup. */ } |
>>> |Tcl_CreateEventSource (Atk_Event_Setup, Atk_Event_Check, 0);
>>> Tcl_SetServiceMode (TCL_SERVICE_ALL);|
>>> I’d be grateful for any suggestions.
>>> Thanks,
>>> Kevin
>>> _______________________________________________
>>> Tcl-Core mailing list
>>> Tcl...@li...
>>> https://lists.sourceforge.net/lists/listinfo/tcl-core
>>
>
>
> _______________________________________________
> Tcl-Core mailing list
> Tcl...@li...
> https://lists.sourceforge.net/lists/listinfo/tcl-core |