Bug 380497

Summary: Yakuake KeepOpen=false doesn't work with Wayland
Product: [Applications] yakuake Reporter: leo_rockway <leo>
Component: generalAssignee: Eike Hein <hein>
Status: RESOLVED FIXED    
Severity: normal CC: avinashrocks1990, bednarczyk.pawel, bugseforuns, claudius.ellsel, dstubbs28, elvis.angelaccio, firlaevhans.fiete, harry, hsantanna, nate, nicolas.fella, oded, rainer, ricardo.calimanis, santiago.tabares, zeertzjq, zorael
Priority: NOR Keywords: wayland
Version: 3.0.5   
Target Milestone: ---   
Platform: Other   
OS: Linux   
See Also: https://bugs.kde.org/show_bug.cgi?id=428383
Latest Commit: Version Fixed In: 21.12.0
Sentry Crash Report:

Description leo_rockway 2017-06-03 09:43:08 UTC
The option KeepOpen=false makes the window hide and show up once and again in Wayland.
Comment 1 Santiago Tabares 2018-02-19 13:13:17 UTC
Confirm.
My guess is that in x11 it checks if it loses focus to hide, but in wayland that's not supported. It would need cooperation with kwin to fix.
Comment 2 leo_rockway 2018-02-19 16:56:01 UTC
I'm using Wayland permanently now, since the latest release of Plasma. I have KeepOpen=false in my config and while it doesn't do what it should, at least it doesn't render Yakuake unusable.
It used to be that Yakuake would hide and show up nonstop, like I mentioned when I opened this bug report. Now it just loses focus (but doesn't actually hide).
It would definitely be nice if this option did what it says it does, but maybe the importance now dropped to minor instead of normal?
Comment 3 Rainer Finke 2020-03-15 13:20:05 UTC
Yakuake 3.0.5 still stays open when focus is lost.
Comment 4 Claudius Ellsel 2020-06-18 15:00:39 UTC
I can confirm this with version 20.07.70

Changing focus works, but the Yakuake dropdown only gets overlayed and does not retract. Minimizing the overlaying Window shows the Yakuake dropdown again.

This also leads to the a bit weird behaviour that one has to press F12 twice to bring it back (once for retracting in the background and once for opening again).
Comment 5 Firlaev-Hans 2020-12-20 13:42:46 UTC
I also noticed this problem, Yakuake doesn't retract when it loses focus on Wayland, but it works fine on X11.
Comment 6 Pawel 2021-01-22 11:55:41 UTC
confirmed on Wayland, plasma 21 Beta, Yakuake
Version 20.12.1

Operating System: Arch Linux
KDE Plasma Version: 5.20.90
KDE Frameworks Version: 5.78.0
Qt Version: 5.15.2
Kernel Version: 5.9.0-rc5-1-amd-staging-drm-next-git-gd6fd19b700d4
OS Type: 64-bit
Processors: 16 × AMD Ryzen 7 3700X 8-Core Processor
Memory: 31.3 GiB of RAM
Graphics Processor: AMD Radeon RX 5700 XT
Comment 7 miku84 2021-03-16 17:48:02 UTC
Hi,
I wanted to report it, but find this.
So yakuake 20.12.03 still has it on wayland
Comment 8 Henrique Sant'Anna 2021-05-17 19:04:43 UTC
May be a duplicate with Bug 428383
Comment 9 zeertzjq 2021-05-19 13:24:03 UTC
Confirmed on Plasma 5.21.5 Wayland, Yakuake 21.04.1

Operating System: Arch Linux
KDE Plasma Version: 5.21.5
KDE Frameworks Version: 5.82.0
Qt Version: 5.15.2
Kernel Version: 5.12.4-arch1-2
OS Type: 64-bit
Graphics Platform: Wayland
Processors: 8 × Intel® Core™ i7-10510U CPU @ 1.80GHz
Memory: 15.3 GiB of RAM
Graphics Processor: Mesa Intel® UHD Graphics
Comment 10 Patrick Silva 2021-07-08 01:01:04 UTC
*** Bug 439572 has been marked as a duplicate of this bug. ***
Comment 11 Firlaev-Hans 2021-07-23 12:23:33 UTC
I admit that I have very little understanding about how all this works but after digging in the source code a bit it appears that the problem may not be in Yakuake itself, but in KDE Frameworks, specifically in KWindowSystem.

To detect a focus loss, Yakuake connects to the activeWindowChanged signal in KWindowSystem, which exists in platforms/xcb but not platforms/wayland
Comment 12 Oded Arbel 2021-09-18 14:36:27 UTC
*** Bug 428383 has been marked as a duplicate of this bug. ***
Comment 13 Oded Arbel 2021-09-18 15:19:16 UTC
(In reply to Firlaev-Hans from comment #11)
> I admit that I have very little understanding about how all this works but
> after digging in the source code a bit it appears that the problem may not
> be in Yakuake itself, but in KDE Frameworks, specifically in KWindowSystem.
> 
> To detect a focus loss, Yakuake connects to the activeWindowChanged signal
> in KWindowSystem, which exists in platforms/xcb but not platforms/wayland

Looking at https://invent.kde.org/frameworks/kwindowsystem/-/blob/master/src/platforms/wayland/kwindowsystem.cpp the implementation is pretty bare - it doesn't emit any of the signals documented in https://api.kde.org/frameworks/kwindowsystem/html/classKWindowSystem.html that other platforms (even Windows) do emit.

It seems likely that all of Yakuake's Wayland issues (this, the bucket list in Bug 433606, as well as Bug 433171, Bug 402634 and Bug 413636, to name a few) are caused by the non-existence of KWindowSystem Wayland's implementation.
Comment 14 Firlaev-Hans 2021-09-18 15:55:39 UTC
I opened a bug report for KWindowSystem: Bug 442662
Comment 15 Firlaev-Hans 2021-10-01 13:21:54 UTC
(In reply to Firlaev-Hans from comment #14)
> I opened a bug report for KWindowSystem: Bug 442662

So basically, they're not going to implement those signals in KWindowSystem on Wayland, and Yakuake will have to find another way to get this functionality on Wayland.
Comment 16 Nicolas Fella 2021-11-07 14:32:12 UTC
Git commit 7a2dbad3628198ddeaea10c044a06cdc8ab2a930 by Nicolas Fella, on behalf of Firlaev-Hans Fiete.
Committed on 07/11/2021 at 14:32.
Pushed by nicolasfella into branch 'master'.

Use QGuiApplication::focusWindowChanged instead of KWindowSystem::activeWindowChanged

It works on Wayland too and therefore fixes closing Yakuake on focus loss on Wayland with KeepOpen=false

M  +4    -10   app/mainwindow.cpp

https://invent.kde.org/utilities/yakuake/commit/7a2dbad3628198ddeaea10c044a06cdc8ab2a930
Comment 17 Pawel 2021-11-07 15:08:16 UTC
I applied this patch and recompiled yakuake to test.

I can happily confirm the patch fixes the issue - the application now properly retracts when it loses focus on Wayland if KeepOpen is set to false. 

I have no tested on X11.

Many thanks for the fix!
Comment 18 Oded Arbel 2021-11-15 10:47:05 UTC
*** Bug 386358 has been marked as a duplicate of this bug. ***
Comment 19 Patrick Silva 2021-11-28 13:34:46 UTC
*** Bug 446190 has been marked as a duplicate of this bug. ***
Comment 20 dstubbs28 2021-12-28 22:39:22 UTC
Can we get the fix in this thread implemented in the official release?
Comment 21 Nate Graham 2021-12-29 03:29:19 UTC
Nicolas, do you think that fix is safely backportable to the stable branch?
Comment 22 Nate Graham 2021-12-29 03:32:04 UTC
Oh wait, it's already supposed to be in the current release...
Comment 23 Nate Graham 2021-12-29 03:41:06 UTC
OK, KeepOpen=false seems to work for me, but KeepOpen=true doesn't. Is that what you're seeing too? If so that's a separate issue.
Comment 24 Firlaev-Hans 2021-12-29 10:13:19 UTC
(In reply to Nate Graham from comment #23)
> OK, KeepOpen=false seems to work for me, but KeepOpen=true doesn't. Is that
> what you're seeing too? If so that's a separate issue.

This is indeed just a fix for KeepOpen=false. But KeepOpen=true already works, it always has. All it's supposed to do AFAIK is to not retract Yakuake when it looses focus, so it just goes behind the currently focused window (like any other normal window would). And that's what it does, on both X11 and Wayland.

What still doesn't work on Wayland is "KeepAbove=true", which is a separate option that, when combined with KeepOpen=true, makes Yakuake always stay in the foreground / as the top most window even when it's not focused. This can be worked around by the user with a KWin rule to keep Yakuake in the foreground. I'm not sure if that issue can be fixed without direct cooperation with KWin.