summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorPier Luigi Fiorini <pierluigi.fiorini@liri.io>2018-06-13 22:11:00 +0200
committerPier Luigi Fiorini <pierluigi.fiorini@liri.io>2018-11-05 07:51:14 +0000
commit7945996fe4360f12a96faad7718325b2a66774b4 (patch)
treeba3061ec7eead3f679e3dafc7c33e7baa8eb1ecb /tests
parentf2f2c2e9e47e777298a76772a3c92fc7c3fe9921 (diff)
Client: Add fullscreen shell integration
[ChangeLog][QPA plugin] Added support for fullscreen-shell unstable v1. The fullscreen_shell_unstable_v1 interface displays a single surface per output and it is used for nested compositors, where each output is rendered in a surface that is then displayed by the main compositor. For example weston could be the main compositor and a QML compositor could be launched as a client using this shell integration to display it inside weston. Change-Id: I037679a283ff03cb4bdf4b3fed59945090ec9250 Reviewed-by: Johan Helsing <johan.helsing@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/client/client.pro1
-rw-r--r--tests/auto/client/fullscreenshellv1/fullscreenshellv1.pro4
-rw-r--r--tests/auto/client/fullscreenshellv1/tst_fullscreenshellv1.cpp111
-rw-r--r--tests/auto/client/shared/mockcompositor.cpp17
-rw-r--r--tests/auto/client/shared/mockcompositor.h4
-rw-r--r--tests/auto/client/shared/mockfullscreenshellv1.cpp43
-rw-r--r--tests/auto/client/shared/mockfullscreenshellv1.h58
-rw-r--r--tests/auto/client/shared/shared.pri5
8 files changed, 242 insertions, 1 deletions
diff --git a/tests/auto/client/client.pro b/tests/auto/client/client.pro
index 9fd8fc3f9..14ce4407d 100644
--- a/tests/auto/client/client.pro
+++ b/tests/auto/client/client.pro
@@ -2,6 +2,7 @@ TEMPLATE=subdirs
SUBDIRS += \
client \
+ fullscreenshellv1 \
iviapplication \
xdgshellv6 \
wl_connect
diff --git a/tests/auto/client/fullscreenshellv1/fullscreenshellv1.pro b/tests/auto/client/fullscreenshellv1/fullscreenshellv1.pro
new file mode 100644
index 000000000..8ce6dfe5c
--- /dev/null
+++ b/tests/auto/client/fullscreenshellv1/fullscreenshellv1.pro
@@ -0,0 +1,4 @@
+include (../shared/shared.pri)
+
+TARGET = tst_client_fullscreenshell1
+SOURCES += tst_fullscreenshellv1.cpp
diff --git a/tests/auto/client/fullscreenshellv1/tst_fullscreenshellv1.cpp b/tests/auto/client/fullscreenshellv1/tst_fullscreenshellv1.cpp
new file mode 100644
index 000000000..f93d9fbc5
--- /dev/null
+++ b/tests/auto/client/fullscreenshellv1/tst_fullscreenshellv1.cpp
@@ -0,0 +1,111 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "mockcompositor.h"
+
+#include <QWindow>
+
+#include <QtTest/QtTest>
+
+static const QSize screenSize(1600, 1200);
+
+class TestWindow : public QWindow
+{
+public:
+ TestWindow()
+ {
+ setSurfaceType(QSurface::RasterSurface);
+ setGeometry(0, 0, 800, 600);
+ create();
+ }
+};
+
+class tst_WaylandClientFullScreenShellV1 : public QObject
+{
+ Q_OBJECT
+public:
+ tst_WaylandClientFullScreenShellV1(MockCompositor *c)
+ : m_compositor(c)
+ {
+ QSocketNotifier *notifier = new QSocketNotifier(m_compositor->waylandFileDescriptor(), QSocketNotifier::Read, this);
+ connect(notifier, &QSocketNotifier::activated, this, &tst_WaylandClientFullScreenShellV1::processWaylandEvents);
+ // connect to the event dispatcher to make sure to flush out the outgoing message queue
+ connect(QCoreApplication::eventDispatcher(), &QAbstractEventDispatcher::awake, this, &tst_WaylandClientFullScreenShellV1::processWaylandEvents);
+ connect(QCoreApplication::eventDispatcher(), &QAbstractEventDispatcher::aboutToBlock, this, &tst_WaylandClientFullScreenShellV1::processWaylandEvents);
+ }
+
+public slots:
+ void processWaylandEvents()
+ {
+ m_compositor->processWaylandEvents();
+ }
+
+ void cleanup()
+ {
+ // make sure the surfaces from the last test are properly cleaned up
+ // and don't show up as false positives in the next test
+ QTRY_VERIFY(!m_compositor->fullScreenShellV1Surface());
+ }
+
+private slots:
+ void createDestroyWindow();
+
+private:
+ MockCompositor *m_compositor = nullptr;
+};
+
+void tst_WaylandClientFullScreenShellV1::createDestroyWindow()
+{
+ TestWindow window;
+ window.show();
+
+ QTRY_VERIFY(m_compositor->fullScreenShellV1Surface());
+
+ window.destroy();
+ QTRY_VERIFY(!m_compositor->fullScreenShellV1Surface());
+}
+
+int main(int argc, char **argv)
+{
+ setenv("XDG_RUNTIME_DIR", ".", 1);
+ setenv("QT_QPA_PLATFORM", "wayland", 1); // force QGuiApplication to use wayland plugin
+ setenv("QT_WAYLAND_SHELL_INTEGRATION", "fullscreen-shell-v1", 1);
+ setenv("QT_WAYLAND_DISABLE_WINDOWDECORATION", "1", 1); // window decorations don't make much sense here
+
+ MockCompositor compositor;
+ compositor.setOutputMode(screenSize);
+
+ QGuiApplication app(argc, argv);
+ compositor.applicationInitialized();
+
+ tst_WaylandClientFullScreenShellV1 tc(&compositor);
+ return QTest::qExec(&tc, argc, argv);
+}
+
+#include <tst_fullscreenshellv1.moc>
diff --git a/tests/auto/client/shared/mockcompositor.cpp b/tests/auto/client/shared/mockcompositor.cpp
index 797c05c44..df24b4091 100644
--- a/tests/auto/client/shared/mockcompositor.cpp
+++ b/tests/auto/client/shared/mockcompositor.cpp
@@ -299,6 +299,16 @@ QSharedPointer<MockXdgToplevelV6> MockCompositor::xdgToplevelV6(int index)
return result;
}
+QSharedPointer<MockSurface> MockCompositor::fullScreenShellV1Surface(int index)
+{
+ QSharedPointer<MockSurface> result;
+ lock();
+ if (Impl::Surface *surface = m_compositor->fullScreenShellV1()->surfaces().value(index, nullptr))
+ result = surface->mockSurface();
+ unlock();
+ return result;
+}
+
MockCompositor::Command MockCompositor::makeCommand(Command::Callback callback, void *target)
{
Command command;
@@ -382,6 +392,7 @@ Compositor::Compositor()
m_iviApplication.reset(new IviApplication(m_display));
m_wlShell.reset(new WlShell(m_display));
m_xdgShellV6.reset(new XdgShellV6(m_display));
+ m_fullScreenShellV1.reset(new FullScreenShellV1(m_display));
m_loop = wl_display_get_event_loop(m_display);
m_fd = wl_event_loop_get_fd(m_loop);
@@ -459,6 +470,11 @@ XdgShellV6 *Compositor::xdgShellV6() const
return m_xdgShellV6.data();
}
+FullScreenShellV1 *Compositor::fullScreenShellV1() const
+{
+ return m_fullScreenShellV1.data();
+}
+
uint32_t Compositor::nextSerial()
{
return wl_display_next_serial(m_display);
@@ -474,6 +490,7 @@ void Compositor::removeSurface(Surface *surface)
m_surfaces.removeOne(surface);
m_keyboard->handleSurfaceDestroyed(surface);
m_pointer->handleSurfaceDestroyed(surface);
+ m_fullScreenShellV1->removeSurface(surface);
}
Surface *Compositor::resolveSurface(const QVariant &v)
diff --git a/tests/auto/client/shared/mockcompositor.h b/tests/auto/client/shared/mockcompositor.h
index b0d6b0885..4bab1ed67 100644
--- a/tests/auto/client/shared/mockcompositor.h
+++ b/tests/auto/client/shared/mockcompositor.h
@@ -31,6 +31,7 @@
#include "mockxdgshellv6.h"
#include "mockiviapplication.h"
+#include "mockfullscreenshellv1.h"
#include <pthread.h>
#include <qglobal.h>
@@ -76,6 +77,7 @@ public:
IviApplication *iviApplication() const;
XdgShellV6 *xdgShellV6() const;
+ FullScreenShellV1 *fullScreenShellV1() const;
void addSurface(Surface *surface);
void removeSurface(Surface *surface);
@@ -135,6 +137,7 @@ private:
QScopedPointer<IviApplication> m_iviApplication;
QScopedPointer<WlShell> m_wlShell;
QScopedPointer<XdgShellV6> m_xdgShellV6;
+ QScopedPointer<FullScreenShellV1> m_fullScreenShellV1;
};
void registerResource(wl_list *list, wl_resource *resource);
@@ -251,6 +254,7 @@ public:
QSharedPointer<MockOutput> output(int index = 0);
QSharedPointer<MockIviSurface> iviSurface(int index = 0);
QSharedPointer<MockXdgToplevelV6> xdgToplevelV6(int index = 0);
+ QSharedPointer<MockSurface> fullScreenShellV1Surface(int index = 0);
void lock();
void unlock();
diff --git a/tests/auto/client/shared/mockfullscreenshellv1.cpp b/tests/auto/client/shared/mockfullscreenshellv1.cpp
new file mode 100644
index 000000000..22c49cde6
--- /dev/null
+++ b/tests/auto/client/shared/mockfullscreenshellv1.cpp
@@ -0,0 +1,43 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "mockfullscreenshellv1.h"
+#include "mocksurface.h"
+
+namespace Impl {
+
+void FullScreenShellV1::zwp_fullscreen_shell_v1_present_surface(Resource *resource, struct ::wl_resource *surface, uint32_t method, struct ::wl_resource *output)
+{
+ Q_UNUSED(resource)
+ Q_UNUSED(method)
+ Q_UNUSED(output)
+
+ m_surfaces.append(Surface::fromResource(surface));
+}
+
+} // namespace Impl
diff --git a/tests/auto/client/shared/mockfullscreenshellv1.h b/tests/auto/client/shared/mockfullscreenshellv1.h
new file mode 100644
index 000000000..819bbc186
--- /dev/null
+++ b/tests/auto/client/shared/mockfullscreenshellv1.h
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef MOCKFULLSCREENSHELLV1_H
+#define MOCKFULLSCREENSHELLV1_H
+
+#include <qwayland-server-fullscreen-shell-unstable-v1.h>
+
+#include <QVector>
+
+namespace Impl {
+
+class Surface;
+class FullScreenShellV1;
+
+class FullScreenShellV1 : public QtWaylandServer::zwp_fullscreen_shell_v1
+{
+public:
+ explicit FullScreenShellV1(::wl_display *display) : zwp_fullscreen_shell_v1(display, 1) {}
+
+ QVector<Surface *> surfaces() const { return m_surfaces; }
+ void removeSurface(Surface *surface) { m_surfaces.removeOne(surface); }
+
+protected:
+ void zwp_fullscreen_shell_v1_present_surface(Resource *resource, struct ::wl_resource *surface, uint32_t method, struct ::wl_resource *output) override;
+
+private:
+ QVector<Surface *> m_surfaces;
+};
+
+} // namespace Impl
+
+#endif // MOCKFULLSCREENSHELLV1_H
diff --git a/tests/auto/client/shared/shared.pri b/tests/auto/client/shared/shared.pri
index f3cb4d5a2..db71de528 100644
--- a/tests/auto/client/shared/shared.pri
+++ b/tests/auto/client/shared/shared.pri
@@ -8,12 +8,14 @@ CONFIG += wayland-scanner
WAYLANDSERVERSOURCES += \
../../../../src/3rdparty/protocol/ivi-application.xml \
../../../../src/3rdparty/protocol/wayland.xml \
- ../../../../src/3rdparty/protocol/xdg-shell-unstable-v6.xml
+ ../../../../src/3rdparty/protocol/xdg-shell-unstable-v6.xml \
+ ../../../../src/3rdparty/protocol/fullscreen-shell-unstable-v1.xml
INCLUDEPATH += ../shared
SOURCES += \
../shared/mockcompositor.cpp \
+ ../shared/mockfullscreenshellv1.cpp \
../shared/mockinput.cpp \
../shared/mockiviapplication.cpp \
../shared/mockwlshell.cpp \
@@ -23,6 +25,7 @@ SOURCES += \
HEADERS += \
../shared/mockcompositor.h \
+ ../shared/mockfullscreenshellv1.h \
../shared/mockinput.h \
../shared/mockiviapplication.h \
../shared/mockwlshell.h \