Icon thumbnail location changes depending on desk

I’m trying to setup a simple situation. I have four desks. When the Iconify button is clicked on any window, the following happens:

  1. It’s moved to desk 3 using wmctrl
  2. It’s thumbnailed using Tavis’s code

What’s weird is that if I Iconify windows that are located on desk 3, the thumbnails stack properly (starting in upper-left corner of screen and going down vertically).

If, however, I Iconify a window from any of the three other desks (0-2), when I then take a look at desk 3, all the thumbnails are stacked on top of each other. I spent a long time making small tweaks (such as adding an IconBox style), but nothing I do seems to help.

Below is my .fvwm2rc. Can anybody point me in the right direction? Also, I’m very new to FVWM and have been trying to build a config from scratch from Nick’s excellent topic, so things are very messy and I"m sure there are some silly things in there that I don’t understand!

Thanks for any help!

# Environment Variables
  #--Image Locations
    SetEnv fvwm_home $[HOME]/.fvwm
    SetEnv fvwm_img $[fvwm_home]/images
    SetEnv fvwm_icon $[fvwm_img]/icons
    SetEnv fvwm_wall $[fvwm_img]/wallpaper
    SetEnv fvwm_curr_wall $[fvwm_wall]/Renoiro-1280x1024-wallpaper-2003-60a-TheVisit.png

  #--Sets the x-offset for a 64px panel on a 1280x1024 res screen to place in upper-right hand
  #--corner of screen
  #--Change this value as needed (for example, should be `+960+0` for a 1024x768 screen)
    SetEnv panel_offset +1216+0
  #--Width of right-hand panel
    SetEnv panel_width 60

# Make sure maximized windows don't overlap our right-hand panel,
# plus a little slit at bottom for mousing 
EwmhBaseStruts 0 $[panel_width] 0 1

# Desktop
DesktopSize 1x1
DesktopName 0 Main
DesktopName 1 Work
DesktopName 2 Games
DesktopName 3 Misc

# Image Path
ImagePath $[fvwm_icon]:$[fvwm_icon];.png:+

# Startup Functions
DestroyFunc StartFunction
AddToFunc StartFunction

 #--Set Wallpaper
  + I Exec exec fvwm-root --retain-pixmap $[fvwm_curr_wall]

 #--Autoraise focused windows after one second
  + I Module FvwmAuto 750

 #--Launch ButtonBar
  + I Module FvwmButtons Panel
# Function to send Iconified windows to desk 3
DestroyFunc FuncFvwmIconify
AddToFunc FuncFvwmIconify
+ I Raise
+ I ThisWindow PipeRead \
     "wmctrl -i -r $[w.id] -t 3"
+ I FuncThumbnail

# Function to return thumbnailed icons back to desk 0
DestroyFunc FuncFvwmUnIconify
AddToFunc FuncFvwmUnIconify
+ I ThisWindow PipeRead \
     "wmctrl -i -r $[w.id] -t 0"
+ I Iconify
+ I Maximize
#+ I FuncDeThumbnail
+ I Exec exec wmctrl -s 0 

# Thumbnailer --this and next stolen from Tavis
DestroyFunc FuncThumbnail
AddToFunc FuncThumbnail
+ I Raise
+ I ThisWindow (!Iconic) SetEnv Icon-$[w.id] $[w.iconfile]
+ I ThisWindow (!Shaded, Iconifiable, !Iconic) PipeRead \
    "xwd -silent -id $[w.id] | convert -scale 128 -frame 1x1 \
    -mattecolor black -quality 0 xwd:- png:$[fvwm_icon]/icon.tmp.$[w.id].png \
    && echo WindowStyle IconOverride, Icon $[fvwm_icon]/icon.tmp.$[w.id].png \
    || echo Nop"
