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.
This commit is contained in:
Roman Gilg 2020-08-17 21:37:40 +02:00 committed by Aleix Pol Gonzalez
parent 8303a4cdf8
commit 001761cea2

View file

@ -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) {