Always focusing a window on the current page

Hi All,

I noticed that other desktop managers (like KDE etc) do the following: When you change the current desktop / page, they give keyboard focus to a window on the current page. I like this a lot, and wrote the function below to acomplish the same in Fvwm. Ofcourse this only helps if you’re using ClickToFocus.

[code]SetEnv FocusPage 0

Remember focused window in current page

DestroyFunc SavePageFocus
AddToFunc SavePageFocus

  • I All (CurrentPage) State $[FocusPage] False
  • I Current State $[FocusPage] True

Restore previous focused window in current page (from fvwm-crystal)

DestroyFunc RestorePageFocus
AddToFunc RestorePageFocus

  • I Current (CurrentPage) Break 1
  • I Next (CurrentPage, State $[FocusPage]) Focus
  • I None (CurrentPage, Focused) Prev (CurrentPage) Focus

*FvwmEvent: Cmd
*FvwmEvent: new_page RestorePageFocus
*FvwmEvent: focus_change SavePageFocus
[/code]
Finally add the line

+ I Module FvwmEvent

to your StartFunction, and you’ll be all set.

The only minor anoyence in the above is that if the current viewport has no windows, then the original window retains keyboard focus. (I don’t konw how to get around this). Also if the window with keyboard focus is only partly visible on the current page, sometimes the page is switched :slight_smile:. Maybe you can either fix these bugs, or live with it :slight_smile: [I’m content the way things are now]

HTH,

GI

Yep, looks good. Not too dissimilr to this:

fvwmwiki.org/cgi/moin.cgi/Ti … emberFocus

As a tip, with FvwmEvent, you should really alias that to something like:

FvwmEvent-Focus: 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.

– Thomas Adam

aha. that’s why they have module aliasing. never figured that one out :slight_smile:

thanks,

GI

You are totally allow to use *FvwmEvent with several tasks !
For instance :

DestroyModuleConfig FvwmEvent: * *FvwmEvent: Cmd Function *FvwmEvent: add_window FuncSelectWindow *FvwmEvent: add_window GenerateMiniIcon *FvwmEvent: Destroy_window DestroyMiniIcon

You miss the point, Lucky – the above is not very good, and for certain modules having aliases (as in the case for FvwmButtons) is the only way to have multiple instances, usually.

– Thomas Adam.