diff options
4 files changed, 24 insertions, 1 deletions
diff --git a/src/compositor/compositor_api/qwaylandsurface.cpp b/src/compositor/compositor_api/qwaylandsurface.cpp index 88b68ebd..8c4c7035 100644 --- a/src/compositor/compositor_api/qwaylandsurface.cpp +++ b/src/compositor/compositor_api/qwaylandsurface.cpp @@ -352,4 +352,11 @@ void QWaylandSurface::destroySurfaceByForce() wl_resource_destroy(surface_resource); } +void QWaylandSurface::ping() +{ + Q_D(QWaylandSurface); + if (d->surface->shellSurface()) + d->surface->shellSurface()->ping(); +} + QT_END_NAMESPACE diff --git a/src/compositor/compositor_api/qwaylandsurface.h b/src/compositor/compositor_api/qwaylandsurface.h index 7de4b709..6714ca83 100644 --- a/src/compositor/compositor_api/qwaylandsurface.h +++ b/src/compositor/compositor_api/qwaylandsurface.h @@ -163,6 +163,7 @@ public: Q_INVOKABLE void destroySurface(); Q_INVOKABLE void destroySurfaceByForce(); + Q_INVOKABLE void ping(); signals: void mapped(); void unmapped(); @@ -180,6 +181,7 @@ signals: void raiseRequested(); void lowerRequested(); void visibilityChanged(); + void pong(); }; QT_END_NAMESPACE diff --git a/src/compositor/wayland_wrapper/qwlshellsurface.cpp b/src/compositor/wayland_wrapper/qwlshellsurface.cpp index a1e6bb37..62f9c5e0 100644 --- a/src/compositor/wayland_wrapper/qwlshellsurface.cpp +++ b/src/compositor/wayland_wrapper/qwlshellsurface.cpp @@ -96,6 +96,13 @@ void ShellSurface::sendConfigure(uint32_t edges, int32_t width, int32_t height) send_configure(edges, width, height); } +void ShellSurface::ping() +{ + uint32_t serial = wl_display_next_serial(m_surface->compositor()->wl_display()); + m_pings.insert(serial); + send_ping(serial); +} + Surface *ShellSurface::surface() const { return m_surface; @@ -279,7 +286,10 @@ void ShellSurface::shell_surface_pong(Resource *resource, uint32_t serial) { Q_UNUSED(resource); - Q_UNUSED(serial); + if (m_pings.remove(serial)) + emit m_surface->waylandSurface()->pong(); + else + qWarning("Received an unexpected pong!"); } void ShellSurface::shell_surface_set_title(Resource *resource, diff --git a/src/compositor/wayland_wrapper/qwlshellsurface_p.h b/src/compositor/wayland_wrapper/qwlshellsurface_p.h index 91fb17c2..5c507884 100644 --- a/src/compositor/wayland_wrapper/qwlshellsurface_p.h +++ b/src/compositor/wayland_wrapper/qwlshellsurface_p.h @@ -43,6 +43,7 @@ #include <wayland-server.h> #include <QPoint> +#include <QSet> #include <private/qwlpointer_p.h> #include <qwayland-server-wayland.h> @@ -78,6 +79,7 @@ class ShellSurface : public QtWaylandServer::wl_shell_surface public: ShellSurface(struct wl_client *client, uint32_t id, Surface *surface); void sendConfigure(uint32_t edges, int32_t width, int32_t height); + void ping(); Surface *surface() const; @@ -100,6 +102,8 @@ private: int32_t m_xOffset; int32_t m_yOffset; + QSet<uint32_t> m_pings; + void shell_surface_destroy_resource(Resource *resource) Q_DECL_OVERRIDE; void shell_surface_move(Resource *resource, |