Improve handling of closed windows
A layer shell window can request a screen edge without having a chance to map the surface. In that case, no Workspace::windowRemoved() signal is not going to be emitted because no surface has been mapped. Perhaps it needs some re-wiring, but on the other hand, it is also more reasonable to monitor Window::closed() signal. With this change, the ScreenEdges manager will reject any request to reserve a screen edge for a closed window. And in addition to that, the ScreenEdges will unreserve screen edges when the window is closed rather than when the window is unmapped. CCBUG: 485318
This commit is contained in:
parent
01a9eb2327
commit
cadf16b12e
1 changed files with 8 additions and 4 deletions
|
@ -797,8 +797,6 @@ ScreenEdges::ScreenEdges()
|
|||
{
|
||||
const int gridUnit = QFontMetrics(QFontDatabase::systemFont(QFontDatabase::GeneralFont)).boundingRect(QLatin1Char('M')).height();
|
||||
m_cornerOffset = 4 * gridUnit;
|
||||
|
||||
connect(workspace(), &Workspace::windowRemoved, this, &ScreenEdges::deleteEdgeForClient);
|
||||
}
|
||||
|
||||
void ScreenEdges::init()
|
||||
|
@ -1340,6 +1338,10 @@ void ScreenEdges::unreserveTouch(ElectricBorder border, QAction *action)
|
|||
|
||||
bool ScreenEdges::createEdgeForClient(Window *client, ElectricBorder border)
|
||||
{
|
||||
if (client->isDeleted()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int y = 0;
|
||||
int x = 0;
|
||||
int width = 0;
|
||||
|
@ -1391,10 +1393,12 @@ bool ScreenEdges::createEdgeForClient(Window *client, ElectricBorder border)
|
|||
return false;
|
||||
}
|
||||
|
||||
m_edges.push_back(createEdge(border, x, y, width, height, output, false));
|
||||
Edge *edge = m_edges.back().get();
|
||||
const auto &edge = m_edges.emplace_back(createEdge(border, x, y, width, height, output, false));
|
||||
edge->setClient(client);
|
||||
edge->reserve();
|
||||
connect(client, &Window::closed, edge.get(), [this, client]() {
|
||||
deleteEdgeForClient(client);
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue