Ubiquitine / MACsimize6

KWin script that moves maximizred and full-screened windows to a separate virtual desktop
https://store.kde.org/p/2141482/
GNU General Public License v3.0
8 stars 3 forks source link

Windows that created as maximized cannot be capture #2

Closed zetako closed 4 months ago

zetako commented 4 months ago

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.

Ubiquitine commented 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...

zetako commented 4 months ago

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.

Ubiquitine commented 4 months ago

Oh. That is actually not that bad. Let me test it.

Ubiquitine commented 4 months ago

Please check v0.2.6 from the releases page. It works in my case with newly created maximized windows.

zetako commented 4 months ago

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?

Ubiquitine commented 4 months ago

You can see log via: journalctl -f QT_CATEGORY=js QT_CATEGORY=kwin_scripting

zetako commented 4 months ago

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!

Ubiquitine commented 4 months ago

Fixed in v0.2.6