summaryrefslogtreecommitdiffstats
path: root/tests/auto/compositor/compositor
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/compositor/compositor')
-rw-r--r--tests/auto/compositor/compositor/CMakeLists.txt47
-rw-r--r--tests/auto/compositor/compositor/compositor.pro36
-rw-r--r--tests/auto/compositor/compositor/mockclient.cpp72
-rw-r--r--tests/auto/compositor/compositor/mockclient.h40
-rw-r--r--tests/auto/compositor/compositor/mockkeyboard.cpp32
-rw-r--r--tests/auto/compositor/compositor/mockkeyboard.h29
-rw-r--r--tests/auto/compositor/compositor/mockpointer.cpp32
-rw-r--r--tests/auto/compositor/compositor/mockpointer.h29
-rw-r--r--tests/auto/compositor/compositor/mockseat.cpp29
-rw-r--r--tests/auto/compositor/compositor/mockseat.h29
-rw-r--r--tests/auto/compositor/compositor/mockxdgoutputv1.cpp43
-rw-r--r--tests/auto/compositor/compositor/mockxdgoutputv1.h39
-rw-r--r--tests/auto/compositor/compositor/testcompositor.cpp29
-rw-r--r--tests/auto/compositor/compositor/testcompositor.h29
-rw-r--r--tests/auto/compositor/compositor/testkeyboardgrabber.cpp29
-rw-r--r--tests/auto/compositor/compositor/testkeyboardgrabber.h29
-rw-r--r--tests/auto/compositor/compositor/testseat.cpp32
-rw-r--r--tests/auto/compositor/compositor/testseat.h29
-rw-r--r--tests/auto/compositor/compositor/tst_compositor.cpp400
19 files changed, 463 insertions, 571 deletions
diff --git a/tests/auto/compositor/compositor/CMakeLists.txt b/tests/auto/compositor/compositor/CMakeLists.txt
new file mode 100644
index 000000000..5cb18b2aa
--- /dev/null
+++ b/tests/auto/compositor/compositor/CMakeLists.txt
@@ -0,0 +1,47 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+# Generated from compositor.pro.
+
+#####################################################################
+## tst_compositor Test:
+#####################################################################
+
+qt_internal_add_test(tst_compositor
+ SOURCES
+ mockclient.cpp mockclient.h
+ mockkeyboard.cpp mockkeyboard.h
+ mockpointer.cpp mockpointer.h
+ mockseat.cpp mockseat.h
+ mockxdgoutputv1.cpp mockxdgoutputv1.h
+ testcompositor.cpp testcompositor.h
+ testkeyboardgrabber.cpp testkeyboardgrabber.h
+ testseat.cpp testseat.h
+ tst_compositor.cpp
+ LIBRARIES
+ Qt::CorePrivate
+ Qt::Gui
+ Qt::GuiPrivate
+ Qt::WaylandCompositor
+ Qt::WaylandCompositorPrivate
+ Wayland::Client
+ Wayland::Server
+)
+
+qt6_generate_wayland_protocol_client_sources(tst_compositor
+ FILES
+ ${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/3rdparty/protocol/idle-inhibit-unstable-v1.xml
+ ${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/3rdparty/protocol/ivi-application.xml
+ ${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/3rdparty/protocol/viewporter.xml
+ ${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/3rdparty/protocol/wayland.xml
+ ${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/3rdparty/protocol/xdg-output-unstable-v1.xml
+ ${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/3rdparty/protocol/xdg-shell.xml
+)
+
+## Scopes:
+#####################################################################
+
+qt_internal_extend_target(tst_compositor CONDITION QT_FEATURE_xkbcommon
+ LIBRARIES
+ XKB::XKB
+)
diff --git a/tests/auto/compositor/compositor/compositor.pro b/tests/auto/compositor/compositor/compositor.pro
deleted file mode 100644
index 500a92c61..000000000
--- a/tests/auto/compositor/compositor/compositor.pro
+++ /dev/null
@@ -1,36 +0,0 @@
-CONFIG += testcase link_pkgconfig
-CONFIG += wayland-scanner
-TARGET = tst_compositor
-
-QT += testlib
-QT += core-private gui-private waylandcompositor waylandcompositor-private
-
-QMAKE_USE += wayland-client wayland-server
-
-qtConfig(xkbcommon): \
- QMAKE_USE += xkbcommon
-
-WAYLANDCLIENTSOURCES += \
- ../../../../src/3rdparty/protocol/ivi-application.xml \
- ../../../../src/3rdparty/protocol/wayland.xml \
- ../../../../src/3rdparty/protocol/xdg-shell.xml \
- ../../../../src/3rdparty/protocol/viewporter.xml
-
-SOURCES += \
- tst_compositor.cpp \
- testcompositor.cpp \
- testkeyboardgrabber.cpp \
- mockclient.cpp \
- mockseat.cpp \
- testseat.cpp \
- mockkeyboard.cpp \
- mockpointer.cpp
-
-HEADERS += \
- testcompositor.h \
- testkeyboardgrabber.h \
- mockclient.h \
- mockseat.h \
- testseat.h \
- mockkeyboard.h \
- mockpointer.h
diff --git a/tests/auto/compositor/compositor/mockclient.cpp b/tests/auto/compositor/compositor/mockclient.cpp
index fa4d4c6b3..6465f9931 100644
--- a/tests/auto/compositor/compositor/mockclient.cpp
+++ b/tests/auto/compositor/compositor/mockclient.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "mockclient.h"
#include "mockseat.h"
@@ -57,7 +32,7 @@ MockClient::MockClient()
fd = wl_display_get_fd(display);
QSocketNotifier *readNotifier = new QSocketNotifier(fd, QSocketNotifier::Read, this);
- connect(readNotifier, SIGNAL(activated(int)), this, SLOT(readEvents()));
+ connect(readNotifier, SIGNAL(activated(QSocketDescriptor)), this, SLOT(readEvents()));
QAbstractEventDispatcher *dispatcher = QGuiApplicationPrivate::eventDispatcher;
connect(dispatcher, SIGNAL(awake()), this, SLOT(flushDisplay()));
@@ -76,7 +51,9 @@ const wl_output_listener MockClient::outputListener = {
MockClient::outputGeometryEvent,
MockClient::outputModeEvent,
MockClient::outputDone,
- MockClient::outputScale
+ MockClient::outputScale,
+ MockClient::outputName,
+ MockClient::outputDesc
};
MockClient::~MockClient()
@@ -123,6 +100,16 @@ void MockClient::outputScale(void *, wl_output *, int)
}
+void MockClient::outputName(void *, wl_output *, const char *)
+{
+
+}
+
+void MockClient::outputDesc(void *, wl_output *, const char *)
+{
+
+}
+
void MockClient::readEvents()
{
if (error)
@@ -166,7 +153,7 @@ void MockClient::handleGlobalRemove(void *data, wl_registry *wl_registry, uint32
void MockClient::handleGlobal(uint32_t id, const QByteArray &interface)
{
if (interface == "wl_compositor") {
- compositor = static_cast<wl_compositor *>(wl_registry_bind(registry, id, &wl_compositor_interface, 3));
+ compositor = static_cast<wl_compositor *>(wl_registry_bind(registry, id, &wl_compositor_interface, 4));
} else if (interface == "wl_output") {
auto output = static_cast<wl_output *>(wl_registry_bind(registry, id, &wl_output_interface, 2));
m_outputs.insert(id, output);
@@ -184,11 +171,19 @@ void MockClient::handleGlobal(uint32_t id, const QByteArray &interface)
} else if (interface == "wl_seat") {
wl_seat *s = static_cast<wl_seat *>(wl_registry_bind(registry, id, &wl_seat_interface, 1));
m_seats << new MockSeat(s);
+ } else if (interface == "zwp_idle_inhibit_manager_v1") {
+ idleInhibitManager = static_cast<zwp_idle_inhibit_manager_v1 *>(wl_registry_bind(registry, id, &zwp_idle_inhibit_manager_v1_interface, 1));
+ } else if (interface == "zxdg_output_manager_v1") {
+ xdgOutputManager = new QtWayland::zxdg_output_manager_v1(registry, id, 2);
}
}
void MockClient::handleGlobalRemove(uint32_t id)
{
+ auto *output = m_outputs[id];
+ if (m_xdgOutputs.contains(output))
+ delete m_xdgOutputs.take(output);
+
m_outputs.remove(id);
}
@@ -222,6 +217,23 @@ ivi_surface *MockClient::createIviSurface(wl_surface *surface, uint iviId)
return ivi_application_surface_create(iviApplication, iviId, surface);
}
+zwp_idle_inhibitor_v1 *MockClient::createIdleInhibitor(wl_surface *surface)
+{
+ flushDisplay();
+
+ auto *idleInhibitor = zwp_idle_inhibit_manager_v1_create_inhibitor(
+ idleInhibitManager, surface);
+ zwp_idle_inhibitor_v1_set_user_data(idleInhibitor, this);
+ return idleInhibitor;
+}
+
+MockXdgOutputV1 *MockClient::createXdgOutput(wl_output *output)
+{
+ auto *xdgOutput = new MockXdgOutputV1(xdgOutputManager->get_xdg_output(output));
+ m_xdgOutputs[output] = xdgOutput;
+ return xdgOutput;
+}
+
ShmBuffer::ShmBuffer(const QSize &size, wl_shm *shm)
{
int stride = size.width() * 4;
diff --git a/tests/auto/compositor/compositor/mockclient.h b/tests/auto/compositor/compositor/mockclient.h
index b537e9df1..2f6d9046e 100644
--- a/tests/auto/compositor/compositor/mockclient.h
+++ b/tests/auto/compositor/compositor/mockclient.h
@@ -1,42 +1,21 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "wayland-wayland-client-protocol.h"
#include <qwayland-xdg-shell.h>
#include <wayland-ivi-application-client-protocol.h>
#include "wayland-viewporter-client-protocol.h"
+#include "wayland-idle-inhibit-unstable-v1-client-protocol.h"
#include <QObject>
#include <QImage>
#include <QRect>
#include <QList>
+#include <QtCore/QMap>
#include <QWaylandOutputMode>
+#include "mockxdgoutputv1.h"
+
class MockSeat;
class ShmBuffer
@@ -63,16 +42,21 @@ public:
xdg_surface *createXdgSurface(wl_surface *surface);
xdg_toplevel *createXdgToplevel(xdg_surface *xdgSurface);
ivi_surface *createIviSurface(wl_surface *surface, uint iviId);
+ zwp_idle_inhibitor_v1 *createIdleInhibitor(wl_surface *surface);
+ MockXdgOutputV1 *createXdgOutput(wl_output *output);
wl_display *display = nullptr;
wl_compositor *compositor = nullptr;
QMap<uint, wl_output *> m_outputs;
+ QMap<wl_output *, MockXdgOutputV1 *> m_xdgOutputs;
wl_shm *shm = nullptr;
wl_registry *registry = nullptr;
wl_shell *wlshell = nullptr;
xdg_wm_base *xdgWmBase = nullptr;
wp_viewporter *viewporter = nullptr;
ivi_application *iviApplication = nullptr;
+ zwp_idle_inhibit_manager_v1 *idleInhibitManager = nullptr;
+ QtWayland::zxdg_output_manager_v1 *xdgOutputManager = nullptr;
QList<MockSeat *> m_seats;
@@ -119,6 +103,8 @@ private:
int refreshRate);
static void outputDone(void *data, wl_output *output);
static void outputScale(void *data, wl_output *output, int factor);
+ static void outputName(void *data, wl_output *output, const char *name);
+ static void outputDesc(void *data, wl_output *output, const char *desc);
void handleGlobal(uint32_t id, const QByteArray &interface);
void handleGlobalRemove(uint32_t id);
diff --git a/tests/auto/compositor/compositor/mockkeyboard.cpp b/tests/auto/compositor/compositor/mockkeyboard.cpp
index e5f5f8d36..b3055ffa9 100644
--- a/tests/auto/compositor/compositor/mockkeyboard.cpp
+++ b/tests/auto/compositor/compositor/mockkeyboard.cpp
@@ -1,33 +1,11 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 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$
-**
-****************************************************************************/
+// Copyright (C) 2018 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "mockkeyboard.h"
+QT_WARNING_DISABLE_GCC("-Wmissing-field-initializers")
+QT_WARNING_DISABLE_CLANG("-Wmissing-field-initializers")
+
void keyboardKeymap(void *keyboard, struct wl_keyboard *wl_keyboard, uint32_t format, int32_t fd, uint32_t size)
{
Q_UNUSED(keyboard);
diff --git a/tests/auto/compositor/compositor/mockkeyboard.h b/tests/auto/compositor/compositor/mockkeyboard.h
index fd7f06aee..093586bb3 100644
--- a/tests/auto/compositor/compositor/mockkeyboard.h
+++ b/tests/auto/compositor/compositor/mockkeyboard.h
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 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$
-**
-****************************************************************************/
+// Copyright (C) 2018 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef MOCKKEYBOARD_H
#define MOCKKEYBOARD_H
diff --git a/tests/auto/compositor/compositor/mockpointer.cpp b/tests/auto/compositor/compositor/mockpointer.cpp
index 6c51d8bd1..65a8b9ce7 100644
--- a/tests/auto/compositor/compositor/mockpointer.cpp
+++ b/tests/auto/compositor/compositor/mockpointer.cpp
@@ -1,33 +1,11 @@
-/****************************************************************************
-**
-** 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$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "mockpointer.h"
+QT_WARNING_DISABLE_GCC("-Wmissing-field-initializers")
+QT_WARNING_DISABLE_CLANG("-Wmissing-field-initializers")
+
static void pointerEnter(void *pointer, struct wl_pointer *wlPointer, uint serial, struct wl_surface *surface, wl_fixed_t x, wl_fixed_t y)
{
Q_UNUSED(wlPointer);
diff --git a/tests/auto/compositor/compositor/mockpointer.h b/tests/auto/compositor/compositor/mockpointer.h
index db6b2b69c..db5c6a0af 100644
--- a/tests/auto/compositor/compositor/mockpointer.h
+++ b/tests/auto/compositor/compositor/mockpointer.h
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** 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$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef MOCKPOINTER_H
#define MOCKPOINTER_H
diff --git a/tests/auto/compositor/compositor/mockseat.cpp b/tests/auto/compositor/compositor/mockseat.cpp
index ce873c129..88b1c94e4 100644
--- a/tests/auto/compositor/compositor/mockseat.cpp
+++ b/tests/auto/compositor/compositor/mockseat.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 LG Electronics Ltd., author: <mikko.levonmaa@lge.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$
-**
-****************************************************************************/
+// Copyright (C) 2016 LG Electronics Ltd., author: <mikko.levonmaa@lge.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "mockseat.h"
diff --git a/tests/auto/compositor/compositor/mockseat.h b/tests/auto/compositor/compositor/mockseat.h
index 0d0f4074c..12a14c727 100644
--- a/tests/auto/compositor/compositor/mockseat.h
+++ b/tests/auto/compositor/compositor/mockseat.h
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 LG Electronics Ltd., author: <mikko.levonmaa@lge.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$
-**
-****************************************************************************/
+// Copyright (C) 2016 LG Electronics Ltd., author: <mikko.levonmaa@lge.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef MOCKSEAT
#define MOCKSEAT
diff --git a/tests/auto/compositor/compositor/mockxdgoutputv1.cpp b/tests/auto/compositor/compositor/mockxdgoutputv1.cpp
new file mode 100644
index 000000000..9349e62d6
--- /dev/null
+++ b/tests/auto/compositor/compositor/mockxdgoutputv1.cpp
@@ -0,0 +1,43 @@
+// Copyright (C) 2019 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#include "mockxdgoutputv1.h"
+
+MockXdgOutputV1::MockXdgOutputV1(struct ::zxdg_output_v1 *object)
+ : QtWayland::zxdg_output_v1(object)
+{
+}
+
+MockXdgOutputV1::~MockXdgOutputV1()
+{
+ destroy();
+}
+
+void MockXdgOutputV1::zxdg_output_v1_logical_position(int32_t x, int32_t y)
+{
+ pending.logicalPosition = QPoint(x, y);
+}
+
+void MockXdgOutputV1::zxdg_output_v1_logical_size(int32_t width, int32_t height)
+{
+ pending.logicalSize = QSize(width, height);
+}
+
+void MockXdgOutputV1::zxdg_output_v1_done()
+{
+ // In version 3 we'll have to do this for wl_output.done as well
+ name = pending.name;
+ description = pending.description;
+ logicalPosition = pending.logicalPosition;
+ logicalSize = pending.logicalSize;
+}
+
+void MockXdgOutputV1::zxdg_output_v1_name(const QString &name)
+{
+ pending.name = name;
+}
+
+void MockXdgOutputV1::zxdg_output_v1_description(const QString &description)
+{
+ pending.description = description;
+}
diff --git a/tests/auto/compositor/compositor/mockxdgoutputv1.h b/tests/auto/compositor/compositor/mockxdgoutputv1.h
new file mode 100644
index 000000000..4e3a05c91
--- /dev/null
+++ b/tests/auto/compositor/compositor/mockxdgoutputv1.h
@@ -0,0 +1,39 @@
+// Copyright (C) 2019 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#ifndef MOCKXDGOUTPUTV1_H
+#define MOCKXDGOUTPUTV1_H
+
+#include <QPoint>
+#include <QSize>
+#include <QString>
+
+#include "qwayland-xdg-output-unstable-v1.h"
+
+class MockXdgOutputV1 : public QtWayland::zxdg_output_v1
+{
+public:
+ explicit MockXdgOutputV1(struct ::zxdg_output_v1 *object);
+ ~MockXdgOutputV1();
+
+ QString name;
+ QString description;
+ QPoint logicalPosition;
+ QSize logicalSize;
+
+ struct {
+ QString name;
+ QString description;
+ QPoint logicalPosition;
+ QSize logicalSize;
+ } pending;
+
+protected:
+ void zxdg_output_v1_logical_position(int32_t x, int32_t y) override;
+ void zxdg_output_v1_logical_size(int32_t width, int32_t height) override;
+ void zxdg_output_v1_done() override;
+ void zxdg_output_v1_name(const QString &name) override;
+ void zxdg_output_v1_description(const QString &description) override;
+};
+
+#endif // MOCKXDGOUTPUTV1_H
diff --git a/tests/auto/compositor/compositor/testcompositor.cpp b/tests/auto/compositor/compositor/testcompositor.cpp
index d5967a416..d2f454a93 100644
--- a/tests/auto/compositor/compositor/testcompositor.cpp
+++ b/tests/auto/compositor/compositor/testcompositor.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "testcompositor.h"
#include "testseat.h"
diff --git a/tests/auto/compositor/compositor/testcompositor.h b/tests/auto/compositor/compositor/testcompositor.h
index 7829f1a65..0e11def13 100644
--- a/tests/auto/compositor/compositor/testcompositor.h
+++ b/tests/auto/compositor/compositor/testcompositor.h
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "qwaylandcompositor.h"
#include "qwaylandsurface.h"
diff --git a/tests/auto/compositor/compositor/testkeyboardgrabber.cpp b/tests/auto/compositor/compositor/testkeyboardgrabber.cpp
index a3aa42ac2..73592dd4f 100644
--- a/tests/auto/compositor/compositor/testkeyboardgrabber.cpp
+++ b/tests/auto/compositor/compositor/testkeyboardgrabber.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 LG Electronics, Inc., author: <mikko.levonmaa@lge.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$
-**
-****************************************************************************/
+// Copyright (C) 2016 LG Electronics, Inc., author: <mikko.levonmaa@lge.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "testkeyboardgrabber.h"
diff --git a/tests/auto/compositor/compositor/testkeyboardgrabber.h b/tests/auto/compositor/compositor/testkeyboardgrabber.h
index 7f0f2c86c..2e2f44df4 100644
--- a/tests/auto/compositor/compositor/testkeyboardgrabber.h
+++ b/tests/auto/compositor/compositor/testkeyboardgrabber.h
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 LG Electronics, Inc., author: <mikko.levonmaa@lge.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$
-**
-****************************************************************************/
+// Copyright (C) 2016 LG Electronics, Inc., author: <mikko.levonmaa@lge.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "qwaylandkeyboard.h"
diff --git a/tests/auto/compositor/compositor/testseat.cpp b/tests/auto/compositor/compositor/testseat.cpp
index 38227872b..21e2bffe5 100644
--- a/tests/auto/compositor/compositor/testseat.cpp
+++ b/tests/auto/compositor/compositor/testseat.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 LG Electronics, Inc., author: <mikko.levonmaa@lge.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$
-**
-****************************************************************************/
+// Copyright (C) 2016 LG Electronics, Inc., author: <mikko.levonmaa@lge.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "testseat.h"
#include <QMouseEvent>
@@ -49,7 +24,8 @@ bool TestSeat::isOwner(QInputEvent *event) const
QList<QMouseEvent *> TestSeat::createMouseEvents(int count)
{
for (int i = 0; i < count; i++) {
- m_events.append(new QMouseEvent(QEvent::MouseMove, QPointF(10 + i, 10 + i), Qt::NoButton, Qt::NoButton, Qt::NoModifier));
+ m_events.append(new QMouseEvent(QEvent::MouseMove, QPointF(10 + i, 10 + i),
+ QPointF(10 + i, 10 + i), Qt::NoButton, Qt::NoButton, Qt::NoModifier));
}
return m_events;
}
diff --git a/tests/auto/compositor/compositor/testseat.h b/tests/auto/compositor/compositor/testseat.h
index f4449f144..a71abc122 100644
--- a/tests/auto/compositor/compositor/testseat.h
+++ b/tests/auto/compositor/compositor/testseat.h
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 LG Electronics, Inc., author: <mikko.levonmaa@lge.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$
-**
-****************************************************************************/
+// Copyright (C) 2016 LG Electronics, Inc., author: <mikko.levonmaa@lge.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QWaylandSeat>
#include <QList>
diff --git a/tests/auto/compositor/compositor/tst_compositor.cpp b/tests/auto/compositor/compositor/tst_compositor.cpp
index 66792621b..c3c0c35fb 100644
--- a/tests/auto/compositor/compositor/tst_compositor.cpp
+++ b/tests/auto/compositor/compositor/tst_compositor.cpp
@@ -1,34 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "mockclient.h"
#include "mockseat.h"
#include "mockpointer.h"
+#include "mockxdgoutputv1.h"
#include "testcompositor.h"
#include "testkeyboardgrabber.h"
#include "testseat.h"
@@ -39,7 +15,6 @@
#include <QtGui/QScreen>
#include <QtWaylandCompositor/QWaylandXdgShell>
-#include <QtWaylandCompositor/private/qwaylandxdgshellv6_p.h>
#include <QtWaylandCompositor/private/qwaylandkeyboard_p.h>
#include <QtWaylandCompositor/QWaylandIviApplication>
#include <QtWaylandCompositor/QWaylandIviSurface>
@@ -47,8 +22,12 @@
#include <QtWaylandCompositor/QWaylandResource>
#include <QtWaylandCompositor/QWaylandKeymap>
#include <QtWaylandCompositor/QWaylandViewporter>
+#include <QtWaylandCompositor/QWaylandIdleInhibitManagerV1>
+#include <QtWaylandCompositor/QWaylandXdgOutputManagerV1>
#include <qwayland-xdg-shell.h>
#include <qwayland-ivi-application.h>
+#include <QtWaylandCompositor/private/qwaylandoutput_p.h>
+#include <QtWaylandCompositor/private/qwaylandsurface_p.h>
#include <QtTest/QtTest>
@@ -73,12 +52,14 @@ private slots:
void singleClient();
void multipleClients();
void geometry();
+ void availableGeometry();
void modes();
void comparingModes();
void sizeFollowsWindow();
void mapSurface();
void mapSurfaceHiDpi();
void frameCallback();
+ void pixelFormats();
void outputs();
void customSurface();
@@ -94,9 +75,6 @@ private slots:
void sendsIviConfigure();
void destroysIviSurfaces();
- void convertsXdgEdgesToQtEdges();
- void xdgShellV6Positioner();
-
void viewporterGlobal();
void viewportDestination();
void viewportSource();
@@ -110,10 +88,19 @@ private slots:
void viewportDestinationNoSurfaceError();
void viewportSourceNoSurfaceError();
void viewportHiDpi();
+
+ void idleInhibit();
+
+ void xdgOutput();
+
+private:
+ QTemporaryDir m_tmpRuntimeDir;
};
void tst_WaylandCompositor::init() {
- qputenv("XDG_RUNTIME_DIR", ".");
+ // We need to set a test specific runtime dir so we don't conflict with other tests'
+ // compositors by accident.
+ qputenv("XDG_RUNTIME_DIR", m_tmpRuntimeDir.path().toLocal8Bit());
}
void tst_WaylandCompositor::singleClient()
@@ -325,14 +312,14 @@ void tst_WaylandCompositor::keyboardGrab()
//QSignalSpy grabModifierSpy(grab, SIGNAL(modifiersCalled()));
seat->setKeyboardFocus(waylandSurface);
- QTRY_COMPARE(grabFocusSpy.count(), 1);
+ QTRY_COMPARE(grabFocusSpy.size(), 1);
QKeyEvent ke(QEvent::KeyPress, Qt::Key_A, Qt::NoModifier, 30, 0, 0);
QKeyEvent ke1(QEvent::KeyRelease, Qt::Key_A, Qt::NoModifier, 30, 0, 0);
seat->sendFullKeyEvent(&ke);
seat->sendFullKeyEvent(&ke1);
- QTRY_COMPARE(grabKeyPressSpy.count(), 1);
- QTRY_COMPARE(grabKeyReleaseSpy.count(), 1);
+ QTRY_COMPARE(grabKeyPressSpy.size(), 1);
+ QTRY_COMPARE(grabKeyReleaseSpy.size(), 1);
QKeyEvent ke2(QEvent::KeyPress, Qt::Key_Shift, Qt::NoModifier, 50, 0, 0);
QKeyEvent ke3(QEvent::KeyRelease, Qt::Key_Shift, Qt::NoModifier, 50, 0, 0);
@@ -340,14 +327,14 @@ void tst_WaylandCompositor::keyboardGrab()
seat->sendFullKeyEvent(&ke3);
//QTRY_COMPARE(grabModifierSpy.count(), 2);
// Modifiers are also keys
- QTRY_COMPARE(grabKeyPressSpy.count(), 2);
- QTRY_COMPARE(grabKeyReleaseSpy.count(), 2);
+ QTRY_COMPARE(grabKeyPressSpy.size(), 2);
+ QTRY_COMPARE(grabKeyReleaseSpy.size(), 2);
// Stop grabbing
seat->setKeyboardFocus(nullptr);
seat->sendFullKeyEvent(&ke);
seat->sendFullKeyEvent(&ke1);
- QTRY_COMPARE(grabKeyPressSpy.count(), 2);
+ QTRY_COMPARE(grabKeyPressSpy.size(), 2);
}
void tst_WaylandCompositor::geometry()
@@ -367,6 +354,22 @@ void tst_WaylandCompositor::geometry()
QTRY_COMPARE(client.refreshRate, 60000);
}
+void tst_WaylandCompositor::availableGeometry()
+{
+ TestCompositor compositor;
+ compositor.create();
+
+ QWaylandOutputMode mode(QSize(1024, 768), 60000);
+ compositor.defaultOutput()->addMode(mode, true);
+ compositor.defaultOutput()->setCurrentMode(mode);
+
+ MockClient client;
+
+ QRect availableGeometry(50, 100, 850, 600);
+ compositor.defaultOutput()->setAvailableGeometry(availableGeometry);
+ QCOMPARE(compositor.defaultOutput()->availableGeometry(), availableGeometry);
+}
+
void tst_WaylandCompositor::modes()
{
TestCompositor compositor;
@@ -463,7 +466,7 @@ void tst_WaylandCompositor::mapSurface()
wl_surface_damage(surface, 0, 0, size.width(), size.height());
wl_surface_commit(surface);
- QTRY_COMPARE(hasContentSpy.count(), 1);
+ QTRY_COMPARE(hasContentSpy.size(), 1);
QCOMPARE(waylandSurface->hasContent(), true);
QCOMPARE(waylandSurface->bufferSize(), size);
QCOMPARE(waylandSurface->destinationSize(), size);
@@ -502,27 +505,30 @@ void tst_WaylandCompositor::mapSurfaceHiDpi()
QCOMPARE(waylandSurface->hasContent(), true);
};
- QObject::connect(waylandSurface, &QWaylandSurface::damaged, [=] (const QRegion &damage) {
- // Currently, QWaylandSurface::size returns the size in pixels.
- // Should be fixed or removed for Qt 6.
+ QObject::connect(waylandSurface, &QWaylandSurface::damaged, this, [=] (const QRegion &damage) {
QCOMPARE(damage, QRect(QPoint(), surfaceSize));
verifyComittedState();
});
QSignalSpy damagedSpy(waylandSurface, SIGNAL(damaged(const QRegion &)));
- QObject::connect(waylandSurface, &QWaylandSurface::hasContentChanged, verifyComittedState);
+ QObject::connect(waylandSurface, &QWaylandSurface::hasContentChanged,
+ this, verifyComittedState);
QSignalSpy hasContentSpy(waylandSurface, SIGNAL(hasContentChanged()));
- QObject::connect(waylandSurface, &QWaylandSurface::sizeChanged, verifyComittedState);
- QSignalSpy sizeSpy(waylandSurface, SIGNAL(sizeChanged()));
+ QObject::connect(waylandSurface, &QWaylandSurface::bufferSizeChanged,
+ this, verifyComittedState);
+ QSignalSpy bufferSizeSpy(waylandSurface, SIGNAL(bufferSizeChanged()));
- QObject::connect(waylandSurface, &QWaylandSurface::destinationSizeChanged, verifyComittedState);
+ QObject::connect(waylandSurface, &QWaylandSurface::destinationSizeChanged,
+ this, verifyComittedState);
QSignalSpy destinationSizeSpy(waylandSurface, SIGNAL(destinationSizeChanged()));
- QObject::connect(waylandSurface, &QWaylandSurface::bufferScaleChanged, verifyComittedState);
+ QObject::connect(waylandSurface, &QWaylandSurface::bufferScaleChanged,
+ this, verifyComittedState);
QSignalSpy bufferScaleSpy(waylandSurface, SIGNAL(bufferScaleChanged()));
- QObject::connect(waylandSurface, &QWaylandSurface::offsetForNextFrame, [=](const QPoint &offset) {
+ QObject::connect(waylandSurface, &QWaylandSurface::offsetForNextFrame,
+ this, [=](const QPoint &offset) {
QCOMPARE(offset, attachOffset);
verifyComittedState();
});
@@ -533,15 +539,21 @@ void tst_WaylandCompositor::mapSurfaceHiDpi()
QCOMPARE(waylandSurface->destinationSize(), QSize());
QCOMPARE(waylandSurface->hasContent(), false);
QCOMPARE(waylandSurface->bufferScale(), 1);
- QCOMPARE(offsetSpy.count(), 0);
+ QCOMPARE(offsetSpy.size(), 0);
wl_surface_commit(surface);
- QTRY_COMPARE(hasContentSpy.count(), 1);
- QTRY_COMPARE(sizeSpy.count(), 1);
- QTRY_COMPARE(destinationSizeSpy.count(), 1);
- QTRY_COMPARE(bufferScaleSpy.count(), 1);
- QTRY_COMPARE(offsetSpy.count(), 1);
+ QTRY_COMPARE(hasContentSpy.size(), 1);
+ QTRY_COMPARE(bufferSizeSpy.size(), 1);
+ QTRY_COMPARE(destinationSizeSpy.size(), 1);
+ QTRY_COMPARE(bufferScaleSpy.size(), 1);
+ QTRY_COMPARE(offsetSpy.size(), 1);
+ QTRY_COMPARE(damagedSpy.size(), 1);
+
+ // Now verify that wl_surface_damage_buffer gets mapped properly
+ wl_surface_damage_buffer(surface, 0, 0, bufferSize.width(), bufferSize.height());
+ wl_surface_commit(surface);
+ QTRY_COMPARE(damagedSpy.size(), 2);
wl_surface_destroy(surface);
}
@@ -561,27 +573,27 @@ static void registerFrameCallback(wl_surface *surface, int *counter)
wl_callback_add_listener(wl_surface_frame(surface), &frameCallbackListener, counter);
}
-void tst_WaylandCompositor::frameCallback()
+class BufferView : public QWaylandView
{
- class BufferView : public QWaylandView
+public:
+ void bufferCommitted(const QWaylandBufferRef &ref, const QRegion &damage) override
{
- public:
- void bufferCommitted(const QWaylandBufferRef &ref, const QRegion &damage) override
- {
- Q_UNUSED(damage);
- bufferRef = ref;
- }
+ Q_UNUSED(damage);
+ bufferRef = ref;
+ }
- QImage image() const
- {
- if (bufferRef.isNull() || !bufferRef.isSharedMemory())
- return QImage();
- return bufferRef.image();
- }
+ QImage image() const
+ {
+ if (bufferRef.isNull() || !bufferRef.isSharedMemory())
+ return QImage();
+ return bufferRef.image();
+ }
- QWaylandBufferRef bufferRef;
- };
+ QWaylandBufferRef bufferRef;
+};
+void tst_WaylandCompositor::frameCallback()
+{
TestCompositor compositor;
compositor.create();
@@ -610,7 +622,7 @@ void tst_WaylandCompositor::frameCallback()
wl_surface_commit(surface);
QTRY_COMPARE(waylandSurface->hasContent(), true);
- QTRY_COMPARE(damagedSpy.count(), i + 1);
+ QTRY_COMPARE(damagedSpy.size(), i + 1);
QCOMPARE(static_cast<BufferView*>(waylandSurface->views().first())->image(), buffer.image);
compositor.defaultOutput()->frameStarted();
@@ -622,6 +634,35 @@ void tst_WaylandCompositor::frameCallback()
wl_surface_destroy(surface);
}
+void tst_WaylandCompositor::pixelFormats()
+{
+ TestCompositor compositor;
+ compositor.create();
+
+ MockClient client;
+
+ wl_surface *surface = client.createSurface();
+ QTRY_COMPARE(compositor.surfaces.size(), 1);
+ QWaylandSurface *waylandSurface = compositor.surfaces.at(0);
+ BufferView* view = new BufferView;
+ view->setSurface(waylandSurface);
+ view->setOutput(compositor.defaultOutput());
+
+ QSize size(32, 32);
+ ShmBuffer buffer(size, client.shm); // Will be WL_SHM_FORMAT_ARGB8888;
+ wl_surface_attach(surface, buffer.handle, 0, 0);
+ wl_surface_damage(surface, 0, 0, size.width(), size.height());
+ wl_surface_commit(surface);
+
+ QTRY_COMPARE(waylandSurface->hasContent(), true);
+
+ // According to https://lists.freedesktop.org/archives/wayland-devel/2017-August/034791.html
+ // all RGB formats with alpha are premultiplied. Verify it here:
+ QCOMPARE(view->image().format(), QImage::Format_ARGB32_Premultiplied);
+
+ wl_surface_destroy(surface);
+}
+
void tst_WaylandCompositor::outputs()
{
TestCompositor compositor;
@@ -637,18 +678,18 @@ void tst_WaylandCompositor::outputs()
window.resize(800, 600);
auto output = new QWaylandOutput(&compositor, &window);
- QTRY_COMPARE(outputAddedSpy.count(), 1);
+ QTRY_COMPARE(outputAddedSpy.size(), 1);
compositor.setDefaultOutput(output);
- QTRY_COMPARE(defaultOutputSpy.count(), 2);
+ QTRY_COMPARE(defaultOutputSpy.size(), 2);
MockClient client;
QTRY_COMPARE(client.m_outputs.size(), 2);
delete output;
- QTRY_COMPARE(outputRemovedSpy.count(), 1);
+ QTRY_COMPARE(outputRemovedSpy.size(), 1);
QEXPECT_FAIL("", "FIXME: defaultOutputChanged() is not emitted when the default output is removed", Continue);
- QTRY_COMPARE(defaultOutputSpy.count(), 3);
+ QTRY_COMPARE(defaultOutputSpy.size(), 3);
compositor.flushClients();
QTRY_COMPARE(client.m_outputs.size(), 1);
}
@@ -845,6 +886,11 @@ void tst_WaylandCompositor::inputRegion()
QVERIFY(!waylandSurface->inputRegionContains(QPoint(1, 6)));
QVERIFY(!waylandSurface->inputRegionContains(QPoint(4, 2)));
+ QVERIFY(!waylandSurface->inputRegionContains(QPointF(0.99, 1.99)));
+ QVERIFY(waylandSurface->inputRegionContains(QPointF(1, 2)));
+ QVERIFY(waylandSurface->inputRegionContains(QPointF(3.99, 4.99)));
+ QVERIFY(!waylandSurface->inputRegionContains(QPointF(4, 5)));
+
// Setting a nullptr input region means we want all events
wl_surface_set_input_region(surface, nullptr);
wl_surface_commit(surface);
@@ -919,13 +965,12 @@ void tst_WaylandCompositor::createsXdgSurfaces()
QSignalSpy xdgSurfaceCreatedSpy(&compositor.xdgShell, &QWaylandXdgShell::xdgSurfaceCreated);
QWaylandXdgSurface *xdgSurface = nullptr;
- QObject::connect(&compositor.xdgShell, &QWaylandXdgShell::xdgSurfaceCreated, [&](QWaylandXdgSurface *s) {
- xdgSurface = s;
- });
+ QObject::connect(&compositor.xdgShell, &QWaylandXdgShell::xdgSurfaceCreated,
+ this, [&](QWaylandXdgSurface *s) { xdgSurface = s; });
wl_surface *surface = client.createSurface();
xdg_surface *clientXdgSurface = client.createXdgSurface(surface);
- QTRY_COMPARE(xdgSurfaceCreatedSpy.count(), 1);
+ QTRY_COMPARE(xdgSurfaceCreatedSpy.size(), 1);
QTRY_VERIFY(xdgSurface);
QTRY_VERIFY(xdgSurface->surface());
@@ -939,9 +984,8 @@ void tst_WaylandCompositor::reportsXdgSurfaceWindowGeometry()
compositor.create();
QWaylandXdgSurface *xdgSurface = nullptr;
- QObject::connect(&compositor.xdgShell, &QWaylandXdgShell::xdgSurfaceCreated, [&](QWaylandXdgSurface *s) {
- xdgSurface = s;
- });
+ QObject::connect(&compositor.xdgShell, &QWaylandXdgShell::xdgSurfaceCreated,
+ this, [&](QWaylandXdgSurface *s) { xdgSurface = s; });
MockClient client;
wl_surface *surface = client.createSurface();
@@ -976,9 +1020,8 @@ void tst_WaylandCompositor::setsXdgAppId()
compositor.create();
QWaylandXdgToplevel *toplevel = nullptr;
- QObject::connect(&compositor.xdgShell, &QWaylandXdgShell::toplevelCreated, [&](QWaylandXdgToplevel *t) {
- toplevel = t;
- });
+ QObject::connect(&compositor.xdgShell, &QWaylandXdgShell::toplevelCreated,
+ this, [&](QWaylandXdgToplevel *t) { toplevel = t; });
MockClient client;
wl_surface *surface = client.createSurface();
@@ -1022,9 +1065,8 @@ void tst_WaylandCompositor::sendsXdgConfigure()
compositor.create();
QWaylandXdgToplevel *toplevel = nullptr;
- QObject::connect(&compositor.xdgShell, &QWaylandXdgShell::toplevelCreated, [&](QWaylandXdgToplevel *t) {
- toplevel = t;
- });
+ QObject::connect(&compositor.xdgShell, &QWaylandXdgShell::toplevelCreated,
+ this, [&](QWaylandXdgToplevel *t) { toplevel = t; });
MockClient client;
wl_surface *surface = client.createSurface();
@@ -1041,7 +1083,7 @@ void tst_WaylandCompositor::sendsXdgConfigure()
QTRY_VERIFY(!toplevel->fullscreen());
QTRY_VERIFY(!toplevel->resizing());
- toplevel->sendConfigure(QSize(10, 20), QVector<QWaylandXdgToplevel::State>{QWaylandXdgToplevel::State::ActivatedState});
+ toplevel->sendConfigure(QSize(10, 20), QList<QWaylandXdgToplevel::State>{QWaylandXdgToplevel::State::ActivatedState});
compositor.flushClients();
QTRY_COMPARE(mockToplevel.configureStates, QList<uint>{QWaylandXdgToplevel::State::ActivatedState});
QTRY_COMPARE(mockToplevel.configureSize, QSize(10, 20));
@@ -1088,7 +1130,7 @@ void tst_WaylandCompositor::sendsXdgConfigure()
QTRY_VERIFY(mockToplevel.configureStates.contains(QWaylandXdgToplevel::State::ActivatedState));
QTRY_VERIFY(!mockToplevel.configureStates.contains(QWaylandXdgToplevel::State::FullscreenState));
- toplevel->sendConfigure(QSize(0, 0), QVector<QWaylandXdgToplevel::State>{});
+ toplevel->sendConfigure(QSize(0, 0), QList<QWaylandXdgToplevel::State>{});
compositor.flushClients();
QTRY_VERIFY(!mockToplevel.configureStates.contains(QWaylandXdgToplevel::State::ActivatedState));
@@ -1136,13 +1178,12 @@ void tst_WaylandCompositor::createsIviSurfaces()
QSignalSpy iviSurfaceCreatedSpy(&compositor.iviApplication, &QWaylandIviApplication::iviSurfaceRequested);
QWaylandIviSurface *iviSurface = nullptr;
- QObject::connect(&compositor.iviApplication, &QWaylandIviApplication::iviSurfaceCreated, [&](QWaylandIviSurface *s) {
- iviSurface = s;
- });
+ QObject::connect(&compositor.iviApplication, &QWaylandIviApplication::iviSurfaceCreated,
+ this, [&](QWaylandIviSurface *s) { iviSurface = s; });
wl_surface *surface = client.createSurface();
client.createIviSurface(surface, 123);
- QTRY_COMPARE(iviSurfaceCreatedSpy.count(), 1);
+ QTRY_COMPARE(iviSurfaceCreatedSpy.size(), 1);
QTRY_VERIFY(iviSurface);
QTRY_VERIFY(iviSurface->surface());
QTRY_COMPARE(iviSurface->iviId(), 123u);
@@ -1158,9 +1199,10 @@ void tst_WaylandCompositor::emitsErrorOnSameIviId()
QTRY_VERIFY(&firstClient.iviApplication);
QWaylandIviSurface *firstIviSurface = nullptr;
- QObject::connect(&compositor.iviApplication, &QWaylandIviApplication::iviSurfaceCreated, [&](QWaylandIviSurface *s) {
- firstIviSurface = s;
- });
+ auto connection = QObject::connect(&compositor.iviApplication,
+ &QWaylandIviApplication::iviSurfaceCreated,
+ this,
+ [&](QWaylandIviSurface *s) { firstIviSurface = s; });
firstClient.createIviSurface(firstClient.createSurface(), 123);
QTRY_VERIFY(firstIviSurface);
@@ -1169,7 +1211,7 @@ void tst_WaylandCompositor::emitsErrorOnSameIviId()
{
MockClient secondClient;
QTRY_VERIFY(&secondClient.iviApplication);
- QTRY_COMPARE(compositor.clients().count(), 2);
+ QTRY_COMPARE(compositor.clients().size(), 2);
secondClient.createIviSurface(secondClient.createSurface(), 123);
compositor.flushClients();
@@ -1177,8 +1219,9 @@ void tst_WaylandCompositor::emitsErrorOnSameIviId()
QTRY_COMPARE(secondClient.error, EPROTO);
QTRY_COMPARE(secondClient.protocolError.interface, &ivi_application_interface);
QTRY_COMPARE(static_cast<ivi_application_error>(secondClient.protocolError.code), IVI_APPLICATION_ERROR_IVI_ID);
- QTRY_COMPARE(compositor.clients().count(), 1);
+ QTRY_COMPARE(compositor.clients().size(), 1);
}
+ QObject::disconnect(connection);
}
// The other clients have passed out of scope and have been destroyed,
@@ -1187,9 +1230,8 @@ void tst_WaylandCompositor::emitsErrorOnSameIviId()
QTRY_VERIFY(&thirdClient.iviApplication);
QWaylandIviSurface *thirdIviSurface = nullptr;
- QObject::connect(&compositor.iviApplication, &QWaylandIviApplication::iviSurfaceCreated, [&](QWaylandIviSurface *s) {
- thirdIviSurface = s;
- });
+ QObject::connect(&compositor.iviApplication, &QWaylandIviApplication::iviSurfaceCreated,
+ this, [&](QWaylandIviSurface *s) { thirdIviSurface = s; });
thirdClient.createIviSurface(thirdClient.createSurface(), 123);
compositor.flushClients();
@@ -1218,9 +1260,8 @@ void tst_WaylandCompositor::sendsIviConfigure()
QTRY_VERIFY(client.iviApplication);
QWaylandIviSurface *iviSurface = nullptr;
- QObject::connect(&compositor.iviApplication, &QWaylandIviApplication::iviSurfaceCreated, [&](QWaylandIviSurface *s) {
- iviSurface = s;
- });
+ QObject::connect(&compositor.iviApplication, &QWaylandIviApplication::iviSurfaceCreated,
+ this, [&](QWaylandIviSurface *s) { iviSurface = s; });
wl_surface *surface = client.createSurface();
ivi_surface *clientIviSurface = client.createIviSurface(surface, 123);
@@ -1242,60 +1283,15 @@ void tst_WaylandCompositor::destroysIviSurfaces()
QTRY_VERIFY(client.iviApplication);
QWaylandIviSurface *iviSurface = nullptr;
- QObject::connect(&compositor.iviApplication, &QWaylandIviApplication::iviSurfaceCreated, [&](QWaylandIviSurface *s) {
- iviSurface = s;
- });
+ QObject::connect(&compositor.iviApplication, &QWaylandIviApplication::iviSurfaceCreated,
+ this, [&](QWaylandIviSurface *s) { iviSurface = s; });
QtWayland::ivi_surface mockIviSurface(client.createIviSurface(client.createSurface(), 123));
QTRY_VERIFY(iviSurface);
QSignalSpy destroySpy(iviSurface, SIGNAL(destroyed()));
mockIviSurface.destroy();
- QTRY_VERIFY(destroySpy.count() == 1);
-}
-
-void tst_WaylandCompositor::convertsXdgEdgesToQtEdges()
-{
- const uint wlLeft = ZXDG_POSITIONER_V6_ANCHOR_LEFT;
- QCOMPARE(QWaylandXdgShellV6Private::convertToEdges(wlLeft), Qt::LeftEdge);
-
- const uint wlRight = ZXDG_POSITIONER_V6_ANCHOR_RIGHT;
- QCOMPARE(QWaylandXdgShellV6Private::convertToEdges(wlRight), Qt::RightEdge);
-
- const uint wlTop = ZXDG_POSITIONER_V6_ANCHOR_TOP;
- QCOMPARE(QWaylandXdgShellV6Private::convertToEdges(wlTop), Qt::TopEdge);
-
- const uint wlBottom = ZXDG_POSITIONER_V6_ANCHOR_BOTTOM;
- QCOMPARE(QWaylandXdgShellV6Private::convertToEdges(wlBottom), Qt::BottomEdge);
-
- QCOMPARE(QWaylandXdgShellV6Private::convertToEdges(wlBottom | wlLeft), Qt::Edges(Qt::BottomEdge | Qt::LeftEdge));
- QCOMPARE(QWaylandXdgShellV6Private::convertToEdges(wlTop | wlRight), Qt::Edges(Qt::TopEdge | Qt::RightEdge));
-}
-
-void tst_WaylandCompositor::xdgShellV6Positioner()
-{
- QWaylandXdgPositionerV6Data p;
- QVERIFY(!p.isComplete());
-
- p.size = QSize(100, 50);
- p.anchorRect = QRect(QPoint(1, 2), QSize(800, 600));
- QVERIFY(p.isComplete());
-
- p.anchorEdges = Qt::TopEdge | Qt::LeftEdge;
- p.gravityEdges = Qt::BottomEdge | Qt::RightEdge;
- QCOMPARE(p.unconstrainedPosition(), QPoint(1, 2));
-
- p.anchorEdges = Qt::RightEdge;
- QCOMPARE(p.unconstrainedPosition(), QPoint(1 + 800, 2 + 600 / 2));
-
- p.gravityEdges = Qt::BottomEdge;
- QCOMPARE(p.unconstrainedPosition(), QPoint(1 + 800 - 100 / 2, 2 + 600 / 2));
-
- p.gravityEdges = Qt::TopEdge;
- QCOMPARE(p.unconstrainedPosition(), QPoint(1 + 800 - 100 / 2, 2 + 600 / 2 - 50));
-
- p.offset = QPoint(4, 8);
- QCOMPARE(p.unconstrainedPosition(), QPoint(1 + 800 - 100 / 2 + 4, 2 + 600 / 2 - 50 + 8));
+ QTRY_VERIFY(destroySpy.size() == 1);
}
class ViewporterTestCompositor: public TestCompositor {
@@ -1699,5 +1695,103 @@ void tst_WaylandCompositor::viewportHiDpi()
wl_surface_destroy(surface);
}
+class IdleInhibitCompositor : public TestCompositor
+{
+ Q_OBJECT
+public:
+ IdleInhibitCompositor() : idleInhibitManager(this) {}
+ QWaylandIdleInhibitManagerV1 idleInhibitManager;
+};
+
+void tst_WaylandCompositor::idleInhibit()
+{
+ IdleInhibitCompositor compositor;
+ compositor.create();
+ MockClient client;
+ QTRY_VERIFY(client.idleInhibitManager);
+
+ auto *surface = client.createSurface();
+ QVERIFY(surface);
+ QTRY_COMPARE(compositor.surfaces.size(), 1);
+
+ QWaylandSurface *waylandSurface = compositor.surfaces.at(0);
+ auto *waylandSurfacePrivate =
+ QWaylandSurfacePrivate::get(waylandSurface);
+ QVERIFY(waylandSurfacePrivate);
+
+ QSignalSpy changedSpy(waylandSurface, SIGNAL(inhibitsIdleChanged()));
+
+ QCOMPARE(waylandSurface->inhibitsIdle(), false);
+
+ auto *idleInhibitor = client.createIdleInhibitor(surface);
+ QVERIFY(idleInhibitor);
+ QTRY_COMPARE(waylandSurfacePrivate->idleInhibitors.size(), 1);
+ QCOMPARE(waylandSurface->inhibitsIdle(), true);
+ QTRY_COMPARE(changedSpy.size(), 1);
+}
+
+class XdgOutputCompositor : public TestCompositor
+{
+ Q_OBJECT
+public:
+ XdgOutputCompositor() : xdgOutputManager(this) {}
+ QWaylandXdgOutputManagerV1 xdgOutputManager;
+};
+
+void tst_WaylandCompositor::xdgOutput()
+{
+ XdgOutputCompositor compositor;
+ compositor.create();
+
+ QWaylandOutputMode mode(QSize(1024, 768), 60000);
+ compositor.defaultOutput()->addMode(mode, true);
+ compositor.defaultOutput()->setCurrentMode(mode);
+
+ MockClient client;
+ QTRY_VERIFY(client.xdgOutputManager);
+ QTRY_COMPARE(client.m_outputs.size(), 1);
+
+ auto *wlOutput = client.m_outputs.first();
+ QVERIFY(wlOutput);
+
+ // Output is not associated yet
+ QCOMPARE(QWaylandOutputPrivate::get(compositor.defaultOutput())->xdgOutput.isNull(), true);
+
+ // Create xdg-output on the server
+ auto *xdgOutputServer = new QWaylandXdgOutputV1(compositor.defaultOutput(), &compositor.xdgOutputManager);
+ QVERIFY(xdgOutputServer);
+ xdgOutputServer->setName(QStringLiteral("OUTPUT1"));
+ xdgOutputServer->setDescription(QStringLiteral("This is a test output"));
+
+ // Create it on the client
+ auto *xdgOutput = client.createXdgOutput(wlOutput);
+ QVERIFY(xdgOutput);
+ QVERIFY(client.m_xdgOutputs.contains(wlOutput));
+
+ // Now it should be associated
+ QCOMPARE(QWaylandOutputPrivate::get(compositor.defaultOutput())->xdgOutput.isNull(), false);
+
+ // Verify initial values
+ QTRY_COMPARE(xdgOutput->name, "OUTPUT1");
+ QTRY_COMPARE(xdgOutput->logicalPosition, QPoint());
+ QTRY_COMPARE(xdgOutput->logicalSize, QSize());
+
+ // Change properties
+ xdgOutputServer->setName(QStringLiteral("OUTPUT2"));
+ xdgOutputServer->setDescription(QStringLiteral("New description"));
+ xdgOutputServer->setLogicalPosition(QPoint(100, 100));
+ xdgOutputServer->setLogicalSize(QSize(1000, 1000));
+ compositor.flushClients();
+
+ // Name and description can't be changed after initialization,
+ // so we expect them to be the same
+ // TODO: With protocol version 3 the description will be allowed to change,
+ // but we implement version 2 now
+ QTRY_COMPARE(xdgOutput->name, "OUTPUT1");
+ QTRY_COMPARE(xdgOutput->description, "This is a test output");
+ QTRY_COMPARE(xdgOutput->logicalPosition, QPoint(100, 100));
+ QTRY_COMPARE(xdgOutput->logicalSize, QSize(1000, 1000));
+}
+
#include <tst_compositor.moc>
QTEST_MAIN(tst_WaylandCompositor);