summaryrefslogtreecommitdiffstats
path: root/XMonad
diff options
context:
space:
mode:
authorSpencer Janssen <spencerjanssen@gmail.com>2008-10-07 11:42:07 +0200
committerSpencer Janssen <spencerjanssen@gmail.com>2008-10-07 11:42:07 +0200
commit801fbda885f7d6121435bc51e90aad6e108e410e (patch)
tree0d7e2666feed1d951f0b1cb508324c31fc03c0ab /XMonad
parent9b5773912c88c372a2451d6046fe1fa84c2b8bb4 (diff)
downloadmetatile-801fbda885f7d6121435bc51e90aad6e108e410e.tar
metatile-801fbda885f7d6121435bc51e90aad6e108e410e.zip
Move screen locating code into pointScreen
darcs-hash:20081007094207-25a6b-8575bf757041b0d1bf2afb879fccf3a6a73b7763
Diffstat (limited to 'XMonad')
-rw-r--r--XMonad/Operations.hs11
1 files 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