Implement ShellSurface::setMaximized
Client and Server part of setting a ShellSurface to maximized.
This commit is contained in:
parent
5dcb3589b3
commit
21f8d7c23a
3 changed files with 74 additions and 1 deletions
|
@ -45,6 +45,7 @@ private Q_SLOTS:
|
||||||
|
|
||||||
void testCreateMultiple();
|
void testCreateMultiple();
|
||||||
void testFullscreen();
|
void testFullscreen();
|
||||||
|
void testMaximize();
|
||||||
void testPing();
|
void testPing();
|
||||||
void testTitle();
|
void testTitle();
|
||||||
void testWindowClass();
|
void testWindowClass();
|
||||||
|
@ -247,6 +248,46 @@ void TestWaylandShell::testFullscreen()
|
||||||
QVERIFY(!fullscreenSpy.first().first().toBool());
|
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()
|
void TestWaylandShell::testPing()
|
||||||
{
|
{
|
||||||
using namespace KWayland::Server;
|
using namespace KWayland::Server;
|
||||||
|
|
|
@ -68,6 +68,7 @@ public:
|
||||||
Private(ShellSurfaceInterface *q, ShellInterface *shell, SurfaceInterface *surface, wl_resource *parentResource);
|
Private(ShellSurfaceInterface *q, ShellInterface *shell, SurfaceInterface *surface, wl_resource *parentResource);
|
||||||
void setFullscreen(bool fullscreen);
|
void setFullscreen(bool fullscreen);
|
||||||
void setToplevel(bool toplevel);
|
void setToplevel(bool toplevel);
|
||||||
|
void setMaximized(bool maximized);
|
||||||
void ping();
|
void ping();
|
||||||
|
|
||||||
SurfaceInterface *surface;
|
SurfaceInterface *surface;
|
||||||
|
@ -77,6 +78,7 @@ public:
|
||||||
quint32 pingSerial = 0;
|
quint32 pingSerial = 0;
|
||||||
bool fullscreen = false;
|
bool fullscreen = false;
|
||||||
bool toplevel = false;
|
bool toplevel = false;
|
||||||
|
bool maximized = false;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// interface callbacks
|
// interface callbacks
|
||||||
|
@ -188,6 +190,7 @@ ShellSurfaceInterface::ShellSurfaceInterface(ShellInterface *shell, SurfaceInter
|
||||||
}
|
}
|
||||||
Q_D();
|
Q_D();
|
||||||
d->setToplevel(false);
|
d->setToplevel(false);
|
||||||
|
d->setMaximized(false);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
connect(this, &ShellSurfaceInterface::toplevelChanged, this,
|
connect(this, &ShellSurfaceInterface::toplevelChanged, this,
|
||||||
|
@ -197,6 +200,17 @@ ShellSurfaceInterface::ShellSurfaceInterface(ShellInterface *shell, SurfaceInter
|
||||||
}
|
}
|
||||||
Q_D();
|
Q_D();
|
||||||
d->setFullscreen(false);
|
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)
|
Q_UNUSED(output)
|
||||||
auto s = cast<Private>(resource);
|
auto s = cast<Private>(resource);
|
||||||
Q_ASSERT(client == *s->client);
|
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)
|
void ShellSurfaceInterface::Private::setTitleCallback(wl_client *client, wl_resource *resource, const char *title)
|
||||||
|
@ -412,6 +436,11 @@ bool ShellSurfaceInterface::isToplevel() const {
|
||||||
return d->toplevel;
|
return d->toplevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ShellSurfaceInterface::isMaximized() const {
|
||||||
|
Q_D();
|
||||||
|
return d->maximized;
|
||||||
|
}
|
||||||
|
|
||||||
ShellSurfaceInterface::Private *ShellSurfaceInterface::d_func() const
|
ShellSurfaceInterface::Private *ShellSurfaceInterface::d_func() const
|
||||||
{
|
{
|
||||||
return reinterpret_cast<ShellSurfaceInterface::Private*>(d.data());
|
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(QByteArray windowClass READ windowClass NOTIFY windowClassChanged)
|
||||||
Q_PROPERTY(bool fullscreen READ isFullscreen NOTIFY fullscreenChanged)
|
Q_PROPERTY(bool fullscreen READ isFullscreen NOTIFY fullscreenChanged)
|
||||||
Q_PROPERTY(bool toplevel READ isToplevel NOTIFY toplevelChanged)
|
Q_PROPERTY(bool toplevel READ isToplevel NOTIFY toplevelChanged)
|
||||||
|
Q_PROPERTY(bool maximized READ isMaximized NOTIFY maximizedChanged)
|
||||||
public:
|
public:
|
||||||
virtual ~ShellSurfaceInterface();
|
virtual ~ShellSurfaceInterface();
|
||||||
|
|
||||||
|
@ -76,6 +77,7 @@ public:
|
||||||
QByteArray windowClass() const;
|
QByteArray windowClass() const;
|
||||||
bool isFullscreen() const;
|
bool isFullscreen() const;
|
||||||
bool isToplevel() const;
|
bool isToplevel() const;
|
||||||
|
bool isMaximized() const;
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void titleChanged(const QString&);
|
void titleChanged(const QString&);
|
||||||
|
@ -84,6 +86,7 @@ Q_SIGNALS:
|
||||||
void pongReceived();
|
void pongReceived();
|
||||||
void fullscreenChanged(bool);
|
void fullscreenChanged(bool);
|
||||||
void toplevelChanged(bool);
|
void toplevelChanged(bool);
|
||||||
|
void maximizedChanged(bool);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class ShellInterface;
|
friend class ShellInterface;
|
||||||
|
|
Loading…
Reference in a new issue