[xmonad] Pointer follows focus (with patch)

Robert robreim at bobturf.org
Sun Feb 3 05:06:50 EST 2008

I sometimes get annoyed at having to get my mouse from several screens 
over to my current window to click on things I'm working on.

I hacked around this by binding a key to Warp.warpToWindow but I'm 
starting to think there should be the following invariant: the pointer 
should always be over the focused window. So not only does the focused 
window follow the pointer as it does now, but the pointer will also 
follow any window focus.Using the Warp module I got this close to 
working in my config file.

I had lots of keybindings which are modified to look like this:

windows W.swapUp >> warpToWindow (1%2) (1%2)

What prevents me from getting the invariant I'm aiming for is new or
destroyed windows.

By adding a new warpToWindow function which takes a window to warp to,
and using a ManageHook I got quite close to getting it working for new
windows. I had something that looked like this:

manageWarp = ask >>= \w -> liftX (warpToWindow w (1%2) (1%2)) >> doF id

It worked great for floating windows but not for tiled windows. I think
the reason is because the hook management code is done before the layout
code, so the pointer just warps to wherever the window asks to be put
which becomes wrong as soon as xmonad puts the window into it's proper

So anyway, I'm starting to think this isn't going to be possible to do
in my config. But I think it's possibly closer to the right way to
handle the pointer than what exists now. I've included a patch which
adds support for a mouseFocusWarpPos config flag to XMonad. It's 
disabled by default but that could be changed if others like it.

Currently it moves the mouse pointer to a relative position within the
window the user configures. I'm not entirely happy with this. What might
be better is for each window to keep track of where the mouse was and go
back there whenever the window regains focus. But that may be too

Feedback appreciated.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: pointer.patch
Type: text/x-patch
Size: 6568 bytes
Desc: not available
Url : http://www.haskell.org/pipermail/xmonad/attachments/20080203/a5e7265f/pointer-0001.bin

More information about the xmonad mailing list