Port some code away from AbstractClient::setDesktop() to AbstractClient::setDesktops()

The main motivation behind this change is to reduce the number of usages
of int-based virtual desktop apis. int-based desktop ids are highly
unreliable. For example, if a new virtual desktop is inserted in the
middle or removed in the middle, the desktop ids will change. This makes
working with virtual desktops code more challenging due to its behavior.
This is not an issue with VirtualDesktop objects.
This commit is contained in:
Vlad Zahorodnii 2021-08-13 09:37:20 +03:00
parent 2aa3ed0005
commit 7f1baf66f9
2 changed files with 7 additions and 6 deletions

View file

@ -542,10 +542,11 @@ void AbstractClient::setOnAllDesktops(bool b)
if ((b && isOnAllDesktops()) ||
(!b && !isOnAllDesktops()))
return;
if (b)
setDesktop(NET::OnAllDesktops);
else
setDesktop(VirtualDesktopManager::self()->current());
if (b) {
setDesktops({});
} else {
setDesktops({VirtualDesktopManager::self()->currentDesktop()});
}
}
int AbstractClient::desktop() const

View file

@ -358,7 +358,7 @@ XdgToplevelClient::XdgToplevelClient(XdgToplevelInterface *shellSurface)
{
setupWindowManagementIntegration();
setupPlasmaShellIntegration();
setDesktop(VirtualDesktopManager::self()->current());
setDesktops({VirtualDesktopManager::self()->currentDesktop()});
#if KWIN_BUILD_ACTIVITIES
if (auto a = Activities::self()) {
setOnActivities({a->current()});
@ -1739,7 +1739,7 @@ XdgPopupClient::XdgPopupClient(XdgPopupInterface *shellSurface)
: XdgSurfaceClient(shellSurface->xdgSurface())
, m_shellSurface(shellSurface)
{
setDesktop(VirtualDesktopManager::self()->current());
setDesktops({VirtualDesktopManager::self()->currentDesktop()});
#if KWIN_BUILD_ACTIVITIES
if (auto a = Activities::self()) {
setOnActivities({a->current()});