Close

Polling the mod key

A project log for FVWM mod-tab fix

Only 1 animal in the entire world cared about mod-tab working in fvwm.

lion-mclionheadlion mclionhead 07/06/2024 at 06:190 Comments

Like most programs for its time, FVWM uses bare X11 calls everywhere.  It has a minimal widget library for users:  modules/FvwmScript/Widgets/.

It's 1 of those programs which reuses the same function name in many files.

The entry point for alt/mod-tab is events.c: dispatch_event ->

events.c: __handle_key

functions.c: __execute_function("Next") ->

conditional.c: CMD_Next -> conditional.c: circulate_cmd ->  conditional.c: Circulate

It needs to know if mod/alt was released before the current event.  If it was released, it needs to toggle windows instead of advance.  It only detects tab being released.

The display is opened & the input flags are set in fvwm/fvwm.: XOpenDisplay(display_name)

Keypress events come from the root window & go to libs/FEvent.c: FNextEvent

For some reason, the program windows detect mod/alt release but not the root window.  Verified all the key event flags are set.  The only internet hit recommended creating a thread that polls XkbGetState in its own display.  XkbGetState had to be polled at least 20 times per second in testing to detect every mod key release.

The next problem was creating a table which translates many state variables including the mod key release to a new circulate direction.  That got it to circulate properly for the 1st time. 

The next problem was clicking on a window to raise it & getting mod-tab to go to the previously raised window.  FVWM never did this properly even before the hack.

Discussions