void WaylandCompositor::destroyClientForSurface(WaylandSurface *surface)
{
- m_compositor->destroyClientForSurface(surface->handle());
+ destroyClient(surface->client());
+}
+
+void WaylandCompositor::destroyClient(WaylandClient *client)
+{
+ m_compositor->destroyClient(client);
+}
+
+QList<WaylandSurface *> WaylandCompositor::surfacesForClient(WaylandClient* c) const
+{
+ wl_client *client = static_cast<wl_client *>(c);
+
+ QList<Wayland::Surface *> surfaces = m_compositor->surfaces();
+
+ QList<WaylandSurface *> result;
+
+ for (int i = 0; i < surfaces.count(); ++i) {
+ if (surfaces.at(i)->base()->resource.client == client) {
+ result.append(surfaces.at(i)->waylandSurface());
+ }
+ }
+
+ return result;
}
void WaylandCompositor::setDirectRenderSurface(WaylandSurface *surface)
void frameFinished(WaylandSurface *surface = 0);
void destroyClientForSurface(WaylandSurface *surface);
+ void destroyClient(WaylandClient *client);
+
+ QList<WaylandSurface *> surfacesForClient(WaylandClient* client) const;
void setDirectRenderSurface(WaylandSurface *surface);
WaylandSurface *directRenderSurface() const;
connect(this, SIGNAL(windowOrientationChanged()), this, SIGNAL(windowRotationChanged()));
}
+WaylandClient *WaylandSurface::client() const
+{
+ Q_D(const WaylandSurface);
+ return d->surface->base()->resource.client;
+}
+
WaylandSurface *WaylandSurface::parentSurface() const
{
Q_D(const WaylandSurface);
WaylandSurface(Wayland::Surface *surface = 0);
+ WaylandClient *client() const;
+
WaylandSurface *parentSurface() const;
QLinkedList<WaylandSurface *> subSurfaces() const;
# endif
#endif
+typedef void WaylandClient;
+
#endif //WAYLANDEXPORT_H
m_dirty_surfaces.insert(surface);
}
-void Compositor::destroyClientForSurface(Surface *surface)
+void Compositor::destroyClient(WaylandClient *c)
{
- wl_client *client = surface->base()->resource.client;
-
+ wl_client *client = static_cast<wl_client *>(c);
if (client) {
m_windowManagerIntegration->removeClient(client);
wl_client_destroy(client);
void surfaceDestroyed(Surface *surface);
void markSurfaceAsDirty(Surface *surface);
- void destroyClientForSurface(Surface *surface);
+ void destroyClient(WaylandClient *client);
static uint currentTimeMsecs();
Surface *directRenderSurface() const {return m_directRenderSurface;}
QPlatformScreenPageFlipper *pageFlipper() const { return m_pageFlipper; }
+ QList<Surface*> surfaces() const { return m_surfaces; }
QList<Surface*> surfacesForClient(wl_client* client);
-
WaylandCompositor *waylandCompositor() const { return m_qt_compositor; }
struct wl_display *wl_display() const { return m_display->handle(); }
wl_surface *sb = client.createSurface();
QTRY_COMPARE(compositor.surfaces.size(), 2);
+ WaylandClient *ca = compositor.surfaces.at(0)->client();
+ WaylandClient *cb = compositor.surfaces.at(1)->client();
+
+ QCOMPARE(ca, cb);
+
+ QList<WaylandSurface *> surfaces = compositor.surfacesForClient(ca);
+ QCOMPARE(surfaces.size(), 2);
+ QVERIFY((surfaces.at(0) == compositor.surfaces.at(0) && surfaces.at(1) == compositor.surfaces.at(1))
+ || (surfaces.at(0) == compositor.surfaces.at(1) && surfaces.at(1) == compositor.surfaces.at(0)));
+
wl_surface_destroy(sa);
QTRY_COMPARE(compositor.surfaces.size(), 1);
QTRY_COMPARE(compositor.surfaces.size(), 3);
+ WaylandClient *ca = compositor.surfaces.at(0)->client();
+ WaylandClient *cb = compositor.surfaces.at(1)->client();
+ WaylandClient *cc = compositor.surfaces.at(2)->client();
+
+ QVERIFY(ca != cb);
+ QVERIFY(ca != cc);
+ QVERIFY(cb != cc);
+
+ QCOMPARE(compositor.surfacesForClient(ca).size(), 1);
+ QCOMPARE(compositor.surfacesForClient(ca).at(0), compositor.surfaces.at(0));
+
+ QCOMPARE(compositor.surfacesForClient(cb).size(), 1);
+ QCOMPARE(compositor.surfacesForClient(cb).at(0), compositor.surfaces.at(1));
+
+ QCOMPARE(compositor.surfacesForClient(cc).size(), 1);
+ QCOMPARE(compositor.surfacesForClient(cc).at(0), compositor.surfaces.at(2));
+
wl_surface_destroy(sa);
wl_surface_destroy(sb);
wl_surface_destroy(sc);