From 09d42195c82112f658fb388a0151e7d0b0403ef5 Mon Sep 17 00:00:00 2001 From: Adam Vogt Date: Tue, 14 Apr 2009 08:18:19 +0200 Subject: ThreeColumns support middle column, with more backwards compatiblity Ignore-this: 5a8991269904986e0e012e955c6d4712 darcs-hash:20090414061819-1499c-fe2d526b41d0224f363e586c392d93f60584b51c.gz --- XMonad/Layout/ThreeColumns.hs | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) (limited to 'XMonad/Layout/ThreeColumns.hs') diff --git a/XMonad/Layout/ThreeColumns.hs b/XMonad/Layout/ThreeColumns.hs index 06eb943..fe203be 100644 --- a/XMonad/Layout/ThreeColumns.hs +++ b/XMonad/Layout/ThreeColumns.hs @@ -5,7 +5,7 @@ -- Module : XMonad.Layout.ThreeColumns -- Copyright : (c) Kai Grossjohann -- License : BSD3-style (see LICENSE) --- +-- -- Maintainer : ? -- Stability : unstable -- Portability : unportable @@ -38,7 +38,7 @@ import Control.Monad -- -- Then edit your @layoutHook@ by adding the ThreeCol layout: -- --- > myLayouts = ThreeCol False 1 (3/100) (1/2) ||| etc.. +-- > myLayouts = ThreeCol 1 (3/100) (1/2) ||| etc.. -- > main = xmonad defaultConfig { layoutHook = myLayouts } -- -- If the first argument is true, the main window is placed in the center @@ -54,20 +54,28 @@ import Control.Monad -- -- "XMonad.Doc.Extending#Editing_the_layout_hook" -data ThreeCol a = ThreeCol !Bool !Int !Rational !Rational deriving (Show,Read) +-- | Arguments are nmaster, delta, fraction +data ThreeCol a = ThreeColMid { threeColNMaster :: !Int, threeColDelta :: !Rational, threeColFrac :: !Rational} + | ThreeCol { threeColNMaster :: !Int, threeColDelta :: !Rational, threeColFrac :: !Rational} + deriving (Show,Read) instance LayoutClass ThreeCol a where - doLayout (ThreeCol middle nmaster _ frac) r = - return . (\x->(x,Nothing)) . - ap zip (tile3 middle frac r nmaster . length) . W.integrate - handleMessage (ThreeCol middle nmaster delta frac) m = + pureLayout (ThreeCol n _ f) r = doL False n f r + pureLayout (ThreeColMid n _ f) r = doL True n f r + handleMessage l m = return $ msum [fmap resize (fromMessage m) ,fmap incmastern (fromMessage m)] - where resize Shrink = ThreeCol middle nmaster delta (max (-0.5) $ frac-delta) - resize Expand = ThreeCol middle nmaster delta (min 1 $ frac+delta) - incmastern (IncMasterN d) = ThreeCol middle (max 0 (nmaster+d)) delta frac + where resize Shrink = l { threeColFrac = max (-0.5) $ f-d } + resize Expand = l { threeColFrac = min 1 $ f+d } + incmastern (IncMasterN x) = l { threeColNMaster = max 0 (n+x) } + n = threeColNMaster l + d = threeColDelta l + f = threeColFrac l description _ = "ThreeCol" +doL :: Bool-> Int-> Rational-> Rectangle-> W.Stack a-> [(a, Rectangle)] +doL m n f r = ap zip (tile3 m f r n . length) . W.integrate + -- | tile3. Compute window positions using 3 panes tile3 :: Bool -> Rational -> Rectangle -> Int -> Int -> [Rectangle] tile3 middle f r nmaster n -- cgit v1.2.3