Correctly apply initial xdg-shell double buffered state

Some double buffered state, e.g. min and max size, should be applied
when the initial state is committed.
This commit is contained in:
Vlad Zahorodnii 2021-11-08 17:26:32 +02:00
parent f4070a23d5
commit 4da5fff033
2 changed files with 19 additions and 22 deletions

View file

@ -145,6 +145,10 @@ XdgSurfaceInterfacePrivate::XdgSurfaceInterfacePrivate(XdgSurfaceInterface *xdgS
void XdgSurfaceInterfacePrivate::commit() void XdgSurfaceInterfacePrivate::commit()
{ {
if (surface->buffer()) {
firstBufferAttached = true;
}
if (next.acknowledgedConfigureIsSet) { if (next.acknowledgedConfigureIsSet) {
current.acknowledgedConfigure = next.acknowledgedConfigure; current.acknowledgedConfigure = next.acknowledgedConfigure;
next.acknowledgedConfigureIsSet = false; next.acknowledgedConfigureIsSet = false;
@ -156,12 +160,11 @@ void XdgSurfaceInterfacePrivate::commit()
next.windowGeometryIsSet = false; next.windowGeometryIsSet = false;
Q_EMIT q->windowGeometryChanged(current.windowGeometry); Q_EMIT q->windowGeometryChanged(current.windowGeometry);
} }
isMapped = surface->buffer();
} }
void XdgSurfaceInterfacePrivate::reset() void XdgSurfaceInterfacePrivate::reset()
{ {
firstBufferAttached = false;
isConfigured = false; isConfigured = false;
current = XdgSurfaceState{}; current = XdgSurfaceState{};
next = XdgSurfaceState{}; next = XdgSurfaceState{};
@ -315,21 +318,13 @@ XdgToplevelInterfacePrivate::XdgToplevelInterfacePrivate(XdgToplevelInterface *t
void XdgToplevelInterfacePrivate::commit() void XdgToplevelInterfacePrivate::commit()
{ {
auto xdgSurfacePrivate = XdgSurfaceInterfacePrivate::get(xdgSurface); auto xdgSurfacePrivate = XdgSurfaceInterfacePrivate::get(xdgSurface);
if (xdgSurfacePrivate->firstBufferAttached && !xdgSurfacePrivate->surface->buffer()) {
bool isResettable = xdgSurfacePrivate->isConfigured && xdgSurfacePrivate->isMapped;
if (xdgSurfacePrivate->isConfigured) {
xdgSurfacePrivate->commit();
} else {
Q_EMIT q->initializeRequested();
return;
}
if (isResettable && !xdgSurfacePrivate->isMapped) {
reset(); reset();
return; return;
} }
xdgSurfacePrivate->commit();
if (current.minimumSize != next.minimumSize) { if (current.minimumSize != next.minimumSize) {
current.minimumSize = next.minimumSize; current.minimumSize = next.minimumSize;
Q_EMIT q->minimumSizeChanged(current.minimumSize); Q_EMIT q->minimumSizeChanged(current.minimumSize);
@ -338,6 +333,10 @@ void XdgToplevelInterfacePrivate::commit()
current.maximumSize = next.maximumSize; current.maximumSize = next.maximumSize;
Q_EMIT q->maximumSizeChanged(current.maximumSize); Q_EMIT q->maximumSizeChanged(current.maximumSize);
} }
if (!xdgSurfacePrivate->isConfigured) {
Q_EMIT q->initializeRequested();
}
} }
void XdgToplevelInterfacePrivate::reset() void XdgToplevelInterfacePrivate::reset()
@ -646,17 +645,15 @@ void XdgPopupInterfacePrivate::commit()
} }
auto xdgSurfacePrivate = XdgSurfaceInterfacePrivate::get(xdgSurface); auto xdgSurfacePrivate = XdgSurfaceInterfacePrivate::get(xdgSurface);
bool isResettable = xdgSurfacePrivate->isConfigured && xdgSurfacePrivate->isMapped; if (xdgSurfacePrivate->firstBufferAttached && !xdgSurfacePrivate->surface->buffer()) {
reset();
if (xdgSurfacePrivate->isConfigured) {
xdgSurfacePrivate->commit();
} else {
Q_EMIT q->initializeRequested();
return; return;
} }
if (isResettable && !xdgSurfacePrivate->isMapped) { xdgSurfacePrivate->commit();
reset();
if (!xdgSurfacePrivate->isConfigured) {
Q_EMIT q->initializeRequested();
} }
} }

View file

@ -103,7 +103,7 @@ public:
QPointer<XdgToplevelInterface> toplevel; QPointer<XdgToplevelInterface> toplevel;
QPointer<XdgPopupInterface> popup; QPointer<XdgPopupInterface> popup;
QPointer<SurfaceInterface> surface; QPointer<SurfaceInterface> surface;
bool isMapped = false; bool firstBufferAttached = false;
bool isConfigured = false; bool isConfigured = false;
XdgSurfaceState next; XdgSurfaceState next;