From e3fa27b9f3abaf43ffd39aa9f44e3b207d557224 Mon Sep 17 00:00:00 2001 From: Brent Yorgey Date: Mon, 3 Mar 2008 21:46:19 +0100 Subject: Magnifier: fix behavior for windows on the bottom + right of the screen. Now all magnified windows will be the same size, possibly shifted in order to fit completely on the screen. darcs-hash:20080303204619-bd4d7-a8b06481a66d9ca146a4a5b0edd6f0d3728f6889.gz --- XMonad/Layout/Magnifier.hs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'XMonad/Layout') diff --git a/XMonad/Layout/Magnifier.hs b/XMonad/Layout/Magnifier.hs index 8ab9bb3..b163fe4 100644 --- a/XMonad/Layout/Magnifier.hs +++ b/XMonad/Layout/Magnifier.hs @@ -123,7 +123,7 @@ unlessMaster mainmod r s wrs = if null (up s) then return (wrs, Nothing) applyMagnifier :: Double -> Rectangle -> t -> [(Window, Rectangle)] -> X ([(Window, Rectangle)], Maybe a) applyMagnifier z r _ wrs = do focused <- withWindowSet (return . peek) - let mag (w,wr) ws | focused == Just w = ws ++ [(w, shrink r $ magnify z wr)] + let mag (w,wr) ws | focused == Just w = ws ++ [(w, fit r $ magnify z wr)] | otherwise = (w,wr) : ws return (reverse $ foldr mag [] wrs, Nothing) @@ -134,9 +134,12 @@ magnify zoom (Rectangle x y w h) = Rectangle x' y' w' h' w' = round $ fromIntegral w * zoom h' = round $ fromIntegral h * zoom -shrink :: Rectangle -> Rectangle -> Rectangle -shrink (Rectangle sx sy sw sh) (Rectangle x y w h) = Rectangle x' y' w' h' - where x' = max sx x - y' = max sy y - w' = min w (fromIntegral sx + sw - fromIntegral x') - h' = min h (fromIntegral sy + sh - fromIntegral y') +fit :: Rectangle -> Rectangle -> Rectangle +fit (Rectangle sx sy sw sh) (Rectangle x y w h) = Rectangle x' y' w' h' + where x' = max sx (x - (max 0 (x + fi w - sx - fi sw))) + y' = max sy (y - (max 0 (y + fi h - sy - fi sh))) + w' = min sw w + h' = min sh h + +fi :: (Num b, Integral a) => a -> b +fi = fromIntegral \ No newline at end of file -- cgit v1.2.3