lingtjien / Grid-Tiling-Kwin

A kwin script that automatically tiles windows
GNU General Public License v3.0
902 stars 43 forks source link

Weird Behaviour on Wayland (Plasma 5) #140

Closed diogogmatos closed 7 months ago

diogogmatos commented 7 months ago

Hi!

First of all, I want to thank you for this amazing project I can't imagine my rice without it.

[!Note] I'm still using Plasma 5, so disregard Plasma 6 update problems.

I recently changed laptops and went from Plasma on X11 to Plasma on Wayland, because it has much better support for High DPI screens and scaling. I installed your script and it works as expected, however I noticed some weird behaviors that did not happen on X11.

The script seems to try to tile every single window on the system, no matter what it is. For example, pop-ups like when adding a WiFi network in settings or even the Picture-In-Picture window in Firefox. I have managed to resolve some of them by adding the app to the blacklist, however I can't do that for things like PIP in Firefox since it shares the same application name.

I searched through the issues and found something similar on #122, you mention you fixed the problem in the dev branch and that you made it "user configurable". Since the issue is quite old, I assume those changes are already on master, however I can't find any configuration regarding window types on the script settings and it doesn't seem to be only activating for normalWindow.

Could you look into it when you have some spare time?

Thank you!

lingtjien commented 7 months ago

The problem is that I don't have a system with Plasma 5 any more after I've upgraded to Plasma 6....

But I can give you some pointers of where you can look to perhaps solve this, but I believe that the underlying issue is that many applications in wayland do not properly set their window type and just mark everything as a normalWindow

What you could try is to use theWindow Operations Menu (there is a global shortcut for it) and when you open a specific window you open this menu and go to more actions > configure special window settings and then in the window types field you could then unmark them from normalWindow.

The code only tiles windows that are marked as normalWindow so that may work.

diogogmatos commented 7 months ago

That did not work :/ I added the correct property to "Force" the window property to be anything but a normalWindow. However for some reason even after rebooting, restarting firefox and re-applying the script it still tiles it. My guess is that the Window Rule only changes the window type once it opens, when the script already has identified it as a normalWindow.

Sad but it's not that big of a deal. Thanks for the help and quick response!

lingtjien commented 7 months ago

There is a delay option in the script configuration that you can use to delay tiling the windows. Defaults to 10ms, you can try to increase it, but beware that if you make it too high your overall experience may feel a bit laggy. But maybe 100ms will work?

diogogmatos commented 7 months ago

I tried that and it still didn't work. I made more research and it appears that the problem is that the actual Window Rules do not work correctly in Wayland, in the sense that only a few properties can be modified. I'm guessing the Window Type isn't one of them, as I'm completely sure the Window Rule was correctly configured.

lingtjien commented 7 months ago

Ah okay, if the window has other window types besides normalWindow you could try to modify the script to also ignore when one of those are present. For example if the window has the window type dialog then you could expand line 10 in https://github.com/lingtjien/Grid-Tiling-Kwin/blob/%3C6.0/contents/code/Manager.qml to additionally also check against that window type by adding client.dialog to the current list of checks like so

return client.transient || client.dialog || !client.normalWindow || (config.blacklist && config.blacklist.test(client.resourceName));
diogogmatos commented 7 months ago

Does the client variable have any information about the window title, description or other window properties? It seems the window type of any window (according to Window Management > Window Rules > Detect Window Properties) is marked as "All Types", as in all window types are selected. If there was a way for me to filter out windows based on other window parameters that would be great!

lingtjien commented 7 months ago

you can use client.resourceName and client.resourceClass but I think those only contain the application name and those are already filtered by the blacklist and whitelist config parameters. I have not been able to find anything else in the KWin API (have also asked the developers) but in X11 we seemed to have more parameters to distinguish.

I did make a hack once that checked on pid so if an application started with a parent pid that was already tiled to then ignore it. The problem with that was that some applications use a managing process and then when you start multiple windows they all have the same parent pid. So only the first chrome window would get tiled and the rest after that would be ignored. So I got rid of that hack again.

lingtjien commented 7 months ago

Did you manage to find a solution to your issue?

diogogmatos commented 7 months ago

Hey, I haven't found the time to explore this further. Maybe some day, but thank you so much for your help! Does this problem also occur on Plasma 6? If not, I will eventually have to update so problem fixed.

lingtjien commented 7 months ago

A lot has changed in Plasma 6 so let's hope so :smile: If you do still encounter the issue or have more questions feel free to open a new ticket

diogogmatos commented 4 months ago

Hey there! Updated to Plasma 6 and this issue persists.