Hello all,
I appreciate that I don’t do this enough, but one question I have seen recently is the question of making a window always on top and not being able to lower, or to toggle a window between it always on top and not – so I shall try and explain the differences here and the means to do that so others might be able to use this information also. In case anyone is interested a lot of this information has been regurgitated by me over IRC in #fvwm on freenode.net
What is a Layer?
A layer is nothing more than a stacking area on screen defined by a number. Hence multiple windows can occupy the same layer – how they’re arranged however depends on their position.
Default Layer
By default, windows which aren’t declared as StaysOnTop or StaysOnBottom are put in Layer 4, which is the defaul for normal windows. Should an application reques it, StaysOnTop is Layer 6 and StaysOnBottom is layer 2.
It is possible though, through the use of the:
DefaultLayers
command to change which layer a window is in by default (i.e., layer 4) and affects the StaysOn{Top,Bottom} styles also.
Raising a Window
When one issues a Raise command on a window what happens is that the window in question is raised within its layer so it appears on top – but this is a falsehood – should a window be in a “ontop” state then any raised window in the default layer won’t be shown in preference of this.
For instance, regardless of its layer, if a window is declared “StaysOnTop” as in:
Style SomeWindow StaysOnTop
Then SomeWindow is automatically placed in Layer 6 – this means any window that was raised via the Raise command in its own layer has now since been superceded since the StaysOnTop style condition has placed that window in a much higher layer.
Lowering a Window
Lowering a window has the opposite effect of raising it. Again, a simple case of Lower will put that window lowered in the same layer. To shift it to the actual lowered layer see:
Style foo StaysOnBottom
This ultimately puts the window in Layer 2
Simple Toggling
If toggling a window in its own layer is OK, using the command RaiseLower is fine – as in:
Pick RaiseLower
Placing a Window in an Explicit Layer
Sometimes though, RaiseLower isn’t enough – especially if you really do want that window to be raised above everything else. There’s two ways of putting a window in its own later. One is through the use of Styles as in:
Style SomeWindow Layer 20
And:
Pick Layer 0 20
Toggling Between Layers
As mentioned, since RaiseLower only works within the one layer, toggling between StaysOnTop and StaysOnBottom becomes possible with a complex function such as the one found here:
Specifically:
DestroyFunc SomeLayerFunc
AddToFunc SomeLayerFunc
+ I ThisWindow (Layer 6) Layer
+ I TestRc (NoMatch) Layer 0 6
This could of course be generalised to match a window passed in as a parameter or bound to a menu, etc.
– Thomas Adam