From e489ad9a166a4109040b753b00ea4b2f57e698c5 Mon Sep 17 00:00:00 2001 From: ivan tkachenko Date: Sun, 28 Aug 2022 15:30:53 +0300 Subject: [PATCH] UserActionsMenu: Add "Move &To Current Desktop" action from task manager for X11 Task Manager has this option, so let's keep them consistent. Surprisingly, when a window is set to "All Desktops", choosing "All Desktops" again clears that flag, i.e. sets the window back to only single desktop. But it is not intuitive at all. So let's have this separate action to pin a window to current desktop. Note: Wayland allows for multiple but not all desktops to be assigned to a window, so it works differently there. Should we have a similar option there too? BUG: 458415 --- src/useractions.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/useractions.cpp b/src/useractions.cpp index 65f1204ff3..29fe95da11 100644 --- a/src/useractions.cpp +++ b/src/useractions.cpp @@ -521,7 +521,18 @@ void UserActionsMenu::desktopPopupAboutToShow() m_desktopMenu->setPalette(m_window->palette()); } QActionGroup *group = new QActionGroup(m_desktopMenu); - QAction *action = m_desktopMenu->addAction(i18n("&All Desktops")); + + QAction *action = m_desktopMenu->addAction(i18n("Move &To Current Desktop")); + action->setEnabled(m_window && (m_window->isOnAllDesktops() || !m_window->isOnDesktop(vds->currentDesktop()))); + connect(action, &QAction::triggered, this, [this]() { + if (!m_window) { + return; + } + VirtualDesktopManager *vds = VirtualDesktopManager::self(); + workspace()->sendWindowToDesktop(m_window, vds->currentDesktop()->x11DesktopNumber(), false); + }); + + action = m_desktopMenu->addAction(i18n("&All Desktops")); connect(action, &QAction::triggered, this, [this]() { if (m_window) { m_window->setOnAllDesktops(!m_window->isOnAllDesktops());