[xmonad] Pointer follows focus (with patch)
Don Stewart
dons at galois.com
Fri Feb 22 20:11:19 EST 2008
xmonad:
> Thanks Robert! I got your code to work in my Config.hs
> without any modifications to xmonad. Here's what I have:
>
> pointerFollowsFocus :: Rational -> Rational -> X ()
> pointerFollowsFocus h v = do
> dpy <- asks display
> root <- asks theRoot
> withFocused $ \w -> do
> wa <- io $ getWindowAttributes dpy w
> (sameRoot,_,w',_,_,_,_,_) <- io $ queryPointer dpy root
> if (sameRoot && w == w') then
> return ()
> else
> io $ warpPointer dpy none w 0 0 0 0
> (fraction h (wa_width wa)) (fraction v (wa_height wa))
> where fraction x y = floor (x * fromIntegral y)
> [...]
> logHook = dynamicLogWithPP hethraelPP
> {ppOutput = hPutStrLn xmobar } >> pointerFollowsFocus 1 1
>
> 'unless' was not in scope, so I changed it to an if
> statement.
>
> I have found a couple of issues with it, but otherwise it's
> great. First, the pointer warps when tabs are clicked. The
> second is a little more complicated. When using a full or
> tabbed layout, calling focusDown (mod+J) to move from the
> last window to the first window causes the pointer to warp
> even if the pointer is in the window. When calling focusUp
> (mod+K), the pointer always warps unless moving from the
> master window to the last window.
Once this is finalised, can we get it as an extension module
for mouse/pointer stuff. Saves people reimplementing this functionality
More information about the xmonad
mailing list