Bug 463491

Summary: Wayland kwin script api gives 0 to client.windowId when 'workspace.clientAdded.connect' event is triggered.
Product: [Plasma] kwin Reporter: shockw424
Component: scriptingAssignee: KWin default assignee <kwin-bugs-null>
Status: RESOLVED NOT A BUG    
Severity: normal CC: kde, kwin-bugs-null, nicolas.fella, shockw424
Priority: NOR    
Version First Reported In: 5.26.4   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description shockw424 2022-12-26 15:12:57 UTC
SUMMARY
wayland kwin script api gives 0 to client.windowId when 'workspace.clientAdded.connect' event is triggered.
The windowId is however given to the client.windowId variable when the application is run using Xwayland.

STEPS TO REPRODUCE
1. Alt+F2, then type 'plasma-interactiveconsole --kwin'
2. Paste this script into the code field.
```
workspace.clientAdded.connect((client) => {console.log(client.windowId);});
```
3. start a terminal emulator and type 'journalctl -g "js:" -f'
4. Execute the code in plasma-interactiveconsole.
5. Open a non Xwayland application, any will suffice. 

OBSERVED RESULT
It should give 0 for each wayland application opened.

EXPECTED RESULT
The expected result should be a windowId similar to this 10485803. 
If you open an Xwayland Application you should see the expected result

SYSTEM INFORMATION
Operating System: Arch Linux
KDE Plasma Version: 5.26.4
KDE Frameworks Version: 5.101.0
Qt Version: 5.15.7
Kernel Version: 6.1.1-arch1-1 (64-bit)
Graphics Platform: Wayland
Processors: 24 × AMD Ryzen 9 3900X 12-Core Processor
Memory: 31.3 GiB of RAM
Graphics Processor: NVIDIA GeForce GTX 1080/PCIe/SSE2
Manufacturer: Gigabyte Technology Co., Ltd.
Product Name: X570 AORUS ELITE
System Version: -CF
Comment 1 David Edmundson 2022-12-27 10:08:08 UTC
windowId only exist for X11 windows. 

src/x11window.h:    Q_PROPERTY(qulonglong windowId READ window CONSTANT)

as it maps to the underlying X11 window ID type.

For something universal use:

src/window.h:    Q_PROPERTY(QUuid internalId READ internalId CONSTANT)