From 001761cea2e04ce32f880d7e507103b541f94734 Mon Sep 17 00:00:00 2001 From: Roman Gilg Date: Mon, 17 Aug 2020 21:37:40 +0200 Subject: [PATCH] fix(space): check edges for nearly complete screen overlap When two outputs are positioned on top of each other in a way that one covers most of the height or width of the onter one with exception of a small gap this gap might be too small to later on substract the orner offset and stay positive. In this case do not create the edge at all. The screen edges test passes again. --- screenedge.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/screenedge.cpp b/screenedge.cpp index 64d3b36af9..9f8cfebc99 100644 --- a/screenedge.cpp +++ b/screenedge.cpp @@ -1068,7 +1068,10 @@ void ScreenEdges::createVerticalEdge(ElectricBorder border, const QRect &screen, const ElectricBorder edge = (border == ElectricLeft) ? ElectricBottomLeft : ElectricBottomRight; m_edges << createEdge(edge, x, screen.y() + screen.height() -1, 1, 1); } - // create border + if (height <= m_cornerOffset) { + // An overlap with another output is near complete. We ignore this border. + return; + } m_edges << createEdge(border, x, y, 1, height); } @@ -1088,6 +1091,10 @@ void ScreenEdges::createHorizontalEdge(ElectricBorder border, const QRect &scree // also right most edge width -= m_cornerOffset; } + if (width <= m_cornerOffset) { + // An overlap with another output is near complete. We ignore this border. + return; + } const int y = (border == ElectricTop) ? screen.y() : screen.y() + screen.height() - 1; m_edges << createEdge(border, x, y, width, 1); } @@ -1099,6 +1106,10 @@ Edge *ScreenEdges::createEdge(ElectricBorder border, int x, int y, int width, in #else Edge *edge = kwinApp()->platform()->createScreenEdge(this); #endif + // Edges can not have negative size. + Q_ASSERT(width >= 0); + Q_ASSERT(height >= 0); + edge->setBorder(border); edge->setGeometry(QRect(x, y, width, height)); if (createAction) {