wayland: Fix xdg-toplevel and xdg-popup window initialization

Buggy clients can commit the wl_surface several times in a row. On the
other hand, XdgToplevelInterface and XdgPopupInterface consider a
surface to be initialized if it has been configured. If the second
wl_surface commit comes before the configure event is sent, kwin will
initialize a toplevel or popup twice, which can trigger asserts.

BUG: 466530
master
Vlad Zahorodnii 2 years ago
parent 4cda16ce3a
commit 43cac75034

@ -155,6 +155,7 @@ void XdgSurfaceInterfacePrivate::reset()
{ {
firstBufferAttached = false; firstBufferAttached = false;
isConfigured = false; isConfigured = false;
isInitialized = false;
current = XdgSurfaceState{}; current = XdgSurfaceState{};
next = XdgSurfaceState{}; next = XdgSurfaceState{};
Q_EMIT q->resetOccurred(); Q_EMIT q->resetOccurred();
@ -321,8 +322,9 @@ void XdgToplevelInterfacePrivate::commit()
Q_EMIT q->maximumSizeChanged(current.maximumSize); Q_EMIT q->maximumSizeChanged(current.maximumSize);
} }
if (!xdgSurfacePrivate->isConfigured) { if (!xdgSurfacePrivate->isInitialized) {
Q_EMIT q->initializeRequested(); Q_EMIT q->initializeRequested();
xdgSurfacePrivate->isInitialized = true;
} }
} }
@ -622,8 +624,9 @@ void XdgPopupInterfacePrivate::commit()
xdgSurfacePrivate->commit(); xdgSurfacePrivate->commit();
if (!xdgSurfacePrivate->isConfigured) { if (!xdgSurfacePrivate->isInitialized) {
Q_EMIT q->initializeRequested(); Q_EMIT q->initializeRequested();
xdgSurfacePrivate->isInitialized = true;
} }
} }

@ -105,6 +105,7 @@ public:
QPointer<SurfaceInterface> surface; QPointer<SurfaceInterface> surface;
bool firstBufferAttached = false; bool firstBufferAttached = false;
bool isConfigured = false; bool isConfigured = false;
bool isInitialized = false;
XdgSurfaceState next; XdgSurfaceState next;
XdgSurfaceState current; XdgSurfaceState current;

Loading…
Cancel
Save