Skip to content
This repository has been archived by the owner on Nov 9, 2022. It is now read-only.

Wayland/Xorg differences #117

Closed
TRPB opened this issue Nov 22, 2018 · 21 comments
Closed

Wayland/Xorg differences #117

TRPB opened this issue Nov 22, 2018 · 21 comments
Labels

Comments

@TRPB
Copy link

TRPB commented Nov 22, 2018

For some reason on Wayland some windows that are tiled under Xorg are not tiled using Wayland. While Thunderbird and Firefox tile correctly, Konsole and Dolphin are not tiled at all. Is there a setting I can change to fix this?

edit: In fact, I don't think any KDE applications are tiled. I just tried Kate and System settings, no tiling.

@faho
Copy link
Collaborator

faho commented Nov 22, 2018

Kwin does not expose wayland clients to scripts. That needs to be changed in kwin upstream.

@faho faho closed this as completed Nov 22, 2018
@faho faho added the upstream label Nov 22, 2018
@TRPB
Copy link
Author

TRPB commented Mar 2, 2019

Did this ever get resolved upstream? I was hoping with 5.15 it might have been fixed.

@faho
Copy link
Collaborator

faho commented Mar 2, 2019

https://bugs.kde.org/show_bug.cgi?id=401309, which is stuck in review (https://phabricator.kde.org/D17097), because apparently there are security concerns.

TL;DR: Don't hold your breath.

@abenz1267
Copy link

I didn't wanna necro, but I just thought about it since I love this script and KDE seems to be pushing Wayland a lot. I looked at the review you linked and it seems to be resolved? Or did I misinterpret something?

Tried Wayland quickly today and f.e. the System Settings window didn't get tiled.

Regards

@TRPB
Copy link
Author

TRPB commented Oct 13, 2019

I'm hoping that the change will appear in Plasma 5.17 which is due to ship on Tuesday.

@laloch
Copy link
Contributor

laloch commented Oct 14, 2019

I'm running Plasma 5.16.90 (5.17 beta) for some time now. I'm sorry to say that scripting only works in nested XWayland session. In native wayland session scripting is completely broken (KWin JavaScript object is not exported to script engine).

@TRPB
Copy link
Author

TRPB commented Oct 14, 2019

The grid-tiling extension https://github.com/lingtjien/Grid-Tiling-Kwin works for detecting and tiling windows. However, the author made some rather strange design decisions (all windows transparent, horrible gaps, no window decorations, odd tiling order, very poor mutli monitor support, can't drag and drop to rearrange, etc). It'd be interesting to see what happens differently in that script and why that works.

@laloch
Copy link
Contributor

laloch commented Oct 14, 2019

That's right. Grid-Tiling-Kwin is much simpler and does not need the interfaces we use.

@TRPB
Copy link
Author

TRPB commented Oct 14, 2019

But surely if that script can detect and position the windows under Wayland, Kwin-Tiling can use the same approach and at least get basic functionality working.

Looking through the code it looks like the KWin object is only used for reading configuration options and registering shortcuts. Grid-Tiling-Kwin manages to register shortcuts, the only thing it doesn't seem to do is have configuration options.

@TRPB
Copy link
Author

TRPB commented Oct 14, 2019

I have a partial fix.

If you change clientAdded to clientActivated in tilielist.js, Wayland windows work after they have been minimized then unminimized. It's buggy and I keep ending up with phantom windows, but it does sort of work.

@TRPB
Copy link
Author

TRPB commented Oct 14, 2019

This patch mostly fixes the issues:

