Xmonad: Float and resize windows to its “natural size”

xmonad

In xmonad she standard behaviour of windows is that they are tiled. One can change this, if one uses for example xprop | grep WM_CLASS and puts something like this:

myManageHook = composeAll
    [ className =? "MPlayer"        --> doFloat
    , className =? "Gimp"           --> doFloat]

Then the windows of those programs float and have a "natural size" (as they would appear e.g. in gnome).

Now my question is the following: Is it possible to do this "on the fly"?

I can click and drag it with the mod-button1 held down and then resize it manually. However, it should resize automatically to it's "natural size". What can I change in my xmonad.hs to achieve this?

Another possibility (which would be sufficient for me) would be to have some "starter script", lets call it xms: If I type xms foo the program foo is started floated and its windows have "natural size".

Best Answer

For a floating workspace:

import XMonad.Layout.PerWorkspace
 -- then in layoutHook:
onWorkspace "float" simplestFloat

From droog's xmonad.hs

There is also more information on the wiki: http://xmonad.org/xmonad-docs/xmonad-contrib/XMonad-Layout-SimplestFloat.html

Related Question