Commit 21f8d7c2 authored by Martina Flöser's avatar Martina Flöser Committed by Martin Flöser
Browse files

Implement ShellSurface::setMaximized

Client and Server part of setting a ShellSurface to maximized.
parent 5dcb3589
......@@ -45,6 +45,7 @@ private Q_SLOTS:
void testCreateMultiple();
void testFullscreen();
void testMaximize();
void testPing();
void testTitle();
void testWindowClass();
......@@ -247,6 +248,46 @@ void TestWaylandShell::testFullscreen()
QVERIFY(!fullscreenSpy.first().first().toBool());
}
void TestWaylandShell::testMaximize()
{
using namespace KWayland::Server;
QScopedPointer<KWayland::Client::Surface> s(m_compositor->createSurface());
QVERIFY(!s.isNull());
QVERIFY(s->isValid());
KWayland::Client::ShellSurface *surface = m_shell->createSurface(s.data(), m_shell);
QSignalSpy sizeSpy(surface, SIGNAL(sizeChanged(QSize)));
QVERIFY(sizeSpy.isValid());
QCOMPARE(surface->size(), QSize());
QSignalSpy serverSurfaceSpy(m_shellInterface, SIGNAL(surfaceCreated(KWayland::Server::ShellSurfaceInterface*)));
QVERIFY(serverSurfaceSpy.isValid());
QVERIFY(serverSurfaceSpy.wait());
ShellSurfaceInterface *serverSurface = serverSurfaceSpy.first().first().value<ShellSurfaceInterface*>();
QVERIFY(serverSurface);
QVERIFY(serverSurface->parentResource());
QSignalSpy maximizedSpy(serverSurface, SIGNAL(maximizedChanged(bool)));
QVERIFY(maximizedSpy.isValid());
surface->setMaximized();
QVERIFY(maximizedSpy.wait());
QCOMPARE(maximizedSpy.count(), 1);
QVERIFY(maximizedSpy.first().first().toBool());
serverSurface->requestSize(QSize(1024, 768));
QVERIFY(sizeSpy.wait());
QCOMPARE(sizeSpy.count(), 1);
QCOMPARE(sizeSpy.first().first().toSize(), QSize(1024, 768));
QCOMPARE(surface->size(), QSize(1024, 768));
// set back to toplevel
maximizedSpy.clear();
wl_shell_surface_set_toplevel(*surface);
QVERIFY(maximizedSpy.wait());
QCOMPARE(maximizedSpy.count(), 1);
QVERIFY(!maximizedSpy.first().first().toBool());
}
void TestWaylandShell::testPing()
{
using namespace KWayland::Server;
......
......@@ -68,6 +68,7 @@ public:
Private(ShellSurfaceInterface *q, ShellInterface *shell, SurfaceInterface *surface, wl_resource *parentResource);
void setFullscreen(bool fullscreen);
void setToplevel(bool toplevel);
void setMaximized(bool maximized);
void ping();
SurfaceInterface *surface;
......@@ -77,6 +78,7 @@ public:
quint32 pingSerial = 0;
bool fullscreen = false;
bool toplevel = false;
bool maximized = false;
private:
// interface callbacks
......@@ -188,6 +190,7 @@ ShellSurfaceInterface::ShellSurfaceInterface(ShellInterface *shell, SurfaceInter
}
Q_D();
d->setToplevel(false);
d->setMaximized(false);
}
);
connect(this, &ShellSurfaceInterface::toplevelChanged, this,
......@@ -197,6 +200,17 @@ ShellSurfaceInterface::ShellSurfaceInterface(ShellInterface *shell, SurfaceInter
}
Q_D();
d->setFullscreen(false);
d->setMaximized(false);
}
);
connect(this, &ShellSurfaceInterface::maximizedChanged, this,
[this] (bool maximized) {
if (!maximized) {
return;
}
Q_D();
d->setFullscreen(false);
d->setToplevel(false);
}
);
}
......@@ -345,7 +359,17 @@ void ShellSurfaceInterface::Private::setMaximizedCallback(wl_client *client, wl_
Q_UNUSED(output)
auto s = cast<Private>(resource);
Q_ASSERT(client == *s->client);
// TODO: implement
s->setMaximized(true);
}
void ShellSurfaceInterface::Private::setMaximized(bool set)
{
if (maximized == set) {
return;
}
maximized = set;
Q_Q(ShellSurfaceInterface);
emit q->maximizedChanged(maximized);
}
void ShellSurfaceInterface::Private::setTitleCallback(wl_client *client, wl_resource *resource, const char *title)
......@@ -412,6 +436,11 @@ bool ShellSurfaceInterface::isToplevel() const {
return d->toplevel;
}
bool ShellSurfaceInterface::isMaximized() const {
Q_D();
return d->maximized;
}
ShellSurfaceInterface::Private *ShellSurfaceInterface::d_func() const
{
return reinterpret_cast<ShellSurfaceInterface::Private*>(d.data());
......
......@@ -61,6 +61,7 @@ class KWAYLANDSERVER_EXPORT ShellSurfaceInterface : public Resource
Q_PROPERTY(QByteArray windowClass READ windowClass NOTIFY windowClassChanged)
Q_PROPERTY(bool fullscreen READ isFullscreen NOTIFY fullscreenChanged)
Q_PROPERTY(bool toplevel READ isToplevel NOTIFY toplevelChanged)
Q_PROPERTY(bool maximized READ isMaximized NOTIFY maximizedChanged)
public:
virtual ~ShellSurfaceInterface();
......@@ -76,6 +77,7 @@ public:
QByteArray windowClass() const;
bool isFullscreen() const;
bool isToplevel() const;
bool isMaximized() const;
Q_SIGNALS:
void titleChanged(const QString&);
......@@ -84,6 +86,7 @@ Q_SIGNALS:
void pongReceived();
void fullscreenChanged(bool);
void toplevelChanged(bool);
void maximizedChanged(bool);
private:
friend class ShellInterface;
......
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