Search code examples
xmonad

xmonad: toggle a window between floating and tiled


Sometimes I launch a window tiled. Maybe as a scratchpad (using NamedScratchpad) or as in this question.

Now I want to be able to zoom (either fullscreen or tile) this floating window, and then toggle back to the previous tiled size & position.

What is a good way to accomplish that?

Also, if I hit the hotkey for a scratchpad, I want it to open according to the specification in my config file --- not according to the current state (e.g. tiled).


Solution

  • If i understand your (zooming) question correctly, XMonad.Layout.Maximize provides what you're looking for. Please note that maximize affects the naming of your Layout - if you use XMonad.Layout.Named you may want to define the name before maximize like

    myLayout = named "myName"
               $ maximize
               $ someLayout
    

    with a keybinding like

    ((modm, xK_backslash), withFocused (sendMessage . maximizeRestore))
    

    described in the linked documentation.

    Currently this module maximizes not completely, but leaves a bit of border. If it bugs you, you can modify the module and place your version at ~/.xmonad/lib/modifiedMaximize from where you can import it with

    import modifiedMaximize
    

    in your xmonad.hs.