Switching input focus policy during runtime

I have gotten my hands on the source code for fvwm 1.2, and I am trying to modify it to be able to switch between the Click to Focus and Focus Follows Mouse input focus policies without restarting fvwm. And I have made it work, sort of, but there is one remaining issue.

My new function added to fvwm.c is activated by sending a USR2 signal to iwm, and changes input focus to Click to Focus like this:

Scr.TheList->off_flags |= CLICK_FOCUS_FLAG; Scr.TheList->on_flags |= SLOPPY_FOCUS_FLAG;
Which makes all the windows opened after this use Click to Focus. But not the already existing windows. So then I added:

CaptureAllWindows();

And then the new policy applies to the existing windows as well. Goody.

Except that the CaptureAllWindows function unmaps/maps the windows, making the desktop “flash”. And I need to avoid this flashing. The function probably does more than I need.

So my question is: Is there a way to apply the input focus policy on existing windows without unmapping them first?

After some more research it looks like the answer to my question is no, you need to map existing windows again to make the new focus policy take effect. And my problem is to do that without flashing the windows. I tried to wrap the BlackoutScreen/UnblackoutScreen functions around the remapping but I still get the flashing. Also tried the hide_screen function from later fvwm versions with the same result.

So I conclude that switching input focus policy during runtime is indeed possible if you are willing to modify the fvwm source code. But you have to live with flashing windows when switching.

For the sake of completeness, my first code example above was way off. To set Click to Focus (for future windows), the way to do it was instead:

ProcessNewStyle(NULL, Scr.Root, NULL, 0, "\"*\" ClickToFocus\n", 0);