
On Sun, Feb 03, 2008 at 07:06:50PM +0900, Robert wrote:
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 location.
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 complicated.
Feedback appreciated.
Have you considered using logHook? It is executed after each windowset change, which should be sufficient. I'd rather not add this feature to the core. Cheers, Spencer Janssen