aboutsummaryrefslogtreecommitdiffstats
path: root/XMonad/Layout
diff options
context:
space:
mode:
authordaniel <daniel@wagner-home.com>2008-09-22 03:09:50 +0200
committerdaniel <daniel@wagner-home.com>2008-09-22 03:09:50 +0200
commit577a6c9b6654cf2e3007bce0fa56334e45be06b1 (patch)
treef0182e4772bf9deac078c7f2c805de61a89a2cfa /XMonad/Layout
parentd92ce0fc37be23cb5db06e7e7c5644218ea1e218 (diff)
downloadXMonadContrib-577a6c9b6654cf2e3007bce0fa56334e45be06b1.tar.gz
XMonadContrib-577a6c9b6654cf2e3007bce0fa56334e45be06b1.tar.xz
XMonadContrib-577a6c9b6654cf2e3007bce0fa56334e45be06b1.zip
let Grid have a configurable aspect ratio goal
darcs-hash:20080922010950-c98ca-2077ed7e1b481c7849d7501ff4435d9a3fabdde9.gz
Diffstat (limited to '')
-rw-r--r--XMonad/Layout/Grid.hs21
-rw-r--r--XMonad/Layout/IM.hs4
2 files changed, 17 insertions, 8 deletions
diff --git a/XMonad/Layout/Grid.hs b/XMonad/Layout/Grid.hs
index 33c4461..09de582 100644
--- a/XMonad/Layout/Grid.hs
+++ b/XMonad/Layout/Grid.hs
@@ -17,7 +17,7 @@
module XMonad.Layout.Grid (
-- * Usage
-- $usage
- Grid(..), arrange
+ Grid(..), arrange, defaultRatio
) where
import XMonad
@@ -33,20 +33,29 @@ import XMonad.StackSet
-- > myLayouts = Grid ||| Full ||| etc..
-- > main = xmonad defaultConfig { layoutHook = myLayouts }
--
+-- You can also specify an aspect ratio for Grid to strive for with the
+-- GridRatio constructor:
+--
+-- > myLayouts = GridRatio (3/4) ||| etc.
+--
-- For more detailed instructions on editing the layoutHook see:
--
-- "XMonad.Doc.Extending#Editing_the_layout_hook"
-data Grid a = Grid deriving (Read, Show)
+data Grid a = Grid | GridRatio Double deriving (Read, Show)
+
+defaultRatio :: Double
+defaultRatio = 9/16
instance LayoutClass Grid a where
- pureLayout Grid r s = arrange r (integrate s)
+ pureLayout Grid r = pureLayout (GridRatio defaultRatio) r
+ pureLayout (GridRatio d) r = arrange d r . integrate
-arrange :: Rectangle -> [a] -> [(a, Rectangle)]
-arrange (Rectangle rx ry rw rh) st = zip st rectangles
+arrange :: Double -> Rectangle -> [a] -> [(a, Rectangle)]
+arrange aspectRatio (Rectangle rx ry rw rh) st = zip st rectangles
where
nwins = length st
- ncols = max 1 . round . sqrt $ fromIntegral nwins * 9 * fromIntegral rw / (16 * fromIntegral rh :: Double)
+ ncols = max 1 . round . sqrt $ aspectRatio * fromIntegral nwins * fromIntegral rw / fromIntegral rh
mincs = nwins `div` ncols
extrs = nwins - ncols * mincs
chop :: Int -> Dimension -> [(Position, Dimension)]
diff --git a/XMonad/Layout/IM.hs b/XMonad/Layout/IM.hs
index 0f45d35..ba342d3 100644
--- a/XMonad/Layout/IM.hs
+++ b/XMonad/Layout/IM.hs
@@ -122,6 +122,6 @@ instance LayoutClass IM Window where
let (masterRect, slaveRect) = splitHorizontallyBy r rect
master <- findM (hasProperty prop) ws
let positions = case master of
- Just w -> (w, masterRect) : arrange slaveRect (filter (w /=) ws)
- Nothing -> arrange rect ws
+ Just w -> (w, masterRect) : arrange defaultRatio slaveRect (filter (w /=) ws)
+ Nothing -> arrange defaultRatio rect ws
return (positions, Nothing)