Bug 485266

Summary: Feature Request/Question
Product: [Plasma] kwin Reporter: LinG <lingtjien>
Component: generalAssignee: KWin default assignee <kwin-bugs-null>
Status: RESOLVED INTENTIONAL    
Severity: wishlist CC: kde
Priority: NOR    
Version: master   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description LinG 2024-04-09 10:21:51 UTC
VirtualDesktop provides a unique identifier https://invent.kde.org/plasma/kwin/-/blob/master/src/virtualdesktops.h?ref_type=heads#L37

However Output does not? I assumed that the `serialNumber` property was unique but apparently it is not. I'm now assuming the `name` property https://invent.kde.org/plasma/kwin/-/blob/master/src/core/output.h?ref_type=heads#L136 to be unique, is that a correct assumption?

If not then I would suggest to implement a unique identifier to the Output class for KWin scripting purposes in a similar fashion as VirtualDesktop provides. This allows Scripting developers to more easily distinguish between Outputs and find them back later again.
Comment 1 David Edmundson 2024-04-09 10:46:19 UTC
Detecting the same monitor is a surprisingly hard problem! Several monitors can have the same serial, and the same monitor can change EDID.

Rules for name match xdg-output's rules:

>each name is unique among all wl_output globals, but if a wl_output global is destroyed the same name may be reused later. The names will also remain consistent across sessions with the same hardware and software configuration.

Obviously it depends on what your end goal is and how you want to handle setup changes. The name should work most the time.
There's also a concept of primary/second/tertiary that we use in plasma to match which wallpaper goes on each desktop. It's a good thing at making something that's more robust at handling setup changes and migrating content. I'm not sure if that's exposed to scripting, but it certainly could be.

I'll close the ticket, but I'll watch for replies. If there's anything you think is missing feel free to reopen it.
Comment 2 LinG 2024-04-09 11:00:18 UTC
Cool, thank you for the explanation. Then based on your description, name is unique enough for my use case.