diff options
author | David Roundy <droundy@darcs.net> | 2007-06-22 16:29:50 +0200 |
---|---|---|
committer | David Roundy <droundy@darcs.net> | 2007-06-22 16:29:50 +0200 |
commit | 060583dd3919eeeb565123c4f2ff7cbd2c999288 (patch) | |
tree | 25b1be9c8f13fc4e54931b45bf607e500f0dc89d /LayoutHelpers.hs | |
parent | 1c0dbc793902f65ddb43f7a4e527c333d745e388 (diff) | |
download | XMonadContrib-060583dd3919eeeb565123c4f2ff7cbd2c999288.tar.gz XMonadContrib-060583dd3919eeeb565123c4f2ff7cbd2c999288.tar.xz XMonadContrib-060583dd3919eeeb565123c4f2ff7cbd2c999288.zip |
add new LayoutHelpers module.
darcs-hash:20070622142950-72aca-6dc011f903d12a056b1124752fc37f23368f898e.gz
Diffstat (limited to 'LayoutHelpers.hs')
-rw-r--r-- | LayoutHelpers.hs | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/LayoutHelpers.hs b/LayoutHelpers.hs new file mode 100644 index 0000000..e134deb --- /dev/null +++ b/LayoutHelpers.hs @@ -0,0 +1,62 @@ +----------------------------------------------------------------------------- +-- | +-- Module : XMonadContrib.LayoutHelpers +-- Copyright : (c) David Roundy <droundy@darcs.net> +-- License : BSD +-- +-- Maintainer : David Roundy <droundy@darcs.net> +-- Stability : unstable +-- Portability : portable +-- +-- Make layouts respect size hints. +----------------------------------------------------------------------------- + +module XMonadContrib.LayoutHelpers ( + -- * usage + -- $usage + DoLayout, ModDo, ModMod, ModLay, + layoutModify, + l2lModDo, + idModMod, + ) where + +import Graphics.X11.Xlib ( Rectangle ) +import XMonad +import StackSet ( Stack, integrate ) + +-- $usage +-- Use LayoutHelpers to help write easy Layouts. + +--type DoLayout a = Rectangle -> Stack a -> X ([(a, Rectangle)], Maybe (Layout a)) +type DoLayout a = Rectangle -> Stack a -> X [(a, Rectangle)] +type ModifyLayout a = SomeMessage -> X (Maybe (Layout a)) + +type ModDo a = Rectangle -> Stack a -> [(a, Rectangle)] -> X ([(a, Rectangle)], Maybe (ModLay a)) +type ModMod a = SomeMessage -> X (Maybe (ModLay a)) + +type ModLay a = Layout a -> Layout a + +layoutModify :: ModDo a -> ModMod a -> ModLay a +layoutModify fdo fmod l = Layout { doLayout = dl, modifyLayout = modl } + where dl r s = do --(ws, ml') <- doLayout l r s + ws <- doLayout l r s + (ws', mmod') <- fdo r s ws + --let ml'' = case mmod' of + -- Just mod' -> Just $ mod' $ maybe l id ml' + -- Nothing -> layoutModify fdo mod `fmap` ml' + --return (ws', ml'') + case mmod' of + Just _ -> fail "Sorry, can't yet safely modify layouts in doLayout." + Nothing -> return ws' + modl m = do ml' <- modifyLayout l m + mmod' <- fmod m + return $ case mmod' of + Just mod' -> Just $ mod' $ maybe l id ml' + Nothing -> layoutModify fdo fmod `fmap` ml' + +l2lModDo :: (Rectangle -> [a] -> [(a,Rectangle)]) -> DoLayout a +--l2lModDo dl r s = return (dl r $ integrate s, Nothing) +l2lModDo dl r s = return (dl r $ integrate s) + +idModMod :: ModMod a +idModMod _ = return Nothing |