aboutsummaryrefslogtreecommitdiffstats
path: root/XMonad/Layout
diff options
context:
space:
mode:
authorLukas Mai <l.mai@web.de>2008-04-02 03:21:26 +0200
committerLukas Mai <l.mai@web.de>2008-04-02 03:21:26 +0200
commitc619e54c3545f8750610939297fffb3d430bf09f (patch)
treefd9435f189eadb89a55a161ac04190a520c61296 /XMonad/Layout
parentac609136b989b7fa97b6a5cea993a8b423a58254 (diff)
downloadXMonadContrib-c619e54c3545f8750610939297fffb3d430bf09f.tar.gz
XMonadContrib-c619e54c3545f8750610939297fffb3d430bf09f.tar.xz
XMonadContrib-c619e54c3545f8750610939297fffb3d430bf09f.zip
Grid/HintedGrid: use an ncolumns formula inspired by dwm's "optimal" mode
darcs-hash:20080402012126-462cf-702c8178aefecd7feacc9fac0fe6774957acaf85.gz
Diffstat (limited to 'XMonad/Layout')
-rw-r--r--XMonad/Layout/Grid.hs2
-rw-r--r--XMonad/Layout/HintedGrid.hs5
2 files changed, 2 insertions, 5 deletions
diff --git a/XMonad/Layout/Grid.hs b/XMonad/Layout/Grid.hs
index 6dcd1bb..070bd2f 100644
--- a/XMonad/Layout/Grid.hs
+++ b/XMonad/Layout/Grid.hs
@@ -46,7 +46,7 @@ arrange :: Rectangle -> [a] -> [(a, Rectangle)]
arrange (Rectangle rx ry rw rh) st = zip st rectangles
where
nwins = length st
- ncols = ceiling . (sqrt :: Double -> Double) . fromIntegral $ nwins
+ ncols = max 1 . round . sqrt $ fromIntegral nwins * fromIntegral rw / (fromIntegral rh :: Double)
mincs = nwins `div` ncols
extrs = nwins - ncols * mincs
chop :: Int -> Dimension -> [(Position, Dimension)]
diff --git a/XMonad/Layout/HintedGrid.hs b/XMonad/Layout/HintedGrid.hs
index 5b50204..2031520 100644
--- a/XMonad/Layout/HintedGrid.hs
+++ b/XMonad/Layout/HintedGrid.hs
@@ -56,9 +56,6 @@ instance LayoutClass Grid Window where
adjBorders :: Dimension -> D -> D
adjBorders b (w, h) = (w + 2 * b, h + 2 * b)
-isqrt :: (Integral a) => a -> a
-isqrt = ceiling . (sqrt :: Double -> Double) . fromIntegral
-
replicateS :: Int -> (a -> (b, a)) -> a -> ([b], a)
replicateS n = runState . replicateM n . State
@@ -110,7 +107,7 @@ arrange' :: D -> [D -> D] -> [Rectangle]
arrange' (rw, rh) adjs = reverse $ doRect rh rw (fromIntegral ncolumns) (ecols ++ cols)
where
nwindows = length adjs
- ncolumns = isqrt nwindows
+ ncolumns = max 1 . round . sqrt $ fromIntegral nwindows * fromIntegral rw / (fromIntegral rh :: Double)
nrows = nwindows `div` ncolumns
nextras = nwindows - ncolumns * nrows
(ecols, adjs') = replicateS nextras (splitAt (nrows + 1)) $ reverse adjs