From 060583dd3919eeeb565123c4f2ff7cbd2c999288 Mon Sep 17 00:00:00 2001 From: David Roundy Date: Fri, 22 Jun 2007 16:29:50 +0200 Subject: add new LayoutHelpers module. darcs-hash:20070622142950-72aca-6dc011f903d12a056b1124752fc37f23368f898e.gz --- Square.hs | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) (limited to 'Square.hs') diff --git a/Square.hs b/Square.hs index 4250410..43e80b6 100644 --- a/Square.hs +++ b/Square.hs @@ -22,14 +22,10 @@ module XMonadContrib.Square ( -- $usage square ) where -import XMonad -import Graphics.X11.Xlib -import StackSet ( integrate ) - -- $usage -- You can use this module with the following in your Config.hs file: -- --- > import XMonadContrib.Spiral +-- > import XMonadContrib.Square -- -- An example layout using square together with "XMonadContrib.Combo" -- to make the very last area square: @@ -39,16 +35,17 @@ import StackSet ( integrate ) -- > ,(combo [(twoPane 0.03 0.8,1),(square,1)] -- > (mirror $ twoPane 0.03 0.85),1)] (twoPane 0.03 0.5) ) +import XMonad +import Graphics.X11.Xlib +import StackSet ( integrate ) +import XMonadContrib.LayoutHelpers ( l2lModDo ) square :: Layout a -square = Layout { doLayout = \r s -> arrange r (integrate s), 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 +square = Layout { doLayout = l2lModDo arrange, modifyLayout = const (return Nothing) } + where arrange :: Rectangle -> [a] -> [(a, Rectangle)] + arrange rect ws@(_:_) = map (\w->(w,rest)) (init ws) ++ [(last ws,sq)] + where (rest, sq) = splitSquare rect + arrange _ [] = [] splitSquare :: Rectangle -> (Rectangle, Rectangle) splitSquare (Rectangle x y w h) -- cgit v1.2.3