Commit 232984c1 authored by Tiago Corrêa's avatar Tiago Corrêa Committed by Vlad Zahorodnii
Browse files

scripting: Provide methods to create and remove virtual desktops

Summary: There are methods to create and remove virtual desktops via dbus, but I think it would be convenient to provide these methods for KWin scripts as well.

Reviewers: #kwin, zzag

Reviewed By: #kwin, zzag

Subscribers: zzag, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D29786
parent 3e337603
......@@ -272,6 +272,21 @@ QString WorkspaceWrapper::desktopName(int desktop) const
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();
......
......@@ -255,6 +255,17 @@ void setter( rettype val );
* 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.
*/
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment