diff --git a/scripting/workspace_wrapper.h b/scripting/workspace_wrapper.h --- a/scripting/workspace_wrapper.h +++ b/scripting/workspace_wrapper.h @@ -255,6 +255,17 @@ * Returns the name for the given @p desktop. */ Q_SCRIPTABLE QString desktopName(int desktop) const; + /** + * Create a new virtual desktop at the requested position. + * @param position The position of the desktop. It should be in range [0, count]. + * @param name The name for the new desktop, if empty the default name will be used. + */ + Q_SCRIPTABLE void createDesktop(int position, const QString &name) const; + /** + * Remove the virtual desktop at the requested position + * @param position The position of the desktop to be removed. It should be in range [0, count - 1]. + */ + Q_SCRIPTABLE void removeDesktop(int position) const; /** * Provides support information about the currently running KWin instance. */ diff --git a/scripting/workspace_wrapper.cpp b/scripting/workspace_wrapper.cpp --- a/scripting/workspace_wrapper.cpp +++ b/scripting/workspace_wrapper.cpp @@ -272,6 +272,21 @@ return VirtualDesktopManager::self()->name(desktop); } +void WorkspaceWrapper::createDesktop(int position, const QString &name) const +{ + VirtualDesktopManager::self()->createVirtualDesktop(position, name); +} + +void WorkspaceWrapper::removeDesktop(int position) const +{ + VirtualDesktop *vd = VirtualDesktopManager::self()->desktopForX11Id(position + 1); + if (!vd) { + return; + } + + VirtualDesktopManager::self()->removeVirtualDesktop(vd->id()); +} + QString WorkspaceWrapper::supportInformation() const { return Workspace::self()->supportInformation();