diff options
author | David Roundy <droundy@darcs.net> | 2007-06-12 04:10:48 +0200 |
---|---|---|
committer | David Roundy <droundy@darcs.net> | 2007-06-12 04:10:48 +0200 |
commit | afafb63be2191e680e19930e483dfefae9337cfc (patch) | |
tree | 99ad15e8bf5734933c147bc9eb331a69aa2202dc | |
parent | 6a07f2897dfbdc799f6ef441b73ab6242721e911 (diff) | |
download | XMonadContrib-afafb63be2191e680e19930e483dfefae9337cfc.tar.gz XMonadContrib-afafb63be2191e680e19930e483dfefae9337cfc.tar.xz XMonadContrib-afafb63be2191e680e19930e483dfefae9337cfc.zip |
add "Square" layout.
This is probably only ever useful in combination with Combo.
It sticks one window in a square region, and makes the rest
of the windows live with what's left (in a full-screen sense).
darcs-hash:20070612021048-72aca-38ad76b633929ff700cc8a88699eadae50ffe67f.gz
-rw-r--r-- | Square.hs | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/Square.hs b/Square.hs new file mode 100644 index 0000000..51519b7 --- /dev/null +++ b/Square.hs @@ -0,0 +1,30 @@ +-- A layout that splits the screen into a square area and the rest of the +-- screen. + + +-- An example layout using square to make the very last area square: + +-- , combo [(tabbed,3),(tabbed,30),(tabbed,1),(tabbed,1)] +-- (combo [(twoPane 0.03 0.2,1) +-- ,(combo [(twoPane 0.03 0.8,1),(square,1)] +-- (mirror $ twoPane 0.03 0.85),1)] (twoPane 0.03 0.5) ) + +module XMonadContrib.Square ( square ) where + +import XMonad +import Graphics.X11.Xlib + +square :: Layout +square = Layout { doLayout = arrange, modifyLayout = message } + where + arrange rect ws@(_:_) = do + let (rest, sq) = splitSquare rect + return (map (\w->(w,rest)) (init ws) ++ [(last ws,sq)]) + arrange _ [] = return [] + + message _ = return Nothing + +splitSquare :: Rectangle -> (Rectangle, Rectangle) +splitSquare (Rectangle x y w h) + | w > h = (Rectangle x y (w - h) h, Rectangle (x+fromIntegral (w-h)) y h h) + | otherwise = (Rectangle x y w (h-w), Rectangle x (y+fromIntegral (h-w)) w w) |