Closed zetako closed 4 months ago
You are right, newly created windows, if they are maximized, will not get handled right away.
In Plasma 6 there are more than one maximized modes (horizontally, vertically and fully). The thing is, for a specific window, those modes are not stored anywhere in API. The only way to know is right before the maximized state is about to changed, using maximizedAboutToChange signal, that also provides the mode that would be applied. When window is just created there is no change in maximized state, the window is created with per-defined geometry and position.
I'm not sure if there is any convenient and reliable way to determine if the window is maximized when it was just created...
I google for a while and got this: https://github.com/Aetf/kwin-maxmize-to-new-desktop/blob/d79d47e87ac96843ff012ba370d2e4b9f0385e96/contents/code/main.js#L190
Their solution is getting the maximize area and compare the geometry between it and the newly created window. This seems to work (although it's not perfect and graceful), and the function workspace.clientArea
is still in the API doc.
Oh. That is actually not that bad. Let me test it.
Please check v0.2.6 from the releases page. It works in my case with newly created maximized windows.
Please check v0.2.6 from the releases page. It works in my case with newly created maximized windows.
Well, it's not working on my PC. I tried restart KDE, but it still not works. I guess we need some debug.
If I uncomment the log
function's print, where will it print?
You can see log via:
journalctl -f QT_CATEGORY=js QT_CATEGORY=kwin_scripting
OK, after a full system restart, the script now works well on my PC. No further debug is needed. KDE may went wrong when I restart it.
Thanks for your help!
Fixed in v0.2.6
First of all, thx for your work! But there's a problem I cannot fixed.
When I use krunner or any other way to launch a new application, it will normally open a maximized window (because I close it when it's maximized). In this situation, this window will not be captured by the script and moved to a new virtual desktop. I had to unmaximized it and maximize again in order to move it to a new virtual desktop.
I check out the code, and I guess in this situation, signal
maximizedAboutToChange
may not be emitted? KDE's API doc is too simple and I can't find any other signal that will be emitted in this situation. Maybe we can try another way, like check if a newly created window is maximized? Unfortunately, I can't find a property to judge this either.