From 699980621be39057f6eaeb2440c4794a89b35eb4 Mon Sep 17 00:00:00 2001 From: Spencer Janssen Date: Tue, 18 Nov 2008 08:28:49 +0100 Subject: Factor rational rect scaling into a separate function darcs-hash:20081118072849-25a6b-a0f2fd04fc8be6f50bcec28136be7dc57fa4d07a --- XMonad/Operations.hs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'XMonad') diff --git a/XMonad/Operations.hs b/XMonad/Operations.hs index d98311c..6d6b04c 100644 --- a/XMonad/Operations.hs +++ b/XMonad/Operations.hs @@ -132,7 +132,7 @@ windows f = do tiled = (W.stack . W.workspace . W.current $ this) >>= W.filter (`M.notMember` W.floating ws) >>= W.filter (`notElem` vis) - viewrect@(Rectangle sx sy sw sh) = screenRect $ W.screenDetail w + viewrect = screenRect $ W.screenDetail w -- just the tiled windows: -- now tile the windows on this workspace, modified by the gap @@ -144,10 +144,7 @@ windows f = do -- now the floating windows: -- move/resize the floating windows, if there are any forM_ flt $ \fw -> whenJust (M.lookup fw (W.floating ws)) $ - \(W.RationalRect rx ry rw rh) -> do - tileWindow fw $ Rectangle - (sx + floor (toRational sw*rx)) (sy + floor (toRational sh*ry)) - (floor (toRational sw*rw)) (floor (toRational sh*rh)) + \r -> tileWindow fw $ scaleRationalRect viewrect r let vs = flt ++ map fst rs io $ restackWindows d vs @@ -172,6 +169,12 @@ windows f = do isMouseFocused <- asks mouseFocused unless isMouseFocused $ clearEvents enterWindowMask +-- | Produce the actual rectangle from a screen and a ratio on that screen. +scaleRationalRect :: Rectangle -> W.RationalRect -> Rectangle +scaleRationalRect (Rectangle sx sy sw sh) (W.RationalRect rx ry rw rh) + = Rectangle (sx + scale sw rx) (sy + scale sh ry) (scale sw rw) (scale sh rh) + where scale s r = floor (toRational s * r) + -- | setWMState. set the WM_STATE property setWMState :: Window -> Int -> X () setWMState w v = withDisplay $ \dpy -> do -- cgit v1.2.3