From 6faf4ec3a2c519b7d20325ed4eeb9d4993c3cd2f Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Sat, 30 Oct 2021 12:54:19 +0300 Subject: [PATCH] Make mapping between outputs and cached screen geometries in Workspace robust Integer screen ids are not robust. On the other hand, AbstractOutput does not change if an output has been connected or disconnected. --- src/workspace.cpp | 8 ++++---- src/workspace.h | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/workspace.cpp b/src/workspace.cpp index e4ae1ae18f..1698ad7fcb 100644 --- a/src/workspace.cpp +++ b/src/workspace.cpp @@ -2091,11 +2091,11 @@ void Workspace::desktopResized() void Workspace::saveOldScreenSizes() { olddisplaysize = m_geometry.size(); - oldscreensizes.clear(); + m_oldScreenGeometries.clear(); const auto outputs = kwinApp()->platform()->enabledOutputs(); for (const AbstractOutput *output : outputs) { - oldscreensizes.append(output->geometry()); + m_oldScreenGeometries.insert(output, output->geometry()); } } @@ -2405,9 +2405,9 @@ QRegion Workspace::previousRestrictedMoveArea(const VirtualDesktop *desktop, Str return strutsToRegion(areas, m_oldRestrictedAreas[desktop]); } -QVector< QRect > Workspace::previousScreenSizes() const +QHash Workspace::previousScreenSizes() const { - return oldscreensizes; + return m_oldScreenGeometries; } int Workspace::oldDisplayWidth() const diff --git a/src/workspace.h b/src/workspace.h index 1157ce6dbb..d3bc39f63e 100644 --- a/src/workspace.h +++ b/src/workspace.h @@ -271,7 +271,7 @@ public: // The calls below are valid only in that case. bool inUpdateClientArea() const; QRegion previousRestrictedMoveArea(const VirtualDesktop *desktop, StrutAreas areas = StrutAreaAll) const; - QVector< QRect > previousScreenSizes() const; + QHash previousScreenSizes() const; int oldDisplayWidth() const; int oldDisplayHeight() const; @@ -670,7 +670,7 @@ private: QHash> m_screenAreas; QRect m_geometry; - QVector< QRect > oldscreensizes; // array of previous sizes of xinerama screens + QHash m_oldScreenGeometries; QSize olddisplaysize; // previous sizes od displayWidth()/displayHeight() QHash m_oldRestrictedAreas;