From 76b62aa4f8b75b704e4e34fe4c7fe536a2e6d1ea Mon Sep 17 00:00:00 2001 From: David Roundy Date: Tue, 25 Sep 2007 19:44:46 +0200 Subject: Make Square work with class. darcs-hash:20070925174446-72aca-34d6f19f65cabcd34fdc7356eead59496bcb0e3a.gz --- Square.hs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'Square.hs') diff --git a/Square.hs b/Square.hs index 02a5adb..c4c0a05 100644 --- a/Square.hs +++ b/Square.hs @@ -20,11 +20,11 @@ module XMonadContrib.Square ( -- * Usage -- $usage - square ) where + Square(..) ) where import XMonad import Graphics.X11.Xlib -import XMonadContrib.LayoutHelpers ( l2lModDo, idModify ) +import StackSet ( integrate ) -- $usage -- You can use this module with the following in your Config.hs file: @@ -40,12 +40,13 @@ import XMonadContrib.LayoutHelpers ( l2lModDo, idModify ) -- %import XMonadContrib.Square -square :: Layout a -square = Layout { doLayout = l2lModDo arrange, modifyLayout = idModify } - where arrange :: Rectangle -> [a] -> [(a, Rectangle)] - arrange rect ws@(_:_) = map (\w->(w,rest)) (init ws) ++ [(last ws,sq)] - where (rest, sq) = splitSquare rect - arrange _ [] = [] +data Square a = Square deriving ( Read, Show ) + +instance Layout Square a where + pureLayout Square r s = arrange (integrate s) + where arrange ws@(_:_) = map (\w->(w,rest)) (init ws) ++ [(last ws,sq)] + arrange [] = [] -- actually, this is an impossible case + (rest, sq) = splitSquare r splitSquare :: Rectangle -> (Rectangle, Rectangle) splitSquare (Rectangle x y w h) -- cgit v1.2.3