After closing a window, how to focus next one?

Currently, when I close a top layer window the below layers remain unfocused. How to autofocus the next window in line?

Hi @rasat

Which application are you using where this is a problem?

All applications remain unfocused, except if opened within the application, such as a text file with Featherpad by Thunar. When Featherpad is closed (Titlebar right-click (+ “Close” Close), then Thunar is focused. If Featherpad and Thunar run independently, remain unfocused if one is closed.

Hi @rasat

Ah, OK. I thought that was the case, just wanted to check.

You’ll want something like this:

DestroyModuleConfig FE:*
*FE: destroy_window FooFunc

Module FvwmEvent FE

DestroyFunc FooFunc
AddToFunc   FooFunc
+ I Schedule 500 ThisWindow (!Focused) Next (AcceptsFocus) Focus

Note that I use ThisWindow, rather than Current, deliberately.

Thanks. Doesn’t make any difference. I copied as you wrote it, and pasted it at the end of my config. Also, checked with ThisWindow and Current.


Then I’m not clear what you’re asking. The FooFunc will focus the next window which accepts focus, if, after closing a window, there is no window focused. This might happen if you’re on the root window after closing a window, for example.

If you meant something different, can you try again to explain?

For example, on the same screen/page open different apps (Thunar, Firefox, Thunderbird, Featherpad, and so on). Next, with a key biding “Next (Focused) Close”, it closes the top window/app which was focused. At that moment, the below window is supposed to become focused, but doesn’t.

The key binding will help to close current windows quickly, one after another.

Got the config to work. It only works (focus) on windows that were opened before running the config. This means to run it each time before closing a window. How do you execute this sequence??

In my test, I have added in my menu:
+ "Focus" Read $[FVWM_USERDIR]/1Functions/nextFocus.sys

After this, I can close windows with key binding one after another.
“Next (Focused) Close”