From 3c21f5475e9aa60bb01d371453bc94146474c51f Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Mon, 27 Dec 2021 22:46:01 +0200 Subject: [PATCH] fix plasma available geometry broadcasting --ignore docks and panels for availableScreenRect(s) etc. when they are in startup and they are painted offscreen --plasma is not ready to accept availableScreenRegion(s) because after startup moves desktop widgets to the left even though it should not --fix availableScreenRegion calculations for Centered and Justified docks and panels --- app/lattecorona.cpp | 12 ++++-- app/main.cpp | 1 - app/plasma/extended/screengeometries.cpp | 50 +++++++++++++++++------- app/view/positioner.cpp | 2 +- 4 files changed, 44 insertions(+), 21 deletions(-) diff --git a/app/lattecorona.cpp b/app/lattecorona.cpp index 5282d2f9d..babee99e4 100644 --- a/app/lattecorona.cpp +++ b/app/lattecorona.cpp @@ -583,7 +583,9 @@ QRegion Corona::availableScreenRegionWithCriteria(int id, bool allEdges = ignoreEdges.isEmpty(); for (const auto *view : views) { - if (view && view->containment() && view->screen() == screen + bool inDesktopOffScreenStartup = desktopUse && view && view->positioner() && view->positioner()->isOffScreen(); + + if (view && view->containment() && view->screen() == screen && !inDesktopOffScreenStartup && ((allEdges || !ignoreEdges.contains(view->location())) && (view->visibility() && !ignoreModes.contains(view->visibility()->mode())))) { int realThickness = view->normalThickness(); @@ -606,7 +608,7 @@ QRegion Corona::availableScreenRegionWithCriteria(int id, case Latte::Types::Center: case Latte::Types::Justify: - x = (view->geometry().center().x() - w/2) + offsetW; + x = (view->geometry().center().x() - w/2) + 1 + offsetW; break; case Latte::Types::Right: @@ -630,7 +632,7 @@ QRegion Corona::availableScreenRegionWithCriteria(int id, case Latte::Types::Center: case Latte::Types::Justify: - y = (view->geometry().center().y() - h/2) + offsetH; + y = (view->geometry().center().y() - h/2) + 1 + offsetH; break; case Latte::Types::Bottom: @@ -785,7 +787,9 @@ QRect Corona::availableScreenRectWithCriteria(int id, bool allEdges = ignoreEdges.isEmpty(); for (const auto *view : views) { - if (view && view->containment() && view->screen() == screen + bool inDesktopOffScreenStartup = desktopUse && view && view->positioner() && view->positioner()->isOffScreen(); + + if (view && view->containment() && view->screen() == screen && !inDesktopOffScreenStartup && ((allEdges || !ignoreEdges.contains(view->location())) && (view->visibility() && !ignoreModes.contains(view->visibility()->mode())))) { diff --git a/app/main.cpp b/app/main.cpp index 87c6590f6..cf9dda37e 100644 --- a/app/main.cpp +++ b/app/main.cpp @@ -467,7 +467,6 @@ inline void filterDebugMessageOutput(QtMsgType type, const QMessageLogContext &c TypeColor = CRED; } else { TypeColor = CIGREEN; - } qDebug().nospace() << TypeColor << "[" << typeStr.toStdString().c_str() << " : " << CGREEN << QTime::currentTime().toString("h:mm:ss.zz").toStdString().c_str() << TypeColor << "]" << CNORMAL diff --git a/app/plasma/extended/screengeometries.cpp b/app/plasma/extended/screengeometries.cpp index c0eaba93c..d30607d52 100644 --- a/app/plasma/extended/screengeometries.cpp +++ b/app/plasma/extended/screengeometries.cpp @@ -171,7 +171,9 @@ void ScreenGeometries::clearGeometries() if (m_corona->screenPool()->hasScreenId(scrId)) { setPlasmaAvailableScreenRect(scrName, QRect()); - setPlasmaAvailableScreenRegion(scrName, QRegion()); + + /* Disabling until Plasma is ready and not making mistakes. + setPlasmaAvailableScreenRegion(scrName, QRegion());*/ } } @@ -189,6 +191,8 @@ void ScreenGeometries::updateGeometries() qDebug() << " PLASMA SCREEN GEOMETRIES, LAST AVAILABLE SCREEN RECTS :: " << m_lastAvailableRect; + QStringList clearedScreenNames; + //! check for available geometries changes for (QScreen *screen : qGuiApp->screens()) { QString scrName = screen->name(); @@ -204,24 +208,38 @@ void ScreenGeometries::updateGeometries() true, true); + + /* Disabling until Plasma is ready and not making mistakes. + * The biggest issue is that after startup when setting Plasma Available Region the right aligned desktop + * widgets are moved to the left. This needs investigation to Plasma code to check out what is happening QRegion availableRegion = m_corona->availableScreenRegionWithCriteria(scrId, QString(), m_ignoreModes, QList(), true, true); - - //! Disable checks because of the workaround concerning plasma desktop behavior - if (!m_lastAvailableRect.contains(scrName) || m_lastAvailableRect[scrName] != availableRect) { - m_lastAvailableRect[scrName] = availableRect; - setPlasmaAvailableScreenRect(scrName, availableRect); - qDebug() << " PLASMA SCREEN GEOMETRIES, AVAILABLE RECT :: " << screen->name() << " : " << availableRect; - } - - if (!m_lastAvailableRegion.contains(scrName) || m_lastAvailableRegion[scrName] != availableRegion) { - m_lastAvailableRegion[scrName] = availableRegion; - setPlasmaAvailableScreenRegion(scrName, availableRegion); - qDebug() << " PLASMA SCREEN GEOMETRIES, AVAILABLE REGION :: " << screen->name() << " : " << availableRegion; + */ + + bool clearedScreen = (availableRect == screen->geometry()); + + if (!clearedScreen) { + //! Disable checks because of the workaround concerning plasma desktop behavior + if (!m_lastAvailableRect.contains(scrName) || m_lastAvailableRect[scrName] != availableRect) { + m_lastAvailableRect[scrName] = availableRect; + setPlasmaAvailableScreenRect(scrName, availableRect); + qDebug() << " PLASMA SCREEN GEOMETRIES, AVAILABLE RECT :: " << screen->name() << " : " << availableRect; + } + + /* Disabling until Plasma is ready and not making mistakes. + * The biggest issue is that after startup when setting Plasma Available Region the right aligned desktop + * widgets are moved to the left. This needs investigation to Plasma code to check out what is happening + if (!m_lastAvailableRegion.contains(scrName) || m_lastAvailableRegion[scrName] != availableRegion) { + m_lastAvailableRegion[scrName] = availableRegion; + setPlasmaAvailableScreenRegion(scrName, availableRegion); + qDebug() << " PLASMA SCREEN GEOMETRIES, AVAILABLE REGION :: " << screen->name() << " : " << availableRegion; + }*/ + } else { + clearedScreenNames << scrName; } } @@ -230,10 +248,12 @@ void ScreenGeometries::updateGeometries() //! check for inactive screens that were published previously for (QString &lastScrName : m_lastScreenNames) { - if (!screenIsActive(lastScrName)) { + if (!screenIsActive(lastScrName) || clearedScreenNames.contains(lastScrName)) { //! screen became inactive and its geometries could be unpublished setPlasmaAvailableScreenRect(lastScrName, QRect()); - setPlasmaAvailableScreenRegion(lastScrName, QRegion()); + + /* Disabling until Plasma is ready and not making mistakes. + setPlasmaAvailableScreenRegion(lastScrName, QRegion());*/ m_lastAvailableRect.remove(lastScrName); m_lastAvailableRegion.remove(lastScrName); diff --git a/app/view/positioner.cpp b/app/view/positioner.cpp index 3b0088518..fb86de38a 100644 --- a/app/view/positioner.cpp +++ b/app/view/positioner.cpp @@ -268,7 +268,7 @@ void Positioner::setInRelocationShowing(bool active) bool Positioner::isOffScreen() const { - return (m_validGeometry.x()<-500 || m_validGeometry.y()<-500); + return (m_view->absoluteGeometry().x()<-500 || m_view->absoluteGeometry().y()<-500); } int Positioner::currentScreenId() const