diff --git a/src/scripting/workspace_wrapper.cpp b/src/scripting/workspace_wrapper.cpp index ed596af531..7cb2eb8cd1 100644 --- a/src/scripting/workspace_wrapper.cpp +++ b/src/scripting/workspace_wrapper.cpp @@ -35,6 +35,7 @@ WorkspaceWrapper::WorkspaceWrapper(QObject* parent) : QObject(parent) connect(ws, &Workspace::clientActivated, this, &WorkspaceWrapper::clientActivated); connect(vds, &VirtualDesktopManager::countChanged, this, &WorkspaceWrapper::numberDesktopsChanged); connect(vds, &VirtualDesktopManager::layoutChanged, this, &WorkspaceWrapper::desktopLayoutChanged); + connect(vds, &VirtualDesktopManager::currentChanged, this, &WorkspaceWrapper::currentVirtualDesktopChanged); connect(ws, &Workspace::clientDemandsAttentionChanged, this, &WorkspaceWrapper::clientDemandsAttentionChanged); #ifdef KWIN_BUILD_ACTIVITIES if (KWin::Activities *activities = KWin::Activities::self()) { @@ -67,6 +68,11 @@ int WorkspaceWrapper::currentDesktop() const return VirtualDesktopManager::self()->current(); } +VirtualDesktop *WorkspaceWrapper::currentVirtualDesktop() const +{ + return VirtualDesktopManager::self()->currentDesktop(); +} + int WorkspaceWrapper::numberOfDesktops() const { return VirtualDesktopManager::self()->count(); @@ -77,6 +83,11 @@ void WorkspaceWrapper::setCurrentDesktop(int desktop) VirtualDesktopManager::self()->setCurrent(desktop); } +void WorkspaceWrapper::setCurrentVirtualDesktop(VirtualDesktop *desktop) +{ + VirtualDesktopManager::self()->setCurrent(desktop); +} + void WorkspaceWrapper::setNumberOfDesktops(int count) { VirtualDesktopManager::self()->setCount(count); diff --git a/src/scripting/workspace_wrapper.h b/src/scripting/workspace_wrapper.h index 68956bcca0..067c65daf3 100644 --- a/src/scripting/workspace_wrapper.h +++ b/src/scripting/workspace_wrapper.h @@ -22,12 +22,17 @@ namespace KWin { // forward declarations class AbstractClient; +class VirtualDesktop; class X11Client; class WorkspaceWrapper : public QObject { Q_OBJECT + /** + * @deprecated use the currentVirtualDesktop property instead + */ Q_PROPERTY(int currentDesktop READ currentDesktop WRITE setCurrentDesktop NOTIFY currentDesktopChanged) + Q_PROPERTY(KWin::VirtualDesktop *currentVirtualDesktop READ currentVirtualDesktop WRITE setCurrentVirtualDesktop NOTIFY currentVirtualDesktopChanged) Q_PROPERTY(KWin::AbstractClient *activeClient READ activeClient WRITE setActiveClient NOTIFY clientActivated) // TODO: write and notify? Q_PROPERTY(QSize desktopGridSize READ desktopGridSize NOTIFY desktopLayoutChanged) @@ -153,6 +158,13 @@ Q_SIGNALS: */ void virtualScreenGeometryChanged(); + /** + * This signal is emitted when the current virtual desktop changes. + * + * @since 5.23 + */ + void currentVirtualDesktopChanged(); + public: //------------------------------------------------------------------ //enums copy&pasted from kwinglobals.h because qtscript is evil @@ -217,6 +229,9 @@ void setter( rettype val ); QSize virtualScreenSize() const; QRect virtualScreenGeometry() const; + VirtualDesktop *currentVirtualDesktop() const; + void setCurrentVirtualDesktop(VirtualDesktop *desktop); + /** * Returns the geometry a Client can use with the specified option. * This method should be preferred over other methods providing screen sizes as the