diff options
Diffstat (limited to 'tests/manual')
85 files changed, 2497 insertions, 991 deletions
diff --git a/tests/manual/CMakeLists.txt b/tests/manual/CMakeLists.txt new file mode 100644 index 000000000..87ae459fd --- /dev/null +++ b/tests/manual/CMakeLists.txt @@ -0,0 +1,19 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +if(TARGET Qt::WaylandClient) + add_subdirectory(qmlclient) + add_subdirectory(subsurface) + add_subdirectory(texture-sharing/cpp-client) + add_subdirectory(texture-sharing-2) +endif() + +if(TARGET Qt::WaylandCompositor) + #add_subdirectory(wip-cpp-compositor) + add_subdirectory(scaling-compositor) + add_subdirectory(hwlayer-compositor) +endif() + +if(QT_FEATURE_opengl AND TARGET Qt::Quick AND TARGET Qt::WaylandClient) + add_subdirectory(server-buffer) +endif() diff --git a/tests/manual/hwlayer-compositor/.gitignore b/tests/manual/hwlayer-compositor/.gitignore new file mode 100644 index 000000000..83a421caf --- /dev/null +++ b/tests/manual/hwlayer-compositor/.gitignore @@ -0,0 +1 @@ +hwlayer-compositor diff --git a/tests/manual/hwlayer-compositor/CMakeLists.txt b/tests/manual/hwlayer-compositor/CMakeLists.txt new file mode 100644 index 000000000..729bae99b --- /dev/null +++ b/tests/manual/hwlayer-compositor/CMakeLists.txt @@ -0,0 +1,48 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +cmake_minimum_required(VERSION 3.16) +project(hwlayer-compositor LANGUAGES CXX) + +set(CMAKE_AUTOMOC ON) + +if(NOT DEFINED INSTALL_EXAMPLESDIR) + set(INSTALL_EXAMPLESDIR "examples") +endif() + +set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/wayland/hwlayer-compositor") + +find_package(Qt6 REQUIRED COMPONENTS Core Gui Qml) + +qt_add_executable(hwlayer-compositor + main.cpp +) + +set_target_properties(hwlayer-compositor PROPERTIES + WIN32_EXECUTABLE TRUE + MACOSX_BUNDLE TRUE +) + +target_link_libraries(hwlayer-compositor PUBLIC + Qt::Core + Qt::Gui + Qt::Qml +) + +# Resources: +set(hwlayer-compositor_resource_files + "main.qml" +) + +qt6_add_resources(hwlayer-compositor "hwlayer-compositor" + PREFIX + "/" + FILES + ${hwlayer-compositor_resource_files} +) + +install(TARGETS hwlayer-compositor + RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" + BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" + LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" +) diff --git a/tests/manual/hwlayer-compositor/hwlayer-compositor.pro b/tests/manual/hwlayer-compositor/hwlayer-compositor.pro new file mode 100644 index 000000000..a6eed9079 --- /dev/null +++ b/tests/manual/hwlayer-compositor/hwlayer-compositor.pro @@ -0,0 +1,14 @@ +QT += gui qml + +SOURCES += \ + main.cpp + +OTHER_FILES = \ + main.qml + +RESOURCES += hwlayer-compositor.qrc + +target.path = $$[QT_INSTALL_EXAMPLES]/wayland/hwlayer-compositor +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS hwlayer-compositor.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/wayland/hwlayer-compositor +INSTALLS += target sources diff --git a/tests/manual/hwlayer-compositor/hwlayer-compositor.qrc b/tests/manual/hwlayer-compositor/hwlayer-compositor.qrc new file mode 100644 index 000000000..5f6483ac3 --- /dev/null +++ b/tests/manual/hwlayer-compositor/hwlayer-compositor.qrc @@ -0,0 +1,5 @@ +<RCC> + <qresource prefix="/"> + <file>main.qml</file> + </qresource> +</RCC> diff --git a/tests/manual/hwlayer-compositor/main.cpp b/tests/manual/hwlayer-compositor/main.cpp new file mode 100644 index 000000000..85cab3cec --- /dev/null +++ b/tests/manual/hwlayer-compositor/main.cpp @@ -0,0 +1,17 @@ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#include <QtCore/QUrl> +#include <QtCore/QDebug> + +#include <QtGui/QGuiApplication> +#include <QQmlContext> + +#include <QtQml/QQmlApplicationEngine> + +int main(int argc, char *argv[]) +{ + QGuiApplication app(argc, argv); + QQmlApplicationEngine appEngine(QUrl("qrc:///main.qml")); + return app.exec(); +} diff --git a/tests/manual/hwlayer-compositor/main.qml b/tests/manual/hwlayer-compositor/main.qml new file mode 100644 index 000000000..32a197ac1 --- /dev/null +++ b/tests/manual/hwlayer-compositor/main.qml @@ -0,0 +1,117 @@ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +import QtQuick +import QtQuick.Window +import QtQuick.Controls +import QtWayland.Compositor +import QtWayland.Compositor.XdgShell +import QtWayland.Compositor.WlShell +import QtWayland.Compositor.IviApplication + +WaylandCompositor { + WaylandOutput { + sizeFollowsWindow: true + window: Window { + color: "tomato" + id: win + width: 1024 + height: 768 + visible: true + Rectangle { + color: "lightgreen" + anchors.centerIn: parent + width: parent.width / 3 + height: parent.width / 3 + NumberAnimation on rotation { + id: rotationAnimation + running: false + from: 0 + to: 90 + loops: Animation.Infinite + duration: 1000 + } + } + Repeater { + model: shellSurfaces + ShellSurfaceItem { + id: waylandItem + onSurfaceDestroyed: shellSurfaces.remove(index) + shellSurface: shSurface + WaylandHardwareLayer { + stackingLevel: level + Component.onCompleted: console.log("Added hardware layer with stacking level", stackingLevel); + } + Component.onCompleted: console.log("Added wayland quick item"); + Behavior on x { + PropertyAnimation { + easing.type: Easing.OutBounce + duration: 1000 + } + } + Timer { + interval: 2000; running: animatePosition; repeat: true + onTriggered: waylandItem.x = waylandItem.x === 0 ? win.width - waylandItem.width : 0 + } + Behavior on opacity { + PropertyAnimation { + duration: 1000 + } + } + Timer { + interval: 2000; running: animateOpacity; repeat: true + onTriggered: waylandItem.opacity = waylandItem.opacity === 1 ? 0 : 1 + } + } + } + Column { + anchors.bottom: parent.bottom + Repeater { + model: shellSurfaces + Row { + Label { + anchors.verticalCenter: parent.verticalCenter + leftPadding: 15 + rightPadding: 15 + text: "Surface " + index + } + CheckBox { + text: "Animate position" + checked: animatePosition + onClicked: animatePosition = !animatePosition + } + CheckBox { + text: "Animate Opacity" + checked: animateOpacity + onClicked: animateOpacity = !animateOpacity + } + Label { + text: "Stacking level" + } + SpinBox { + value: level + onValueModified: level = value; + } + Button { + text: "Kill" + onClicked: shSurface.surface.client.kill() + } + } + } + CheckBox { + text: "Rotation" + checked: rotationAnimation.running + onClicked: rotationAnimation.running = !rotationAnimation.running + padding: 30 + } + } + } + } + ListModel { id: shellSurfaces } + function addShellSurface(shellSurface) { + shellSurfaces.append({shSurface: shellSurface, animatePosition: false, animateOpacity: false, level: 0}); + } + XdgShell { onToplevelCreated: (toplevel, xdgSurface) => addShellSurface(xdgSurface) } + IviApplication { onIviSurfaceCreated: (iviSurface) => addShellSurface(iviSurface) } + WlShell { onWlShellSurfaceCreated: (shellSurface) => addShellSurface(shellSurface) } +} diff --git a/tests/manual/import-qml-modules/CMakeLists.txt b/tests/manual/import-qml-modules/CMakeLists.txt new file mode 100644 index 000000000..c99218203 --- /dev/null +++ b/tests/manual/import-qml-modules/CMakeLists.txt @@ -0,0 +1,25 @@ +# Copyright (C) 2024 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +cmake_minimum_required(VERSION 3.16) + +project(import_wayland_qml_modules VERSION 0.1 LANGUAGES CXX) + +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +find_package(Qt6 6.4 REQUIRED + COMPONENTS + Quick + WaylandCompositor + WaylandCompositorIviapplication + WaylandCompositorPresentationTime + WaylandCompositorWLShell + WaylandCompositorXdgShell +) + +qt_standard_project_setup() + +qt_add_qml_module(import_wayland_qml_modules + URI Qml + QML_FILES Main.qml +) diff --git a/tests/manual/import-qml-modules/Main.qml b/tests/manual/import-qml-modules/Main.qml new file mode 100644 index 000000000..07b8bc482 --- /dev/null +++ b/tests/manual/import-qml-modules/Main.qml @@ -0,0 +1,18 @@ +// Copyright (C) 2024 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +import QtQuick +import QtWayland.Compositor.IviApplication +import QtWayland.Compositor.PresentationTime +import QtWayland.Compositor.QtShell +import QtWayland.Compositor.WlShell +import QtWayland.Compositor.XdgShell + + +Item { + property var p1: IviApplication {} + property var p2: PresentationTime {} + property var p3: QtShellChrome {} + property var p4: WlShellSurface {} + property var p5: XdgPopup {} +} diff --git a/tests/manual/import-qml-modules/main.cpp b/tests/manual/import-qml-modules/main.cpp new file mode 100644 index 000000000..1b0b801ff --- /dev/null +++ b/tests/manual/import-qml-modules/main.cpp @@ -0,0 +1,19 @@ +// Copyright (C) 2024 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#include <QtGui/QGuiApplication> +#include <QtQml/QQmlApplicationEngine> + +int main(int argc, char *argv[]) +{ + QGuiApplication app(argc, argv); + + QQmlApplicationEngine engine; + const QUrl url(QStringLiteral("qrc:/Qml/Main.qml")); + QObject::connect( + &engine, &QQmlApplicationEngine::objectCreationFailed, &app, + []() { QCoreApplication::exit(-1); }, Qt::QueuedConnection); + engine.load(url); + + return app.exec(); +} diff --git a/tests/manual/keymap/keymapcompositor.qml b/tests/manual/keymap/keymapcompositor.qml index 77111c815..7d8bcda7c 100644 --- a/tests/manual/keymap/keymapcompositor.qml +++ b/tests/manual/keymap/keymapcompositor.qml @@ -1,55 +1,9 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only import QtQuick 2.0 import QtWayland.Compositor 1.0 +import QtWayland.Compositor.WlShell import QtQuick.Window 2.2 WaylandCompositor { @@ -91,7 +45,4 @@ WaylandCompositor { WlShell { onWlShellSurfaceCreated: chromeComponent.createObject(surfaceArea, { "shellSurface": shellSurface } ); } - XdgShellV5 { - onXdgSurfaceCreated: chromeComponent.createObject(surfaceArea, { "shellSurface": xdgSurface } ); - } } diff --git a/tests/manual/qmlclient/CMakeLists.txt b/tests/manual/qmlclient/CMakeLists.txt new file mode 100644 index 000000000..7dedc67bf --- /dev/null +++ b/tests/manual/qmlclient/CMakeLists.txt @@ -0,0 +1,36 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +# Generated from qmlclient.pro. + +##################################################################### +## qmlclient Binary: +##################################################################### + +qt_internal_add_manual_test(qmlclient + GUI + SOURCES + main.cpp + LIBRARIES + Qt::CorePrivate + Qt::Gui + Qt::GuiPrivate + Qt::Quick + Qt::WaylandClient +) + +# Resources: +set(qml_resource_files + "main.qml" +) + +qt_internal_add_resource(qmlclient "qml" + PREFIX + "/" + FILES + ${qml_resource_files} +) + + +#### Keys ignored in scope 1:.:.:qmlclient.pro:<TRUE>: +# TEMPLATE = "app" diff --git a/tests/manual/qmlclient/main.cpp b/tests/manual/qmlclient/main.cpp index 9e0774b13..673359b52 100644 --- a/tests/manual/qmlclient/main.cpp +++ b/tests/manual/qmlclient/main.cpp @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <QtGui/QGuiApplication> #include <QtQml/QQmlApplicationEngine> diff --git a/tests/manual/qmlclient/main.qml b/tests/manual/qmlclient/main.qml index 5ee63955b..b5061c182 100644 --- a/tests/manual/qmlclient/main.qml +++ b/tests/manual/qmlclient/main.qml @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only import QtQuick 2.2 import QtQuick.Window 2.2 diff --git a/tests/manual/qt-shell/CMakeLists.txt b/tests/manual/qt-shell/CMakeLists.txt new file mode 100644 index 000000000..daf8fb25d --- /dev/null +++ b/tests/manual/qt-shell/CMakeLists.txt @@ -0,0 +1,46 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +cmake_minimum_required(VERSION 3.14) +project(qt-shell LANGUAGES CXX) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) +set(CMAKE_AUTOUIC ON) + +find_package(Qt6 COMPONENTS Core) +find_package(Qt6 COMPONENTS Gui) +find_package(Qt6 COMPONENTS Qml) + +qt_add_executable(qt-shell + main.cpp +) +set_target_properties(qt-shell PROPERTIES + WIN32_EXECUTABLE TRUE + MACOSX_BUNDLE TRUE +) +target_link_libraries(qt-shell PUBLIC + Qt::Core + Qt::Gui + Qt::Qml +) + + +# Resources: +set(qt-shell_resource_files + "images/background.jpg" + "qml/Chrome.qml" + "qml/HandleHandler.qml" + "qml/CompositorScreen.qml" + "qml/Keyboard.qml" + "qml/main.qml" +) + +qt6_add_resources(qt-shell "qt-shell" + PREFIX + "/" + FILES + ${qt-shell_resource_files} +) diff --git a/tests/manual/qt-shell/images/background.jpg b/tests/manual/qt-shell/images/background.jpg Binary files differnew file mode 100644 index 000000000..445567fbd --- /dev/null +++ b/tests/manual/qt-shell/images/background.jpg diff --git a/tests/manual/qt-shell/main.cpp b/tests/manual/qt-shell/main.cpp new file mode 100644 index 000000000..31bd58fae --- /dev/null +++ b/tests/manual/qt-shell/main.cpp @@ -0,0 +1,21 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#include <QtCore/QUrl> +#include <QtCore/QDebug> + +#include <QtGui/QGuiApplication> + +#include <QtQml/QQmlApplicationEngine> + +int main(int argc, char *argv[]) +{ + // ShareOpenGLContexts is needed for using the threaded renderer + // on Nvidia EGLStreams + QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts, true); + QGuiApplication app(argc, argv); + + QQmlApplicationEngine appEngine(QUrl("qrc:///qml/main.qml")); + + return app.exec(); +} diff --git a/tests/manual/qt-shell/qml/Chrome.qml b/tests/manual/qt-shell/qml/Chrome.qml new file mode 100644 index 000000000..9eb2f1965 --- /dev/null +++ b/tests/manual/qt-shell/qml/Chrome.qml @@ -0,0 +1,458 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +import QtQuick +import QtQuick.Controls +import QtQuick.Layouts +import QtWayland.Compositor + +Item { + id: chrome + + property bool positionSet: false + + x: shellSurface.windowGeometry.x - leftResizeHandle.width + y: shellSurface.windowGeometry.y - topResizeHandle.height - titleBar.height + width: shellSurface.windowGeometry.width + leftResizeHandle.width + rightResizeHandle.width + height: shellSurface.windowGeometry.height + topResizeHandle.height + titleBar.height + bottomResizeHandle.height + + property rect oldGeometry: Qt.rect(0, 0, 100, 100) + property bool isChild: parent.shellSurface !== undefined + property alias shellSurface: shellSurfaceItem.shellSurface + + property int windowState: Qt.WindowNoState + + signal destroyAnimationFinished + signal activated + signal deactivated + + property int windowFlags: shellSurface.windowFlags !== Qt.Window + ? shellSurface.windowFlags + : defaultFlags + onDecorationsShowingChanged:{ + shellSurfaceItem.updateFrameMargins() + } + + Component.onCompleted: { + shellSurface.active = true + } + + property int defaultFlags: (Qt.Window + | Qt.WindowMaximizeButtonHint + | Qt.WindowMinimizeButtonHint + | Qt.WindowCloseButtonHint) + + property bool frameless: (chrome.windowFlags & Qt.FramelessWindowHint) != 0 + || (chrome.windowState & Qt.WindowFullScreen) != 0 + || ((chrome.windowFlags & Qt.Popup) == Qt.Popup + && (chrome.windowFlags & Qt.Tool) != Qt.Tool) + + property bool decorationsShowing: (chrome.windowFlags & Qt.Window) != 0 && !frameless + + transform: [ + Scale { + id: scaleTransform + origin.x: chrome.width / 2 + origin.y: chrome.height / 2 + } + ] + + Rectangle { + id: leftResizeHandle + color: "gray" + width: visible ? 5 : 0 + anchors.left: parent.left + anchors.top: parent.top + anchors.bottom: parent.bottom + visible: decorationsShowing + + HandleHandler { + enabled: (chrome.windowState & (Qt.WindowMinimized|Qt.WindowMaximized)) == 0 + flags: westBound + } + } + + Rectangle { + id: rightResizeHandle + color: "gray" + width: visible ? 5 : 0 + anchors.right: parent.right + anchors.top: parent.top + anchors.bottom: parent.bottom + visible: decorationsShowing + + HandleHandler { + enabled: (chrome.windowState & (Qt.WindowMinimized|Qt.WindowMaximized)) == 0 + flags: eastBound + } + } + + Rectangle { + id: topResizeHandle + color: "gray" + height: visible ? 5 : 0 + anchors.left: parent.left + anchors.top: parent.top + anchors.right: parent.right + visible: decorationsShowing + + HandleHandler { + enabled: (chrome.windowState & (Qt.WindowMinimized|Qt.WindowMaximized)) == 0 + flags: northBound + } + } + + Rectangle { + id: bottomResizeHandle + color: "gray" + height: visible ? 5 : 0 + anchors.left: parent.left + anchors.bottom: parent.bottom + anchors.right: parent.right + visible: decorationsShowing + + HandleHandler { + enabled: (chrome.windowState & (Qt.WindowMinimized|Qt.WindowMaximized)) == 0 + flags: southBound + } + } + + Rectangle { + id: topLeftResizeHandle + color: "gray" + height: 5 + width: 5 + anchors.left: parent.left + anchors.top: parent.top + visible: decorationsShowing + + HandleHandler { + enabled: (chrome.windowState & (Qt.WindowMinimized|Qt.WindowMaximized)) == 0 + flags: westBound | northBound + } + } + + Rectangle { + id: topRightResizeHandle + color: "gray" + height: 5 + width: 5 + anchors.right: parent.right + anchors.top: parent.top + visible: decorationsShowing + + HandleHandler { + enabled: (chrome.windowState & (Qt.WindowMinimized|Qt.WindowMaximized)) == 0 + flags: eastBound | northBound + } + } + + Rectangle { + id: bottomLeftResizeHandle + color: "gray" + height: 5 + width: 5 + anchors.left: parent.left + anchors.bottom: parent.bottom + visible: decorationsShowing + + HandleHandler { + enabled: (chrome.windowState & (Qt.WindowMinimized|Qt.WindowMaximized)) == 0 + flags: westBound | southBound + } + } + + Rectangle { + id: bottomRightResizeHandle + color: "gray" + height: 5 + width: 5 + anchors.right: parent.right + anchors.bottom: parent.bottom + visible: decorationsShowing + + HandleHandler { + enabled: (chrome.windowState & (Qt.WindowMinimized|Qt.WindowMaximized)) == 0 + flags: eastBound | southBound + } + } + + function constrainPoint(mousePos) { + var x0 = usableArea.x + var y0 = usableArea.y + var x1 = x0 + usableArea.width + var y1 = y0 + usableArea.height + return Qt.point(Math.min(Math.max(x0,mousePos.x), x1), + Math.min(Math.max(y0,mousePos.y), y1)) + } + + function maxContentRect() { + var x0 = usableArea.x + leftResizeHandle.width + var x1 = usableArea.x + usableArea.width - rightResizeHandle.width + var y0 = usableArea.y + topResizeHandle.height + titleBar.height + var y1 = usableArea.y + usableArea.height - bottomResizeHandle.height + return Qt.rect(x0, y0, x1 - x0, y1 - y0) + } + + function randomPos(windowSize, screenSize) { + var res = (windowSize >= screenSize) ? 0 : Math.floor(Math.random() * (screenSize - windowSize)) + return res + } + + function activate() + { + shellSurface.active = true + shellSurfaceItem.raise() + activated() + } + + function deactivate() + { + shellSurface.active = true + deactivated() + } + + function setWindowState(nextState) { + var currentState = chrome.windowState + if (currentState === nextState) + return + + console.log("setWindowState", nextState.toString(16)) + + if ((currentState & (Qt.WindowMinimized | Qt.WindowMaximized | Qt.WindowFullScreen)) == 0) + chrome.oldGeometry = chrome.shellSurface.windowGeometry + + chrome.windowState = nextState + + if ((nextState & Qt.WindowMinimized) != 0) { + console.log("MINIMIZE") + chrome.shellSurface.requestWindowGeometry(nextState, Qt.rect(0, 0, 1, 1)) + shellSurfaceItem.visible = false + } else if ((nextState & Qt.WindowFullScreen) != 0) { + console.log("FULLSCREENIZE") + chrome.shellSurface.requestWindowGeometry(nextState, Qt.rect(0, 0, output.window.width, output.window.height)) + shellSurfaceItem.visible = true + } else if ((nextState & Qt.WindowMaximized) != 0) { + console.log("MAXIMIZE") + chrome.shellSurface.requestWindowGeometry(nextState, maxContentRect()) + shellSurfaceItem.visible = true + } else { + console.log("NORMALIZE", chrome.oldGeometry) + chrome.shellSurface.requestWindowGeometry(nextState, chrome.oldGeometry) + shellSurfaceItem.visible = true + } + } + + Rectangle { + id: titleBar + anchors.top: topResizeHandle.bottom + anchors.left: leftResizeHandle.right + anchors.right: rightResizeHandle.left + height: visible ? xButton.height + 10 : 0 + color: shellSurface.active ? "cornflowerblue" : "lightgray" + visible: !frameless + + Text { + anchors.left: parent.left + anchors.right: rowLayout.left + anchors.verticalCenter: parent.verticalCenter + + font.pixelSize: xButton.height + text: shellSurface.windowTitle + fontSizeMode: Text.Fit + } + + RowLayout { + id: rowLayout + anchors.right: parent.right + anchors.rightMargin: 5 + + ToolButton { + text: "-" + Layout.margins: 5 + visible: (chrome.windowFlags & Qt.WindowMinimizeButtonHint) != 0 + onClicked: { + var newState + if ((shellSurface.windowState & Qt.WindowMinimized) != 0) + newState = chrome.windowState & ~Qt.WindowMinimized + else + newState = chrome.windowState | Qt.WindowMinimized + + if ((newState & Qt.WindowMaximized) != 0) + newState &= ~Qt.WindowMaximized + + setWindowState(newState) + } + } + + ToolButton { + text: "+" + Layout.margins: 5 + visible: (chrome.windowFlags & Qt.WindowMaximizeButtonHint) != 0 + onClicked: { + var newState + if ((shellSurface.windowState & Qt.WindowMaximized) != 0) + newState = shellSurface.windowState & ~Qt.WindowMaximized + else + newState = shellSurface.windowState | Qt.WindowMaximized + + if ((newState & Qt.WindowMinimized) != 0) + newState &= ~Qt.WindowMinimized + + setWindowState(newState) + } + } + + ToolButton { + id: xButton + text: "X" + Layout.margins: 5 + visible: (chrome.windowFlags & Qt.WindowCloseButtonHint) != 0 + onClicked: shellSurface.sendClose() + } + } + + DragHandler { + target: null + property real xOffset: -1.0 + property real yOffset: -1.0 + property bool started: false + enabled: (shellSurface.windowState & (Qt.WindowMinimized|Qt.WindowMaximized)) == 0 + + onGrabChanged: { + started = false + activate() + } + + onCentroidChanged: { + if (!active) + return + + if (!started) { + xOffset = shellSurface.windowPosition.x - centroid.scenePressPosition.x + yOffset = shellSurface.windowPosition.y - centroid.scenePressPosition.y + started = true + chrome.positionAutomatic = false + } + + var pos = chrome.constrainPoint(centroid.scenePosition) + shellSurface.windowPosition = Qt.point(pos.x + xOffset, pos.y + yOffset) + } + } + } + + ShellSurfaceItem { + id: shellSurfaceItem + anchors.top: titleBar.bottom + anchors.bottom: bottomResizeHandle.top + anchors.left: leftResizeHandle.right + anchors.right: rightResizeHandle.left + + moveItem: chrome + + staysOnBottom: shellSurface.windowFlags & Qt.WindowStaysOnBottomHint + staysOnTop: !staysOnBottom && shellSurface.windowFlags & Qt.WindowStaysOnTopHint + function updateFrameMargins() + { + shellSurface.frameMarginLeft = (decorationsShowing ? leftResizeHandle.width : 0) + shellSurface.frameMarginRight = (decorationsShowing ? rightResizeHandle.width : 0) + shellSurface.frameMarginTop = (decorationsShowing ? topResizeHandle.height : 0) + + (!frameless ? titleBar.height : 0) + shellSurface.frameMarginBottom = (decorationsShowing ? bottomResizeHandle.height : 0) + } + + Component.onCompleted: { + updateFrameMargins() + } + + onSurfaceDestroyed: { + bufferLocked = true; + destroyAnimation.start(); + } + + Connections { + target: shellSurface + function onWindowFlagsChanged() { + console.log("FLAGS", shellSurface.windowFlags.toString(16)) + shellSurfaceItem.updateFrameMargins() + } + + function onWindowStateChanged() { + setWindowState(shellSurface.windowState) + } + + function onActiveChanged() { + if (shellSurface.active) { + shellSurfaceItem.raise() + activated() + } else { + deactivated() + } + } + + function onStartResize() { + console.log("START SYSTEM RESIZE") + } + function onStartMove() { + console.log("START SYSTEM MOVE") + } + + function onRaiseRequested() { + console.log("RAISE") + shellSurfaceItem.raise() + } + function onLowerRequested() { + console.log("LOWER") + shellSurfaceItem.lower() + } + + function onWindowGeometryChanged() { + console.log("GEOM CHANGE", shellSurface.windowGeometry) + } + } + + Connections { + target: shellSurface.surface + function onHasContentChanged() { + if (!chrome.positionSet) { + var rect = shellSurface.windowGeometry + var w = rect.width + var h = rect.height + + var space = maxContentRect() + + var randomize = shellSurface.positionAutomatic + var xpos = randomize ? randomPos(w, space.width) + space.x : Math.max(rect.x, space.x) + var ypos = randomize ? randomPos(h, space.height) + space.y : Math.max(rect.y, space.y) + shellSurface.windowPosition = Qt.point(xpos, ypos) + } + chrome.positionSet = true + } + } + + SequentialAnimation { + id: destroyAnimation + + ParallelAnimation { + NumberAnimation { target: scaleTransform; property: "yScale"; to: 2/height; duration: 150 } + NumberAnimation { target: scaleTransform; property: "xScale"; to: 0.4; duration: 150 } + NumberAnimation { target: chrome; property: "opacity"; to: chrome.isChild ? 0 : 1; duration: 150 } + } + NumberAnimation { target: scaleTransform; property: "xScale"; to: 0; duration: 150 } + ScriptAction { script: chrome.destroyAnimationFinished() } + } + + SequentialAnimation { + id: receivedFocusAnimation + + ParallelAnimation { + NumberAnimation { target: scaleTransform; property: "yScale"; to: 1.02; duration: 100; easing.type: Easing.OutQuad } + NumberAnimation { target: scaleTransform; property: "xScale"; to: 1.02; duration: 100; easing.type: Easing.OutQuad } + } + ParallelAnimation { + NumberAnimation { target: scaleTransform; property: "yScale"; to: 1; duration: 100; easing.type: Easing.InOutQuad } + NumberAnimation { target: scaleTransform; property: "xScale"; to: 1; duration: 100; easing.type: Easing.InOutQuad } + } + } + } +} diff --git a/tests/manual/qt-shell/qml/CompositorScreen.qml b/tests/manual/qt-shell/qml/CompositorScreen.qml new file mode 100644 index 000000000..92b75b348 --- /dev/null +++ b/tests/manual/qt-shell/qml/CompositorScreen.qml @@ -0,0 +1,144 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +import QtQuick +import QtQuick.Window +import QtQuick.Controls +import QtWayland.Compositor + +WaylandOutput { + id: output + + property ListModel shellSurfaces: ListModel {} + property bool isNestedCompositor: Qt.platform.pluginName.startsWith("wayland") || Qt.platform.pluginName === "xcb" + property int currentActiveWindow: -1 + + function handleShellSurface(shellSurface) { + shellSurfaces.append({shellSurface: shellSurface}); + } + + // During development, it can be useful to start the compositor inside X11 or + // another Wayland compositor. In such cases, set sizeFollowsWindow to true to + // enable resizing of the compositor window to be forwarded to the Wayland clients + // as the output (screen) changing resolution. Consider setting it to false if you + // are running the compositor using eglfs, linuxfb or similar QPA backends. + sizeFollowsWindow: output.isNestedCompositor + + window: Window { + width: 1920 + height: 1080 + visible: true + + WaylandMouseTracker { + id: mouseTracker + + anchors.fill: parent + + // Set this to false to disable the outer mouse cursor when running nested + // compositors. Otherwise you would see two mouse cursors, one for each compositor. + windowSystemCursorEnabled: output.isNestedCompositor + + Image { + id: background + + anchors.fill: parent + fillMode: Image.Tile + source: "qrc:/images/background.jpg" + smooth: true + + Repeater { + id: chromeRepeater + model: output.shellSurfaces + // Chrome displays a shell surface on the screen (See Chrome.qml) + Chrome { + shellSurface: modelData + onDestroyAnimationFinished: + { + if (currentActiveWindow > index) { + --currentActiveWindow + } else if (currentActiveWindow === index) { + currentActiveWindow = index - 1 + if (currentActiveWindow >= 0) { + var nextActiveSurface = output.shellSurfaces.get(currentActiveWindow).shellSurface + if (nextActiveSurface !== undefined) // More than one surface can get destroyed at the same time + nextActiveSurface.active = true + } + } + output.shellSurfaces.remove(index) + } + + onDeactivated: { + if (index === currentActiveWindow) + currentActiveWindow = -1 + } + + onActivated: { + if (index !== currentActiveWindow && currentActiveWindow >= 0) { + // This may already have been destroyed + if (output.shellSurfaces.get(currentActiveWindow).shellSurface !== undefined) + output.shellSurfaces.get(currentActiveWindow).shellSurface.active = false + } + + currentActiveWindow = index + } + } + } + } + + Rectangle { + anchors.fill: taskbar + color: "lavenderblush" + } + + Row { + id: taskbar + height: 40 + anchors.left: parent.left + anchors.right: parent.right + anchors.bottom: parent.bottom + + Repeater { + anchors.fill: parent + model: output.shellSurfaces + + ToolButton { + anchors.verticalCenter: parent.verticalCenter + text: modelData.windowTitle + onClicked: { + modelData.requestWindowGeometry(modelData.windowState & ~Qt.WindowMinimized, + modelData.windowGeometry) + chromeRepeater.itemAt(index).activate() + } + } + } + } + + Item { + id: usableArea + anchors.top: parent.top + anchors.left: parent.left + anchors.right: parent.right + anchors.bottom: taskbar.top + } + + // Virtual Keyboard + Loader { + anchors.fill: parent + source: "Keyboard.qml" + } + + // Draws the mouse cursor for a given Wayland seat + WaylandCursorItem { + inputEventsEnabled: false + x: mouseTracker.mouseX + y: mouseTracker.mouseY + seat: output.compositor.defaultSeat + } + } + + Shortcut { + sequence: "Ctrl+Alt+Backspace" + onActivated: Qt.quit() + } + } +} diff --git a/tests/manual/qt-shell/qml/HandleHandler.qml b/tests/manual/qt-shell/qml/HandleHandler.qml new file mode 100644 index 000000000..7b31ad4d5 --- /dev/null +++ b/tests/manual/qt-shell/qml/HandleHandler.qml @@ -0,0 +1,86 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +import QtQuick + +DragHandler { + target: null + + function selectCursor(f) + { + switch (f) { + case (southBound | eastBound): + case (northBound | westBound): + return Qt.SizeFDiagCursor + case (southBound | westBound): + case (northBound | eastBound): + return Qt.SizeBDiagCursor + case westBound: + case eastBound: + return Qt.SizeHorCursor + default: + return Qt.SizeVerCursor + } + } + + property int flags: WestBound + readonly property int westBound: 1 + readonly property int eastBound: 2 + readonly property int northBound: 4 + readonly property int southBound: 8 + + cursorShape: selectCursor(flags) + + property rect geom + property real startX: -1.0 + property real startY: -1.0 + property bool started: false + onGrabChanged: { + started = false + } + onCentroidChanged: { + if (!active) + return + if (!started) { + geom = shellSurface.windowGeometry + startX = centroid.scenePressPosition.x + startY = centroid.scenePressPosition.y + started = true + } + + var pos = chrome.constrainPoint(centroid.scenePosition) + var dx = pos.x - startX + var dy = pos.y - startY + + var minWidth = Math.max(0, shellSurface.minimumSize.width) + var minHeight = Math.max(0, shellSurface.minimumSize.height) + + var maxWidth = shellSurface.maximumSize.width > 0 ? shellSurface.maximumSize.width : Number.MAX_VALUE + var maxHeight = shellSurface.maximumSize.height > 0 ? shellSurface.maximumSize.height : Number.MAX_VALUE + + var newLeft = geom.left + if (flags & westBound) + newLeft = Math.max(geom.right - maxWidth, Math.min(geom.right - minWidth, newLeft + dx)); + + var newTop = geom.top + if (flags & northBound) + newTop = Math.max(geom.bottom - maxHeight, Math.min(geom.bottom - minHeight, newTop + dy)); + + var newRight = geom.right + if (flags & eastBound) + newRight = Math.max(geom.left, newRight + dx); + + var newBottom = geom.bottom + if (flags & southBound) + newBottom = Math.max(geom.top, newBottom + dy); + + console.log("RESIZE HANDLER", shellSurface.windowGeometry, geom, dy, newTop) + + + shellSurface.requestWindowGeometry(shellSurface.windowState, + Qt.rect(newLeft, + newTop, + newRight - newLeft, + newBottom - newTop)) + } +} diff --git a/tests/manual/qt-shell/qml/Keyboard.qml b/tests/manual/qt-shell/qml/Keyboard.qml new file mode 100644 index 000000000..a6e1bec30 --- /dev/null +++ b/tests/manual/qt-shell/qml/Keyboard.qml @@ -0,0 +1,12 @@ +// Copyright (C) 2021 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +import QtQuick +import QtQuick.VirtualKeyboard + +InputPanel { + visible: active + y: active ? parent.height - height : parent.height + anchors.left: parent.left + anchors.right: parent.right +} diff --git a/tests/manual/qt-shell/qml/main.qml b/tests/manual/qt-shell/qml/main.qml new file mode 100644 index 000000000..986e0a490 --- /dev/null +++ b/tests/manual/qt-shell/qml/main.qml @@ -0,0 +1,22 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +import QtQuick +import QtWayland.Compositor +import QtWayland.Compositor.QtShell + +WaylandCompositor { + id: waylandCompositor + + CompositorScreen { id: screen; compositor: waylandCompositor } + + // Shell surface extension. Needed to provide a window concept for Wayland clients. + // I.e. requests and events for maximization, minimization, resizing, closing etc. + + QtShell { + onQtShellSurfaceCreated: screen.handleShellSurface(qtShellSurface) + } + + // Extension for Input Method (QT_IM_MODULE) support at compositor-side + QtTextInputMethodManager {} +} diff --git a/tests/manual/qt-shell/qt-shell.pro b/tests/manual/qt-shell/qt-shell.pro new file mode 100644 index 000000000..c7e2cd912 --- /dev/null +++ b/tests/manual/qt-shell/qt-shell.pro @@ -0,0 +1,13 @@ +QT += gui qml + +SOURCES += \ + main.cpp + +OTHER_FILES = \ + qml/main.qml \ + qml/CompositorScreen.qml \ + qml/Chrome.qml \ + qml/Keyboard.qml \ + images/background.jpg \ + +RESOURCES += qt-shell.qrc diff --git a/tests/manual/qt-shell/qt-shell.qrc b/tests/manual/qt-shell/qt-shell.qrc new file mode 100644 index 000000000..3120382fd --- /dev/null +++ b/tests/manual/qt-shell/qt-shell.qrc @@ -0,0 +1,10 @@ +<RCC> + <qresource prefix="/"> + <file>images/background.jpg</file> + <file>qml/main.qml</file> + <file>qml/CompositorScreen.qml</file> + <file>qml/Chrome.qml</file> + <file>qml/Keyboard.qml</file> + <file>qml/HandleHandler.qml</file> + </qresource> +</RCC> diff --git a/tests/manual/scaling-compositor/CMakeLists.txt b/tests/manual/scaling-compositor/CMakeLists.txt new file mode 100644 index 000000000..2ee7d96bc --- /dev/null +++ b/tests/manual/scaling-compositor/CMakeLists.txt @@ -0,0 +1,33 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +# Generated from scaling-compositor.pro. + +##################################################################### +## scaling-compositor Binary: +##################################################################### + +qt_internal_add_manual_test(scaling-compositor + GUI + SOURCES + main.cpp + LIBRARIES + Qt::Gui + Qt::Qml +) + +# Resources: +set(qml_resource_files + "main.qml" +) + +qt_internal_add_resource(scaling-compositor "qml" + PREFIX + "/" + FILES + ${qml_resource_files} +) + + +#### Keys ignored in scope 1:.:.:scaling-compositor.pro:<TRUE>: +# TEMPLATE = "app" diff --git a/tests/manual/scaling-compositor/main.cpp b/tests/manual/scaling-compositor/main.cpp index b5c7dd688..e972b9ca6 100644 --- a/tests/manual/scaling-compositor/main.cpp +++ b/tests/manual/scaling-compositor/main.cpp @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <QtGui/QGuiApplication> #include <QtQml/QQmlApplicationEngine> diff --git a/tests/manual/scaling-compositor/main.qml b/tests/manual/scaling-compositor/main.qml index 056af4e5b..f173de3a0 100644 --- a/tests/manual/scaling-compositor/main.qml +++ b/tests/manual/scaling-compositor/main.qml @@ -1,57 +1,11 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only -import QtQuick 2.2 +import QtQuick 2.15 import QtQuick.Window 2.2 -import QtQuick.Controls 2.0 -import QtWayland.Compositor 1.0 +import QtWayland.Compositor 1.3 +import QtWayland.Compositor.WlShell +import QtWayland.Compositor.XdgShell WaylandCompositor { id: comp @@ -66,16 +20,7 @@ WaylandCompositor { height: 500 visible: true title: "Scaling compositor x" + output.scaleFactor - Button { - id: incrementButton - text: "+" - onClicked: ++output.scaleFactor - } - Button { - text: "-" - onClicked: output.scaleFactor = Math.max(1, output.scaleFactor - 1) - anchors.left: incrementButton.right - } + Repeater { model: shellSurfaces ShellSurfaceItem { @@ -83,6 +28,33 @@ WaylandCompositor { onSurfaceDestroyed: shellSurfaces.remove(index); } } + + Rectangle { + id: incrementButton + color: "#c0f0d0" + Text { + text: "+" + } + width: 100 + height: 30 + TapHandler { + onTapped: ++output.scaleFactor + } + } + + Rectangle { + id: decrementButton + color: "#f0d0c0" + Text { + text: "-" + } + width: 100 + height: 30 + TapHandler { + onTapped: output.scaleFactor = Math.max(1, output.scaleFactor - 1) + } + anchors.left: incrementButton.right + } } } @@ -91,4 +63,8 @@ WaylandCompositor { WlShell { onWlShellSurfaceCreated: shellSurfaces.append({shellSurface: shellSurface}); } + XdgShell { + onToplevelCreated: + shellSurfaces.append({shellSurface: xdgSurface}); + } } diff --git a/tests/manual/scaling-compositor/scaling-compositor.pro b/tests/manual/scaling-compositor/scaling-compositor.pro index 847e07ea7..200dc8c40 100644 --- a/tests/manual/scaling-compositor/scaling-compositor.pro +++ b/tests/manual/scaling-compositor/scaling-compositor.pro @@ -1,7 +1,6 @@ TEMPLATE = app -QT += gui qml quickcontrols2 - +QT += gui qml SOURCES += main.cpp RESOURCES += qml.qrc diff --git a/tests/manual/server-buffer/CMakeLists.txt b/tests/manual/server-buffer/CMakeLists.txt new file mode 100644 index 000000000..973063c71 --- /dev/null +++ b/tests/manual/server-buffer/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 3.16) +project(server-buffer) + +add_subdirectory(cpp-client) +add_subdirectory(compositor) diff --git a/tests/manual/server-buffer/README b/tests/manual/server-buffer/README new file mode 100644 index 000000000..ae76ca755 --- /dev/null +++ b/tests/manual/server-buffer/README @@ -0,0 +1,32 @@ +This example shows how to use the low-level server buffer extension. This +version of Qt also provides a texture sharing extension that provides more +functionality and convenience for sharing graphical assets with Qt Quick +clients: see the texture-sharing example. + +Compile up both compositor and client. + +If you have the dmabuf-server buffer integration (and you are running Mesa) +then start the compositor with: + +$ QT_WAYLAND_SERVER_BUFFER_INTEGRATION=dmabuf-server ./compositor + + +Note: if you are running a compositor on an X11 desktop, you also need to +set QT_XCB_GL_INTEGRATION=xcb_egl as usual. + +The compositor broadcasts the name of the server buffer integration to +all clients through the hardware integration extension. Therefore, +all you need to do is to start the client with + +$ ./server-buffer-cpp-client -platform wayland + +The client will show all the buffers shared by the compositor. + +For testing on desktop, there is also a shared memory based server buffer +integration that works with any graphics hardware: + +$ QT_WAYLAND_SERVER_BUFFER_INTEGRATION=shm-emulation-server QT_XCB_GL_INTEGRATION=xcb_egl ./compositor + +Note: the shm-emulation-server integration does not actually share graphics +buffers, so it will not give any graphics memory savings. It is intended solely +for testing during development and should never be used in production. diff --git a/tests/manual/server-buffer/compositor/CMakeLists.txt b/tests/manual/server-buffer/compositor/CMakeLists.txt new file mode 100644 index 000000000..5f4fb0c51 --- /dev/null +++ b/tests/manual/server-buffer/compositor/CMakeLists.txt @@ -0,0 +1,57 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +cmake_minimum_required(VERSION 3.16) +project(compositor) + +set(CMAKE_AUTOMOC ON) + +if(NOT DEFINED INSTALL_EXAMPLESDIR) + set(INSTALL_EXAMPLESDIR "examples") +endif() + +set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/wayland/server-buffer/compositor") + +find_package(Qt6 REQUIRED COMPONENTS Core Gui Qml WaylandCompositor) + +qt_add_executable(compositor + main.cpp + sharebufferextension.cpp sharebufferextension.h +) + +qt6_generate_wayland_protocol_server_sources(compositor + FILES + ${CMAKE_CURRENT_SOURCE_DIR}/../share-buffer.xml +) + +set_target_properties(compositor PROPERTIES + WIN32_EXECUTABLE TRUE + MACOSX_BUNDLE TRUE +) + +target_link_libraries(compositor PUBLIC + Qt::Core + Qt::Gui + Qt::Qml + Qt::WaylandCompositorPrivate +) + +# Resources: +set(compositor_resource_files + "images/Siberischer_tiger_de_edit02.jpg" + "images/background.png" + "qml/main.qml" +) + +qt6_add_resources(compositor "compositor" + PREFIX + "/" + FILES + ${compositor_resource_files} +) + +install(TARGETS compositor + RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" + BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" + LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" +) diff --git a/tests/manual/server-buffer/compositor/compositor.pro b/tests/manual/server-buffer/compositor/compositor.pro new file mode 100644 index 000000000..26334c63c --- /dev/null +++ b/tests/manual/server-buffer/compositor/compositor.pro @@ -0,0 +1,26 @@ +QT += core gui qml + +QT += waylandcompositor-private + +CONFIG += wayland-scanner +CONFIG += c++11 +SOURCES += \ + main.cpp \ + sharebufferextension.cpp + +OTHER_FILES = \ + qml/main.qml \ + images/background.jpg + +WAYLANDSERVERSOURCES += \ + ../share-buffer.xml + +RESOURCES += compositor.qrc + +TARGET = compositor + +HEADERS += \ + sharebufferextension.h + +target.path = $$[QT_INSTALL_EXAMPLES]/wayland/server-buffer/compositor +INSTALLS += target diff --git a/tests/manual/server-buffer/compositor/compositor.qrc b/tests/manual/server-buffer/compositor/compositor.qrc new file mode 100644 index 000000000..b50594b55 --- /dev/null +++ b/tests/manual/server-buffer/compositor/compositor.qrc @@ -0,0 +1,7 @@ +<RCC> + <qresource prefix="/"> + <file>images/background.png</file> + <file>images/Siberischer_tiger_de_edit02.jpg</file> + <file>qml/main.qml</file> + </qresource> +</RCC> diff --git a/tests/manual/server-buffer/compositor/images/Siberischer_tiger_de_edit02.jpg b/tests/manual/server-buffer/compositor/images/Siberischer_tiger_de_edit02.jpg Binary files differnew file mode 100644 index 000000000..eb1b73f84 --- /dev/null +++ b/tests/manual/server-buffer/compositor/images/Siberischer_tiger_de_edit02.jpg diff --git a/tests/manual/server-buffer/compositor/images/Siberischer_tiger_de_edit02.txt b/tests/manual/server-buffer/compositor/images/Siberischer_tiger_de_edit02.txt new file mode 100644 index 000000000..3a26c00d3 --- /dev/null +++ b/tests/manual/server-buffer/compositor/images/Siberischer_tiger_de_edit02.txt @@ -0,0 +1,5 @@ +Image from https://en.wikipedia.org/wiki/File:Siberischer_tiger_de_edit02.jpg + +Author: S. Taheri, edited by Fir0002 + +License: Creative Commons Attribution-Share Alike 2.5 Generic diff --git a/tests/manual/server-buffer/compositor/images/background.png b/tests/manual/server-buffer/compositor/images/background.png Binary files differnew file mode 100644 index 000000000..292160cd8 --- /dev/null +++ b/tests/manual/server-buffer/compositor/images/background.png diff --git a/tests/manual/server-buffer/compositor/main.cpp b/tests/manual/server-buffer/compositor/main.cpp new file mode 100644 index 000000000..36e607e34 --- /dev/null +++ b/tests/manual/server-buffer/compositor/main.cpp @@ -0,0 +1,29 @@ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#include <QtCore/QUrl> +#include <QtCore/QDebug> +#include <QtGui/QGuiApplication> +#include <QtQml/QQmlApplicationEngine> + +#include <QtQml/qqml.h> +#include <QtQml/QQmlEngine> + +#include "sharebufferextension.h" + +static void registerTypes() +{ + qmlRegisterType<ShareBufferExtensionQuickExtension>("io.qt.examples.sharebufferextension", 1, 0, "ShareBufferExtension"); +} + +int main(int argc, char *argv[]) +{ + // Make sure there is a valid OpenGL context in the main thread + qputenv("QSG_RENDER_LOOP", "basic"); + + QGuiApplication app(argc, argv); + registerTypes(); + QQmlApplicationEngine appEngine(QUrl("qrc:///qml/main.qml")); + + return app.exec(); +} diff --git a/tests/manual/server-buffer/compositor/qml/main.qml b/tests/manual/server-buffer/compositor/qml/main.qml new file mode 100644 index 000000000..4227584af --- /dev/null +++ b/tests/manual/server-buffer/compositor/qml/main.qml @@ -0,0 +1,43 @@ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +import QtQuick +import QtWayland.Compositor +import QtWayland.Compositor.WlShell +import QtQuick.Window + +import io.qt.examples.sharebufferextension + +WaylandCompositor { + WaylandOutput { + sizeFollowsWindow: true + window: Window { + width: 1024 + height: 768 + visible: true + Image { + id: surfaceArea + anchors.fill: parent + fillMode: Image.Tile + source: "qrc:/images/background.png" + smooth: false + } + } + } + + Component { + id: chromeComponent + ShellSurfaceItem { + onSurfaceDestroyed: destroy() + } + } + + WlShell { + onWlShellSurfaceCreated: (shellSurface) => { + chromeComponent.createObject(surfaceArea, { "shellSurface": shellSurface } ); + } + } + + ShareBufferExtension { + } +} diff --git a/tests/manual/server-buffer/compositor/sharebufferextension.cpp b/tests/manual/server-buffer/compositor/sharebufferextension.cpp new file mode 100644 index 000000000..bc8b01af3 --- /dev/null +++ b/tests/manual/server-buffer/compositor/sharebufferextension.cpp @@ -0,0 +1,86 @@ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#include "sharebufferextension.h" + +#include <QWaylandSurface> + +#include <QDebug> + +#include <QQuickWindow> + +#include <QPainter> +#include <QPen> + +ShareBufferExtension::ShareBufferExtension(QWaylandCompositor *compositor) + : QWaylandCompositorExtensionTemplate(compositor) +{ +} + +void ShareBufferExtension::initialize() +{ + QWaylandCompositorExtensionTemplate::initialize(); + QWaylandCompositor *compositor = static_cast<QWaylandCompositor *>(extensionContainer()); + init(compositor->display(), 1); +} + +QtWayland::ServerBuffer *ShareBufferExtension::addImage(const QImage &img) +{ + if (!m_server_buffer_integration) { + QWaylandCompositor *compositor = static_cast<QWaylandCompositor *>(extensionContainer()); + + m_server_buffer_integration = QWaylandCompositorPrivate::get(compositor)->serverBufferIntegration(); + if (!m_server_buffer_integration) { + qWarning("Could not find a server buffer integration"); + return nullptr; + } + } + + QImage image = img.convertToFormat(QImage::Format_RGBA8888); + + auto *buffer = m_server_buffer_integration->createServerBufferFromImage(image, QtWayland::ServerBuffer::RGBA32); + + m_server_buffers.append(buffer); + return buffer; +} + +void ShareBufferExtension::createServerBuffers() +{ + QImage image(100,100,QImage::Format_ARGB32_Premultiplied); + image.fill(QColor(0x55,0x0,0x55,0x01)); + { + QPainter p(&image); + QPen pen = p.pen(); + pen.setWidthF(3); + pen.setColor(Qt::red); + p.setPen(pen); + p.drawLine(0,0,100,100); + pen.setColor(Qt::green); + p.setPen(pen); + p.drawLine(100,0,0,100); + pen.setColor(Qt::blue); + p.setPen(pen); + p.drawLine(25,15,75,15); + } + + addImage(image); + + QImage image2(":/images/Siberischer_tiger_de_edit02.jpg"); + addImage(image2); + + m_server_buffers_created = true; +} + + +void ShareBufferExtension::share_buffer_bind_resource(Resource *resource) +{ + if (!m_server_buffers_created) + createServerBuffers(); + + for (auto *buffer : std::as_const(m_server_buffers)) { + qDebug() << "sending" << buffer << "to client"; + struct ::wl_client *client = wl_resource_get_client(resource->handle); + struct ::wl_resource *buffer_resource = buffer->resourceForClient(client); + send_cross_buffer(resource->handle, buffer_resource); + } +} diff --git a/tests/manual/server-buffer/compositor/sharebufferextension.h b/tests/manual/server-buffer/compositor/sharebufferextension.h new file mode 100644 index 000000000..58809e3d4 --- /dev/null +++ b/tests/manual/server-buffer/compositor/sharebufferextension.h @@ -0,0 +1,53 @@ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#ifndef SHAREBUFFEREXTENSION_H +#define SHAREBUFFEREXTENSION_H + +#include "wayland-util.h" + +#include <QtCore/QMap> + +#include <QtWaylandCompositor/QWaylandCompositorExtensionTemplate> +#include <QtWaylandCompositor/QWaylandQuickExtension> +#include <QtWaylandCompositor/QWaylandCompositor> + +#include <QtWaylandCompositor/private/qwaylandcompositor_p.h> +#include <QtWaylandCompositor/private/qwlserverbufferintegration_p.h> + +#include "qwayland-server-share-buffer.h" + +QT_BEGIN_NAMESPACE + +namespace QtWayland +{ + class ServerBufferIntegration; +}; + + +class ShareBufferExtension : public QWaylandCompositorExtensionTemplate<ShareBufferExtension> + , public QtWaylandServer::qt_share_buffer +{ + Q_OBJECT +public: + ShareBufferExtension(QWaylandCompositor *compositor = nullptr); + void initialize() override; + +protected slots: + QtWayland::ServerBuffer *addImage(const QImage &image); + +protected: + void share_buffer_bind_resource(Resource *resource) override; + +private: + void createServerBuffers(); + QList<QtWayland::ServerBuffer *> m_server_buffers; + QtWayland::ServerBufferIntegration *m_server_buffer_integration = nullptr; + bool m_server_buffers_created = false; +}; + +Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_CLASS(ShareBufferExtension) + +QT_END_NAMESPACE + +#endif // SHAREBUFFEREXTENSION_H diff --git a/tests/manual/server-buffer/cpp-client/CMakeLists.txt b/tests/manual/server-buffer/cpp-client/CMakeLists.txt new file mode 100644 index 000000000..01c0df44f --- /dev/null +++ b/tests/manual/server-buffer/cpp-client/CMakeLists.txt @@ -0,0 +1,44 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +cmake_minimum_required(VERSION 3.16) +project(server-buffer-cpp-client) + +set(CMAKE_AUTOMOC ON) + +if(NOT DEFINED INSTALL_EXAMPLESDIR) + set(INSTALL_EXAMPLESDIR "examples") +endif() + +set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/wayland/server-buffer/cpp-client") + +find_package(Qt6 REQUIRED COMPONENTS Core Gui OpenGL WaylandClient) + +qt_add_executable(server-buffer-cpp-client + main.cpp + sharebufferextension.cpp sharebufferextension.h +) + +qt6_generate_wayland_protocol_client_sources(server-buffer-cpp-client + FILES + ${CMAKE_CURRENT_SOURCE_DIR}/../share-buffer.xml +) + +set_target_properties(server-buffer-cpp-client PROPERTIES + WIN32_EXECUTABLE TRUE + MACOSX_BUNDLE TRUE +) + +target_link_libraries(server-buffer-cpp-client PUBLIC + Qt::Core + Qt::Gui + Qt::GuiPrivate + Qt::OpenGL + Qt::WaylandClientPrivate +) + +install(TARGETS server-buffer-cpp-client + RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" + BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" + LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" +) diff --git a/tests/manual/server-buffer/cpp-client/cpp-client.pro b/tests/manual/server-buffer/cpp-client/cpp-client.pro new file mode 100644 index 000000000..6ac551323 --- /dev/null +++ b/tests/manual/server-buffer/cpp-client/cpp-client.pro @@ -0,0 +1,15 @@ +QT += waylandclient-private gui-private opengl +CONFIG += wayland-scanner + +WAYLANDCLIENTSOURCES += ../share-buffer.xml + +SOURCES += main.cpp \ + sharebufferextension.cpp + +HEADERS += \ + sharebufferextension.h + +TARGET = server-buffer-cpp-client + +target.path = $$[QT_INSTALL_EXAMPLES]/wayland/server-buffer/cpp-client +INSTALLS += target diff --git a/tests/manual/server-buffer/cpp-client/main.cpp b/tests/manual/server-buffer/cpp-client/main.cpp new file mode 100644 index 000000000..b11921f67 --- /dev/null +++ b/tests/manual/server-buffer/cpp-client/main.cpp @@ -0,0 +1,88 @@ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#include <QGuiApplication> +#include <QtGui/private/qguiapplication_p.h> +#include <QOpenGLWindow> +#include <QOpenGLTexture> +#include <QOpenGLTextureBlitter> +#include <QPainter> +#include <QMouseEvent> +#include <QPlatformSurfaceEvent> + +#include <QtWaylandClient/private/qwaylanddisplay_p.h> +#include <QtWaylandClient/private/qwaylandintegration_p.h> +#include <QtWaylandClient/private/qwaylandserverbufferintegration_p.h> +#include "sharebufferextension.h" + +#include <QDebug> +#include <QtGui/qpa/qplatformnativeinterface.h> +#include <QTimer> +#include <QMap> + +class TestWindow : public QOpenGLWindow +{ + Q_OBJECT + +public: + TestWindow() + { + m_extension = new ShareBufferExtension; + connect(m_extension, SIGNAL(bufferReceived(QtWaylandClient::QWaylandServerBuffer*)), this, SLOT(receiveBuffer(QtWaylandClient::QWaylandServerBuffer*))); + } + +public slots: + void receiveBuffer(QtWaylandClient::QWaylandServerBuffer *buffer) + { + m_buffers.append(buffer); + update(); + } + +protected: + + void initializeGL() override + { + m_blitter = new QOpenGLTextureBlitter; + m_blitter->create(); + } + + void paintGL() override { + glClearColor(.5, .45, .42, 1.); + glClear(GL_COLOR_BUFFER_BIT); + int x = 0; + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + for (auto buffer: m_buffers) { + m_blitter->bind(); + QPointF pos(x,0); + QSize s(buffer->size()); + QRectF targetRect(pos, s); + QOpenGLTexture *texture = buffer->toOpenGlTexture(); + auto surfaceOrigin = QOpenGLTextureBlitter::OriginTopLeft; + QMatrix4x4 targetTransform = QOpenGLTextureBlitter::targetTransform(targetRect, QRect(QPoint(), size())); + m_blitter->blit(texture->textureId(), targetTransform, surfaceOrigin); + m_blitter->release(); + x += s.width() + 10; + } + } + +private: + + QOpenGLTextureBlitter *m_blitter = nullptr; + ShareBufferExtension *m_extension = nullptr; + QList<QtWaylandClient::QWaylandServerBuffer*> m_buffers; + +}; + +int main (int argc, char **argv) +{ + QGuiApplication app(argc, argv); + + TestWindow window; + window.show(); + + return app.exec(); +} + +#include "main.moc" diff --git a/tests/manual/server-buffer/cpp-client/sharebufferextension.cpp b/tests/manual/server-buffer/cpp-client/sharebufferextension.cpp new file mode 100644 index 000000000..299684a89 --- /dev/null +++ b/tests/manual/server-buffer/cpp-client/sharebufferextension.cpp @@ -0,0 +1,36 @@ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#include "sharebufferextension.h" +#include <QtWaylandClient/private/qwaylanddisplay_p.h> +#include <QtWaylandClient/private/qwaylandintegration_p.h> +#include <QtWaylandClient/private/qwaylandserverbufferintegration_p.h> +#include <QtGui/QGuiApplication> +#include <QtGui/private/qguiapplication_p.h> +#include <QtGui/QWindow> +#include <QtGui/QPlatformSurfaceEvent> +#include <QtGui/qpa/qplatformnativeinterface.h> +#include <QDebug> + +QT_BEGIN_NAMESPACE + +ShareBufferExtension::ShareBufferExtension() + : QWaylandClientExtensionTemplate(/* Supported protocol version */ 1 ) +{ + + auto *wayland_integration = static_cast<QtWaylandClient::QWaylandIntegration *>(QGuiApplicationPrivate::platformIntegration()); + m_server_buffer_integration = wayland_integration->serverBufferIntegration(); + if (!m_server_buffer_integration) { + qCritical() << "This application requires a working serverBufferIntegration"; + QGuiApplication::quit(); + } +} + +void ShareBufferExtension::share_buffer_cross_buffer(struct ::qt_server_buffer *buffer) +{ + QtWaylandClient::QWaylandServerBuffer *serverBuffer = m_server_buffer_integration->serverBuffer(buffer); + emit bufferReceived(serverBuffer); +} + + +QT_END_NAMESPACE diff --git a/tests/manual/server-buffer/cpp-client/sharebufferextension.h b/tests/manual/server-buffer/cpp-client/sharebufferextension.h new file mode 100644 index 000000000..6fc429194 --- /dev/null +++ b/tests/manual/server-buffer/cpp-client/sharebufferextension.h @@ -0,0 +1,36 @@ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#ifndef SHAREBUFFEREXTENSION_H +#define SHAREBUFFEREXTENSION_H + +#include <qpa/qwindowsysteminterface.h> +#include <QtWaylandClient/private/qwayland-wayland.h> +#include <QtWaylandClient/qwaylandclientextension.h> +#include "qwayland-share-buffer.h" + +QT_BEGIN_NAMESPACE + +namespace QtWaylandClient { + class QWaylandServerBuffer; + class QWaylandServerBufferIntegration; +}; + +class ShareBufferExtension : public QWaylandClientExtensionTemplate<ShareBufferExtension> + , public QtWayland::qt_share_buffer +{ + Q_OBJECT +public: + ShareBufferExtension(); + +signals: + void bufferReceived(QtWaylandClient::QWaylandServerBuffer *buffer); + +private: + void share_buffer_cross_buffer(struct ::qt_server_buffer *buffer) override; + QtWaylandClient::QWaylandServerBufferIntegration *m_server_buffer_integration = nullptr; +}; + +QT_END_NAMESPACE + +#endif // SHAREBUFFEREXTENSION_H diff --git a/tests/manual/server-buffer/server-buffer.pro b/tests/manual/server-buffer/server-buffer.pro new file mode 100644 index 000000000..0c737ea8c --- /dev/null +++ b/tests/manual/server-buffer/server-buffer.pro @@ -0,0 +1,6 @@ +TEMPLATE=subdirs + +SUBDIRS += cpp-client compositor + +EXAMPLE_FILES += \ + share-buffer.xml diff --git a/tests/manual/server-buffer/share-buffer.xml b/tests/manual/server-buffer/share-buffer.xml new file mode 100644 index 000000000..2a4ae6748 --- /dev/null +++ b/tests/manual/server-buffer/share-buffer.xml @@ -0,0 +1,13 @@ +<protocol name="share_buffer"> + + <copyright> + Copyright (C) 2015 The Qt Company Ltd. + SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + </copyright> + + <interface name="qt_share_buffer" version="1"> + <event name="cross_buffer"> + <arg name="buffer" type="object" interface="qt_server_buffer"/> + </event> + </interface> +</protocol> diff --git a/tests/manual/subsurface/CMakeLists.txt b/tests/manual/subsurface/CMakeLists.txt new file mode 100644 index 000000000..0c1b50e0c --- /dev/null +++ b/tests/manual/subsurface/CMakeLists.txt @@ -0,0 +1,38 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +# Generated from subsurface.pro. + +##################################################################### +## subsurface Binary: +##################################################################### + +qt_internal_add_manual_test(subsurface + GUI + SOURCES + main.cpp + shmwindow.cpp shmwindow.h + LIBRARIES + Qt::CorePrivate + Qt::Gui + Qt::GuiPrivate + Qt::Quick + Qt::WaylandClient +) + +# Resources: +set(qml_resource_files + "child.qml" + "main.qml" +) + +qt_internal_add_resource(subsurface "qml" + PREFIX + "/" + FILES + ${qml_resource_files} +) + + +#### Keys ignored in scope 1:.:.:subsurface.pro:<TRUE>: +# TEMPLATE = "app" diff --git a/tests/manual/subsurface/child.qml b/tests/manual/subsurface/child.qml index f1bdd66ef..82d2e0757 100644 --- a/tests/manual/subsurface/child.qml +++ b/tests/manual/subsurface/child.qml @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2015 LG Electronics Inc, author: <mikko.levonmaa@lge.com> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2015 LG Electronics Inc, author: <mikko.levonmaa@lge.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only import QtQuick 2.4 import QtQuick.Window 2.2 diff --git a/tests/manual/subsurface/main.cpp b/tests/manual/subsurface/main.cpp index 375e5d2b9..c353496c0 100644 --- a/tests/manual/subsurface/main.cpp +++ b/tests/manual/subsurface/main.cpp @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2015 LG Electronics Inc, author: <mikko.levonmaa@lge.com> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2015 LG Electronics Inc, author: <mikko.levonmaa@lge.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <QGuiApplication> #include <QQmlEngine> @@ -54,8 +7,6 @@ #include <QQmlContext> #include <QQuickView> -#include <QtPlatformHeaders/qwaylandwindowfunctions.h> - #include "shmwindow.h" class Filter : public QObject @@ -84,12 +35,6 @@ public: void toggleSync(QWindow *w) { - sync = !QWaylandWindowFunctions::isSync(w); - if (QWaylandWindowFunctions::isSync(w)) - QWaylandWindowFunctions::setDeSync(w); - else - QWaylandWindowFunctions::setSync(w); - emit syncChanged(); } bool getSync() const diff --git a/tests/manual/subsurface/main.qml b/tests/manual/subsurface/main.qml index 8c27ac78d..e6f7eeb79 100644 --- a/tests/manual/subsurface/main.qml +++ b/tests/manual/subsurface/main.qml @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2015 LG Electronics Inc, author: <mikko.levonmaa@lge.com> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2015 LG Electronics Inc, author: <mikko.levonmaa@lge.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only import QtQuick 2.4 import QtQuick.Window 2.2 diff --git a/tests/manual/subsurface/shmwindow.cpp b/tests/manual/subsurface/shmwindow.cpp index 323582101..c6b59d132 100644 --- a/tests/manual/subsurface/shmwindow.cpp +++ b/tests/manual/subsurface/shmwindow.cpp @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2015 LG Electronics Ltd, author: <mikko.levonmaa@lge.com> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2015 LG Electronics Ltd, author: <mikko.levonmaa@lge.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "shmwindow.h" diff --git a/tests/manual/subsurface/shmwindow.h b/tests/manual/subsurface/shmwindow.h index 10041eea9..55a0336e6 100644 --- a/tests/manual/subsurface/shmwindow.h +++ b/tests/manual/subsurface/shmwindow.h @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2015 LG Electronics Ltd, author: <mikko.levonmaa@lge.com> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2015 LG Electronics Ltd, author: <mikko.levonmaa@lge.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef SHMWINDOW_H #define SHMWINDOW_H diff --git a/tests/manual/texture-sharing-2/.gitignore b/tests/manual/texture-sharing-2/.gitignore new file mode 100644 index 000000000..c684448d3 --- /dev/null +++ b/tests/manual/texture-sharing-2/.gitignore @@ -0,0 +1,2 @@ +custom-compositor/custom-compositor +qml-client/qml-client diff --git a/tests/manual/texture-sharing-2/CMakeLists.txt b/tests/manual/texture-sharing-2/CMakeLists.txt new file mode 100644 index 000000000..9a212ea3e --- /dev/null +++ b/tests/manual/texture-sharing-2/CMakeLists.txt @@ -0,0 +1,7 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +# Generated from texture-sharing.pro. + +add_subdirectory(qml-client) +add_subdirectory(custom-compositor) diff --git a/tests/manual/texture-sharing-2/README b/tests/manual/texture-sharing-2/README new file mode 100644 index 000000000..27ea76745 --- /dev/null +++ b/tests/manual/texture-sharing-2/README @@ -0,0 +1,27 @@ +This example shows how to use the texture sharing extension, allowing +multiple clients to share the same copy of an image in graphics memory. + +The texture sharing extension uses the server buffer extension to transport +graphics buffers. There are different server buffer plugins for different +graphics hardware. This is specified by setting an environment variable for +the compositor process. + +-On a device with Mesa and Intel integrated graphics, set: + + QT_WAYLAND_SERVER_BUFFER_INTEGRATION=dmabuf-server + +-On a device with NVIDIA graphics, set: + + QT_WAYLAND_SERVER_BUFFER_INTEGRATION=vulkan-server + +'custom-compositor' shows how to write a server that creates shared textures +programmatically. + +The file 'minimal-compositor.qml' shows how to add texture sharing to an +existing compositor, using only QML. It is based on the minimal-qml example, +and can be executed with qmlscene. + +'qml-client' shows how to use shared textures in a Qt Quick client. +The compositor uses the hardware integration extension to broadcast +the name of the server buffer integration to all clients, so qml-client +can be started like any normal wayland client. diff --git a/tests/manual/texture-sharing-2/custom-compositor/CMakeLists.txt b/tests/manual/texture-sharing-2/custom-compositor/CMakeLists.txt new file mode 100644 index 000000000..1a6c1494a --- /dev/null +++ b/tests/manual/texture-sharing-2/custom-compositor/CMakeLists.txt @@ -0,0 +1,28 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +qt_internal_add_manual_test(texture-sharing-custom-compositor + GUI + SOURCES + main.cpp + LIBRARIES + Qt::Qml + Qt::WaylandCompositorPrivate +) + + +# Resources: +set(compositor_resource_files + "images/background.png" + "images/car.ktx" + "images/qt4.astc" + "images/qt_logo.png" + "qml/main.qml" +) + +qt_internal_add_resource(texture-sharing-custom-compositor "compositor" + PREFIX + "/" + FILES + ${compositor_resource_files} +) diff --git a/tests/manual/texture-sharing-2/custom-compositor/compositor.qrc b/tests/manual/texture-sharing-2/custom-compositor/compositor.qrc new file mode 100644 index 000000000..86a8567f7 --- /dev/null +++ b/tests/manual/texture-sharing-2/custom-compositor/compositor.qrc @@ -0,0 +1,9 @@ +<RCC> + <qresource prefix="/"> + <file>images/background.png</file> + <file>images/qt_logo.png</file> + <file>images/qt4.astc</file> + <file>images/car.ktx</file> + <file>qml/main.qml</file> + </qresource> +</RCC> diff --git a/tests/manual/texture-sharing-2/custom-compositor/custom-compositor.pro b/tests/manual/texture-sharing-2/custom-compositor/custom-compositor.pro new file mode 100644 index 000000000..098034f3b --- /dev/null +++ b/tests/manual/texture-sharing-2/custom-compositor/custom-compositor.pro @@ -0,0 +1,17 @@ +QT += core gui qml + +QT += waylandcompositor-private + +SOURCES += \ + main.cpp + +OTHER_FILES = \ + qml/main.qml \ + images/background.jpg + +RESOURCES += compositor.qrc + +TARGET = texture-sharing-custom-compositor + +target.path = $$[QT_INSTALL_EXAMPLES]/wayland/texture-sharing/custom-compositor +INSTALLS += target diff --git a/tests/manual/texture-sharing-2/custom-compositor/images/background.png b/tests/manual/texture-sharing-2/custom-compositor/images/background.png Binary files differnew file mode 100644 index 000000000..845830c59 --- /dev/null +++ b/tests/manual/texture-sharing-2/custom-compositor/images/background.png diff --git a/tests/manual/texture-sharing-2/custom-compositor/images/car.ktx b/tests/manual/texture-sharing-2/custom-compositor/images/car.ktx Binary files differnew file mode 100644 index 000000000..2aefdd306 --- /dev/null +++ b/tests/manual/texture-sharing-2/custom-compositor/images/car.ktx diff --git a/tests/manual/texture-sharing-2/custom-compositor/images/qt4.astc b/tests/manual/texture-sharing-2/custom-compositor/images/qt4.astc Binary files differnew file mode 100644 index 000000000..7f7a3f473 --- /dev/null +++ b/tests/manual/texture-sharing-2/custom-compositor/images/qt4.astc diff --git a/tests/manual/texture-sharing-2/custom-compositor/images/qt_logo.png b/tests/manual/texture-sharing-2/custom-compositor/images/qt_logo.png Binary files differnew file mode 100644 index 000000000..5e2b355ea --- /dev/null +++ b/tests/manual/texture-sharing-2/custom-compositor/images/qt_logo.png diff --git a/tests/manual/texture-sharing-2/custom-compositor/main.cpp b/tests/manual/texture-sharing-2/custom-compositor/main.cpp new file mode 100644 index 000000000..0c229413b --- /dev/null +++ b/tests/manual/texture-sharing-2/custom-compositor/main.cpp @@ -0,0 +1,100 @@ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#include <QtCore/QUrl> +#include <QtCore/QDebug> +#include <QtGui/QGuiApplication> +#include <QtQml/QQmlApplicationEngine> + +#include <QtQml/qqml.h> +#include <QtQml/QQmlEngine> + +#include <QtGui/QPainter> +#include <QtGui/QImage> + +#include <QtCore/QDateTime> + +#include "QtWaylandCompositor/private/qwltexturesharingextension_p.h" + +#ifndef GL_RGBA8 +#define GL_RGBA8 0x8058 +#endif + +class CustomSharingExtension : public QWaylandTextureSharingExtension +{ + Q_OBJECT +public: + CustomSharingExtension() {qDebug("Instantiating custom texture sharing extension.");} +protected: + bool customPixelData(const QString &key, QByteArray *data, QSize *size, uint *glInternalFormat) override + { + qDebug() << "CustomSharingExtension looking for local texture data for" << key; + if (key.startsWith("unreasonably large ")) { + int w = 10000; + int h = 10000; + int numBytes = w * h * 4; + *data = QByteArray(numBytes, 0); + quint32 *pixels = reinterpret_cast<quint32*>(data->data()); + for (int i = 0; i < w*h; ++i) + pixels[i] = 0xff7f1fff; + *glInternalFormat = GL_RGBA8; + *size = QSize(w,h); + return true; + } + + QImage img; + + if (key == QLatin1String("test pattern 1")) { + img = QImage(128,128,QImage::Format_ARGB32_Premultiplied); + img.fill(QColor(0x55,0x0,0x55,0x01)); + { + QPainter p(&img); + QPen pen = p.pen(); + pen.setWidthF(3); + pen.setColor(Qt::red); + p.setPen(pen); + p.drawLine(0,0,128,128); + pen.setColor(Qt::green); + p.setPen(pen); + p.drawLine(128,0,0,128); + pen.setColor(Qt::blue); + p.setPen(pen); + p.drawLine(32,16,96,16); + pen.setColor(Qt::black); + p.setPen(pen); + p.translate(64, 64); + p.rotate(45); + p.drawText(QRect(-48, -32, 96, 64), + QDateTime::currentDateTime().toString(), + QTextOption(Qt::AlignHCenter)); + } + } + + if (!img.isNull()) { + img = img.convertToFormat(QImage::Format_RGBA8888); + *data = QByteArray(reinterpret_cast<const char*>(img.constBits()), img.sizeInBytes()); + *size = img.size(); + *glInternalFormat = GL_RGBA8; + return true; + } + return false; + } +}; + +Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_CLASS(CustomSharingExtension); + +int main(int argc, char *argv[]) +{ + QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts, true); + QGuiApplication app(argc, argv); + QQmlApplicationEngine appEngine; + + qmlRegisterType<CustomSharingExtensionQuickExtension>("io.qt.tests.customsharingextension", 1, 0, "CustomSharingExtension"); + appEngine.addImageProvider("wlshared", new QWaylandSharedTextureProvider); + + appEngine.load(QUrl("qrc:///qml/main.qml")); + + return app.exec(); +} + +#include "main.moc" diff --git a/tests/manual/texture-sharing-2/custom-compositor/qml/main.qml b/tests/manual/texture-sharing-2/custom-compositor/qml/main.qml new file mode 100644 index 000000000..dd1f60f4e --- /dev/null +++ b/tests/manual/texture-sharing-2/custom-compositor/qml/main.qml @@ -0,0 +1,72 @@ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +import QtQuick +import QtQuick.Window +import QtWayland.Compositor +import QtWayland.Compositor.XdgShell +import QtWayland.Compositor.WlShell + +import io.qt.tests.customsharingextension + +WaylandCompositor { + WaylandOutput { + sizeFollowsWindow: true + window: Window { + width: 1024 + height: 768 + visible: true + Image { + id: background + anchors.fill: parent + fillMode: Image.Tile + source: "qrc:/images/background.png" + smooth: true + + Rectangle { + width: 100 + height: 100 + color: "red" + anchors.bottom: parent.bottom; + anchors.right: parent.right; + MouseArea { + anchors.fill: parent + onClicked: sharedTextureImage.source = "image://wlshared/car.ktx" + } + } + Image { + id: sharedTextureImage + anchors.bottom: parent.bottom; + anchors.right: parent.right; + source: "" + } + Image { + id: topRightImage + anchors.top: parent.top; + anchors.right: parent.right; + source: "image://wlshared/qt_logo.png" + } + } + Repeater { + model: shellSurfaces + ShellSurfaceItem { + shellSurface: modelData + onSurfaceDestroyed: shellSurfaces.remove(index) + } + } + } + } + WlShell { + onWlShellSurfaceCreated: + shellSurfaces.append({shellSurface: shellSurface}); + } + XdgShell { + onToplevelCreated: + shellSurfaces.append({shellSurface: xdgSurface}); + } + ListModel { id: shellSurfaces } + + CustomSharingExtension { + imageSearchPath: ":/images;." + } +} diff --git a/tests/manual/texture-sharing-2/minimal-compositor.qml b/tests/manual/texture-sharing-2/minimal-compositor.qml new file mode 100644 index 000000000..d12216156 --- /dev/null +++ b/tests/manual/texture-sharing-2/minimal-compositor.qml @@ -0,0 +1,43 @@ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +import QtQuick +import QtQuick.Window +import QtWayland.Compositor +import QtWayland.Compositor.XdgShell +import QtWayland.Compositor.WlShell + +// importing the texture sharing extension: +import QtWayland.Compositor.TextureSharingExtension + +WaylandCompositor { + WaylandOutput { + sizeFollowsWindow: true + window: Window { + width: 1024 + height: 768 + visible: true + Repeater { + model: shellSurfaces + ShellSurfaceItem { + shellSurface: modelData + onSurfaceDestroyed: shellSurfaces.remove(index) + } + } + } + } + WlShell { + onWlShellSurfaceCreated: + shellSurfaces.append({shellSurface: shellSurface}); + } + XdgShell { + onToplevelCreated: + shellSurfaces.append({shellSurface: xdgSurface}); + } + ListModel { id: shellSurfaces } + + // instantiating the texture sharing extension: + TextureSharingExtension { + imageSearchPath: ".;/tmp;/usr/share/pixmaps" + } +} diff --git a/tests/manual/texture-sharing-2/qml-client/CMakeLists.txt b/tests/manual/texture-sharing-2/qml-client/CMakeLists.txt new file mode 100644 index 000000000..ce6bc118d --- /dev/null +++ b/tests/manual/texture-sharing-2/qml-client/CMakeLists.txt @@ -0,0 +1,22 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +qt_internal_add_manual_test(qml-client + GUI + SOURCES + main.cpp + LIBRARIES + Qt::Quick +) + +# Resources: +set(qml-client_resource_files + "main.qml" +) + +qt_internal_add_resource(qml-client "qml-client" + PREFIX + "/" + FILES + ${qml-client_resource_files} +) diff --git a/tests/manual/texture-sharing-2/qml-client/main.cpp b/tests/manual/texture-sharing-2/qml-client/main.cpp new file mode 100644 index 000000000..8af386939 --- /dev/null +++ b/tests/manual/texture-sharing-2/qml-client/main.cpp @@ -0,0 +1,21 @@ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#include <QGuiApplication> +#include <QtQuick/QQuickView> +#include <QStandardPaths> +#include <QFileInfo> +#include <QQmlApplicationEngine> +#include <QDebug> +#include <QDir> +#include <QTimer> + +int main(int argc, char **argv) +{ + QGuiApplication app(argc, argv); + QQmlApplicationEngine appEngine; + + appEngine.load(QUrl("qrc:///main.qml")); + + return app.exec(); +} diff --git a/tests/manual/texture-sharing-2/qml-client/main.qml b/tests/manual/texture-sharing-2/qml-client/main.qml new file mode 100644 index 000000000..819a93bcf --- /dev/null +++ b/tests/manual/texture-sharing-2/qml-client/main.qml @@ -0,0 +1,201 @@ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +import QtQuick +import QtQuick.Window + +import QtWayland.Client.TextureSharing + +Window { + width: 800 + height: 500 + visible: true + + Rectangle { + anchors.fill: parent + color: "#C0FEFE" + + Flickable { + anchors.fill: parent + contentHeight: imageGrid.height + + Grid { + id: imageGrid + columns: 2 + width: parent.width + spacing: 25 + padding: 25 + + + // loadedImage + Text { + width: 400 + wrapMode: Text.Wrap + text: "An Image element using the shared buffer provider to load from a PNG image.<br>" + + "Source: '" + loadedImage.source + "'" + + (loadedImage.sourceSize.height <= 0 ? "<font color=\"#FF0000\"><br>[Image not loaded]</font>" : "") + } + Image { + id: loadedImage + fillMode: Image.PreserveAspectFit + source: "image://wlshared/qt_logo.png" + } + Rectangle { + visible: loadedImage.height <= 0 + width:100; height: 100 + color: "green" + } + + // paintedImage + Text { + width: 400 + wrapMode: Text.Wrap + text: "An Image element using the shared buffer provider.<br>" + + "This texture is created by the compositor using QPainter. <br>" + + "Source: '" + paintedImage.source + "'" + + (paintedImage.sourceSize.height <= 0 ? "<font color=\"#FF0000\"><br>[Image not loaded]</font>" : "") + } + Image { + id: paintedImage + fillMode: Image.PreserveAspectFit + source: "image://wlshared/test pattern 1" + } + Rectangle { + visible: paintedImage.height <= 0 + width:100; height: 100 + color: "green" + } + + // ktxImage + Text { + width: 400 + wrapMode: Text.Wrap + text: "An Image element using the shared buffer provider to load an ETC2 compressed texture." + + "<br>Source: '" + ktxImage.source + "'" + + (ktxImage.sourceSize.height <= 0 ? "<font color=\"#FF0000\"><br>[Image not loaded]</font>" : "") + } + Image { + id: ktxImage + source: "image://wlshared/car.ktx" + fillMode: Image.PreserveAspectFit + } + Rectangle { + visible: ktxImage.height <= 0 + width:100; height: 100 + color: "green" + } + + //astcImage + Text { + width: 400 + wrapMode: Text.Wrap + text: "An Image element using the shared buffer provider to load an ASTC compressed texture." + + "<br>Source: '" + astcImage.source + "'" + + (astcImage.sourceSize.height <= 0 ? "<font color=\"#FF0000\"><br>[Image not loaded]</font>" : "") + } + + Image { + id: astcImage + source: "image://wlshared/qt4.astc" + fillMode: Image.PreserveAspectFit + } + Rectangle { + visible: astcImage.height <= 0 + width:100; height: 100 + color: "green" + } + + // dynamicImage + Column { + Text { + width: 400 + wrapMode: Text.Wrap + text: "An Image element using the shared buffer provider." + + "<br>Source: '" + dynamicImage.source + "'" + + (dynamicImage.sourceSize.height <= 0 ? "<font color=\"#FF0000\"><br>[Image not loaded]</font>" : "") + } + Row { + spacing: 10 + Text { + text: "Enter filename:" + } + Rectangle { + color: "white" + width: sourceEdit.contentWidth + 30 + height: sourceEdit.contentHeight + TextInput { + id: sourceEdit + anchors.fill: parent + horizontalAlignment: TextInput.AlignHCenter + onEditingFinished: dynamicImage.source = text ? "image://wlshared/" + text : "" + } + } + } + } + Image { + id: dynamicImage + fillMode: Image.PreserveAspectFit + } + Rectangle { + visible: dynamicImage.height <= 0 + width:100; height: 100 + color: "green" + } + + // largeImage + Text { + width: 400 + wrapMode: Text.Wrap + text: "An Image element using the shared buffer provider.<br>" + + "Left click to load a very large image. " + + "Right click to unload the image, potentially freeing graphics memory on the server-side " + + "if no other client is using the image." + + "<br>Source: '" + largeImage.source + "'" + + "<br>Size: " + largeImage.sourceSize + + (largeImage.sourceSize.height <= 0 ? "<font color=\"#FF0000\"><br>[Image not loaded]</font>" : "") + } + + Rectangle { + width: 200 + height: 200 + border.color: "black" + border.width: 2 + color: "transparent" + Image { + id: largeImage + anchors.fill: parent + fillMode: Image.PreserveAspectFit + } + MouseArea { + anchors.fill: parent + acceptedButtons: Qt.LeftButton | Qt.RightButton + onClicked: { + if (mouse.button == Qt.LeftButton) + largeImage.source = "image://wlshared/unreasonably large image" + else + largeImage.source = "" + + } + } + } + + } // Grid + } + + Rectangle { + color: "gray" + width: parent.width + height: 20 + anchors.bottom: parent.bottom + + Text { + color: "white" + anchors.fill: parent + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + text: "Scroll or drag for more" + } + } + + } +} diff --git a/tests/manual/texture-sharing-2/qml-client/qml-client.pro b/tests/manual/texture-sharing-2/qml-client/qml-client.pro new file mode 100644 index 000000000..67d5c7071 --- /dev/null +++ b/tests/manual/texture-sharing-2/qml-client/qml-client.pro @@ -0,0 +1,13 @@ +QT += quick + +SOURCES += \ + main.cpp + +RESOURCES += \ + qml-client.qrc + +DISTFILES += \ + main.qml + +target.path = $$[QT_INSTALL_EXAMPLES]/wayland/texture-sharing/qml-client +INSTALLS += target diff --git a/tests/manual/texture-sharing-2/qml-client/qml-client.qrc b/tests/manual/texture-sharing-2/qml-client/qml-client.qrc new file mode 100644 index 000000000..5f6483ac3 --- /dev/null +++ b/tests/manual/texture-sharing-2/qml-client/qml-client.qrc @@ -0,0 +1,5 @@ +<RCC> + <qresource prefix="/"> + <file>main.qml</file> + </qresource> +</RCC> diff --git a/tests/manual/texture-sharing-2/texture-sharing.pro b/tests/manual/texture-sharing-2/texture-sharing.pro new file mode 100644 index 000000000..3f7792828 --- /dev/null +++ b/tests/manual/texture-sharing-2/texture-sharing.pro @@ -0,0 +1,5 @@ +TEMPLATE=subdirs + +SUBDIRS += \ + qml-client \ + custom-compositor diff --git a/tests/manual/texture-sharing/cpp-client/CMakeLists.txt b/tests/manual/texture-sharing/cpp-client/CMakeLists.txt new file mode 100644 index 000000000..1059e6e5e --- /dev/null +++ b/tests/manual/texture-sharing/cpp-client/CMakeLists.txt @@ -0,0 +1,32 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +# Generated from cpp-client.pro. + +##################################################################### +## cpp-client Binary: +##################################################################### + +qt_internal_add_manual_test(cpp-client + GUI + SOURCES + ../../../../src/imports/texture-sharing/texturesharingextension.cpp + ../../../../src/imports/texture-sharing/texturesharingextension_p.h + main.cpp + INCLUDE_DIRECTORIES + ../../../../src/imports/texture-sharing + LIBRARIES + Qt::Gui + Qt::GuiPrivate + Qt::OpenGL + Qt::WaylandClientPrivate +) + +qt6_generate_wayland_protocol_client_sources(cpp-client + FILES + ${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/extensions/qt-texture-sharing-unstable-v1.xml +) + +#### Keys ignored in scope 1:.:.:cpp-client.pro:<TRUE>: +# INSTALLS = "target" +# target.path = "$$[QT_INSTALL_EXAMPLES]/wayland/texture-sharing/cpp-client" diff --git a/tests/manual/texture-sharing/cpp-client/cpp-client.pro b/tests/manual/texture-sharing/cpp-client/cpp-client.pro index d251791db..99a100e07 100644 --- a/tests/manual/texture-sharing/cpp-client/cpp-client.pro +++ b/tests/manual/texture-sharing/cpp-client/cpp-client.pro @@ -1,4 +1,4 @@ -QT += waylandclient-private gui-private +QT += waylandclient-private gui-private opengl CONFIG += wayland-scanner WAYLANDCLIENTSOURCES += $$PWD/../../../../src/extensions/qt-texture-sharing-unstable-v1.xml diff --git a/tests/manual/texture-sharing/cpp-client/main.cpp b/tests/manual/texture-sharing/cpp-client/main.cpp index e3f6d7025..f992ea1b6 100644 --- a/tests/manual/texture-sharing/cpp-client/main.cpp +++ b/tests/manual/texture-sharing/cpp-client/main.cpp @@ -1,52 +1,5 @@ -/**************************************************************************** - ** - ** Copyright (C) 2019 The Qt Company Ltd. - ** Contact: https://www.qt.io/licensing/ - ** - ** This file is part of the examples of the Qt Wayland module - ** - ** $QT_BEGIN_LICENSE:BSD$ - ** 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. - ** - ** BSD License Usage - ** Alternatively, you may use this file under the terms of the BSD license - ** as follows: - ** - ** "Redistribution and use in source and binary forms, with or without - ** modification, are permitted provided that the following conditions are - ** met: - ** * Redistributions of source code must retain the above copyright - ** notice, this list of conditions and the following disclaimer. - ** * Redistributions in binary form must reproduce the above copyright - ** notice, this list of conditions and the following disclaimer in - ** the documentation and/or other materials provided with the - ** distribution. - ** * Neither the name of The Qt Company Ltd nor the names of its - ** contributors may be used to endorse or promote products derived - ** from this software without specific prior written permission. - ** - ** - ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." - ** - ** $QT_END_LICENSE$ - ** - ****************************************************************************/ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <QGuiApplication> #include <QtGui/private/qguiapplication_p.h> @@ -134,7 +87,7 @@ protected: int x = 0; qDebug() << "*** paintGL ***"; showBuffers(); - for (auto buffer: qAsConst(m_buffers)) { + for (auto buffer: std::as_const(m_buffers)) { m_blitter->bind(); QSize s(buffer->size()); qDebug() << "painting" << buffer << s; diff --git a/tests/manual/wip-cpp-compositor/CMakeLists.txt b/tests/manual/wip-cpp-compositor/CMakeLists.txt new file mode 100644 index 000000000..4d8a166ed --- /dev/null +++ b/tests/manual/wip-cpp-compositor/CMakeLists.txt @@ -0,0 +1,23 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +# Generated from wip-cpp-compositor.pro. + +##################################################################### +## wip-cpp-compositor Binary: +##################################################################### + +qt_internal_add_manual_test(wip-cpp-compositor + GUI + SOURCES + compositor.cpp compositor.h + main.cpp + window.cpp window.h + LIBRARIES + Qt::Gui + Qt::WaylandCompositor +) + +#### Keys ignored in scope 1:.:.:wip-cpp-compositor.pro:<TRUE>: +# INSTALLS = "target" +# target.path = "$$[QT_INSTALL_EXAMPLES]/wayland/reference-cpp" diff --git a/tests/manual/wip-cpp-compositor/compositor.cpp b/tests/manual/wip-cpp-compositor/compositor.cpp index d65c5f0c3..2f7025115 100644 --- a/tests/manual/wip-cpp-compositor/compositor.cpp +++ b/tests/manual/wip-cpp-compositor/compositor.cpp @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2019 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Wayland module -** -** $QT_BEGIN_LICENSE:BSD$ -** 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. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "compositor.h" #include "window.h" @@ -80,7 +33,7 @@ QPoint View::mapToLocal(const QPoint &globalPosition) const void View::updateAnchoredPosition() { QPoint offset; - QSize size = surface()->size(); + QSize size = surface()->bufferSize(); QSize delta = size - m_lastSize; if (m_anchorEdges & Qt::RightEdge) offset.setX(-delta.width()); @@ -109,7 +62,7 @@ ToplevelView::ToplevelView(QWaylandXdgToplevel *toplevel) setAnchorEdges(opposite); emit startResize(); }); - QVector<QWaylandXdgToplevel::State> states{QWaylandXdgToplevel::ActivatedState}; + QList<QWaylandXdgToplevel::State> states{QWaylandXdgToplevel::ActivatedState}; toplevel->sendConfigure(QSize(0, 0), states); } diff --git a/tests/manual/wip-cpp-compositor/compositor.h b/tests/manual/wip-cpp-compositor/compositor.h index 5c2d6a2f5..b2810d0da 100644 --- a/tests/manual/wip-cpp-compositor/compositor.h +++ b/tests/manual/wip-cpp-compositor/compositor.h @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2019 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Wayland module -** -** $QT_BEGIN_LICENSE:BSD$ -** 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. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef COMPOSITOR_H #define COMPOSITOR_H @@ -71,8 +24,8 @@ class View : public QWaylandView public: explicit View() = default; QOpenGLTexture *getTexture(); - QSize size() const { return surface() ? surface()->size() : QSize(); } - QRect globalGeometry() const { return {globalPosition(), surface()->size()}; } + QSize bufferSize() const { return surface() ? surface()->bufferSize() : QSize(); } + QRect globalGeometry() const { return {globalPosition(), surface()->bufferSize()}; } QPoint globalPosition() const { return m_globalPosition; } void setGlobalPosition(const QPoint &position); QPoint mapToLocal(const QPoint &globalPosition) const; diff --git a/tests/manual/wip-cpp-compositor/main.cpp b/tests/manual/wip-cpp-compositor/main.cpp index 8ca5a6f33..e8a34a14f 100644 --- a/tests/manual/wip-cpp-compositor/main.cpp +++ b/tests/manual/wip-cpp-compositor/main.cpp @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2019 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Wayland module -** -** $QT_BEGIN_LICENSE:BSD$ -** 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. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <QGuiApplication> #include "window.h" diff --git a/tests/manual/wip-cpp-compositor/window.cpp b/tests/manual/wip-cpp-compositor/window.cpp index b5b2581e0..413e56572 100644 --- a/tests/manual/wip-cpp-compositor/window.cpp +++ b/tests/manual/wip-cpp-compositor/window.cpp @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2019 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Wayland module -** -** $QT_BEGIN_LICENSE:BSD$ -** 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. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "window.h" #include "compositor.h" @@ -116,23 +69,28 @@ void Window::paintGL() void Window::mousePressEvent(QMouseEvent *event) { - m_compositor->handleMousePress(event->localPos().toPoint(), event->button()); + m_compositor->handleMousePress(event->position().toPoint(), event->button()); } void Window::mouseReleaseEvent(QMouseEvent *event) { - m_compositor->handleMouseRelease(event->localPos().toPoint(), event->button(), event->buttons()); + m_compositor->handleMouseRelease(event->position().toPoint(), event->button(), event->buttons()); } void Window::mouseMoveEvent(QMouseEvent *event) { - m_compositor->handleMouseMove(event->localPos().toPoint()); + m_compositor->handleMouseMove(event->position().toPoint()); } +#if QT_CONFIG(wheelevent) void Window::wheelEvent(QWheelEvent *event) { - m_compositor->handleMouseWheel(event->orientation(), event->delta()); + if (event->angleDelta().x() != 0) + m_compositor->handleMouseWheel(Qt::Horizontal, event->angleDelta().x()); + if (event->angleDelta().y() != 0) + m_compositor->handleMouseWheel(Qt::Vertical, event->angleDelta().y()); } +#endif void Window::keyPressEvent(QKeyEvent *event) { diff --git a/tests/manual/wip-cpp-compositor/window.h b/tests/manual/wip-cpp-compositor/window.h index bc71207ee..58ed1d5a0 100644 --- a/tests/manual/wip-cpp-compositor/window.h +++ b/tests/manual/wip-cpp-compositor/window.h @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2019 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Wayland module -** -** $QT_BEGIN_LICENSE:BSD$ -** 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. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef WINDOW_H #define WINDOW_H @@ -71,7 +24,9 @@ protected: void mousePressEvent(QMouseEvent *event) override; void mouseReleaseEvent(QMouseEvent *event) override; void mouseMoveEvent(QMouseEvent *event) override; +#if QT_CONFIG(wheelevent) void wheelEvent(QWheelEvent *event) override; +#endif void keyPressEvent(QKeyEvent *event) override; void keyReleaseEvent(QKeyEvent *event) override; diff --git a/tests/manual/wlscaler/main.cpp b/tests/manual/wlscaler/main.cpp deleted file mode 100644 index b836e3787..000000000 --- a/tests/manual/wlscaler/main.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QtGui/QGuiApplication> -#include <QtQml/QQmlApplicationEngine> - -int main(int argc, char* argv[]) -{ - QGuiApplication app(argc, argv); - QQmlApplicationEngine engine(QUrl("qrc:/main.qml")); - return app.exec(); -} diff --git a/tests/manual/wlscaler/main.qml b/tests/manual/wlscaler/main.qml deleted file mode 100644 index ddadf4801..000000000 --- a/tests/manual/wlscaler/main.qml +++ /dev/null @@ -1,100 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.2 -import QtQuick.Window 2.2 -import QtWayland.Compositor 1.13 - -WaylandCompositor { - id: comp - WaylandOutput { - id: output - compositor: comp - sizeFollowsWindow: true - window: Window { - id: win - width: 500 - height: 500 - visible: true - title: "wlscaler-compositor - " + comp.socketName - Repeater { - model: shellSurfaces - ShellSurfaceItem { - shellSurface: modelData - onSurfaceDestroyed: shellSurfaces.remove(index); - autoCreatePopupItems: true - } - } - } - } - - WlScaler {} - - ListModel { id: shellSurfaces } - - XdgShell { - onToplevelCreated: shellSurfaces.append({shellSurface: xdgSurface}); - } - - // Including legacy shell extensions as well, as clients using wl-scaler - // probably use outdated shells as well. - - WlShell { - onWlShellSurfaceCreated: shellSurfaces.append({shellSurface: shellSurface}); - } - - XdgShellV5 { - onXdgSurfaceCreated: shellSurfaces.append({shellSurface: xdgSurface}); - } - - XdgShellV6 { - onToplevelCreated: shellSurfaces.append({shellSurface: xdgSurface}); - } -} diff --git a/tests/manual/wlscaler/qml.qrc b/tests/manual/wlscaler/qml.qrc deleted file mode 100644 index 6b2d0a781..000000000 --- a/tests/manual/wlscaler/qml.qrc +++ /dev/null @@ -1,5 +0,0 @@ -<!DOCTYPE RCC><RCC version="1.0"> -<qresource> - <file>main.qml</file> -</qresource> -</RCC> diff --git a/tests/manual/wlscaler/wlscaler.pro b/tests/manual/wlscaler/wlscaler.pro deleted file mode 100644 index e4ba825f8..000000000 --- a/tests/manual/wlscaler/wlscaler.pro +++ /dev/null @@ -1,7 +0,0 @@ -TEMPLATE = app - -QT += gui qml - -SOURCES += main.cpp - -RESOURCES += qml.qrc |