aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSpencer Janssen <sjanssen@cse.unl.edu>2007-11-22 06:31:54 +0100
committerSpencer Janssen <sjanssen@cse.unl.edu>2007-11-22 06:31:54 +0100
commit4ee2843346b2ef4d7f82f338090b2a6a17bae9d5 (patch)
tree34881d310fa29665ccbe66b8f36b5acce83e7d44
parentee995e4d26a9c081acfc7da86bc9f0cdf9e293d8 (diff)
downloadXMonadContrib-4ee2843346b2ef4d7f82f338090b2a6a17bae9d5.tar.gz
XMonadContrib-4ee2843346b2ef4d7f82f338090b2a6a17bae9d5.tar.xz
XMonadContrib-4ee2843346b2ef4d7f82f338090b2a6a17bae9d5.zip
More HintedTile refactoring
darcs-hash:20071122053154-a5988-b06311b0da1c1b1b957a161181ea7a733d0b2472.gz
-rw-r--r--XMonad/Layout/HintedTile.hs36
1 files changed, 16 insertions, 20 deletions
diff --git a/XMonad/Layout/HintedTile.hs b/XMonad/Layout/HintedTile.hs
index ff79601..0bdeffa 100644
--- a/XMonad/Layout/HintedTile.hs
+++ b/XMonad/Layout/HintedTile.hs
@@ -52,18 +52,15 @@ data HintedTile a = HintedTile
data Orientation = Wide | Tall deriving ( Show, Read )
instance LayoutClass HintedTile Window where
- doLayout c rect w' = do
+ doLayout (HintedTile { orientation = o, nmaster = nm, frac = f }) r w' = do
bhs <- mapM getHints w
- let (masters, slaves) = splitAt (nmaster c) bhs
- return (zip w (tiler (frac c) rect masters slaves), Nothing)
+ let (masters, slaves) = splitAt nm bhs
+ return (zip w (tiler masters slaves), Nothing)
where
w = W.integrate w'
- (split, divide) = case orientation c of
- Tall -> (splitHorizontally, divideVertically)
- Wide -> (splitVertically, divideHorizontally)
- tiler f r masters slaves
- | null masters || null slaves = divide (masters ++ slaves) r
- | otherwise = split f r (divide masters) (divide slaves)
+ tiler masters slaves
+ | null masters || null slaves = divide o (masters ++ slaves) r
+ | otherwise = split o f r (divide o masters) (divide o slaves)
pureMessage c m = fmap resize (fromMessage m) `mplus`
fmap incmastern (fromMessage m)
@@ -87,29 +84,28 @@ getHints w = withDisplay $ \d -> io $ liftM2 (,)
(getWMNormalHints d w)
-- Divide the screen vertically (horizontally) into n subrectangles
-divideVertically, divideHorizontally :: [(Dimension, SizeHints)] -> Rectangle -> [Rectangle]
-divideVertically [] _ = [] -- there's a fold here, struggling to get out
-divideVertically (bh:bhs) (Rectangle sx sy sw sh) = (Rectangle sx sy w h) :
- (divideVertically bhs (Rectangle sx (sy + fromIntegral h) sw (sh - h)))
+divide :: Orientation -> [(Dimension, SizeHints)] -> Rectangle -> [Rectangle]
+divide _ [] _ = []
+divide Tall (bh:bhs) (Rectangle sx sy sw sh) = (Rectangle sx sy w h) :
+ (divide Tall bhs (Rectangle sx (sy + fromIntegral h) sw (sh - h)))
where (w, h) = hintsUnderBorder bh (sw, sh `div` fromIntegral (1 + (length bhs)))
-divideHorizontally [] _ = []
-divideHorizontally (bh:bhs) (Rectangle sx sy sw sh) = (Rectangle sx sy w h) :
- (divideHorizontally bhs (Rectangle (sx + fromIntegral w) sy (sw - w) sh))
+divide Wide (bh:bhs) (Rectangle sx sy sw sh) = (Rectangle sx sy w h) :
+ (divide Wide bhs (Rectangle (sx + fromIntegral w) sy (sw - w) sh))
where
(w, h) = hintsUnderBorder bh (sw `div` fromIntegral (1 + (length bhs)), sh)
-- Split the screen into two rectangles, using a rational to specify the ratio
-splitHorizontally, splitVertically :: Rational -> Rectangle -> (Rectangle -> [Rectangle])
- -> (Rectangle -> [Rectangle]) -> [Rectangle]
-splitHorizontally f (Rectangle sx sy sw sh) left right = leftRects ++ rightRects
+split :: Orientation -> Rational -> Rectangle -> (Rectangle -> [Rectangle])
+ -> (Rectangle -> [Rectangle]) -> [Rectangle]
+split Tall f (Rectangle sx sy sw sh) left right = leftRects ++ rightRects
where
leftw = floor $ fromIntegral sw * f
leftRects = left $ Rectangle sx sy leftw sh
rightx = (maximum . map rect_width) leftRects
rightRects = right $ Rectangle (sx + fromIntegral rightx) sy (sw - rightx) sh
-splitVertically f (Rectangle sx sy sw sh) top bottom = topRects ++ bottomRects
+split Wide f (Rectangle sx sy sw sh) top bottom = topRects ++ bottomRects
where
toph = floor $ fromIntegral sh * f
topRects = top $ Rectangle sx sy sw toph