Understanding Layers...

Talk about anything related to FVWM, but don't ask support questions here!
thomasadam
Administrator
Administrator
Posts: 3046
Joined: Mon Nov 08, 2004 1:12 am
Location: England
Contact:

Understanding Layers...

Postby thomasadam » Thu Nov 20, 2008 8:55 am

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:

Code: Select all

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:

Code: Select all

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:

Code: Select all

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:

Code: Select all

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:

Code: Select all

Style SomeWindow Layer 20


And:

Code: Select all

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:

Code: Select all

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
Last edited by thomasadam on Wed Apr 08, 2009 11:25 pm, edited 1 time in total.
Reason: Typo fixes.

Warnaud
Cat in the hat
Cat in the hat
Posts: 63
Joined: Sat May 06, 2006 9:04 pm
Location: Collonges (01) France
Contact:

Re: Understanding Layers...

Postby Warnaud » Mon Jul 23, 2012 3:47 pm

thomasadam wrote:
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:

Code: Select all

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 :(

Code: Select all

# Toggle layers Top doesn't work
DestroyFunc ToggleLayerTop
AddToFunc   ToggleLayerTop
+ I Next (Layer 6,FvwmPager) Layer
+ I TestRc (NoMatch) All (FvwmPager) Layer 0 6

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? :)
~( )~
http://archlinux.fr
French community site around Archlinux

thomasadam
Administrator
Administrator
Posts: 3046
Joined: Mon Nov 08, 2004 1:12 am
Location: England
Contact:

Re: Understanding Layers...

Postby thomasadam » Mon Jul 23, 2012 4:20 pm

What styles have you set for FvwmPager, if any?

-- Thomas Adam

Warnaud
Cat in the hat
Cat in the hat
Posts: 63
Joined: Sat May 06, 2006 9:04 pm
Location: Collonges (01) France
Contact:

Re: Understanding Layers...

Postby Warnaud » Mon Jul 23, 2012 4:26 pm

Replying to myself:

Code: Select all

# Toggle layers Top doesn't work
DestroyFunc ToggleLayerTop
AddToFunc   ToggleLayerTop
+ I All (Layer 6,FvwmPager) Layer
+ I TestRc (NoMatch) All (FvwmPager) Layer 0 6


Works like a charm!

A more "non-specific function" Would be:

Code: Select all

 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


Calling the function with ToggleLayerTop <name of the window>
~( )~

http://archlinux.fr

French community site around Archlinux

Warnaud
Cat in the hat
Cat in the hat
Posts: 63
Joined: Sat May 06, 2006 9:04 pm
Location: Collonges (01) France
Contact:

Re: Understanding Layers...

Postby Warnaud » Mon Jul 23, 2012 4:27 pm

thomasadam wrote:What styles have you set for FvwmPager, if any?

-- Thomas Adam


I have:

Code: Select all

# 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
~( )~

http://archlinux.fr

French community site around Archlinux

thomasadam
Administrator
Administrator
Posts: 3046
Joined: Mon Nov 08, 2004 1:12 am
Location: England
Contact:

Re: Understanding Layers...

Postby thomasadam » Mon Jul 23, 2012 5:09 pm

Remove CirculateSkip.

-- Thomas Adam

Warnaud
Cat in the hat
Cat in the hat
Posts: 63
Joined: Sat May 06, 2006 9:04 pm
Location: Collonges (01) France
Contact:

Re: Understanding Layers...

Postby Warnaud » Tue Jul 24, 2012 7:13 am

Perfect thanks a lot :-)
I've changed the function accordingly:

Code: Select all

DestroyFunc ToggleLayerTop
AddToFunc   ToggleLayerTop
+ I Next (Layer 6,$0) Layer
+ I TestRc (NoMatch) Next ($0) Layer 0 6
~( )~

http://archlinux.fr

French community site around Archlinux

boncsi
Kitten
Kitten
Posts: 4
Joined: Mon Nov 04, 2013 1:34 pm

Re: Understanding Layers...

Postby boncsi » Mon Nov 04, 2013 2:00 pm

thomasadam wrote:...
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:
...
-- Thomas Adam

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: Select all

#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


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!

User avatar
TF
Moderator
Moderator
Posts: 247
Joined: Sat Sep 10, 2005 12:30 am
Location: Germany
Contact:

Re: Understanding Layers...

Postby TF » Wed Nov 06, 2013 11:20 pm

boncsi wrote: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: Select all

#ColormapFocus FollowsMouse
...
+ "I" exec xsetroot -solid darkslategray

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:

Code: Select all

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:

Code: Select all

DestroyMenu Window-Ops
AddToMenu Window-Ops
...

Use

Code: Select all

Style "Mozilla*"     Layer 0 6
instead of

Code: Select all

Style "Mozilla*"     StaysOnTop
This guarantees that the application stays allways on top

For your Alt+Tab try this function:

Code: Select all

DestroyFunc FuncFvwmNextWindow
AddToFunc FuncFvwmNextWindow
+ I Next (CurrentPage, !Iconic, AcceptsFocus) FlipFocus NoWarp
+ I Current Raise

Key Tab A       M       FuncFvwmNextWindow
This works fine on my system.

Hope this helps.

Best,
TF
"Two things are infinite: the universe and human stupidity; and I'm not sure about the the universe." -- Albert Einstein
Fvwm version: 2.6.5
Fvwm config: Fvwm-Nightshade

boncsi
Kitten
Kitten
Posts: 4
Joined: Mon Nov 04, 2013 1:34 pm

Re: Understanding Layers...

Postby boncsi » Wed Nov 20, 2013 11:15 am

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. :)

boncsi
Kitten
Kitten
Posts: 4
Joined: Mon Nov 04, 2013 1:34 pm

Re: Understanding Layers...

Postby boncsi » Wed Jan 15, 2014 7:22 pm

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!

User avatar
theBlackDragon
Administrator
Administrator
Posts: 714
Joined: Wed Oct 27, 2004 9:22 pm
Location: Zingem, Belgium
Contact:

Re: Understanding Layers...

Postby theBlackDragon » Tue Jan 21, 2014 2:57 pm

boncsi wrote: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.

boncsi
Kitten
Kitten
Posts: 4
Joined: Mon Nov 04, 2013 1:34 pm

Re: Understanding Layers...

Postby boncsi » Mon Jan 27, 2014 12:07 pm

theBlackDragon wrote:
boncsi wrote: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.


Return to “General FVWM discussion”

Who is online

Users browsing this forum: No registered users and 1 guest