Commit c5691ba4 authored by Vlad Zahorodnii's avatar Vlad Zahorodnii
Browse files

Make xdg-surface acknowledged configure serials double-buffered state

This will be needed to delay applying surface state.
parent 9210e25c
......@@ -544,6 +544,7 @@ void XdgShellTest::testConfigureStates()
QVERIFY(ackSpy.isValid());
xdgSurface->ackConfigure(configureSpy.first().at(2).value<quint32>());
surface->commit(Surface::CommitFlag::None);
QVERIFY(ackSpy.wait());
QCOMPARE(ackSpy.count(), 1);
QCOMPARE(ackSpy.first().first().value<quint32>(), configureSpy.first().at(2).value<quint32>());
......@@ -590,6 +591,7 @@ void XdgShellTest::testConfigureMultipleAcks()
QCOMPARE(xdgSurface->size(), QSize(30, 40));
xdgSurface->ackConfigure(serial3);
surface->commit(Surface::CommitFlag::None);
QVERIFY(ackSpy.wait());
QCOMPARE(ackSpy.count(), 1);
QCOMPARE(ackSpy.last().first().value<quint32>(), serial3);
......
......@@ -151,17 +151,26 @@ XdgSurfaceInterfacePrivate::XdgSurfaceInterfacePrivate(XdgSurfaceInterface *xdgS
void XdgSurfaceInterfacePrivate::commit()
{
if (current.windowGeometry != next.windowGeometry) {
if (next.acknowledgedConfigureIsSet) {
current.acknowledgedConfigure = next.acknowledgedConfigure;
next.acknowledgedConfigureIsSet = false;
Q_EMIT q->configureAcknowledged(current.acknowledgedConfigure);
}
if (next.windowGeometryIsSet) {
current.windowGeometry = next.windowGeometry;
next.windowGeometryIsSet = false;
Q_EMIT q->windowGeometryChanged(current.windowGeometry);
}
isMapped = surface->buffer();
}
void XdgSurfaceInterfacePrivate::reset()
{
isConfigured = false;
current = next = State();
current = XdgSurfaceState{};
next = XdgSurfaceState{};
Q_EMIT q->resetOccurred();
}
......@@ -253,12 +262,14 @@ void XdgSurfaceInterfacePrivate::xdg_surface_set_window_geometry(Resource *resou
}
next.windowGeometry = QRect(x, y, width, height);
next.windowGeometryIsSet = true;
}
void XdgSurfaceInterfacePrivate::xdg_surface_ack_configure(Resource *resource, uint32_t serial)
{
Q_UNUSED(resource)
Q_EMIT q->configureAcknowledged(serial);
next.acknowledgedConfigure = serial;
next.acknowledgedConfigureIsSet = true;
}
XdgSurfaceInterface::XdgSurfaceInterface(XdgShellInterface *shell, SurfaceInterface *surface,
......
......@@ -84,6 +84,14 @@ protected:
void xdg_positioner_set_parent_configure(Resource *resource, uint32_t serial) override;
};
struct XdgSurfaceState
{
QRect windowGeometry;
quint32 acknowledgedConfigure;
bool acknowledgedConfigureIsSet : 1 = false;
bool windowGeometryIsSet : 1 = false;
};
class XdgSurfaceInterfacePrivate : public QtWaylandServer::xdg_surface
{
public:
......@@ -100,13 +108,8 @@ public:
bool isMapped = false;
bool isConfigured = false;
struct State
{
QRect windowGeometry;
};
State next;
State current;
XdgSurfaceState next;
XdgSurfaceState current;
static XdgSurfaceInterfacePrivate *get(XdgSurfaceInterface *surface);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment