From 801fbda885f7d6121435bc51e90aad6e108e410e Mon Sep 17 00:00:00 2001 From: Spencer Janssen Date: Tue, 7 Oct 2008 11:42:07 +0200 Subject: Move screen locating code into pointScreen darcs-hash:20081007094207-25a6b-8575bf757041b0d1bf2afb879fccf3a6a73b7763 --- XMonad/Operations.hs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/XMonad/Operations.hs b/XMonad/Operations.hs index 41e5790..8c10e13 100644 --- a/XMonad/Operations.hs +++ b/XMonad/Operations.hs @@ -412,10 +412,9 @@ floatLocation w = withDisplay $ \d -> do ws <- gets windowset wa <- io $ getWindowAttributes d w bw <- fi <$> asks (borderWidth . config) + sc <- fromMaybe (W.current ws) <$> pointScreen (fi $ wa_x wa) (fi $ wa_y wa) - -- XXX horrible - let sc = fromMaybe (W.current ws) $ find (pointWithin (fi $ wa_x wa) (fi $ wa_y wa) . screenRect . W.screenDetail) $ W.screens ws - sr = screenRect . W.screenDetail $ sc + let sr = screenRect . W.screenDetail $ sc rr = W.RationalRect ((fi (wa_x wa) - fi (rect_x sr)) % fi (rect_width sr)) ((fi (wa_y wa) - fi (rect_y sr)) % fi (rect_height sr)) (fi (wa_width wa + bw*2) % fi (rect_width sr)) @@ -424,6 +423,12 @@ floatLocation w = withDisplay $ \d -> do return (W.screen $ sc, rr) where fi x = fromIntegral x +-- | Given a point, determine the screen (if any) that contains it. +pointScreen :: Position -> Position + -> X (Maybe (W.Screen WorkspaceId (Layout Window) Window ScreenId ScreenDetail)) +pointScreen x y = withWindowSet $ return . find p . W.screens + where p = pointWithin x y . screenRect . W.screenDetail + -- | 'pointWithin x y r' returns 'True' if the '(x, y)' co-ordinate is within -- the 'Rectangle'. pointWithin :: Position -> Position -> Rectangle -> Bool -- cgit v1.2.3