Reserve a screen edge on the same output as the window

This makes the association between the window's output and the screen
edge's output more robust.
This commit is contained in:
Vlad Zahorodnii 2024-01-24 17:42:48 +02:00
parent 2d399e93f0
commit 16aaf92782

View file

@ -1341,71 +1341,58 @@ bool ScreenEdges::createEdgeForClient(Window *client, ElectricBorder border)
int x = 0;
int width = 0;
int height = 0;
Output *output = client->output();
const QRect geo = client->frameGeometry().toRect();
const QRect fullArea = workspace()->geometry();
const auto outputs = workspace()->outputs();
Output *foundOutput = nullptr;
for (Output *output : outputs) {
foundOutput = output;
const QRect screen = output->geometry();
if (!screen.contains(geo)) {
// ignoring Clients having a geometry overlapping with multiple screens
// this would make the code more complex. If it's needed in future it can be added
continue;
}
if (border == ElectricTop) {
switch (border) {
case ElectricTop:
if (!isTopScreen(screen, fullArea)) {
continue;
return false;
}
y = screen.y();
x = geo.x();
height = 1;
width = geo.width();
break;
}
if (border == ElectricBottom) {
case ElectricBottom:
if (!isBottomScreen(screen, fullArea)) {
continue;
return false;
}
y = screen.y() + screen.height() - 1;
x = geo.x();
height = 1;
width = geo.width();
break;
}
if (border == ElectricLeft) {
case ElectricLeft:
if (!isLeftScreen(screen, fullArea)) {
continue;
return false;
}
x = screen.x();
y = geo.y();
width = 1;
height = geo.height();
break;
}
if (border == ElectricRight) {
case ElectricRight:
if (!isRightScreen(screen, fullArea)) {
continue;
return false;
}
x = screen.x() + screen.width() - 1;
y = geo.y();
width = 1;
height = geo.height();
break;
}
default:
return false;
}
if (width > 0 && height > 0) {
m_edges.push_back(createEdge(border, x, y, width, height, foundOutput, false));
m_edges.push_back(createEdge(border, x, y, width, height, output, false));
Edge *edge = m_edges.back().get();
edge->setClient(client);
edge->reserve();
return true;
}
return false;
}
void ScreenEdges::deleteEdgeForClient(Window *window)