From 27ceaf9793b607aa63305eef3eddb2abc49aa771 Mon Sep 17 00:00:00 2001 From: David Edmundson Date: Wed, 15 Jul 2020 16:49:54 +0100 Subject: [PATCH] Only call VirtualDesktops::load once It was called twice once with and without X as our implementation of setRootInfo() missed some calls. This was done to avoid a bug as setRootInfo() didn't update everything. This patch aims to resolve that at the root cause. I tested the original conditions of the patch with an empty kwinrc and a file in /etc/xdg/kwinrc setting desktops to 2 and everything loaded correctly. --- virtualdesktops.cpp | 18 +++++++----------- workspace.cpp | 5 +---- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/virtualdesktops.cpp b/virtualdesktops.cpp index a5d61a491d..121c5f602d 100644 --- a/virtualdesktops.cpp +++ b/virtualdesktops.cpp @@ -247,6 +247,13 @@ void VirtualDesktopManager::setRootInfo(NETRootInfo *info) // Nothing will be connected to rootInfo if (m_rootInfo) { + int columns = count() / m_rows; + if (count() % m_rows > 0) { + columns++; + } + m_rootInfo->setDesktopLayout(NET::OrientationHorizontal, columns, m_rows, NET::DesktopLayoutCornerTopLeft); + updateRootInfo(); + m_rootInfo->setCurrentDesktop(currentDesktop()->x11DesktopNumber()); for (auto *vd : m_desktops) { m_rootInfo->setDesktopName(vd->x11DesktopNumber(), vd->name().toUtf8().data()); } @@ -713,7 +720,6 @@ void VirtualDesktopManager::load() const QString sId = group.readEntry(QStringLiteral("Id_%1").arg(i), QString()); - //load gets called 2 times, see workspace.cpp line 416 and BUG 385260 if (m_desktops[i-1]->id().isEmpty()) { m_desktops[i-1]->setId(sId.isEmpty() ? generateDesktopId() : sId.toUtf8()); } else { @@ -727,16 +733,6 @@ void VirtualDesktopManager::load() int rows = group.readEntry("Rows", 2); m_rows = qBound(1, rows, n); - if (m_rootInfo) { - // avoid weird cases like having 3 rows for 4 desktops, where the last row is unused - int columns = n / m_rows; - if (n % m_rows > 0) { - columns++; - } - m_rootInfo->setDesktopLayout(NET::OrientationHorizontal, columns, m_rows, NET::DesktopLayoutCornerTopLeft); - m_rootInfo->activate(); - } - s_loadingDesktopSettings = false; } diff --git a/workspace.cpp b/workspace.cpp index bf9b100beb..900a66392c 100644 --- a/workspace.cpp +++ b/workspace.cpp @@ -359,10 +359,7 @@ void Workspace::initWithX11() RootInfo *rootInfo = RootInfo::create(); const auto vds = VirtualDesktopManager::self(); vds->setRootInfo(rootInfo); - // load again to sync to RootInfo, see BUG 385260 - vds->load(); - vds->updateRootInfo(); - rootInfo->setCurrentDesktop(vds->currentDesktop()->x11DesktopNumber()); + rootInfo->activate(); // TODO: only in X11 mode // Extra NETRootInfo instance in Client mode is needed to get the values of the properties