Simplify Workspace::sendClientToDesktop()

This allows changing the type of desk to QVector<VirtualDesktop *>.

Based on the dont_activate flag, Workspace::sendClientToDesktop() will
try to focus the window if it's moved to the current virtual desktop.

In order to implement that, it needs to know whether the window has been
on the current desktop. c->isOnDesktop(desk) is a much sophisticated way
to do that.
This commit is contained in:
Vlad Zahorodnii 2021-08-17 15:56:52 +03:00
parent 2e0336681f
commit 1fbd99b572

View file

@ -1261,7 +1261,7 @@ void Workspace::sendClientToDesktop(AbstractClient* c, int desk, bool dont_activ
if ((desk < 1 && desk != NET::OnAllDesktops) || desk > static_cast<int>(VirtualDesktopManager::self()->count()))
return;
int old_desktop = c->desktop();
bool was_on_desktop = c->isOnDesktop(desk) || c->isOnAllDesktops();
const bool wasOnCurrent = c->isOnCurrentDesktop();
c->setDesktop(desk);
if (c->desktop() != desk) // No change or desktop forced
return;
@ -1269,7 +1269,7 @@ void Workspace::sendClientToDesktop(AbstractClient* c, int desk, bool dont_activ
if (c->isOnCurrentDesktop()) {
if (c->wantsTabFocus() && options->focusPolicyIsReasonable() &&
!was_on_desktop && // for stickyness changes
!wasOnCurrent && // for stickyness changes
!dont_activate)
requestFocus(c);
else