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
This commit is contained in:
ivan tkachenko 2022-08-28 15:30:53 +03:00
parent d477b31842
commit e489ad9a16
No known key found for this signature in database
GPG key ID: AF72731B7C654CB3

View file

@ -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());