Remove AbstractClient plumbing casts in WaylandServer

This commit is contained in:
Vlad Zahorodnii 2022-04-18 11:27:27 +03:00
parent 817656cb0b
commit 507bad4843

View file

@ -521,15 +521,10 @@ SurfaceInterface *WaylandServer::findForeignTransientForSurface(SurfaceInterface
return m_XdgForeign->transientFor(surface); return m_XdgForeign->transientFor(surface);
} }
void WaylandServer::shellClientShown(AbstractClient *toplevel) void WaylandServer::shellClientShown(AbstractClient *window)
{ {
auto client = static_cast<AbstractClient *>(toplevel->isClient() ? toplevel : nullptr); disconnect(window, &AbstractClient::windowShown, this, &WaylandServer::shellClientShown);
if (!client) { Q_EMIT shellClientAdded(window);
qCWarning(KWIN_CORE) << "Failed to cast a Toplevel which is supposed to be an AbstractClient to AbstractClient";
return;
}
disconnect(client, &AbstractClient::windowShown, this, &WaylandServer::shellClientShown);
Q_EMIT shellClientAdded(client);
} }
void WaylandServer::initWorkspace() void WaylandServer::initWorkspace()
@ -551,10 +546,9 @@ void WaylandServer::initWorkspace()
QVector<quint32> ids; QVector<quint32> ids;
QVector<QString> uuids; QVector<QString> uuids;
for (AbstractClient *toplevel : workspace()->stackingOrder()) { for (AbstractClient *toplevel : workspace()->stackingOrder()) {
auto *client = static_cast<AbstractClient *>(toplevel->isClient() ? toplevel : nullptr); if (toplevel->windowManagementInterface()) {
if (client && client->windowManagementInterface()) { ids << toplevel->windowManagementInterface()->internalId();
ids << client->windowManagementInterface()->internalId(); uuids << toplevel->windowManagementInterface()->uuid();
uuids << client->windowManagementInterface()->uuid();
} }
} }
m_windowManagement->setStackingOrder(ids); m_windowManagement->setStackingOrder(ids);