Linux – xmonad: focus window when mouse is moved

haskelllinuxxmonad

In my xmonad config, I have set focusFollowsMouse=true so that a window is focused when the mouse pointer is moved onto it. However, I would also like a window to become focused when the mouse pointer is already on it, and it is moved.

Steps to reproduce:

  1. Move the mouse pointer over some window.
  2. Focus a different window using the keyboard, e.g. by Mod+Tab or selecting a different screen.
  3. Move the mouse pointer slightly, so that it stays on the same window.

Desired behavior:

The window becomes focused again.

Actual behavior:

Focus does not change.

Is there any way I can achieve the desired behavior?

Best Answer

Looks like this can be done with: https://hackage.haskell.org/package/xmonad-contrib-0.13/docs/XMonad-Actions-UpdateFocus.html

To enable it you need to add the focusOnMouseMove event handler:

import XMonad.Actions.UpdateFocus
xmonad $ def {
  ..
  startupHook = adjustEventInput
  handleEventHook = focusOnMouseMove
  ..
}
Related Question