Skip to content

Fix "use open/retract action to focus window" on Wayland

BUG:402634 BUG:381541

This patchset was originally part of MR !81 (closed).

Problem description: Yakuake's feature of "Keep window open when it loses focus" has a sub-feature labeled "Use open/retract action to focus window", without it keeping the window open when it loses focus is a bit annoying as you can't ALT-TAB to the window (Yakuake is always using skip switcher / skip taskbar). The focus action doesn't work on Wayland using KWindowSystem or Qt API because it requires using the activation protocol, which kwin_wayland implements with a very aggressive and strict focus stealing prevention which basically boils down to "if you don't have focus, you can't grant focus" (unlike kwin_x11 focus stealing prevention which is much more granular).

Additional Note: "Keep window open when it loses focus" is also a bit useless on kwin_wayland as there is no API to ask to be always on top, so the open window stays behind other windows and is not visible enough - where the main reason to keep the window open is that the user can refer to the contents of the window on other applications, but that issue may be dealt in the future when bug 460873 is resolved, or using a kwin rule as a workaround.

So without this MR, the Yakuake Wayland behavior is inconsistent with X11 behavior in that pressing the activation key once opens the Yakuake window, then switching to another window and keeping the Yakuake window open, pressing the activation key a second time will focus ("activate") the Yakuake window on X11 but won't work on Wayland.

This MR implements a workaround (one might say a hack) to the kwin_wayland strict activation protocol requirements, by using an activation helper widget that takes advantage that we can create top level windows even when we can't activate existing windows - the activation helper opens as a top level window (but minimally sized and hopefully invisible), gaining focus so it can activate the main window and then properly disposed of itself.

Ideally, we won't need to do these kind of hacks, but until kwin_wayland inconsistent behavior (applications can trivially gain focus by creating new windows but not by raising existing windows - even when activated by a user action) is fixed, this is what we need to do fix KDE bug 402634 (and others).

Edited by Oded Arbel

Merge request reports