The screen property of a client is now readonly? I'm pretty sure it used to be read and write, thus allowing me to change the screen on which a client resides but now I can't? How do I change the screen on which a client resides through the scripting API now? Additional question regarding the documentation (https://techbase.kde.org/Development/Tutorials/KWin/Scripting/API_4.9): the desktop property has the description to prefer the use of `isOnDesktop()` method over accessing this variable directly, however this method is not documented in the kwin scripting documentation. Latest packages on ArchLinux
Here is a MWE var clients = workspace.clientList(); for (var i = 0; i < clients.length; i++) { if (clients[i] === null) {continue;} if (clients[i].resourceName.toString() === 'konsole') // or any other client that you have open { var pre = clients[i].screen; clients[i].screen = 1; var post = clients[i].screen; print(pre, post, workspace.numScreens); // output: 0 0 2, expected output 0 1 2 } }
There seems to be a sendToScreen method ( https://github.com/KDE/kwin/blob/fbfd1ac705212892f417aa5cc9df5fcd9ce9cb52/abstract_client.h#L453 ) however it's not accessible to scripts. using `workspace.activeScreen = 1` doesn't work either, since it's readonly too and it doesn't seem possible to activate a client either. Finally, https://api.kde.org doesn't seem to contain any scripting docs for KWin 5+
(In reply to LinG from comment #0) > The screen property of a client is now readonly? I'm pretty sure it used to > be read and write, thus allowing me to change the screen on which a client > resides but now I can't? How do I change the screen on which a client > resides through the scripting API now? As far as I know, it has always been read-only. (In reply to Lo from comment #2) > There seems to be a sendToScreen method ( > https://github.com/KDE/kwin/blob/fbfd1ac705212892f417aa5cc9df5fcd9ce9cb52/ > abstract_client.h#L453 ) however it's not accessible to scripts. No, what you need is Workspace::sendClientToScreen(), which is not exposed to scripting API unfortunately.
So how does one move a client from a screen to another?
(In reply to Lo from comment #4) > So how does one move a client from a screen to another? See https://phabricator.kde.org/D26988. You would do `workspace.sendClientToScreen(client, screen);` or something.
It would be great if you could test my patch. ;-)
(In reply to Vlad Zahorodnii from comment #3) > (In reply to LinG from comment #0) > > The screen property of a client is now readonly? I'm pretty sure it used to > > be read and write, thus allowing me to change the screen on which a client > > resides but now I can't? How do I change the screen on which a client > > resides through the scripting API now? > As far as I know, it has always been read-only. I've always used this screen property of the client the same way as I have been using the desktop property and am still using. So it's interesting to me that you say that this property has never been writable. Question 1: What would be the reason to not make the screen property writable like the desktop property on a client? I'm fine with using your proposed method as well, but isn't the former more in line with the rest of the API?
(In reply to LinG from comment #7) > I've always used this screen property of the client the same way as I have > been using the desktop property and am still using. So it's interesting to > me that you say that this property has never been writable. You shouldn't actually use that property, it's deprecated. > Question 1: What would be the reason to not make the screen property > writable like the desktop property on a client? I'm fine with using your > proposed method as well, but isn't the former more in line with the rest of > the API? It matches what KWin is doing whenever it needs to send a client to another screen.
Git commit 76297196e898c838ed89d21f44e8a8560cd7391f by Vlad Zahorodnii. Committed on 29/01/2020 at 15:14. Pushed by vladz into branch 'Plasma/5.18'. [scripting] Expose Workspace::sendClientToDesktop() Summary: FIXED-IN: 5.18.0 Test Plan: Only compile-time check. Reviewers: #kwin, davidedmundson Reviewed By: #kwin, davidedmundson Subscribers: kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D26988 M +8 -0 scripting/workspace_wrapper.cpp M +5 -0 scripting/workspace_wrapper.h https://commits.kde.org/kwin/76297196e898c838ed89d21f44e8a8560cd7391f
(In reply to Vlad Zahorodnii from comment #8) > (In reply to LinG from comment #7) > > I've always used this screen property of the client the same way as I have > > been using the desktop property and am still using. So it's interesting to > > me that you say that this property has never been writable. > You shouldn't actually use that property, it's deprecated. Alright, where can I find the most recent documentation about the methods and properties that I should use? (What method should I use to send clients to different desktops and is there also something available to send clients to different activities?) > > > Question 1: What would be the reason to not make the screen property > > writable like the desktop property on a client? I'm fine with using your > > proposed method as well, but isn't the former more in line with the rest of > > the API? > It matches what KWin is doing whenever it needs to send a client to another > screen. That's fair, keeping the API as close to the internals seems like the best way to me as well.
(In reply to LinG from comment #10) > Alright, where can I find the most recent documentation about the methods > and properties that I should use? Unfortunately, only source code. API dox is not generated for KWin since KDE Plasma 5. > (What method should I use to send clients to different desktops and is there > also something available to send clients to different activities?) So, with the new virtual desktop model, a client can enter and leave more than just one desktop. On X11, a client can be either only on one or on all desktops, though. The relevant AbstractClient property I'm talking about is x11DesktopsIds. It seems like scripts can modify only legacy `desktop` property. :/
(In reply to Vlad Zahorodnii from comment #11) > (In reply to LinG from comment #10) > > Alright, where can I find the most recent documentation about the methods > > and properties that I should use? > Unfortunately, only source code. API dox is not generated for KWin since KDE > Plasma 5. Alright, could you point out to me where I can find the code that is related to the KWin::client and KWin::toplevel (assuming client still inherits from toplevel as in 4.9). The scripting/workspace_wrapper.h is very readable so I'm fine with working with that but I didn't find a client_wrapper.h or something in this directory