Use FvwmEvent
if you want to catch all page changes, instead of using a function to switch pages.
How would you know which page you last were on? I see how everything else can be done with FvwmEvent, but would you store or check the previous page?
You would have to save that in an InfoStore
variable since the new_page
and new_desk
events will only send the desk you moved to. Either that or store info about which window was last focused using State
, and in this case you donāt really need to know what the previous page is. Next (CurrentPage, State X)
will find the window you want to focus.
This State
function works fine for my Xfce friends. I like it. It does the focus on any number of pages. Also, not a problem if it turns the previous window unfocused from an empty page because nobody goes to empty pages without doing anything there.
Has a slightly unstable focus when going drastically from one end of a Desk to another. Not a problem, just a sign of moving between Desks.
The function is simple and easy to understand. I copied it here below, add it at the beginning of your config.
Remember focused window in current page:
SetEnv FocusPage 0
DestroyFunc SavePageFocus
AddToFunc SavePageFocus
+ I All (CurrentPage) State $[FocusPage] False
+ I Current State $[FocusPage] True
Restore previously focused window in current page:
DestroyFunc RestorePageFocus
AddToFunc RestorePageFocus
+ I Current (CurrentPage) Break 1
+ I Next (CurrentPage, State $[FocusPage]) Focus
+ I None (CurrentPage, Focused) Prev (CurrentPage) Focus
DestroyModuleConfig FvwmEvent-FDpg:*
*FvwmEvent-FDpg: Cmd
*FvwmEvent-FDpg: new_page RestorePageFocus
*FvwmEvent-FDpg: new_desk RestorePageFocus
*FvwmEvent-FDpg: focus_change SavePageFocus
Module FvwmEvent FvwmEvent-FDpg
NOTE: This shared code is tested and works well.
It keeps focus on the adjacent page of the next desk but no further distance e.g. from Desk 1 Page 1 0
to Desk 2 Page 0 0
. Would be good also to fix this. Desker script in Fvwm Kise has 4 Desks, two pages each. Gets annoying with a focused email window on Desk 1 and going to search for data on an unfocused Desk 3.
It should be possible to include CurrentDesk
and CurrentPageAnyDesk
.
Donāt use CurrentPageAnyDesk
, that is not what you want, add the new_desk
event to FvwmEvent
and run the exact same function.
Also, the FvwmEvent
config is incorrect in the shared code, you need to use *FvwmEvent-Focus
for all the configuration options (you were missing the -Focus
). And then you launch it with Module FvwmEvent FvwmEvent-Focus
.
Thank you @somiaj, the focus works perfectly on all pages and desks.
Note: Doesnāt work if FvwmEvent-Focus
is on all configuration options. This I also understood with @thomasadam suggestion: FvwmEvent-Focus: Cmd
. -Focus is just any name to differentiate from other FvwmEvent. Only for Cmd.
so that multiple FvwmEventās can then be defined for other Events. It might be the case that a user has other events scheduled which would get overriden with the binding to just āFvwmEventā, as you have it in your example.
Not to confuse -Focus as a command, I edited it to *FvwmEvent-FDpg: Cmd
and added option *FvwmEvent: new_desk RestorePageFocus.
My shared code that was posted, I have corrected and tested it. Works well.
That is not how module alias work. Thomasā suggestion was to use a module alias. In this case you need to configure the alias with *AliasName: ConfigOption
, and then launch the module with Module FvwmEvent AliasName
. For an example see the default-config and how it uses the EventNewDesk
alias for FvwmEvent
.
Note this isnāt special to FvwmEvent
either. The default-config also uses the alias RightPanel
for the FvwmButtons
module. All of the options to configure it use *RightPanel
for the alias configuration. Because you are setting configurations for the main FvwmEvent
module, you wonāt achieve the effect Thomas was talking about because you are writing the configuration for just FvwmEvent
.
The way you would use an alias in your case is as follows:
DestroyModuleConfig FvwmEvent-FDpg:*
*FvwmEvent-FDpg: Cmd
*FvwmEvent-FDpg: new_page RestorePageFocus
*FvwmEvent-FDpg: new_desk RestorePageFocus
*FvwmEvent-FDpg: focus_change SavePageFocus
Module FvwmEvent FvwmEvent-FDpg
Iām unsure why your test are failing, but I think you are just getting lucky that your code works since you are setting configuration for the main FvwmEvent
and not just the alias. And the only thing you are setting for the alias is Cmd
which is the default anyways.
@amlug, I am glad that you worked out the solution, though, last part is not correct.
@somiaj is right. I think you are using Fvwm Kise? The Thumbnails script has FvwmEvent that causes a double event which makes the focus work.
With somiaj correction, I will add this function to Kise.
Good to know. I have corrected the code.
Today I noticed, that when returning from an empty page the current window is unfocused because one of the buttons or pager has taken it. The solution is to make all visible modules NeverFocus
. End of my config I added a long listā¦
Style RightPager NeverFocus
Style ControlMP NeverFocus
Style ExitBar NeverFocus
Style RightTbar NeverFocus
Style HideBar NeverFocus
Now when returning, a window is always focused even if a window was closed on another page.