wayland – Alt-Tab Focus Lost on Wayland with Secondary-Click Window Focus

22.04focusmouse pointerwayland

I've been a fan of the Window Focus mode called "Secondary-Click" (previously "sloppy focus") – available via Gnome Tweaks under the "Windows" tab – which used to work as follows:

  1. Take two windows, A and B.
  2. A has focus and mouse pointer over it.
  3. Alt-Tab to switch focus to B
  4. Focus is now on B and remains on B despite mouse still being over A
  5. Moving the mouse over a different window causes focus to shift.

What's now happening is that in step 4, the focus switches to B, but then a fraction of a second later, it switches back to A (where the mouse is), even without the mouse being moved.

The reason I like the old behaviour is that:

  • I can navigate windows with the keyboard only. e.g. "start a new email" might mean Alt-tab to Thunderbird and hit Ctrl+N.
  • I can focus a non-foreground window with the mouse. This is super useful, especially when doing multiple copy-and-paste type operations.

I believe it might be Wayland that made the difference. (Unfortunately I can no longer use Xorg/X11 because of bugs in the Intel software that cause system hangs.)

I'm using (have always used) Gnome Shell, not Unity.

It might be the case that Wayland interprets what it's supposed to do differently, and that is final, but posting here in case anyone else misses the old behaviour and has found a workaround?

To save people asking:

  • yes this is similar to a question about 12.04 but that is (a) about 12.04 and (b) about a bug in unity and (c) the workaround mentioned therein does not apply/work.

  • this is similar to a question from 2020 but that seemed to be a faulty touchpad issue.

  • this is not the same as my question from 2019 where Gnome settings removed access to the sloppy focus mode, which has since been exposed by Gnome Tweaks.

Best Answer

You can fix this in a hackish way by installing the following gnome shell extension which moves the mouse to the centre of the selected window after alt-tab.

https://extensions.gnome.org/extension/4673/alt-tab-move-mouse/

Credit to author of the amazing AATWS extension who pointed this out to me.