Understanding Layers...

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:

viewtopic.php?f=33&t=1834

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

Hi, I’m trying to do this with FvwmPager but no luck :frowning:

[code]# Toggle layers Top doesn’t work
DestroyFunc ToggleLayerTop
AddToFunc ToggleLayerTop

  • I Next (Layer 6,FvwmPager) Layer
  • I TestRc (NoMatch) All (FvwmPager) Layer 0 6
    [/code]
    The second command works, however the first one just give the correct result to the second (looks like) since the pager is at the bottom per default, then switch to layer 6 but never returned to bottom.

Any ideas? :slight_smile:

What styles have you set for FvwmPager, if any?

– Thomas Adam

Replying to myself:

[code]# Toggle layers Top doesn’t work
DestroyFunc ToggleLayerTop
AddToFunc ToggleLayerTop

  • I All (Layer 6,FvwmPager) Layer
  • I TestRc (NoMatch) All (FvwmPager) Layer 0 6[/code]

Works like a charm!

A more “non-specific function” Would be:

[code] Toggle layers Top doesn’t work
DestroyFunc ToggleLayerTop
AddToFunc ToggleLayerTop

  • I All (Layer 6,FvwmPager) Layer
  • I TestRc (NoMatch) All (FvwmPager) Layer 0 6
  • I All (Layer 6,$0) Layer
  • I TestRc (NoMatch) All ($0) Layer 0 6
    [/code]

Calling the function with ToggleLayerTop

I have:

[code]# Default FvwmPager Style
Style “FvwmPager” NoTitle, !Handles, !Borders, Sticky, WindowListSkip, CirculateSkip, StaysOnBottom, FixedPosition, FixedSize

Default FvwmPager configuration

DestroyModuleConfig FvwmPager: *
*FvwmPager: Geometry 180x135-10-10
*FvwmPager: DeskHilight
*FvwmPager: MiniIcons
*FvwmPager: SolidSeparators
*FvwmPager: Balloons
*FvwmPager: Font none
*FvwmPager: UseSkipList
[/code]

Remove CirculateSkip.

– Thomas Adam

Perfect thanks a lot :slight_smile:
I’ve changed the function accordingly:

[code]DestroyFunc ToggleLayerTop
AddToFunc ToggleLayerTop

  • I Next (Layer 6,$0) Layer
  • I TestRc (NoMatch) Next ($0) Layer 0 6
    [/code]

Hi,

I have read what you wrote about layers and the StayOnTop feature which I use trying to find a solution to my problem, but it remained a mystery to me.
I am developing an application that opens a Firefox browser. The browser - when open - should stay always on top of the application window. To reach this I use the following settings (excerpt):

[code]#ColormapFocus FollowsMouse

default styles

Style “" ClickToFocusRaises
Style "
” MouseFocusClickRaises
Style “" SmartPlacement
Style "
” FocusFollowsMouse

Style “MyApp*” NoTitle
Style “MyApp*” DumbPlacement
Style “MyApp*” BorderWidth 0
Style “MyApp*” HandleWidth 0

Style “Mozilla*” StaysOnTop
Style “Mozilla*” NoTitle
Style “Mozilla*” DumbPlacement
Style “Mozilla*” BorderWidth 0
Style “Mozilla*” HandleWidth 0
Style “Mozilla*” PositionPlacement 800p 0p

#Key Tab A M Cycle-Focus-and-Raise
#Key F4 A M Close

Mouse 1 R A Nop
#Mouse 3 R A Menu Window-Ops Nop

DestroyMenu RootMenu
#AddToMenu RootMenu “Root Menu” Title
#+ “XTerm” Exec exec xterm
#+ “Restart Fvwm2” Restart fvwm2
#+ “Exit Fvwm2” Quit

AddToMenu Window-Ops2 “&Close” Close

  •                   "Destroy"       Destroy
    
  •                   "(un)Ma&ximize" Maximize
    

AddToMenu Window-Ops “Window Ops” Title

  •                   "Move"          Move
    
  •                   "Resize"        Resize
    
  •                   "Raise"         Raise
    
  •                   "Lower"         Lower 
    
  •                   "(Un)Stick"     Stick           
    
  •                   "(Un)Maximize"  Maximize
    
  •                   "Delete"        Delete
    
  •                   "Close"         Close
    
  •                   "Destroy"       Destroy
    
  •                   "Refresh Window" RefreshWindow
    

AddToFunc Move-or-Raise “I” Raise

  •                           "M" Move
    
  •                           "D" Lower
    

AddToFunc Resize-or-Raise “I” Raise

  •                           "M" Resize
    
  •                           "D" Lower
    

AddToFunc Cycle-Focus-and-Raise “I” Prev [*] Raise

  •                           "I" Prev [*] Focus
    

AddToFunc StartFunction

  • “I” exec xsetroot -solid darkslategray
    [/code]

The Style “Mozilla*” StaysOnTop feature usually works but time to time when I restart the machine I work for, this behavior stops working. When I touch the window of my application “MyApp” behind the Firefox window, the browser gets hidden, the “MyApp” comes to front.
I have noticed that this misbehaving goes together with the phenomenon that with the Alt+Tab key combination I can go over all the open windows. When the StayOnTOp works fine, the Alt+Tab does not do anything.

I would really appreciate any idea what can cause this uncertain working of the WM!
Thanks!

To prevent side effects add the following lines to your functions like:

DestroyFunc Move-or-Raise AddToFunc Move-or-Raise ...This assures that no code will added to a function while restarting. Do the same with menus]DestroyMenu Window-Ops
AddToMenu Window-Ops
…[/code]
Use Style "Mozilla*" Layer 0 6 instead of Style "Mozilla*" StaysOnTop This guarantees that the application stays allways on top

For your Alt+Tab try this function]DestroyFunc FuncFvwmNextWindow
AddToFunc FuncFvwmNextWindow

  • I Next (CurrentPage, !Iconic, AcceptsFocus) FlipFocus NoWarp
  • I Current Raise

Key Tab A M FuncFvwmNextWindow[/code]This works fine on my system.

Hope this helps.

Best,
TF

Thank you for your help! So far I could not test it (other tasks), but as soon as I have the chance I will return with the result.
But I didn’t want to miss saying thanks. :slight_smile:

Hello again,

Now I am facing a new problem.

My (java) application opens a (modal) dialog. After the dialog is closed the focus seems to remain on the dialog instead of going back to the parent window. Due to this the application some times does not handle bar code reader events until I do not touch the app window and give it the focus manually. (Touch screen.) Strange enough but it handles 1-2-3 times but then not any more.

I have investigated this from the point of view of Java, I found some bug reports that remind me of this, but nothing certain.

I have a faint hope that this has something to do with WM. Maybe a wrong or a missing setting?
My configuration can be read in my previous post (Nov. 06).

Any hint?

Thanks is advance!

That’s a common problem with Java applications and really has nothing to do with the topic of this thread, see here for example.

Thanks! I have not found this thread.