[wayland] add explict AbstractClient::setDesktops(QList)
Summary: Currently setDesktop and unsetDesktop were out of sync, with the latter missing several important signals and updating of transients. By using a a shared implementation we avoid that, it also allows for an atomic move of a window between desktops. setDesktop is changed back to be a moval of desktop as it currently broke several unit tests as well as changing the behaviour of the move to desktop shortcut on wayland. Test Plan: testBindings now passes Moved windows with the context menu on X11 Reviewers: #kwin, graesslin Reviewed By: #kwin, graesslin Subscribers: graesslin, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D16703
This commit is contained in:
parent
7e73ad230a
commit
2fb2fb9a44
2 changed files with 39 additions and 35 deletions
|
@ -490,44 +490,52 @@ void AbstractClient::setDesktop(int desktop)
|
||||||
desktop = qMax(1, qMin(numberOfDesktops, desktop));
|
desktop = qMax(1, qMin(numberOfDesktops, desktop));
|
||||||
desktop = qMin(numberOfDesktops, rules()->checkDesktop(desktop));
|
desktop = qMin(numberOfDesktops, rules()->checkDesktop(desktop));
|
||||||
|
|
||||||
VirtualDesktop *virtualDesktop = desktop == NET::OnAllDesktops ? nullptr : VirtualDesktopManager::self()->desktopForX11Id(desktop);
|
QVector<VirtualDesktop *> desktops;
|
||||||
|
if (desktop != NET::OnAllDesktops) {
|
||||||
|
desktops << VirtualDesktopManager::self()->desktopForX11Id(desktop);
|
||||||
|
}
|
||||||
|
setDesktops(desktops);
|
||||||
|
}
|
||||||
|
|
||||||
// Don't do anything if we're already there, if the desktop is already in desktops or if the desktop is NET::OnAllDesktops and m_desktops is already empty.
|
void AbstractClient::setDesktops(QVector<VirtualDesktop*> desktops)
|
||||||
if (m_desktops.contains(virtualDesktop) ||
|
{
|
||||||
(desktop == NET::OnAllDesktops && m_desktops.isEmpty())) {
|
//on x11 we can have only one desktop at a time
|
||||||
|
if (kwinApp()->operationMode() == Application::OperationModeX11 && desktops.size() > 1) {
|
||||||
|
desktops = QVector<VirtualDesktop*>({desktops.first()});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (desktops == m_desktops) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int was_desk = AbstractClient::desktop();
|
int was_desk = AbstractClient::desktop();
|
||||||
const bool wasOnCurrentDesktop = isOnCurrentDesktop() && was_desk >= 0;
|
const bool wasOnCurrentDesktop = isOnCurrentDesktop() && was_desk >= 0;
|
||||||
|
|
||||||
//on x11 we can have only one desktop at a time
|
m_desktops = desktops;
|
||||||
if (kwinApp()->operationMode() == Application::OperationModeX11) {
|
|
||||||
m_desktops.clear();
|
|
||||||
}
|
|
||||||
if (desktop == NET::OnAllDesktops) {
|
|
||||||
m_desktops.clear();
|
|
||||||
} else {
|
|
||||||
//if would become on all desktops, clear the list, as empty == on all desktops
|
|
||||||
if (m_desktops.count() > 1 && static_cast<uint>(m_desktops.count()) == VirtualDesktopManager::self()->count() - 1) {
|
|
||||||
m_desktops.clear();
|
|
||||||
} else {
|
|
||||||
m_desktops << virtualDesktop;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (windowManagementInterface()) {
|
if (windowManagementInterface()) {
|
||||||
if (m_desktops.isEmpty()) {
|
if (m_desktops.isEmpty()) {
|
||||||
windowManagementInterface()->setOnAllDesktops(true);
|
windowManagementInterface()->setOnAllDesktops(true);
|
||||||
} else {
|
} else {
|
||||||
windowManagementInterface()->addPlasmaVirtualDesktop(virtualDesktop->id());
|
windowManagementInterface()->setOnAllDesktops(false);
|
||||||
|
auto currentDesktops = windowManagementInterface()->plasmaVirtualDesktops();
|
||||||
|
for (auto desktop: m_desktops) {
|
||||||
|
if (!currentDesktops.contains(desktop->id())) {
|
||||||
|
windowManagementInterface()->addPlasmaVirtualDesktop(desktop->id());
|
||||||
|
} else {
|
||||||
|
currentDesktops.removeOne(desktop->id());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (auto desktopId: currentDesktops) {
|
||||||
|
windowManagementInterface()->removePlasmaVirtualDesktop(desktopId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (info) {
|
if (info) {
|
||||||
info->setDesktop(desktop);
|
info->setDesktop(desktop());
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((was_desk == NET::OnAllDesktops) != (desktop == NET::OnAllDesktops)) {
|
if ((was_desk == NET::OnAllDesktops) != (desktop() == NET::OnAllDesktops)) {
|
||||||
// onAllDesktops changed
|
// onAllDesktops changed
|
||||||
workspace()->updateOnAllDesktopsOfTransients(this);
|
workspace()->updateOnAllDesktopsOfTransients(this);
|
||||||
}
|
}
|
||||||
|
@ -536,17 +544,17 @@ void AbstractClient::setDesktop(int desktop)
|
||||||
for (auto it = transients_stacking_order.constBegin();
|
for (auto it = transients_stacking_order.constBegin();
|
||||||
it != transients_stacking_order.constEnd();
|
it != transients_stacking_order.constEnd();
|
||||||
++it)
|
++it)
|
||||||
(*it)->setDesktop(desktop);
|
(*it)->setDesktops(desktops);
|
||||||
|
|
||||||
if (isModal()) // if a modal dialog is moved, move the mainwindow with it as otherwise
|
if (isModal()) // if a modal dialog is moved, move the mainwindow with it as otherwise
|
||||||
// the (just moved) modal dialog will confusingly return to the mainwindow with
|
// the (just moved) modal dialog will confusingly return to the mainwindow with
|
||||||
// the next desktop change
|
// the next desktop change
|
||||||
{
|
{
|
||||||
foreach (AbstractClient * c2, mainClients())
|
foreach (AbstractClient * c2, mainClients())
|
||||||
c2->setDesktop(desktop);
|
c2->setDesktops(desktops);
|
||||||
}
|
}
|
||||||
|
|
||||||
doSetDesktop(desktop, was_desk);
|
doSetDesktop(desktop(), was_desk);
|
||||||
|
|
||||||
FocusChain::self()->update(this, FocusChain::MakeFirst);
|
FocusChain::self()->update(this, FocusChain::MakeFirst);
|
||||||
updateWindowRules(Rules::Desktop);
|
updateWindowRules(Rules::Desktop);
|
||||||
|
@ -570,7 +578,6 @@ void AbstractClient::unSetDesktop(int desktop)
|
||||||
if (m_desktops.isEmpty()) {
|
if (m_desktops.isEmpty()) {
|
||||||
setOnAllDesktops(false);
|
setOnAllDesktops(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -580,15 +587,10 @@ void AbstractClient::unSetDesktop(int desktop)
|
||||||
}
|
}
|
||||||
|
|
||||||
VirtualDesktop *virtualDesktop = VirtualDesktopManager::self()->desktopForX11Id(desktop);
|
VirtualDesktop *virtualDesktop = VirtualDesktopManager::self()->desktopForX11Id(desktop);
|
||||||
|
Q_ASSERT(virtualDesktop);
|
||||||
m_desktops.removeAll(virtualDesktop);
|
auto desktops = m_desktops;
|
||||||
|
desktops.removeOne(virtualDesktop);
|
||||||
if (!windowManagementInterface()) {
|
setDesktops(desktops);
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
windowManagementInterface()->removePlasmaVirtualDesktop(virtualDesktop->id());
|
|
||||||
emit x11DesktopIdsChanged();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AbstractClient::setOnAllDesktops(bool b)
|
void AbstractClient::setOnAllDesktops(bool b)
|
||||||
|
|
|
@ -1104,6 +1104,8 @@ protected:
|
||||||
|
|
||||||
bool tabTo(AbstractClient *other, bool behind, bool activate);
|
bool tabTo(AbstractClient *other, bool behind, bool activate);
|
||||||
|
|
||||||
|
void setDesktops(QVector<VirtualDesktop *> desktops);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void handlePaletteChange();
|
void handlePaletteChange();
|
||||||
QSharedPointer<TabBox::TabBoxClientImpl> m_tabBoxClient;
|
QSharedPointer<TabBox::TabBoxClientImpl> m_tabBoxClient;
|
||||||
|
|
Loading…
Reference in a new issue