Bug 486297 - Kwin screen ID is not stable when monitors unplugged
Summary: Kwin screen ID is not stable when monitors unplugged
Status: CONFIRMED
Alias: None
Product: kwin
Classification: Plasma
Component: rules (show other bugs)
Version: 6.0.4
Platform: Fedora RPMs Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-04-29 13:56 UTC by mitchell
Modified: 2025-01-24 12:23 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description mitchell 2024-04-29 13:56:36 UTC
SUMMARY

The core issue is that there is no way to write a kwin rule to move a window to a specific monitor in a stable way. The Kwin screen IDs change whenever a monitor is unplugged, even briefly or when PC is idle.

More background:

I have two main Firefox windows, I want one to appear on my second monitor. With wayland, Firefox cannot do that itself, so I write a kwin window rule to set the Firefox. 

This works fine - however, my primary monitor appears to be unplugged whenever it turns off for power saving (some kind of displayport issue, I think), so my secondary monitor becomes kwin screen 0, and this causes my window rule to force the Firefox window to my primary monitor, which I don't want.

STEPS TO REPRODUCE
1. Have a PC with two monitors.
2. Create a kwin window rule, forcing any window to be on screen ID 1.
3. Window moves to the secondary monitor. 
4. Unplug primary monitor, then replug.

OBSERVED RESULT

Window is now forced onto primary monitor.

EXPECTED RESULT

Window should remain on secondary monitor.


SOFTWARE/OS VERSIONS
Linux:  6.8.7, Fedora Silverblue
(available in About System)
KDE Plasma Version: 6.0.4
KDE Frameworks Version: 6.1.0
Qt Version: 6.7.0

ADDITIONAL INFORMATION

Ideally, there should be a way to use GUIDs or similar to refer to monitors. Does this exist on a hardware level? Alternatively, is there any way to use a similar mechanism to how windows will remember their monitor automatically when said monitor is unplugged, and apply that mechanism to the screen ID in Kwin window rules?
Comment 1 krims0n32 2025-01-16 08:54:14 UTC
Facing the same issue, creating a window rule that forces an application on a specific screen is basicly impossible right now on Wayland.
Comment 2 Zamundaaa 2025-01-24 12:23:46 UTC
> Ideally, there should be a way to use GUIDs or similar to refer to monitors. Does this exist on a hardware level?
Displays technically have a serial number, but unfortunately display manufacturers are very, very far from reliable in implementing it. Some displays have an empty string in it, some displays have a serial string but no serial number, some the reverse, some just have the same serial for all displays of the same model...

We can however make up a unique ID that's stored in the display configuration, which would be as reliable as we can make it.