diff options
author | David Edmundson <[email protected]> | 2025-06-13 10:07:58 +0100 |
---|---|---|
committer | David Edmundson <[email protected]> | 2025-06-27 15:21:45 +0000 |
commit | 2f221dbb376ac0fa1b1198b112cfc439137a0c13 (patch) | |
tree | 1b83a2350b493a1a2e62fa4d122102d70bc83249 /src | |
parent | b8c09d2e3b1eabf3f908ca9e0633a4430a976f89 (diff) |
wayland: Move error checking before xdg surface creation
8c0dd12f4bf7a09304a136c9ceacfb60e0632e50 changed behaviour when
QtWayland is asked to enter an invalid state of creating a popup where
no parent window is explicitly set or can be guessed. It now early
returns before creating an xdg role.
It is apparently an error on some compositors to create and then destroy
an xdg_surface without creating a role.
Fixes: QTBUG-137702
Pick-to: 6.10
Change-Id: I8b4dcb54f03660cb47e93b54a68834b371f76c71
Reviewed-by: David Redondo <[email protected]>
Diffstat (limited to 'src')
2 files changed, 24 insertions, 16 deletions
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 9c40103d1e5..b19899db59a 100644 --- a/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp +++ b/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp @@ -331,23 +331,13 @@ QWaylandXdgSurface::QWaylandXdgSurface(QWaylandXdgShell *shell, ::xdg_surface *s Qt::WindowType type = static_cast<Qt::WindowType>(int(window->windowFlags() & Qt::WindowType_Mask)); auto *transientParent = window->transientParent(); - if (type == Qt::ToolTip) { - if (transientParent) { - setPopup(transientParent); - } else { - qCWarning(lcQpaWayland) << "Failed to create popup. Ensure popup " << window->window() << "has a transientParent set."; - QWindowSystemInterface::handleCloseEvent<QWindowSystemInterface::AsynchronousDelivery>(m_window->window()); - } - } else if (type == Qt::Popup ) { - if (transientParent && display->lastInputDevice()) { - setGrabPopup(transientParent, display->lastInputDevice(), display->lastInputSerial()); - } else { - qCWarning(lcQpaWayland) << "Failed to create grabbing popup. Ensure popup " << window->window() << "has a transientParent set and that parent window has received input."; - QWindowSystemInterface::handleCloseEvent<QWindowSystemInterface::AsynchronousDelivery>(m_window->window()); - } - } else { + if (type == Qt::ToolTip) + setPopup(transientParent); + else if (type == Qt::Popup ) + setGrabPopup(transientParent, display->lastInputDevice(), display->lastInputSerial()); + else setToplevel(); - } + setSizeHints(); } diff --git a/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp b/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp index f1bb8bee478..90a5965bba6 100644 --- a/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp +++ b/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp @@ -8,6 +8,8 @@ #include <QtWaylandClient/private/qwaylandwindow_p.h> #include <QtWaylandClient/private/qwaylanddisplay_p.h> +#include <qpa/qwindowsysteminterface.h> + QT_BEGIN_NAMESPACE namespace QtWaylandClient { @@ -43,6 +45,22 @@ void QWaylandXdgShellIntegration::xdg_wm_base_ping(uint32_t serial) QWaylandShellSurface *QWaylandXdgShellIntegration::createShellSurface(QWaylandWindow *window) { + QWaylandDisplay *display = window->display(); + Qt::WindowType type = static_cast<Qt::WindowType>(int(window->windowFlags() & Qt::WindowType_Mask)); + auto *transientParent = window->transientParent(); + + if (type == Qt::ToolTip && !transientParent) { + qCWarning(lcQpaWayland) << "Failed to create popup. Ensure popup " << window->window() << "has a transientParent set."; + QWindowSystemInterface::handleCloseEvent<QWindowSystemInterface::AsynchronousDelivery>(window->window()); + return new QWaylandShellSurface(window); + } + + if (type == Qt::Popup && (!transientParent || !display->lastInputDevice())) { + qCWarning(lcQpaWayland) << "Failed to create grabbing popup. Ensure popup " << window->window() << "has a transientParent set and that parent window has received input."; + QWindowSystemInterface::handleCloseEvent<QWindowSystemInterface::AsynchronousDelivery>(window->window()); + return new QWaylandShellSurface(window); + } + return new QWaylandXdgSurface(mXdgShell.get(), get_xdg_surface(window->wlSurface()), window); } |