aboutsummaryrefslogtreecommitdiffstats
path: root/Square.hs
diff options
context:
space:
mode:
authorDavid Roundy <droundy@darcs.net>2007-09-25 19:44:46 +0200
committerDavid Roundy <droundy@darcs.net>2007-09-25 19:44:46 +0200
commit76b62aa4f8b75b704e4e34fe4c7fe536a2e6d1ea (patch)
tree6e9b54c4a54c544f7fde8866dded965e0a192486 /Square.hs
parent2bee8de664327906945db65a7be4e628c72624b3 (diff)
downloadXMonadContrib-76b62aa4f8b75b704e4e34fe4c7fe536a2e6d1ea.tar.gz
XMonadContrib-76b62aa4f8b75b704e4e34fe4c7fe536a2e6d1ea.tar.xz
XMonadContrib-76b62aa4f8b75b704e4e34fe4c7fe536a2e6d1ea.zip
Make Square work with class.
darcs-hash:20070925174446-72aca-34d6f19f65cabcd34fdc7356eead59496bcb0e3a.gz
Diffstat (limited to 'Square.hs')
-rw-r--r--Square.hs17
1 files changed, 9 insertions, 8 deletions
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)