From 4f8399d3070ad70c297175a848a7a20e3ae5468f Mon Sep 17 00:00:00 2001 From: David Rosca Date: Mon, 17 Apr 2023 13:37:47 +0200 Subject: [PATCH] QWaylandWindow: Init parent wl_surface when creating subsurface Fixes recreating subsurfaces after hiding and then again showing the window. Pick-to: 6.5 Change-Id: I2e3e7ceb42ec6b25cb64db260dfb74f6ebb10d27 Reviewed-by: David Edmundson --- src/plugins/platforms/wayland/qwaylandwindow.cpp | 2 ++ tests/auto/wayland/surface/tst_surface.cpp | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/src/plugins/platforms/wayland/qwaylandwindow.cpp b/src/plugins/platforms/wayland/qwaylandwindow.cpp index 2b7f199c05f..7634aedd6e9 100644 --- a/src/plugins/platforms/wayland/qwaylandwindow.cpp +++ b/src/plugins/platforms/wayland/qwaylandwindow.cpp @@ -131,6 +131,8 @@ void QWaylandWindow::initWindow() Q_ASSERT(!mSubSurfaceWindow); auto *parent = static_cast(QPlatformWindow::parent()); + if (!parent->mSurface) + parent->initializeWlSurface(); if (parent->wlSurface()) { if (::wl_subsurface *subsurface = mDisplay->createSubSurface(this, parent)) mSubSurfaceWindow = new QWaylandSubSurface(this, parent, subsurface); diff --git a/tests/auto/wayland/surface/tst_surface.cpp b/tests/auto/wayland/surface/tst_surface.cpp index 083bc4faa90..b583390f024 100644 --- a/tests/auto/wayland/surface/tst_surface.cpp +++ b/tests/auto/wayland/surface/tst_surface.cpp @@ -199,6 +199,10 @@ void tst_surface::createSubsurfaceForHiddenParent() // Make sure the client doesn't quit before it has a chance to crash xdgPingAndWaitForPong(); + + // Make sure the subsurface was actually created + const Subsurface *subsurface = exec([=] {return subSurface(0);}); + QVERIFY(subsurface); } QCOMPOSITOR_TEST_MAIN(tst_surface)