The basic idea is to have a base layout and a set of layout transformers,
of which at most one is active at any time. Enabling another transformer
first disables any currently active transformer; i.e. it works like a
group of radio buttons.
A side effect of this meta-layout is that layout transformers no longer
receive any messages; any message not handled by MultiToggle itself will
undo the current layout transformer, pass the message on to the base
layout, then reapply the transformer.
To use this module, you need some data types which represent
transformers; for some commonly used transformers (including
MIRROR, NOBORDERS, and FULL used in the examples below) you can
simply import XMonad.Layout.MultiToggle.Instances.
Somewhere else in your file you probably have a definition of layout;
the default looks like this:
layout = tiled ||| Mirror tiled ||| Full
After changing this to
layout = mkToggle (single MIRROR) (tiled ||| Full)
you can now dynamically apply the XMonad.Layout.Mirror transformation:
...
, ((modMask, xK_x ), sendMessage $ Toggle MIRROR)
...
(That should be part of your key bindings.) When you press mod-x, the
active layout is mirrored. Another mod-x and it's back to normal.
It's also possible to stack MultiToggles. For example:
layout = id
. XMonad.Layout.NoBorders.smartBorders
. mkToggle (NOBORDERS ?? FULL ?? EOT)
. mkToggle (single MIRROR)
$ tiled ||| XMonad.Layout.Grid.Grid ||| XMonad.Layout.Circle.Circle
By binding a key to (sendMessage $ Toggle FULL) you can temporarily
maximize windows, in addition to being able to rotate layouts and remove
window borders.
You can also define your own transformers by creating a data type
which is an instance of the Transformer class. For example, here
is the definition of MIRROR:
data MIRROR = MIRROR deriving (Read, Show, Eq, Typeable)
instance Transformer MIRROR Window where
transform _ x k = k (Mirror x)
Note, you need to put {-# LANGUAGE DeriveDataTypeable #-} at the
beginning of your file (ghc 6.8 only; with ghc 6.6 you can use
{-# OPTIONS_GHC -fglasgow-exts #-} instead) to be able to
derive Data.Typeable.
|