mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-05-19 03:20:21 -07:00
X.L.MultiColumns bugfix and formating
Fix bug where a column list of insufficient length could be used to find the column of the window. Also fix formating to conform better with standards.
This commit is contained in:
parent
3fd77f5386
commit
6e84273e03
@ -77,27 +77,26 @@ data MultiCol a = MultiCol
|
|||||||
|
|
||||||
instance LayoutClass MultiCol a where
|
instance LayoutClass MultiCol a where
|
||||||
doLayout l r s = return (zip w rlist, resl)
|
doLayout l r s = return (zip w rlist, resl)
|
||||||
where rlist = doL (multiColNWin l') (multiColSize l') r wlen
|
where rlist = doL (multiColNWin l') (multiColSize l') r wlen
|
||||||
w = W.integrate s
|
w = W.integrate s
|
||||||
wlen = length w
|
wlen = length w
|
||||||
-- Make sure the list of columns is big enough and update active column
|
-- Make sure the list of columns is big enough and update active column
|
||||||
nw = multiColNWin l ++ repeat (multiColDefWin l)
|
nw = multiColNWin l ++ repeat (multiColDefWin l)
|
||||||
l' = l { multiColNWin = take (max (length $ multiColNWin l) $ getCol (wlen-1) nw + 1) nw
|
l' = l { multiColNWin = take (max (length $ multiColNWin l) $ getCol (wlen-1) nw + 1) nw
|
||||||
, multiColActive = getCol (length $ W.up s) (multiColNWin l)
|
, multiColActive = getCol (length $ W.up s) nw
|
||||||
}
|
}
|
||||||
-- Only return new layout if it has been modified
|
-- Only return new layout if it has been modified
|
||||||
resl = if l'==l
|
resl = if l'==l
|
||||||
then Nothing
|
then Nothing
|
||||||
else Just l'
|
else Just l'
|
||||||
handleMessage l m =
|
handleMessage l m =
|
||||||
return $ msum [fmap resize (fromMessage m)
|
return $ msum [fmap resize (fromMessage m)
|
||||||
,fmap incmastern (fromMessage m)]
|
,fmap incmastern (fromMessage m)]
|
||||||
where resize Shrink = l { multiColSize = max (-0.5) $ s-ds }
|
where resize Shrink = l { multiColSize = max (-0.5) $ s-ds }
|
||||||
resize Expand = l { multiColSize = min 1 $ s+ds }
|
resize Expand = l { multiColSize = min 1 $ s+ds }
|
||||||
incmastern (IncMasterN x)
|
incmastern (IncMasterN x) = l { multiColNWin = take a n ++ [newval] ++ tail r }
|
||||||
= l { multiColNWin = take a n ++ [newval] ++ tail r }
|
where newval = max 0 $ head r + x
|
||||||
where newval = max 0 $ head r + x
|
r = drop a n
|
||||||
r = drop a n
|
|
||||||
n = multiColNWin l
|
n = multiColNWin l
|
||||||
ds = multiColDeltaSize l
|
ds = multiColDeltaSize l
|
||||||
s = multiColSize l
|
s = multiColSize l
|
||||||
@ -105,7 +104,7 @@ instance LayoutClass MultiCol a where
|
|||||||
description _ = "MultiCol"
|
description _ = "MultiCol"
|
||||||
|
|
||||||
|
|
||||||
-- Get which column a window is in.
|
-- | Get which column a window is in, starting at 0.
|
||||||
getCol :: Int -> [Int] -> Int
|
getCol :: Int -> [Int] -> Int
|
||||||
getCol w (n:ns) = if n<1 || w < n
|
getCol w (n:ns) = if n<1 || w < n
|
||||||
then 0
|
then 0
|
||||||
@ -115,29 +114,29 @@ getCol _ _ = -1
|
|||||||
|
|
||||||
doL :: [Int] -> Rational -> Rectangle -> Int -> [Rectangle]
|
doL :: [Int] -> Rational -> Rectangle -> Int -> [Rectangle]
|
||||||
doL nwin s r n = rlist
|
doL nwin s r n = rlist
|
||||||
where -- Number of columns to tile
|
where -- Number of columns to tile
|
||||||
size = floor $ abs s * fromIntegral (rect_width r)
|
size = floor $ abs s * fromIntegral (rect_width r)
|
||||||
ncol = getCol (n-1) nwin + 1
|
ncol = getCol (n-1) nwin + 1
|
||||||
-- Extract all but last column to tile
|
-- Extract all but last column to tile
|
||||||
c = take (ncol-1) nwin
|
c = take (ncol-1) nwin
|
||||||
-- Compute number of windows in last column and add it to the others
|
-- Compute number of windows in last column and add it to the others
|
||||||
col = c ++ [n-sum c]
|
col = c ++ [n-sum c]
|
||||||
-- Compute width of columns
|
-- Compute width of columns
|
||||||
width = if s>0
|
width = if s>0
|
||||||
then if ncol==1
|
then if ncol==1
|
||||||
then [fromIntegral $ rect_width r]
|
then [fromIntegral $ rect_width r]
|
||||||
else size:replicate (ncol-1) ((fromIntegral (rect_width r) - size) `div` (ncol-1))
|
else size:replicate (ncol-1) ((fromIntegral (rect_width r) - size) `div` (ncol-1))
|
||||||
else if fromIntegral ncol * abs s >= 1
|
else if fromIntegral ncol * abs s >= 1
|
||||||
-- Split equally
|
-- Split equally
|
||||||
then replicate ncol $ fromIntegral (rect_width r) `div` ncol
|
then replicate ncol $ fromIntegral (rect_width r) `div` ncol
|
||||||
-- Let the master cover what is left...
|
-- Let the master cover what is left...
|
||||||
else (fromIntegral (rect_width r) - (ncol-1)*size):replicate (ncol-1) size
|
else (fromIntegral (rect_width r) - (ncol-1)*size):replicate (ncol-1) size
|
||||||
-- Compute the horizontal position of columns
|
-- Compute the horizontal position of columns
|
||||||
xpos = accumEx (fromIntegral $ rect_x r) width
|
xpos = accumEx (fromIntegral $ rect_x r) width
|
||||||
-- Exclusive accumulation
|
-- Exclusive accumulation
|
||||||
accumEx a (x:xs) = a:accumEx (a+x) xs
|
accumEx a (x:xs) = a:accumEx (a+x) xs
|
||||||
accumEx _ _ = []
|
accumEx _ _ = []
|
||||||
-- Create a rectangle for each column
|
-- Create a rectangle for each column
|
||||||
cr = zipWith (\x w -> r { rect_x=fromIntegral x, rect_width=fromIntegral w }) xpos width
|
cr = zipWith (\x w -> r { rect_x=fromIntegral x, rect_width=fromIntegral w }) xpos width
|
||||||
-- Split the columns into the windows
|
-- Split the columns into the windows
|
||||||
rlist = concat $ zipWith (\num rect -> splitVertically num rect) col cr
|
rlist = concat $ zipWith (\num rect -> splitVertically num rect) col cr
|
||||||
|
Loading…
x
Reference in New Issue
Block a user