SUMMARY According to the documentation[1] and code[2], the KWin::Toplevel::windowClosed signal should be usable from the js script, and have two parameters. However, on the js side, the handler gets nothing. [1]: https://develop.kde.org/docs/extend/plasma/kwin/api/#signals-2 [2]: https://invent.kde.org/plasma/kwin/-/blob/master/src/toplevel.h#L578 STEPS TO REPRODUCE 1. Start the scripting console: `plasma-interactiveconsole --kwin` 2. Enter the following test script and execute it ```js function closedHandler() { console.log('all args in closed handler are ', JSON.stringify(arguments)); } workspace.clientMaximizeSet.connect(function(client) { console.log('client is ', client); client.windowClosed.connect(closedHandler); }); ``` 3. Create a new window, i.e. konsole 4. Maximize the konsole window 5. Directly close the konsole window OBSERVED RESULT The kwin output: ``` js: client is KWin::X11Client(0x555f1610a7f0) js: all args in closed handler are {} ``` The closed handler was correctly installed, but didn't get any argument. EXPECTED RESULT The closed handler gets 2 arguments as documented. SOFTWARE/OS VERSIONS Operating System: Arch Linux KDE Plasma Version: 5.23.5 KDE Frameworks Version: 5.90.0 Qt Version: 5.15.2 Kernel Version: 5.16.1-zen1-1-zen (64-bit) Graphics Platform: X11 Processors: 12 × Intel® Core™ i7-10750H CPU @ 2.60GHz Memory: 31.1 GiB of RAM Graphics Processor: Mesa Intel® UHD Graphics ADDITIONAL INFORMATION First reported here: https://github.com/Aetf/kwin-maxmize-to-new-desktop/issues/14
Most likely, QJSEngine doesn't know about KWin::Deleted so it refuses passing both signal arguments. `Deleted` is an implementation detail that generally should not be exposed to scripts. Not sure what to do about it other than ask script developers not to use the Toplevel argument and instead do something like client.windowClosed.connect(() => console.log(client.caption, "has been closed"));
That's indeed what I'm doing in my script to work around this. Maybe creating a wrapper class to expose X11Clients to scripts is a better way to move forward in the long term.
This bug was reported against an outdated version of KWin. We have made many changes since the. If the issue persists in newer versions can you reopen the bug report updating the version number.