Client: Test for xdg toplevel min and max size
Change-Id: I60605f494eebfde9a7737911eefe69a93041ced5 Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
This commit is contained in:
parent
3572bcb831
commit
8d23c3b5b8
@ -149,6 +149,7 @@ XdgToplevel::XdgToplevel(XdgSurface *xdgSurface, int id, int version)
|
|||||||
: QtWaylandServer::xdg_toplevel(xdgSurface->resource()->client(), id, version)
|
: QtWaylandServer::xdg_toplevel(xdgSurface->resource()->client(), id, version)
|
||||||
, m_xdgSurface(xdgSurface)
|
, m_xdgSurface(xdgSurface)
|
||||||
{
|
{
|
||||||
|
connect(surface(), &Surface::commit, this, [this] { m_committed = m_pending; });
|
||||||
}
|
}
|
||||||
|
|
||||||
void XdgToplevel::sendConfigure(const QSize &size, const QVector<uint> &states)
|
void XdgToplevel::sendConfigure(const QSize &size, const QVector<uint> &states)
|
||||||
@ -162,6 +163,22 @@ uint XdgToplevel::sendCompleteConfigure(const QSize &size, const QVector<uint> &
|
|||||||
return m_xdgSurface->sendConfigure();
|
return m_xdgSurface->sendConfigure();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void XdgToplevel::xdg_toplevel_set_max_size(Resource *resource, int32_t width, int32_t height)
|
||||||
|
{
|
||||||
|
Q_UNUSED(resource);
|
||||||
|
QSize size(width, height);
|
||||||
|
QVERIFY(size.isValid());
|
||||||
|
m_pending.maxSize = size;
|
||||||
|
}
|
||||||
|
|
||||||
|
void XdgToplevel::xdg_toplevel_set_min_size(Resource *resource, int32_t width, int32_t height)
|
||||||
|
{
|
||||||
|
Q_UNUSED(resource);
|
||||||
|
QSize size(width, height);
|
||||||
|
QVERIFY(size.isValid());
|
||||||
|
m_pending.minSize = size;
|
||||||
|
}
|
||||||
|
|
||||||
XdgPopup::XdgPopup(XdgSurface *xdgSurface, int id, int version)
|
XdgPopup::XdgPopup(XdgSurface *xdgSurface, int id, int version)
|
||||||
: QtWaylandServer::xdg_popup(xdgSurface->resource()->client(), id, version)
|
: QtWaylandServer::xdg_popup(xdgSurface->resource()->client(), id, version)
|
||||||
, m_xdgSurface(xdgSurface)
|
, m_xdgSurface(xdgSurface)
|
||||||
|
@ -99,14 +99,24 @@ protected:
|
|||||||
void xdg_surface_ack_configure(Resource *resource, uint32_t serial) override;
|
void xdg_surface_ack_configure(Resource *resource, uint32_t serial) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
class XdgToplevel : public QtWaylandServer::xdg_toplevel
|
class XdgToplevel : public QObject, public QtWaylandServer::xdg_toplevel
|
||||||
{
|
{
|
||||||
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit XdgToplevel(XdgSurface *xdgSurface, int id, int version = 1);
|
explicit XdgToplevel(XdgSurface *xdgSurface, int id, int version = 1);
|
||||||
void sendConfigure(const QSize &size = {0, 0}, const QVector<uint> &states = {});
|
void sendConfigure(const QSize &size = {0, 0}, const QVector<uint> &states = {});
|
||||||
uint sendCompleteConfigure(const QSize &size = {0, 0}, const QVector<uint> &states = {});
|
uint sendCompleteConfigure(const QSize &size = {0, 0}, const QVector<uint> &states = {});
|
||||||
Surface *surface() { return m_xdgSurface->m_surface; }
|
Surface *surface() { return m_xdgSurface->m_surface; }
|
||||||
|
|
||||||
XdgSurface *m_xdgSurface = nullptr;
|
XdgSurface *m_xdgSurface = nullptr;
|
||||||
|
struct DoubleBufferedState {
|
||||||
|
QSize minSize = {0, 0};
|
||||||
|
QSize maxSize = {0, 0};
|
||||||
|
} m_pending, m_committed;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void xdg_toplevel_set_max_size(Resource *resource, int32_t width, int32_t height) override;
|
||||||
|
void xdg_toplevel_set_min_size(Resource *resource, int32_t width, int32_t height) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
class XdgPopup : public QtWaylandServer::xdg_popup
|
class XdgPopup : public QtWaylandServer::xdg_popup
|
||||||
|
@ -43,6 +43,7 @@ private slots:
|
|||||||
void configureStates();
|
void configureStates();
|
||||||
void popup();
|
void popup();
|
||||||
void pongs();
|
void pongs();
|
||||||
|
void minMaxSize();
|
||||||
};
|
};
|
||||||
|
|
||||||
void tst_xdgshell::showMinimized()
|
void tst_xdgshell::showMinimized()
|
||||||
@ -265,5 +266,26 @@ void tst_xdgshell::pongs()
|
|||||||
QCOMPARE(pongSpy.first().at(0).toUInt(), serial);
|
QCOMPARE(pongSpy.first().at(0).toUInt(), serial);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void tst_xdgshell::minMaxSize()
|
||||||
|
{
|
||||||
|
QRasterWindow window;
|
||||||
|
window.setMinimumSize(QSize(100, 100));
|
||||||
|
window.setMaximumSize(QSize(1000, 1000));
|
||||||
|
window.resize(400, 320);
|
||||||
|
window.show();
|
||||||
|
QCOMPOSITOR_TRY_VERIFY(xdgToplevel());
|
||||||
|
|
||||||
|
exec([=] { xdgToplevel()->sendCompleteConfigure(); });
|
||||||
|
|
||||||
|
QCOMPOSITOR_TRY_COMPARE(xdgToplevel()->m_committed.minSize, QSize(100, 100));
|
||||||
|
QCOMPOSITOR_TRY_COMPARE(xdgToplevel()->m_committed.maxSize, QSize(1000, 1000));
|
||||||
|
|
||||||
|
window.setMaximumSize(QSize(500, 400));
|
||||||
|
QCOMPOSITOR_TRY_COMPARE(xdgToplevel()->m_committed.maxSize, QSize(500, 400));
|
||||||
|
|
||||||
|
window.setMinimumSize(QSize(50, 40));
|
||||||
|
QCOMPOSITOR_TRY_COMPARE(xdgToplevel()->m_committed.minSize, QSize(50, 40));
|
||||||
|
}
|
||||||
|
|
||||||
QCOMPOSITOR_TEST_MAIN(tst_xdgshell)
|
QCOMPOSITOR_TEST_MAIN(tst_xdgshell)
|
||||||
#include "tst_xdgshell.moc"
|
#include "tst_xdgshell.moc"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user