Bug 481577

Summary: ship a window rule to keep picture-in-picture windows above
Product: [Plasma] kwin Reporter: Mariusz Libera <mariusz.libera>
Component: wayland-genericAssignee: KWin default assignee <kwin-bugs-null>
Status: RESOLVED INTENTIONAL    
Severity: wishlist CC: nate
Priority: NOR Keywords: qt6
Version First Reported In: 5.93.0   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description Mariusz Libera 2024-02-20 11:37:08 UTC
I understand that wayland protocol seems to be the long term solution, but how about a band aid in the meantime - a simple window rule enabled by default that forces picture-in-picture windows to be kept above. It seems to work fine.

Operating System: Arch Linux 
KDE Plasma Version: 5.93.0
KDE Frameworks Version: 5.249.0
Qt Version: 6.7.0
Kernel Version: 6.7.5-arch1-1 (64-bit)
Graphics Platform: Wayland
Processors: 16 × AMD Ryzen 7 6800H with Radeon Graphics
Memory: 14.8 GiB of RAM
Graphics Processor: AMD Radeon Graphics
Manufacturer: LENOVO
Product Name: 82RE
System Version: Legion 5 15ARH7
Comment 1 Nate Graham 2024-02-21 18:07:01 UTC
I would be super in favor of this if it works properly. Does it work fine with new PiP windows, not just the one you created it for? And are there rules that work for all PiP windows for both Firefox and Chrome/Chromium? Can you test those?
Comment 2 Mariusz Libera 2024-03-08 14:06:48 UTC
(In reply to Nate Graham from comment #1)
> I would be super in favor of this if it works properly. Does it work fine
> with new PiP windows, not just the one you created it for? And are there
> rules that work for all PiP windows for both Firefox and Chrome/Chromium?
> Can you test those?

This rule works fine for me, no issues whatsoever:

Description=Picture in picture for firefox
above=true
aboverule=3
title=Picture-in-Picture
titlematch=1
types=1
wmclass=firefox
wmclassmatch=1

Chrome seems to work fine out of the box, if it's run in xwayland, native wayland version needs a rule:

Description=Picture in picture for chrome
above=true
aboverule=3
title=Picture in picture
titlematch=1
types=1
wmclass=chrome
wmclassmatch=1

I would imagine that a regex would be needed to catch all chromium based browsers in 'wmclass'.
By the way, it would be nice if there was a checkbox to enable/disable window rules instead of having to delete and recreate them to test.
Comment 3 Vlad Zahorodnii 2024-03-08 15:29:42 UTC
> above=true
> aboverule=3

in plasma 6, I recommend to create a "layer" window rule instead to force pip windows to be placed in the overlay layer. With that, pip windows will be visible even if there's a fullscreen window.
Comment 4 Mariusz Libera 2024-03-08 18:47:35 UTC
(In reply to Vlad Zahorodnii from comment #3)
> > above=true
> > aboverule=3
> 
> in plasma 6, I recommend to create a "layer" window rule instead to force
> pip windows to be placed in the overlay layer. With that, pip windows will
> be visible even if there's a fullscreen window.

I wasn't aware of that, but it works even better.

Description=Picture in picture for firefox
layer=overlay
layerrule=2
title=Picture-in-Picture
titlematch=1
types=1
wmclass=firefox
wmclassmatch=1
Comment 5 Nate Graham 2024-03-08 23:17:37 UTC
An exact title match for "Picture-in-Picture" might work in English, but does this still work if the system is in another language?
Comment 6 Mariusz Libera 2024-03-09 05:42:56 UTC
(In reply to Nate Graham from comment #5)
> An exact title match for "Picture-in-Picture" might work in English, but
> does this still work if the system is in another language?

Good point, just checked, Firefox does indeed translate that. Wouldn't expect it. Well, this is pretty hopeless then.
Comment 7 Nate Graham 2024-03-10 03:13:58 UTC
Indeed. It's a shame, I'd like to ship a workaround too, as this is a real issue that annoys people. But as you can see, sometimes life doesn't cooperate!