+ I TestRc (Match) Test (f $[w.miniiconfile], f $[fvwm_icon]/icon.tmp.$[w.id].png) PipeRead \
    "composite -geometry +2+4 $[w.miniiconfile] $[fvwm_icon]/icon.tmp.$[w.id].png \
    $[fvwm_icon]/icon.tmp.$[w.id].png; echo Nop"
+ I Iconify

# De-Thumbnailer
DestroyFunc FuncDeThumbnail
AddToFunc FuncDeThumbnail
+ I PipeRead "echo Test \\(i \\$\\[Icon-$[w.id]\\]\\) WindowStyle Icon \\$\\[Icon-$[w.id]\\]"
+ I TestRc (NoMatch) WindowStyle NoIconOverride, Icon
+ I Exec rm -f $[fvwm_icon]/icon.tmp.$[w.id].png
+ I All (Iconic, CurrentPage) PlaceAgain icon
+ I UnsetEnv Icon-$[w.id]

# Event Handlers
#*FvwmEvent: deiconify FuncDeThumbnail

# Move viewport to desk 3
DestroyFunc FuncMoveToDesk3
AddToFunc FuncMoveToDesk3
+ I Exec exec wmctrl -s 3

# Window Bindings
Mouse 1 1 N Close
Mouse 1 4 N FuncFvwmIconify
Mouse 1 2 N Maximize 
Mouse 3 I A FuncFvwmUnIconify

# ButtonBar
DestroyModuleConfig Panel: *
*Panel: Rows 16
*Panel: Columns 1
*Panel: Geometry 64x1024+1216+0
*Panel: (1x1, Icon 'mozilla-firefox.xpm', \
     Action(Mouse 1) `Function FuncMoveToDesk3`
*Panel: (1x1, Icon 'mutt.xpm',            \
     Action(Mouse 2) `Exec exec /usr/bin/mozilla-firefox`
*Panel: (1x6)
*Panel: (1x1, Icon 'pstree16.xpm', \
     Action(Mouse 1) `Function FuncMoveToDesk3`
*Panel: (1x1, Icon 'mutt.xpm', \
     Action(Mouse 1) `quit`,
     Action(Mouse 3) `restart`
*Panel: (1x1)
*Panel: (1x1, Swallow "xclock" `Exec exec xclock`)
*Panel: (1x4, Swallow "FvwmPager" "FvwmPager 0 3")

# Pager
*FvwmPager: Columns 1
*FvwmPager: Rows 4
*FvwmPager: Font "none"
*FvwmPager: Back "none"

# Global Styles
Style "*" MinOverlapPlacement
Style "*" IconBox 20 20 100 -15, IconGrid 3 3, IconFill left top

# Module Styles
Style "Panel"  \
     NoTitle,              \
     BorderWidth 0,        \
     handlewidth 0,        \
     sticky,               \


I’m not shure, but you might have to add
wmctrl -s 3

after the window is moved to desk 3, but before before it is iconified.
This will switch to desk 3

If you do not do this, still desk 0 is active, what might confuse fvwms icon-arrangement.

Greetings, Mark

Just for curiosity’s sake – why are you using wmctrl when FVWM can do all of this internally for you?

– Thomas Adam.

A good question, and one I’ll answer with another question: how can I do it without wmctrl? I told you I’m a newb :stuck_out_tongue:

Well, take:

+ I ThisWindow PipeRead \
     "wmctrl -i -r $[w.id] -t 3" 

The equivalent of that in FVWM is:

+ I ThisWindow WindowId $[w.id] MoveToDesk 3

As another example:

+ I Exec exec wmctrl -s 0

in FVWM is:

 + I GotoDesk 0

– Thomas Adam

Simple. Elegant. Of course I should have known FVWM can do it!

Thanks for the tips; I will implement this instead.

I think the wmctrl-example was taken from my expose-stuff.

There I use it, because I want to use expose with other windowmanagers, too.

Of course if you use fvwm only, it makes more sense to use the inbuilt functions.

Greets, Mark

Yes, it was :smiley: And now it makes sense why you used wmctrl. Thanks to you both!