From 489eb44274ce281158d1d3d77260db41bb4204d0 Mon Sep 17 00:00:00 2001 From: robreim Date: Sun, 11 May 2008 11:40:56 +0200 Subject: Fix window region checking in UpdatePointer darcs-hash:20080511094056-d4c7e-6145e3a96972b1be277f633c7d4ac7c7dcd74804.gz --- XMonad/Actions/UpdatePointer.hs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'XMonad/Actions/UpdatePointer.hs') diff --git a/XMonad/Actions/UpdatePointer.hs b/XMonad/Actions/UpdatePointer.hs index b2751bf..6761506 100644 --- a/XMonad/Actions/UpdatePointer.hs +++ b/XMonad/Actions/UpdatePointer.hs @@ -60,9 +60,9 @@ updatePointer p = withFocused $ \w -> do root <- asks theRoot mouseIsMoving <- asks mouseFocused wa <- io $ getWindowAttributes dpy w - (_sameRoot,_,w',rootx,rooty,_,_,_) <- io $ queryPointer dpy root - -- Can sameRoot ever be false in this case? I'm going to assume not - unless (w == w' || mouseIsMoving) $ + (_sameRoot,_,_,rootx,rooty,_,_,_) <- io $ queryPointer dpy root + unless (pointWithinRegion rootx rooty (wa_x wa) (wa_y wa) (wa_width wa) (wa_height wa) + || mouseIsMoving) $ case p of Nearest -> do let x = moveWithin rootx (wa_x wa) ((wa_x wa) + (wa_width wa)) @@ -81,3 +81,9 @@ moveWithin current lower upper = then upper else current +-- Test that a point resides within a region. +-- This belongs somewhere more generally accessible than this module. +pointWithinRegion :: Integral a => a -> a -> a -> a -> a -> a -> Bool +pointWithinRegion px py rx ry rw rh = + within px rx (rx + rw) && within py ry (ry + rh) + where within x left right = x >= left && x <= right -- cgit v1.2.3