diff --git a/contents/code/tilelist.js b/contents/code/tilelist.js
index a4b43fa..c511a60 100644
--- a/contents/code/tilelist.js
+++ b/contents/code/tilelist.js
@@ -64,7 +64,7 @@ function TileList(timer) {
     // clients are added in order to be able to keep track of the
     // new tiles
     var self = this;
-    workspace.clientAdded.connect(function(client) {
+    workspace.clientActivated.connect(function(client) {
         // TODO: When compositing is on,
         // we need to delay first tiling until the window is shown
         // otherwise we end up with artifacts.
@@ -74,13 +74,8 @@ function TileList(timer) {
         // - "compositingMode"
         // - "compositingInitialized"
         // change when it is disabled/enabled.
-        if (options.useCompositing) {
-            client.windowShown.connect(function(client) {
-                self.addClient(client);
-            });
-        } else {
-            self.addClient(client);
-        }
+
+        self.addClient(client);
         // NOTE: When a new client is added, activeChanged will be called before it even appears
         // in workspace.clientList(), so we need to keep track of the focus change here as well.
         self.trackFocusChanges(client);

@laloch
Copy link
Contributor

laloch commented Oct 14, 2019

clientAdded now works on Wayland in Plasma 5.17. The scriptengine is however severely broken and I'm not going to work it around in our script.

@laloch
Copy link
Contributor

laloch commented Oct 14, 2019

I'll rather try to fix KWin and push the fix for the next release.

@TRPB
Copy link
Author

TRPB commented Oct 14, 2019

the above patch gets Kwin-tiling to a useable state on Wayland 5.16+. The config options are unavailable but the script's basic behaviour works fine and the keyboard shortcuts are registered. I didn't try every keyboard option but for what I need it seems to be working fine.

@laloch
Copy link
Contributor

laloch commented Oct 14, 2019

OK, what I wrote above was complete BS. The global objects are only missing if the script is reloaded. The following patch makes kwin-tiling work on Plasma>=5.16.90. We are, however, really bad in detecting clients to be ignored on Wayland, so we tile almost everything.

  diff --git a/contents/code/tilelist.js b/contents/code/tilelist.js
  index a4b43fa..0835bbd 100644
  --- a/contents/code/tilelist.js
  +++ b/contents/code/tilelist.js
  @@ -65,22 +65,7 @@ function TileList(timer) {
       // new tiles
       var self = this;
       workspace.clientAdded.connect(function(client) {
  -        // TODO: When compositing is on,
  -        // we need to delay first tiling until the window is shown
  -        // otherwise we end up with artifacts.
  -        // However, we can only determine what the option is set to on start
  -        // neither of (options.):
  -        // - "useCompositing"
  -        // - "compositingMode"
  -        // - "compositingInitialized"
  -        // change when it is disabled/enabled.
  -        if (options.useCompositing) {
  -            client.windowShown.connect(function(client) {
  -                self.addClient(client);
  -            });
  -        } else {
  -            self.addClient(client);
  -        }
  +        self.addClient(client);
           // NOTE: When a new client is added, activeChanged will be called before it even appears
           // in workspace.clientList(), so we need to keep track of the focus change here as well.
           self.trackFocusChanges(client);

@TRPB
Copy link
Author

TRPB commented Nov 1, 2019

I've found I get quite a few phantom windows and issues with clientAdded. clientActivated seems to give a much less buggy experience, I'm not sure why as I'm not sure what the differences are supposed to be.

In addition, here's a few classes which need adding to ignored.js's _blacklist array:

  • org.kde.krunner - on Wayland krunner has this class
  • org.kde.kscreenlocker_greet - lockscreen on wayland
  • pinentry-gtk-2 - Password prompt. Although this could potentially be tiled, for some reason it has a fixed height so doesn't tile correctly. Keeping it as a floating window makes sense.

I also can't fullscreen windows in MPV as of 0.30, which is strange because I'm fairly sure it worked before. vlc works fine.

With these changes, Wayland is actually a better experience with this script than on X because X has the problem of frozen windows (try maximising google chrome, or opening a VM in Virtualbox) where you have to move the window to a different tile before it's drawn. This rather annoying bug doesn't happen on Wayland.

@TRPB
Copy link
Author

TRPB commented Jan 4, 2020

There's a weird issue where some applications keep getting resized. Try opening Lutris on a Wayland session. It starts off the correct size and keeps getting made full size then 1px less. It's like it animates getting smaller. Really strange.

@WillPower3309
Copy link

@TRPB any updates on this? I'm not super experienced with low level linux programming but I'd love to lend a helping hand in any way that I can

@TRPB
Copy link
Author

TRPB commented Jun 26, 2020

take a look at my fork here: https://github.com/TRPB/kwin-tiling

There are a few tweaks but nothing major, mostly just adding wayland windows to the ignore list.

@WillPower3309
Copy link

WillPower3309 commented Jun 26, 2020

Ah, okay thanks! Despite https://phabricator.kde.org/R108:4bbef8d128ce339b4fa08816780c42c40bdd909e, it looks like wayland clients still aren't tiled, tried with your fork and with the main project

@TRPB
Copy link
Author

TRPB commented Jun 26, 2020

Should work with my fork, this commit fixes it: TRPB@1fd493b

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

5 participants