From 997b12fd56a5b6b4dfd60d6fcf7d5c62e8fabde0 Mon Sep 17 00:00:00 2001 From: David Redondo Date: Wed, 31 Jan 2024 17:03:04 +0100 Subject: [PATCH] client: Roundtrip in an own queue when exporting window instead of default queue This way no other events will be dispatched which could cause calls into user code when delivering events synchronously. Change-Id: I5c195877388d178832067b5aba6b5f5abd26e099 Reviewed-by: David Edmundson --- .../xdg-shell/qwaylandxdgexporterv2.cpp | 6 ------ .../xdg-shell/qwaylandxdgexporterv2_p.h | 1 - .../shellintegration/xdg-shell/qwaylandxdgshell.cpp | 13 +++++++++++-- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgexporterv2.cpp b/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgexporterv2.cpp index 58baad02412..5cbbecc5396 100644 --- a/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgexporterv2.cpp +++ b/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgexporterv2.cpp @@ -36,12 +36,6 @@ QWaylandXdgExporterV2::~QWaylandXdgExporterV2() { destroy(); } - -QtWaylandClient::QWaylandXdgExportedV2 *QWaylandXdgExporterV2::exportToplevel(wl_surface *surface) -{ - return new QWaylandXdgExportedV2(export_toplevel(surface)); -} - } QT_END_NAMESPACE diff --git a/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgexporterv2_p.h b/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgexporterv2_p.h index b260dbacbac..c993e390a24 100644 --- a/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgexporterv2_p.h +++ b/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgexporterv2_p.h @@ -40,7 +40,6 @@ class QWaylandXdgExporterV2 : public QtWayland::zxdg_exporter_v2 public: QWaylandXdgExporterV2(wl_registry *registry, uint32_t id, int version); ~QWaylandXdgExporterV2() override; - QWaylandXdgExportedV2 *exportToplevel(wl_surface *surface); }; } diff --git a/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp b/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp index 977657e59f6..498710bebe7 100644 --- a/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp +++ b/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp @@ -711,9 +711,18 @@ QString QWaylandXdgSurface::externWindowHandle() return QString(); } if (!m_toplevel->m_exported) { - m_toplevel->m_exported.reset(m_shell->exporter()->exportToplevel(m_window->wlSurface())); + auto *exporterWrapper = static_cast( + wl_proxy_create_wrapper(m_shell->exporter()->object())); + auto exportQueue = wl_display_create_queue(m_shell->display()->wl_display()); + wl_proxy_set_queue(reinterpret_cast(exporterWrapper), exportQueue); + m_toplevel->m_exported.reset(new QWaylandXdgExportedV2( + zxdg_exporter_v2_export_toplevel(exporterWrapper, m_window->wlSurface()))); // handle events is sent immediately - m_shell->display()->forceRoundTrip(); + wl_display_roundtrip_queue(m_shell->display()->wl_display(), exportQueue); + + wl_proxy_set_queue(reinterpret_cast(m_toplevel->m_exported->object()), nullptr); + wl_proxy_wrapper_destroy(exporterWrapper); + wl_event_queue_destroy(exportQueue); } return m_toplevel->m_exported->handle(); }