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
(cherry picked from commit 43cac750343ad107ab92f29628cabb2a70a8d17f)
icc-effect-5.27.2
Vlad Zahorodnii 2023-02-27 16:54:14 +02:00
parent 548ccc8036
commit c6b91e901a
2 changed files with 6 additions and 2 deletions

View File

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

View File

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