aboutsummaryrefslogtreecommitdiffstats
path: root/Operations.hs
diff options
context:
space:
mode:
authorJason Creighton <jcreigh@gmail.com>2007-05-16 05:14:37 +0200
committerJason Creighton <jcreigh@gmail.com>2007-05-16 05:14:37 +0200
commit9f2a16d8682c2842b59ffdf3c9e182ec044f54de (patch)
treee598766453c94b3607a9d75b048d1da2a880a784 /Operations.hs
parent0bcb67752095fb875ff79715b90be84577698234 (diff)
downloadxmonad-9f2a16d8682c2842b59ffdf3c9e182ec044f54de.tar.gz
xmonad-9f2a16d8682c2842b59ffdf3c9e182ec044f54de.tar.xz
xmonad-9f2a16d8682c2842b59ffdf3c9e182ec044f54de.zip
variable number of windows in master area
darcs-hash:20070516031437-b9aa7-03d82cb2565a45fa0e17a34c4c20740b51ff625c.gz
Diffstat (limited to 'Operations.hs')
-rw-r--r--Operations.hs23
1 files changed, 13 insertions, 10 deletions
diff --git a/Operations.hs b/Operations.hs
index faf9aed..eb17c86 100644
--- a/Operations.hs
+++ b/Operations.hs
@@ -101,19 +101,22 @@ sendMessage a = layout $ \x@(l, ls) -> maybe x (flip (,) ls) (modifyLayout l (So
data Resize = Shrink | Expand deriving Typeable
instance Message Resize
+data IncMasterN = IncMasterN Int deriving Typeable
+instance Message IncMasterN
+
full :: Layout
full = Layout { doLayout = \sc ws -> return [ (w,sc) | w <- ws ]
, modifyLayout = const Nothing } -- no changes
-tall, wide :: Rational -> Rational -> Layout
-wide delta frac = mirrorLayout (tall delta frac)
+tall, wide :: Int -> Rational -> Rational -> Layout
+wide nmaster delta frac = mirrorLayout (tall nmaster delta frac)
-tall delta frac = Layout { doLayout = \r w -> return $ zip w $ tile frac r (length w)
- , modifyLayout = fmap handler . fromMessage }
+tall nmaster delta frac = Layout { doLayout = \r w -> return $ zip w $ tile frac r nmaster (length w)
+ , modifyLayout = \m -> fmap resize (fromMessage m) `mplus` fmap incmastern (fromMessage m) }
- where handler s = tall delta $ (case s of
- Shrink -> (-)
- Expand -> (+)) frac delta
+ where resize Shrink = tall nmaster delta (frac-delta)
+ resize Expand = tall nmaster delta (frac+delta)
+ incmastern (IncMasterN d) = tall (max 1 (nmaster+d)) delta frac
-- | Mirror a rectangle
mirrorRect :: Rectangle -> Rectangle
@@ -131,9 +134,9 @@ mirrorLayout (Layout { doLayout = dl, modifyLayout = ml }) =
-- * no windows overlap
-- * no gaps exist between windows.
--
-tile :: Rational -> Rectangle -> Int -> [Rectangle]
-tile _ d n | n < 2 = [d]
-tile f r n = r1 : splitVertically (n-1) r2
+tile :: Rational -> Rectangle -> Int -> Int -> [Rectangle]
+tile _ r nmaster n | n <= nmaster = splitVertically n r
+tile f r nmaster n = splitVertically nmaster r1 ++ splitVertically (n-nmaster) r2
where (r1,r2) = splitHorizontallyBy f r
splitVertically, splitHorizontally :: Int -> Rectangle -> [Rectangle]