Don’t you just love those really sweet screenshots with the thumbnails as iconified windows? Then when you try it out, it’s laggy as hell. Well, here is my way of doing thumbnails. The following functions make all of your iconified windows show as screenshots of the window, AND provide a menu of window screenshots (FvwmReveal). And they do it efficiently without any noticably slowdown (with about a 10-25% increase in CPU utilization every now and then).
Fell free to modify any of these to your liking or for your specific system, and post any suggestions.
Here is the function which actually captures a window. Rather than raise the window when I want to capture it, I’ve made it so that the window must be raised in order to capture it (otherwise, break).
[code]# don’t expect the image to be available IMMEDIATELY
make sure xwd and convert aren’t running first (if they are, break)
DestroyFunc CaptureWindow
AddToFunc CaptureWindow
- I ThisWindow (Raised, !Iconic, !Shaded, CurrentPage, !FvwmIdent)
- I TestRc (NoMatch) Break
- I PipeRead ‘if [[
ps aux | grep xwd | grep -v grep
||ps aux | grep convert | grep -v grep
]]; then echo Break; fi’ - I WindowId $[w.id] Exec exec xwd -silent -id $[w.id] | convert -scale 128 -frame 1x1 -mattecolor black -quality 0 xwd:- png:/tmp/$[w.id].png
- I WindowId $[w.id] WindowStyle IconOverride, Icon /tmp/$[w.id].png [/code]
Here is the function that opens up a menu of all windows, showing each one as a thumbnail:
[code]# open a menu that consists of the latest screenshots of all windows
DestroyFunc FvwmReveal
AddToFunc FvwmReveal
- I AddToMenu FvwmExposeMenu “” Title
- I All (CurrentPage, !Sticky) And
‘AddToMenu FvwmExposeMenu “$[w.name]”%/tmp/$[w.id].png% WindowID $[w.id]\
And Raise “Iconify off” “WindowShade off” “WarpToWindow 50 50”’ - I AddToMenu FvwmExposeMenu DynamicPopDownAction And
“DestroyMenu recreate FvwmExposeMenu” - I Menu FvwmExposeMenu [/code]
I have two ways that I grab screenshots. One way is by periodically polling, capturing the currently focused window. This helps get changes from the window that you are using, and updating the thumbnail accordinly. The other way is by using FvwmEvent to capture windows whenever they are created, focused, raised, etc…
[code]DestroyFunc StartFunction
AddToFunc StartFunction
- I Module FvwmEvent
- I Test (Restart) LoadCaptured
- I RepeatedCapture 5000
if it gets laggy you can turn some of these off
the ‘schedule’ is necessary here because many windows
are not available as soon as they are added/deiconified/unshaded
*FvwmEvent raise_window CaptureWindow
*FvwmEvent add_window “Schedule 250 CaptureWindow”
#*FvwmEvent enter_window CaptureWindow
*FvwmEvent focus_change CaptureWindow
*FvwmEvent deiconify “Schedule 500 CaptureWindow”
*FvwmEvent dewindowshade “Schedule 500 CaptureWindow” [/code]
If you’re wondering what the heck that LoadCaptured thing is in my StartFunction, here it is:
[code]# whenever we restart fvwm, we have to set all the icons as their screenshots…
otherwise, they’ll revert to icons
DestroyFunc LoadCaptured
AddToFunc LoadCaptured
- I All (*) PipeRead
if [ -e /tmp/$[w.id].png ]; then \ echo WindowId $[w.id] WindowStyle IconOverride, Icon /tmp/$[w.id].png; fi
[/code]
Then I like to have mouse bindings like this:
Mouse 2 R N NoWindow FvwmReveal
Mouse 2 A 4 NoWindow FvwmReveal
Note: Just call Iconify the way you always do. No changes to it are necessary.