From 5100deee38454a4c063ad867547d708e9a6744a9 Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Sun, 17 Apr 2022 17:22:31 +0300 Subject: [PATCH] startup:track background brightness correctly --plasma is doing some funny stuff in multi-screen environments by changing screen ids and back and forth when primary screen is changed. We now take into account this and when screen plasma pools updates its ids in any case the wallpapers tracking follows instantly. --- app/plasma/extended/backgroundcache.cpp | 1 + app/plasma/extended/screenpool.cpp | 10 ++++++---- app/plasma/extended/screenpool.h | 2 ++ 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/app/plasma/extended/backgroundcache.cpp b/app/plasma/extended/backgroundcache.cpp index 7d5a77b14..1334d6802 100644 --- a/app/plasma/extended/backgroundcache.cpp +++ b/app/plasma/extended/backgroundcache.cpp @@ -52,6 +52,7 @@ BackgroundCache::BackgroundCache(QObject *parent) if (!m_pool) { m_pool = new ScreenPool(this); + connect(m_pool, &ScreenPool::idsChanged, this, &BackgroundCache::reload); } reload(); diff --git a/app/plasma/extended/screenpool.cpp b/app/plasma/extended/screenpool.cpp index b5f21c890..b4ebc604d 100644 --- a/app/plasma/extended/screenpool.cpp +++ b/app/plasma/extended/screenpool.cpp @@ -27,8 +27,8 @@ namespace PlasmaExtended { ScreenPool::ScreenPool(QObject *parent) : QObject(parent) { - KSharedConfigPtr plasmaPtr = KSharedConfig::openConfig(PLASMARC); - m_screensGroup = KConfigGroup(plasmaPtr, "ScreenConnectors"); + m_plasmarcConfig = KSharedConfig::openConfig(PLASMARC); + m_screensGroup = KConfigGroup(m_plasmarcConfig, "ScreenConnectors"); load(); @@ -62,12 +62,14 @@ void ScreenPool::load() m_connectorForId.clear(); m_idForConnector.clear(); + m_plasmarcConfig->reparseConfiguration(); + bool updated{false}; for (const auto &screenId : m_screensGroup.keyList()) { QString screenName = m_screensGroup.readEntry(screenId, QString()); - if (screenId != 0) { - int scrId = screenId.toInt(); + int scrId = screenId.toInt(); + if (scrId != 0) { insertScreenMapping(scrId, screenName); if (!connectorForId.contains(scrId) || connectorForId[scrId] != m_connectorForId[scrId]) { diff --git a/app/plasma/extended/screenpool.h b/app/plasma/extended/screenpool.h index 172e92c05..1324c6aed 100644 --- a/app/plasma/extended/screenpool.h +++ b/app/plasma/extended/screenpool.h @@ -13,6 +13,7 @@ // KDE #include +#include namespace Latte { namespace PlasmaExtended { @@ -42,6 +43,7 @@ private: QMap m_connectorForId; QHash m_idForConnector; + KSharedConfig::Ptr m_plasmarcConfig; KConfigGroup m_screensGroup; };