Files
komorebi/docs/usage/focus-follows-mouse.md
T
LGUG2Z 9a0693f5d1 feat(kwin): focus follows mouse through KWin's focus policy
KWin has a focus policy that gives the focus to the window under the pointer, so
komorebi asks for it and follows where the focus goes, as it does for any change
of focus. Both implementations komorebi for Windows names are the same thing
here. The KWin backend sets the focus policy and no delay in the user's kwinrc
and has KWin read it, and puts the two keys back as the user had them when it is
turned off and, with every other setting, when komorebi exits. The state of the
daemon says whether it is on.

komorebic gets focus-follows-mouse and toggle-focus-follows-mouse. The session
node gets a pointer that a test drives from inside the guest: the program
komorebi-pointer makes an absolute device with uinput, and komorebi_vm.Pointer
sends it commands. vm-focus-follows-mouse moves it over each of two windows and
checks the focus, then the policy that is put back.

komorebi.json takes focus_follows_mouse, which is on with Windows or Komorebi,
and a file that leaves it out turns it off and gives the user's focus policy
back.

Loading a configuration asks the backend for the focus policy now, so the tests
that load one do it with a backend installed.
2026-10-28 07:20:49 -07:00

2.2 KiB

Focus follows mouse

With focus follows mouse, the window under the pointer is the window that has the focus: moving the pointer into another window gives that window the focus, with no click. komorebi does not do this itself. It asks KWin to, by changing KWin's own focus policy, and follows where the focus goes like it follows any other change of focus.

Turning it on and off

komorebic focus-follows-mouse turns it on or off, and komorebic toggle-focus-follows-mouse switches it. It is off by default: KWin's focus policy is the user's own until komorebi changes it.

komorebic focus-follows-mouse enable
komorebic focus-follows-mouse disable
komorebic toggle-focus-follows-mouse

Both take --implementation, windows (the default) or komorebi, the two that komorebi for Windows has. On KDE they are the same: both ask KWin for its own focus policy, and which one was asked for is only remembered, in the focus_follows_mouse of the daemon's state.

In komorebi.json

The focus_follows_mouse key of komorebi.json is "Windows" or "Komorebi" to turn it on, which is what --implementation names, and has no value or is left out to leave it off:

{
  "focus_follows_mouse": "Windows"
}

The file sets it when the daemon starts and when the file changes, and a file that leaves it out turns it off and gives the user's focus policy back, also when it was turned on with a command.

What it does to KWin

Turning it on sets two keys in the group [Windows] of the user's kwinrc, FocusPolicy=1 ("focus follows mouse") and DelayFocusInterval=0, and asks KWin to read its configuration again. Turning it off, and exiting komorebi, put back what the user had: the value each key had before komorebi changed it, or no value if the key was not there. A daemon that was killed leaves the keys changed until the next run, whose exit puts them back.

The pointer follows the focus too

komorebic mouse-follows-focus is the other direction: the pointer goes to the middle of the window that is given the focus. With both on, the pointer and the focus stay in the same window.