QWaylandClient *QWaylandClient::fromWlClient(wl_client *wlClient) { if (!wlClient) return 0; QWaylandClient *client = Q_NULLPTR; wl_listener *l = wl_client_get_destroy_listener(wlClient, QWaylandClientPrivate::client_destroy_callback); if (l) client = reinterpret_cast<QWaylandClientPrivate::Listener *>( wl_container_of(l, (QWaylandClientPrivate::Listener *)0, listener))->parent; if (!client) { // The original idea was to create QWaylandClient instances when // a client bound wl_compositor, but it's legal for a client to // bind several times resulting in multiple QWaylandClient // instances for the same wl_client therefore we create it from // here on demand client = new QWaylandClient(wlClient); QtWayland::Compositor::instance()->m_clients.append(client); } return client; }
//static client Client* Client::find(wl_client& client) { wl_listener* listener = wl_client_get_destroy_listener(&client, &clientDestroyListener); if(listener) { Client::listenerPOD* pod; pod = wl_container_of(listener, pod, listener); if(pod) return pod->client; else return nullptr; } else { return nullptr; } }