I like the “focus follows mouse” window-focussing model from X11, because
- I don’t have to click on the window, just move the mouse and the window it’s over is focussed
- I can focus a window without bringing it to the front, which is sometimes handy. If I want it in front, I can click it.
However MS-Windows follows the old-fashioned, Macintosh/Smalltalk style of having users click on a window to focus it for the keyboard. How do you make MS-Windows behave more like X11?
I used to install TweakUI from Microsoft, just so that I could turn on an X11-like focus-follows-mouse mode, but Microsoft don’t make TweakUI for Vista (there is TweakVI instead, if you want to Google for it. It’s by some other company. It’s not bad, but overkill for what I want to do).
In Vista, Microsoft added a GUI for this mode that’s almost what I want. You can do this:
Open Control Panel (new view, not Classic)
> Ease of Access Center
> Make the mouse easier to use
> [ ] Activate a window by hovering over it with the mouse
But this also brings the window to the front when it’s focussed. If that’s what you want, then you’re done. If you’re like me and you want the window under the mouse to have keyboard focus, but you don’t want it brought to the front without clicking on it, you’ll need to hack the Windows Registry. Here are some steps, which should be good for any release of Windows that is based on Windows NT (NT, 2000, XP, Vista, Win7):
- Run regedit (Win+R, regedit, OK)
- Open up the key HKEY_CURRENT_USER\Control Panel\Mouse
- Change the value of the REG_DWORD ActiveWindowTracking to 0×0000001 (1)
- Open up the key HKEY_CURRENT_USER\Control Panel\Desktop
- Change the MSB (most significant byte) of the REG_BINARY UserPreferencesMask to be 01. That is, if the current value is df 3e 03 80 12 00 00 00, then change it to 01 3e 03 80 12 00 00 00. If you used the GUI as above, the MSB might be 41 (which brings the focused window to the front as well), so change it back to 01.
- To make the focus a little slower, so that pop-up windows are useable, you also want to change the focus timing. Change the REG_DWORD ActiveWindTrkTimeout (also in HKEY_CURRENT_USER\Control Panel\Desktop) to the number of milliseconds to wait before focus shifts to the window under the mouse. I like a value of 0×00000080 (128ms). You might like 200ms (c8), or some faster or slower value.
So, in summary, the Registry keys are as follows for X11-like window focus:
HKEY_CURRENT_USERS\Control Panel\Mouse REG_DWORD ActiveWindowTracking = 0x00000001 (1) HKEY_CURRENT_USERS\Control Panel\Desktop REG_DWORD ActiveWindTrkTimeout = 0x00000080 (128) REG_BINARY UserPreferencesMask = 01 .. .. .. .. .. .. .. ..
These registry hacks require a reboot to take effect.