From 9a2a1c043522d01fc575fada45d6dedfc0273b74 Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Thu, 19 Aug 2021 18:17:10 +0300 Subject: [PATCH] scripting: Add desktops property to AbstractClient With the new virtual desktops model, a window can be on several virtual desktops. Currently, scripts have no any way to get the list of desktops the window is on. This change addresses that. --- src/abstract_client.h | 9 +++++++++ src/scripting/scripting.cpp | 2 ++ 2 files changed, 11 insertions(+) diff --git a/src/abstract_client.h b/src/abstract_client.h index 523308e9c3..2c6377499f 100644 --- a/src/abstract_client.h +++ b/src/abstract_client.h @@ -75,9 +75,16 @@ class KWIN_EXPORT AbstractClient : public Toplevel /** * The desktop this Client is on. If the Client is on all desktops the property has value -1. * This is a legacy property, use x11DesktopIds instead + * + * @deprecated Use the desktops property instead. */ Q_PROPERTY(int desktop READ desktop WRITE setDesktop NOTIFY desktopChanged) + /** + * The virtual desktops this client is on. If it's on all desktops, the list is empty. + */ + Q_PROPERTY(QVector desktops READ desktops WRITE setDesktops NOTIFY desktopChanged) + /** * Whether the Client is on all desktops. That is desktop is -1. */ @@ -90,6 +97,8 @@ class KWIN_EXPORT AbstractClient : public Toplevel /** * The x11 ids for all desktops this client is in. On X11 this list will always have a length of 1 + * + * @deprecated prefer using apis that use VirtualDesktop objects */ Q_PROPERTY(QVector x11DesktopIds READ x11DesktopIds NOTIFY x11DesktopIdsChanged) diff --git a/src/scripting/scripting.cpp b/src/scripting/scripting.cpp index e6f15d0655..b901db7455 100644 --- a/src/scripting/scripting.cpp +++ b/src/scripting/scripting.cpp @@ -24,6 +24,7 @@ #include "input.h" #include "options.h" #include "screenedge.h" +#include "virtualdesktops.h" #include "workspace.h" #include "x11client.h" // KDE @@ -656,6 +657,7 @@ void KWin::Scripting::init() }); qmlRegisterType(); + qmlRegisterType(); qmlRegisterType(); qmlRegisterType();