Add a WaylandServer::findClient which takes a QWindow

Of course only works with internal clients.
This commit is contained in:
Martin Gräßlin 2015-08-17 14:56:15 +02:00
parent f76c18bfb8
commit 9272d01a2d
2 changed files with 17 additions and 0 deletions

View file

@ -422,6 +422,22 @@ ShellClient *WaylandServer::findClient(SurfaceInterface *surface) const
return nullptr;
}
ShellClient *WaylandServer::findClient(QWindow *w) const
{
if (!w) {
return nullptr;
}
auto it = std::find_if(m_internalClients.constBegin(), m_internalClients.constEnd(),
[w] (const ShellClient *c) {
return c->internalWindow() == w;
}
);
if (it != m_internalClients.constEnd()) {
return *it;
}
return nullptr;
}
quint32 WaylandServer::createWindowId(SurfaceInterface *surface)
{
auto it = m_clientIds.constFind(surface->client());

View file

@ -90,6 +90,7 @@ public:
void removeClient(ShellClient *c);
ShellClient *findClient(quint32 id) const;
ShellClient *findClient(KWayland::Server::SurfaceInterface *surface) const;
ShellClient *findClient(QWindow *w) const;
AbstractBackend *backend() const {
return m_backend;