diff --git a/useractions.cpp b/useractions.cpp index e13751184e..3e2736c603 100644 --- a/useractions.cpp +++ b/useractions.cpp @@ -497,6 +497,13 @@ void Workspace::desktopPopupAboutToShow() !active_popup_client->isOnAllDesktops() && active_popup_client->desktop() == i) action->setChecked(true); } + + desk_popup->addSeparator(); + action = desk_popup->addAction(i18nc("Create a new desktop and move there the window", "&New Desktop")); + action->setData(numberOfDesktops() + 1); + + if (numberOfDesktops() >= Workspace::self()->maxNumberOfDesktops()) + action->setEnabled(false); } /*! @@ -1435,6 +1442,8 @@ void Workspace::slotSendToDesktop(QAction *action) // the 'on_all_desktops' menu entry active_popup_client->setOnAllDesktops(!active_popup_client->isOnAllDesktops()); return; + } else if (desk > numberOfDesktops()) { + setNumberOfDesktops(desk); } sendClientToDesktop(active_popup_client, desk, false); diff --git a/workspace.cpp b/workspace.cpp index bc264d970d..d501d24569 100644 --- a/workspace.cpp +++ b/workspace.cpp @@ -1422,6 +1422,11 @@ bool Workspace::setCurrentDesktop(int new_desktop) return true; } +int Workspace::maxNumberOfDesktops() const +{ + return KWIN_MAX_NUMBER_DESKTOPS; +} + #ifdef KWIN_BUILD_ACTIVITIES //BEGIN threaded activity list fetching diff --git a/workspace.h b/workspace.h index 703ab012be..254bf4ef30 100644 --- a/workspace.h +++ b/workspace.h @@ -214,6 +214,10 @@ public: * @returns Total number of desktops currently in existence. */ int numberOfDesktops() const; + /** + * @returns The maximum number of desktops that KWin supports. + */ + int maxNumberOfDesktops() const; /** * Set the number of available desktops to @a count. This function overrides any previous * grid layout.