diff --git a/src/wayland/xdgshell_interface.cpp b/src/wayland/xdgshell_interface.cpp index dbe899dd53..5bae580380 100644 --- a/src/wayland/xdgshell_interface.cpp +++ b/src/wayland/xdgshell_interface.cpp @@ -145,6 +145,10 @@ XdgSurfaceInterfacePrivate::XdgSurfaceInterfacePrivate(XdgSurfaceInterface *xdgS void XdgSurfaceInterfacePrivate::commit() { + if (surface->buffer()) { + firstBufferAttached = true; + } + if (next.acknowledgedConfigureIsSet) { current.acknowledgedConfigure = next.acknowledgedConfigure; next.acknowledgedConfigureIsSet = false; @@ -156,12 +160,11 @@ void XdgSurfaceInterfacePrivate::commit() next.windowGeometryIsSet = false; Q_EMIT q->windowGeometryChanged(current.windowGeometry); } - - isMapped = surface->buffer(); } void XdgSurfaceInterfacePrivate::reset() { + firstBufferAttached = false; isConfigured = false; current = XdgSurfaceState{}; next = XdgSurfaceState{}; @@ -315,21 +318,13 @@ XdgToplevelInterfacePrivate::XdgToplevelInterfacePrivate(XdgToplevelInterface *t void XdgToplevelInterfacePrivate::commit() { auto xdgSurfacePrivate = XdgSurfaceInterfacePrivate::get(xdgSurface); - - bool isResettable = xdgSurfacePrivate->isConfigured && xdgSurfacePrivate->isMapped; - - if (xdgSurfacePrivate->isConfigured) { - xdgSurfacePrivate->commit(); - } else { - Q_EMIT q->initializeRequested(); - return; - } - - if (isResettable && !xdgSurfacePrivate->isMapped) { + if (xdgSurfacePrivate->firstBufferAttached && !xdgSurfacePrivate->surface->buffer()) { reset(); return; } + xdgSurfacePrivate->commit(); + if (current.minimumSize != next.minimumSize) { current.minimumSize = next.minimumSize; Q_EMIT q->minimumSizeChanged(current.minimumSize); @@ -338,6 +333,10 @@ void XdgToplevelInterfacePrivate::commit() current.maximumSize = next.maximumSize; Q_EMIT q->maximumSizeChanged(current.maximumSize); } + + if (!xdgSurfacePrivate->isConfigured) { + Q_EMIT q->initializeRequested(); + } } void XdgToplevelInterfacePrivate::reset() @@ -646,17 +645,15 @@ void XdgPopupInterfacePrivate::commit() } auto xdgSurfacePrivate = XdgSurfaceInterfacePrivate::get(xdgSurface); - bool isResettable = xdgSurfacePrivate->isConfigured && xdgSurfacePrivate->isMapped; - - if (xdgSurfacePrivate->isConfigured) { - xdgSurfacePrivate->commit(); - } else { - Q_EMIT q->initializeRequested(); + if (xdgSurfacePrivate->firstBufferAttached && !xdgSurfacePrivate->surface->buffer()) { + reset(); return; } - if (isResettable && !xdgSurfacePrivate->isMapped) { - reset(); + xdgSurfacePrivate->commit(); + + if (!xdgSurfacePrivate->isConfigured) { + Q_EMIT q->initializeRequested(); } } diff --git a/src/wayland/xdgshell_interface_p.h b/src/wayland/xdgshell_interface_p.h index 6eea727937..0e3190fe2a 100644 --- a/src/wayland/xdgshell_interface_p.h +++ b/src/wayland/xdgshell_interface_p.h @@ -103,7 +103,7 @@ public: QPointer toplevel; QPointer popup; QPointer surface; - bool isMapped = false; + bool firstBufferAttached = false; bool isConfigured = false; XdgSurfaceState next;