diff options
Diffstat (limited to 'src/compositor')
238 files changed, 6841 insertions, 14369 deletions
diff --git a/src/compositor/CMakeLists.txt b/src/compositor/CMakeLists.txt new file mode 100644 index 000000000..fc742c7a1 --- /dev/null +++ b/src/compositor/CMakeLists.txt @@ -0,0 +1,237 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +# Generated from compositor.pro. + +##################################################################### +## WaylandCompositor Module: +##################################################################### + +qt_internal_add_module(WaylandCompositor + PLUGIN_TYPES wayland-graphics-integration-server wayland-hardware-layer-integration + SOURCES + compat/removed_api.cpp + ../shared/qwaylandinputmethodeventbuilder.cpp ../shared/qwaylandinputmethodeventbuilder_p.h + ../shared/qwaylandmimehelper.cpp ../shared/qwaylandmimehelper_p.h + ../shared/qwaylandsharedmemoryformathelper_p.h + compositor_api/qwaylandbufferref.cpp compositor_api/qwaylandbufferref.h + compositor_api/qwaylandclient.cpp compositor_api/qwaylandclient.h + compositor_api/qwaylandcompositor.cpp compositor_api/qwaylandcompositor.h compositor_api/qwaylandcompositor_p.h + compositor_api/qwaylanddestroylistener.cpp compositor_api/qwaylanddestroylistener.h compositor_api/qwaylanddestroylistener_p.h + compositor_api/qwaylandkeyboard.cpp compositor_api/qwaylandkeyboard.h compositor_api/qwaylandkeyboard_p.h + compositor_api/qwaylandkeymap.cpp compositor_api/qwaylandkeymap.h compositor_api/qwaylandkeymap_p.h + compositor_api/qwaylandoutput.cpp compositor_api/qwaylandoutput.h compositor_api/qwaylandoutput_p.h + compositor_api/qwaylandoutputmode.cpp compositor_api/qwaylandoutputmode.h compositor_api/qwaylandoutputmode_p.h + compositor_api/qwaylandpointer.cpp compositor_api/qwaylandpointer.h compositor_api/qwaylandpointer_p.h + compositor_api/qwaylandresource.cpp compositor_api/qwaylandresource.h + compositor_api/qwaylandseat.cpp compositor_api/qwaylandseat.h compositor_api/qwaylandseat_p.h + compositor_api/qwaylandsurface.cpp compositor_api/qwaylandsurface.h compositor_api/qwaylandsurface_p.h + compositor_api/qwaylandsurfacegrabber.cpp compositor_api/qwaylandsurfacegrabber.h + compositor_api/qwaylandtouch.cpp compositor_api/qwaylandtouch.h compositor_api/qwaylandtouch_p.h + compositor_api/qwaylandview.cpp compositor_api/qwaylandview.h compositor_api/qwaylandview_p.h + extensions/qwaylandidleinhibitv1.cpp extensions/qwaylandidleinhibitv1.h extensions/qwaylandidleinhibitv1_p.h + extensions/qwaylandiviapplication.cpp extensions/qwaylandiviapplication.h extensions/qwaylandiviapplication_p.h + extensions/qwaylandivisurface.cpp extensions/qwaylandivisurface.h extensions/qwaylandivisurface_p.h + extensions/qwaylandqttextinputmethod.cpp extensions/qwaylandqttextinputmethod.h extensions/qwaylandqttextinputmethod_p.h + extensions/qwaylandqttextinputmethodmanager.cpp extensions/qwaylandqttextinputmethodmanager.h extensions/qwaylandqttextinputmethodmanager_p.h + extensions/qwaylandqtwindowmanager.cpp extensions/qwaylandqtwindowmanager.h extensions/qwaylandqtwindowmanager_p.h + extensions/qwaylandshell.cpp extensions/qwaylandshell.h extensions/qwaylandshell_p.h + extensions/qwaylandshellsurface.cpp extensions/qwaylandshellsurface.h extensions/qwaylandshellsurface_p.h + extensions/qwaylandtextinput.cpp extensions/qwaylandtextinput.h extensions/qwaylandtextinput_p.h + extensions/qwaylandtextinputmanager.cpp extensions/qwaylandtextinputmanager.h extensions/qwaylandtextinputmanager_p.h + extensions/qwaylandtextinputv3.cpp extensions/qwaylandtextinputv3.h extensions/qwaylandtextinputv3_p.h + extensions/qwaylandtextinputmanagerv3.cpp extensions/qwaylandtextinputmanagerv3.h extensions/qwaylandtextinputmanagerv3_p.h + extensions/qwaylandviewporter.cpp extensions/qwaylandviewporter.h extensions/qwaylandviewporter_p.h + extensions/qwaylandwlshell.cpp extensions/qwaylandwlshell.h extensions/qwaylandwlshell_p.h + extensions/qwaylandxdgdecorationv1.cpp extensions/qwaylandxdgdecorationv1.h extensions/qwaylandxdgdecorationv1_p.h + extensions/qwaylandxdgoutputv1.cpp extensions/qwaylandxdgoutputv1.h extensions/qwaylandxdgoutputv1_p.h + extensions/qwaylandxdgshell.cpp extensions/qwaylandxdgshell.h extensions/qwaylandxdgshell_p.h + extensions/qwaylandxdgdialogv1.cpp extensions/qwaylandxdgdialogv1_p.h + extensions/qwlqtkey.cpp extensions/qwlqtkey_p.h + extensions/qwlqttouch.cpp extensions/qwlqttouch_p.h + global/qtwaylandcompositorglobal.h global/qtwaylandcompositorglobal_p.h + global/qtwaylandqmlinclude.h + global/qwaylandcompositorextension.cpp global/qwaylandcompositorextension.h global/qwaylandcompositorextension_p.h + global/qwaylandutils_p.h + hardware_integration/qwlclientbufferintegration.cpp hardware_integration/qwlclientbufferintegration_p.h + wayland_wrapper/qwlbuffermanager.cpp wayland_wrapper/qwlbuffermanager_p.h + wayland_wrapper/qwlclientbuffer.cpp wayland_wrapper/qwlclientbuffer_p.h + wayland_wrapper/qwlregion.cpp wayland_wrapper/qwlregion_p.h + INCLUDE_DIRECTORIES + ../shared + compositor_api + extensions + global + wayland_wrapper + LIBRARIES + Qt::CorePrivate + Qt::GuiPrivate + Qt::WaylandGlobalPrivate + PUBLIC_LIBRARIES + Qt::Core + Qt::Gui + Wayland::Server + PRIVATE_MODULE_INTERFACE + Qt::CorePrivate + Qt::GuiPrivate + Qt::WaylandGlobalPrivate + PRIVATE_HEADER_FILTERS + "^qwayland-.*\.h|^wayland-.*-protocol\.h" +) + +# all those macros define structs with Q_OBJECT macros, and should be picked up by moc +set_target_properties(WaylandCompositor WaylandCompositorPrivate + PROPERTIES + INTERFACE_AUTOMOC_MACRO_NAMES "Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_NAMED_ELEMENT;Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_NAMED_CLASS;Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_CLASS;Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_CONTAINER_CLASS" +) + +set(compositor_no_pch_sources + compat/removed_api.cpp +) + +foreach(src ${compositor_no_pch_sources}) + qt_update_ignore_pch_source(WaylandCompositor ${src}) +endforeach() + +# Resources: +set(compositor_resource_files + "shaders/surface.vert.qsb" + "shaders/surface_rgba.frag.qsb" + "shaders/surface_rgbx.frag.qsb" + "shaders/surface_y_u_v.frag.qsb" + "shaders/surface_y_uv.frag.qsb" + "shaders/surface_y_xuxv.frag.qsb" + "shaders/surface_oes_external.frag" +) + +qt_internal_add_resource(WaylandCompositor "compositor" + PREFIX + "/qt-project.org/wayland/compositor" + FILES + ${compositor_resource_files} +) + +qt6_generate_wayland_protocol_server_sources(WaylandCompositor + FILES + ${CMAKE_CURRENT_SOURCE_DIR}/../3rdparty/protocol/idle-inhibit-unstable-v1.xml + ${CMAKE_CURRENT_SOURCE_DIR}/../3rdparty/protocol/ivi-application.xml + ${CMAKE_CURRENT_SOURCE_DIR}/../3rdparty/protocol/presentation-time.xml + ${CMAKE_CURRENT_SOURCE_DIR}/../3rdparty/protocol/scaler.xml + ${CMAKE_CURRENT_SOURCE_DIR}/../3rdparty/protocol/text-input-unstable-v2.xml + ${CMAKE_CURRENT_SOURCE_DIR}/../3rdparty/protocol/text-input-unstable-v3.xml + ${CMAKE_CURRENT_SOURCE_DIR}/../3rdparty/protocol/viewporter.xml + ${CMAKE_CURRENT_SOURCE_DIR}/../3rdparty/protocol/wayland.xml + ${CMAKE_CURRENT_SOURCE_DIR}/../3rdparty/protocol/xdg-decoration-unstable-v1.xml + ${CMAKE_CURRENT_SOURCE_DIR}/../3rdparty/protocol/xdg-output-unstable-v1.xml + ${CMAKE_CURRENT_SOURCE_DIR}/../3rdparty/protocol/xdg-shell.xml + ${CMAKE_CURRENT_SOURCE_DIR}/../3rdparty/protocol/xdg-dialog-v1.xml + ${CMAKE_CURRENT_SOURCE_DIR}/../extensions/hardware-integration.xml + ${CMAKE_CURRENT_SOURCE_DIR}/../extensions/qt-key-unstable-v1.xml + ${CMAKE_CURRENT_SOURCE_DIR}/../extensions/qt-text-input-method-unstable-v1.xml + ${CMAKE_CURRENT_SOURCE_DIR}/../extensions/qt-texture-sharing-unstable-v1.xml + ${CMAKE_CURRENT_SOURCE_DIR}/../extensions/qt-windowmanager.xml + ${CMAKE_CURRENT_SOURCE_DIR}/../extensions/server-buffer-extension.xml + ${CMAKE_CURRENT_SOURCE_DIR}/../extensions/touch-extension.xml +) + +#### Keys ignored in scope 1:.:.:compositor.pro:<TRUE>: +# MODULE = "waylandcompositor" + +## Scopes: +##################################################################### + +qt_internal_extend_target(WaylandCompositor CONDITION QT_FEATURE_opengl + SOURCES + hardware_integration/qwlclientbufferintegrationfactory.cpp hardware_integration/qwlclientbufferintegrationfactory_p.h + hardware_integration/qwlclientbufferintegrationplugin.cpp hardware_integration/qwlclientbufferintegrationplugin_p.h + hardware_integration/qwlhardwarelayerintegration.cpp hardware_integration/qwlhardwarelayerintegration_p.h + hardware_integration/qwlhardwarelayerintegrationfactory.cpp hardware_integration/qwlhardwarelayerintegrationfactory_p.h + hardware_integration/qwlhardwarelayerintegrationplugin.cpp hardware_integration/qwlhardwarelayerintegrationplugin_p.h + hardware_integration/qwlhwintegration.cpp hardware_integration/qwlhwintegration_p.h + hardware_integration/qwlserverbufferintegration.cpp hardware_integration/qwlserverbufferintegration_p.h + hardware_integration/qwlserverbufferintegrationfactory.cpp hardware_integration/qwlserverbufferintegrationfactory_p.h + hardware_integration/qwlserverbufferintegrationplugin.cpp hardware_integration/qwlserverbufferintegrationplugin_p.h + hardware_integration/qwltextureorphanage.cpp hardware_integration/qwltextureorphanage_p.h + PUBLIC_LIBRARIES + Qt::OpenGL +) + +qt_internal_extend_target(WaylandCompositor CONDITION TARGET Qt::Quick + PUBLIC_LIBRARIES + Qt::Quick +) + +qt_internal_extend_target(WaylandCompositor CONDITION QT_FEATURE_wayland_compositor_quick + SOURCES + compositor_api/qwaylandcompositorquickextensions.cpp compositor_api/qwaylandcompositorquickextensions_p.h + compositor_api/qwaylandmousetracker.cpp compositor_api/qwaylandmousetracker_p.h + compositor_api/qwaylandquickchildren.h + compositor_api/qwaylandquickcompositor.cpp compositor_api/qwaylandquickcompositor.h + compositor_api/qwaylandquickitem.cpp compositor_api/qwaylandquickitem.h compositor_api/qwaylandquickitem_p.h + compositor_api/qwaylandquickoutput.cpp compositor_api/qwaylandquickoutput.h + compositor_api/qwaylandquicksurface.cpp compositor_api/qwaylandquicksurface.h compositor_api/qwaylandquicksurface_p.h + extensions/qwaylandivisurfaceintegration.cpp extensions/qwaylandivisurfaceintegration_p.h + extensions/qwaylandquickshellintegration.cpp extensions/qwaylandquickshellintegration.h + extensions/qwaylandquickshellsurfaceitem.cpp extensions/qwaylandquickshellsurfaceitem.h extensions/qwaylandquickshellsurfaceitem_p.h + extensions/qwaylandquickxdgoutputv1.cpp extensions/qwaylandquickxdgoutputv1.h + extensions/qwaylandwlshellintegration.cpp extensions/qwaylandwlshellintegration_p.h + extensions/qwaylandxdgshellintegration.cpp extensions/qwaylandxdgshellintegration_p.h + extensions/qwaylandpresentationtime.cpp extensions/qwaylandpresentationtime_p.h extensions/qwaylandpresentationtime_p_p.h + global/qwaylandquickextension.cpp global/qwaylandquickextension.h + LIBRARIES + Qt::QmlPrivate + Qt::QuickPrivate + PUBLIC_LIBRARIES + Qt::Qml + Qt::Quick + PRIVATE_MODULE_INTERFACE + Qt::QmlPrivate + Qt::QuickPrivate +) + + +qt_internal_extend_target(WaylandCompositor CONDITION QT_FEATURE_wayland_datadevice + SOURCES + wayland_wrapper/qwldatadevice.cpp wayland_wrapper/qwldatadevice_p.h + wayland_wrapper/qwldatadevicemanager.cpp wayland_wrapper/qwldatadevicemanager_p.h + wayland_wrapper/qwldataoffer.cpp wayland_wrapper/qwldataoffer_p.h + wayland_wrapper/qwldatasource.cpp wayland_wrapper/qwldatasource_p.h +) + +qt_internal_extend_target(WaylandCompositor CONDITION QT_FEATURE_im + SOURCES + compositor_api/qwaylandinputmethodcontrol.cpp compositor_api/qwaylandinputmethodcontrol.h compositor_api/qwaylandinputmethodcontrol_p.h +) + +qt_internal_extend_target(WaylandCompositor CONDITION QT_FEATURE_draganddrop + SOURCES + compositor_api/qwaylanddrag.cpp compositor_api/qwaylanddrag.h +) + +qt_internal_extend_target(WaylandCompositor CONDITION QT_FEATURE_opengl AND QT_FEATURE_wayland_compositor_quick + SOURCES + compositor_api/qwaylandquickhardwarelayer.cpp compositor_api/qwaylandquickhardwarelayer_p.h + extensions/qwltexturesharingextension.cpp extensions/qwltexturesharingextension_p.h +) +qt_internal_add_docs(WaylandCompositor + doc/qtwaylandcompositor.qdocconf +) + +if (TARGET Qt::Qml) + qt_internal_add_qml_module(WaylandCompositor + URI QtWayland.Compositor + VERSION ${PROJECT_VERSION} + CLASS_NAME QWaylandCompositorPlugin + PLUGIN_TARGET qwaylandcompositorplugin + PAST_MAJOR_VERSIONS 1 + QML_FILES + qmlfiles/WaylandCursorItem.qml + qmlfiles/WaylandOutputWindow.qml + DEPENDENCIES + QtQuick + NO_GENERATE_CPP_EXPORTS + ) +endif() + +qt_record_extra_qt_main_tools_package_dependency(WaylandCompositor WaylandScannerTools "${PROJECT_VERSION}") +qt_record_extra_qt_package_dependency(WaylandCompositor WaylandGlobalPrivate "${PROJECT_VERSION}") diff --git a/src/compositor/Qt6WaylandCompositorMacros.cmake b/src/compositor/Qt6WaylandCompositorMacros.cmake new file mode 100644 index 000000000..05d16af6c --- /dev/null +++ b/src/compositor/Qt6WaylandCompositorMacros.cmake @@ -0,0 +1,92 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +function(qt6_generate_wayland_protocol_server_sources target) + cmake_parse_arguments(arg "" "__QT_INTERNAL_WAYLAND_INCLUDE_DIR" "FILES" ${ARGN}) + if(DEFINED arg_UNPARSED_ARGUMENTS) + message(FATAL_ERROR "Unknown arguments were passed to qt6_generate_wayland_protocol_server_sources: (${arg_UNPARSED_ARGUMENTS}).") + endif() + + get_target_property(target_binary_dir ${target} BINARY_DIR) + + if(NOT TARGET Wayland::Scanner) + message(FATAL_ERROR "Wayland::Scanner target not found. You might be missing the WaylandScanner CMake package.") + endif() + + if(NOT TARGET Qt6::qtwaylandscanner) + message(FATAL_ERROR "qtwaylandscanner executable not found. Most likely there is an issue with your Qt installation.") + endif() + + string(TOUPPER "${target}" module_define_infix) + string(REPLACE "-" "_" module_define_infix "${module_define_infix}") + string(REPLACE "." "_" module_define_infix "${module_define_infix}") + set(build_macro "QT_BUILD_${module_define_infix}_LIB") + + foreach(protocol_file IN LISTS arg_FILES) + get_filename_component(protocol_name "${protocol_file}" NAME_WLE) + + set(waylandscanner_header_output "${target_binary_dir}/wayland-${protocol_name}-server-protocol.h") + set(waylandscanner_code_output "${target_binary_dir}/wayland-${protocol_name}-protocol.c") + set(qtwaylandscanner_header_output "${target_binary_dir}/qwayland-server-${protocol_name}.h") + set(qtwaylandscanner_code_output "${target_binary_dir}/qwayland-server-${protocol_name}.cpp") + + add_custom_command( + OUTPUT "${waylandscanner_header_output}" + #TODO: Maybe put the files in ${CMAKE_CURRENT_BINARY_DIR/wayland_generated instead? + COMMAND Wayland::Scanner --include-core-only server-header < "${protocol_file}" > "${waylandscanner_header_output}" + DEPENDS ${protocol_file} Wayland::Scanner + ) + add_custom_command( + OUTPUT "${waylandscanner_code_output}" + COMMAND Wayland::Scanner --include-core-only public-code < "${protocol_file}" > "${waylandscanner_code_output}" + DEPENDS ${protocol_file} Wayland::Scanner + ) + + set(wayland_include_dir "") + if(arg___QT_INTERNAL_WAYLAND_INCLUDE_DIR) + set(wayland_include_dir "${arg___QT_INTERNAL_WAYLAND_INCLUDE_DIR}") + else() + get_target_property(qt_module ${target} _qt_module_interface_name) + get_target_property(is_for_module "${target}" _qt_module_has_headers) + if (qt_module) + set(wayland_include_dir "Qt${qt_module}/private") + elseif (is_for_module) + set(wayland_include_dir "QtWaylandCompositor/private") + endif() + endif() + + add_custom_command( + OUTPUT "${qtwaylandscanner_header_output}" + COMMAND Qt6::qtwaylandscanner server-header + "${protocol_file}" + --build-macro=${build_macro} + --header-path='${wayland_include_dir}' + > "${qtwaylandscanner_header_output}" + DEPENDS ${protocol_file} Qt6::qtwaylandscanner + ) + + add_custom_command( + OUTPUT "${qtwaylandscanner_code_output}" + COMMAND Qt6::qtwaylandscanner server-code + "${protocol_file}" + --build-macro=${build_macro} + --header-path='${wayland_include_dir}' + > "${qtwaylandscanner_code_output}" + DEPENDS ${protocol_file} Qt6::qtwaylandscanner + ) + + target_sources(${target} PRIVATE + "${waylandscanner_header_output}" + "${waylandscanner_code_output}" + "${qtwaylandscanner_header_output}" + "${qtwaylandscanner_code_output}" + ) + endforeach() + target_include_directories(${target} PRIVATE ${target_binary_dir}) +endfunction() + +if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS) + function(qt_generate_wayland_protocol_server_sources) + qt6_generate_wayland_protocol_server_sources(${ARGV}) + endfunction() +endif() diff --git a/src/compositor/compat/removed_api.cpp b/src/compositor/compat/removed_api.cpp new file mode 100644 index 000000000..9a4f7c6a7 --- /dev/null +++ b/src/compositor/compat/removed_api.cpp @@ -0,0 +1,32 @@ +// Copyright (C) 2022 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#define QT_WAYLANDCOMPOSITOR_BUILD_REMOVED_API + +#include "qtwaylandcompositorglobal.h" + +QT_USE_NAMESPACE + +#if QT_WAYLANDCOMPOSITOR_REMOVED_SINCE(6, 3) + +#include "qwaylandbufferref.h" + +bool QWaylandBufferRef::operator==(const QWaylandBufferRef &other) +{ + return std::as_const(*this) == other; +} + +bool QWaylandBufferRef::operator!=(const QWaylandBufferRef &other) +{ + return std::as_const(*this) != other; +} + +#endif // QT_WAYLANDCOMPOSITOR_REMOVED_SINCE(6, 3) + +#if QT_WAYLANDCOMPOSITOR_REMOVED_SINCE(6, 4) + +// #include "qotherheader.h" +// // implement removed functions from qotherheader.h +// order alphabetically + +#endif // QT_WAYLANDCOMPOSITOR_REMOVED_SINCE(6, 4) diff --git a/src/compositor/compositor.pro b/src/compositor/compositor.pro deleted file mode 100644 index b887cf281..000000000 --- a/src/compositor/compositor.pro +++ /dev/null @@ -1,40 +0,0 @@ -TARGET = QtWaylandCompositor -MODULE = waylandcompositor - -QT = core gui-private - -qtConfig(xkbcommon) { - QT_FOR_PRIVATE += xkbcommon_support-private -} - -qtHaveModule(quick): QT += quick - -CONFIG -= precompile_header -CONFIG += link_pkgconfig - -QMAKE_DOCS = $$PWD/doc/qtwaylandcompositor.qdocconf - -QMAKE_USE += wayland-server - -INCLUDEPATH += ../shared - -HEADERS += ../shared/qwaylandmimehelper_p.h \ - ../shared/qwaylandinputmethodeventbuilder_p.h \ - ../shared/qwaylandsharedmemoryformathelper_p.h - -SOURCES += ../shared/qwaylandmimehelper.cpp \ - ../shared/qwaylandinputmethodeventbuilder.cpp - -RESOURCES += compositor.qrc - -include ($$PWD/global/global.pri) -include ($$PWD/wayland_wrapper/wayland_wrapper.pri) -include ($$PWD/hardware_integration/hardware_integration.pri) -include ($$PWD/compositor_api/compositor_api.pri) -include ($$PWD/extensions/extensions.pri) - -MODULE_PLUGIN_TYPES = \ - wayland-graphics-integration-server \ - wayland-hardware-layer-integration \ - -load(qt_module) diff --git a/src/compositor/compositor.qrc b/src/compositor/compositor.qrc deleted file mode 100644 index 5dc7a70a5..000000000 --- a/src/compositor/compositor.qrc +++ /dev/null @@ -1,11 +0,0 @@ -<RCC> - <qresource prefix="/qt-project.org/wayland/compositor"> - <file>shaders/surface.vert</file> - <file>shaders/surface_oes_external.frag</file> - <file>shaders/surface_rgba.frag</file> - <file>shaders/surface_rgbx.frag</file> - <file>shaders/surface_y_u_v.frag</file> - <file>shaders/surface_y_uv.frag</file> - <file>shaders/surface_y_xuxv.frag</file> - </qresource> -</RCC> diff --git a/src/compositor/compositor_api/compositor_api.pri b/src/compositor/compositor_api/compositor_api.pri index bbc3a03e7..d8cfcaad3 100644 --- a/src/compositor/compositor_api/compositor_api.pri +++ b/src/compositor/compositor_api/compositor_api.pri @@ -27,8 +27,7 @@ HEADERS += \ compositor_api/qwaylandview_p.h \ compositor_api/qwaylandresource.h \ compositor_api/qwaylandsurfacegrabber.h \ - compositor_api/qwaylandoutputmode_p.h \ - compositor_api/qwaylandquickchildren.h + compositor_api/qwaylandoutputmode_p.h SOURCES += \ compositor_api/qwaylandcompositor.cpp \ @@ -55,7 +54,7 @@ qtConfig(im) { compositor_api/qwaylandinputmethodcontrol.cpp } -QT += core-private +QT += core-private gui-private qtConfig(draganddrop) { HEADERS += \ @@ -66,14 +65,19 @@ qtConfig(draganddrop) { qtConfig(wayland-compositor-quick) { SOURCES += \ + compositor_api/qwaylandmousetracker.cpp \ compositor_api/qwaylandquickcompositor.cpp \ compositor_api/qwaylandquicksurface.cpp \ compositor_api/qwaylandquickoutput.cpp \ compositor_api/qwaylandquickitem.cpp HEADERS += \ + compositor_api/qwaylandcompositorquickextensions_p.h \ + compositor_api/qwaylandmousetracker_p.h \ + compositor_api/qwaylandquickchildren.h \ compositor_api/qwaylandquickcompositor.h \ compositor_api/qwaylandquicksurface.h \ + compositor_api/qwaylandquicksurface_p.h \ compositor_api/qwaylandquickoutput.h \ compositor_api/qwaylandquickitem.h \ compositor_api/qwaylandquickitem_p.h diff --git a/src/compositor/compositor_api/qwaylandbufferref.cpp b/src/compositor/compositor_api/qwaylandbufferref.cpp index d7f6c43bb..556bc0925 100644 --- a/src/compositor/compositor_api/qwaylandbufferref.cpp +++ b/src/compositor/compositor_api/qwaylandbufferref.cpp @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 Jolla Ltd, author: <giulio.camuffo@jollamobile.com> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 Jolla Ltd, author: <giulio.camuffo@jollamobile.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <QDebug> #include <QAtomicInt> @@ -33,8 +7,34 @@ #include "qwaylandbufferref.h" #include "wayland_wrapper/qwlclientbuffer_p.h" +#include <type_traits> + QT_BEGIN_NAMESPACE +#define CHECK1(l, r, op) \ + static_assert(std::is_same_v< \ + bool, \ + decltype(std::declval<QWaylandBufferRef l >() op \ + std::declval<QWaylandBufferRef r >()) \ + >) +#define CHECK2(l, r) \ + CHECK1(l, r, ==); \ + CHECK1(l, r, !=) +#define CHECK(l, r) \ + CHECK2(l, r); \ + CHECK2(l &, r); \ + CHECK2(l &, r &); \ + CHECK2(l, r &) + +CHECK(, ); +CHECK(const, ); +CHECK(const, const); +CHECK(, const); + +#undef CHECK +#undef CHECK2 +#undef CHECK1 + class QWaylandBufferRefPrivate { public: @@ -114,22 +114,22 @@ QWaylandBufferRef &QWaylandBufferRef::operator=(const QWaylandBufferRef &ref) } /*! - * Returns true if this QWaylandBufferRef references the same buffer as \a ref. - * Otherwise returns false. + \fn bool QWaylandBufferRef::operator==(const QWaylandBufferRef &lhs, const QWaylandBufferRef &rhs) + + Returns \c true if \a lhs references the same buffer as \a rhs. + Otherwise returns \c{false}. */ -bool QWaylandBufferRef::operator==(const QWaylandBufferRef &ref) +bool operator==(const QWaylandBufferRef &lhs, const QWaylandBufferRef &rhs) noexcept { - return d->buffer == ref.d->buffer; + return lhs.d->buffer == rhs.d->buffer; } /*! - * Returns false if this QWaylandBufferRef references the same buffer as \a ref. - * Otherwise returns true. + \fn bool QWaylandBufferRef::operator!=(const QWaylandBufferRef &lhs, const QWaylandBufferRef &rhs) + + Returns \c false if \a lhs references the same buffer as \a rhs. + Otherwise returns \c {true}. */ -bool QWaylandBufferRef::operator!=(const QWaylandBufferRef &ref) -{ - return d->buffer != ref.d->buffer; -} /*! * Returns true if this QWaylandBufferRef does not reference a buffer. @@ -160,6 +160,19 @@ bool QWaylandBufferRef::hasContent() const { return QtWayland::ClientBuffer::hasContent(d->buffer); } +/*! + * Returns true if this QWaylandBufferRef references a buffer that has protected content. Otherwise returns false. + * + * \note This is an enabler which presumes support in the client buffer integration. None of the + * client buffer integrations included with Qt currently support protected content buffers. + * + * \since 6.2 + * \sa hasContent() + */ +bool QWaylandBufferRef::hasProtectedContent() const +{ + return QtWayland::ClientBuffer::hasProtectedContent(d->buffer); +} /*! * Returns true if this QWaylandBufferRef references a buffer that diff --git a/src/compositor/compositor_api/qwaylandbufferref.h b/src/compositor/compositor_api/qwaylandbufferref.h index b1aaf5f19..a917726f0 100644 --- a/src/compositor/compositor_api/qwaylandbufferref.h +++ b/src/compositor/compositor_api/qwaylandbufferref.h @@ -1,44 +1,17 @@ -/**************************************************************************** -** -** Copyright (C) 2017 Jolla Ltd, author: <giulio.camuffo@jollamobile.com> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 Jolla Ltd, author: <giulio.camuffo@jollamobile.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDBUFFERREF_H #define QWAYLANDBUFFERREF_H #include <QtWaylandCompositor/qtwaylandcompositorglobal.h> -#include <QImage> +#include <QtGui/QImage> #if QT_CONFIG(opengl) #include <QtGui/qopengl.h> #endif #include <QtWaylandCompositor/QWaylandSurface> -#include <QtWaylandCompositor/qtwaylandcompositorglobal.h> struct wl_resource; @@ -51,7 +24,7 @@ namespace QtWayland class ClientBuffer; } -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandBufferRef +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandBufferRef { public: QWaylandBufferRef(); @@ -62,9 +35,12 @@ public: bool isNull() const; bool hasBuffer() const; bool hasContent() const; + bool hasProtectedContent() const; bool isDestroyed() const; +#if QT_WAYLANDCOMPOSITOR_REMOVED_SINCE(6, 3) bool operator==(const QWaylandBufferRef &ref); bool operator!=(const QWaylandBufferRef &ref); +#endif struct wl_resource *wl_buffer() const; @@ -106,6 +82,12 @@ private: class QWaylandBufferRefPrivate *const d; friend class QWaylandBufferRefPrivate; friend class QWaylandSurfacePrivate; + + friend Q_WAYLANDCOMPOSITOR_EXPORT + bool operator==(const QWaylandBufferRef &lhs, const QWaylandBufferRef &rhs) noexcept; + friend inline + bool operator!=(const QWaylandBufferRef &lhs, const QWaylandBufferRef &rhs) noexcept + { return !(lhs == rhs); } }; QT_END_NAMESPACE diff --git a/src/compositor/compositor_api/qwaylandclient.cpp b/src/compositor/compositor_api/qwaylandclient.cpp index 2dba85faf..9c8bc704f 100644 --- a/src/compositor/compositor_api/qwaylandclient.cpp +++ b/src/compositor/compositor_api/qwaylandclient.cpp @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "qwaylandclient.h" #include <QtCore/private/qobject_p.h> @@ -75,10 +49,13 @@ public: QWaylandClient *parent = nullptr; }; Listener listener; + + QWaylandClient::TextInputProtocols mTextInputProtocols = QWaylandClient::NoProtocol; }; /*! * \qmltype WaylandClient + * \instantiates QWaylandClient * \inqmlmodule QtWayland.Compositor * \since 5.8 * \brief Represents a client connecting to the WaylandCompositor. @@ -157,7 +134,7 @@ QWaylandClient *QWaylandClient::fromWlClient(QWaylandCompositor *compositor, wl_ } /*! - * \qmlproperty WaylandCompositor QtWaylandCompositor::WaylandClient::compositor + * \qmlproperty WaylandCompositor QtWayland.Compositor::WaylandClient::compositor * * This property holds the compositor of this WaylandClient. */ @@ -185,7 +162,7 @@ wl_client *QWaylandClient::client() const } /*! - * \qmlproperty int QtWaylandCompositor::WaylandClient::userId + * \qmlproperty int QtWayland.Compositor::WaylandClient::userId * * This property holds the user id of this WaylandClient. */ @@ -204,7 +181,7 @@ qint64 QWaylandClient::userId() const } /*! - * \qmlproperty int QtWaylandCompositor::WaylandClient::groupId + * \qmlproperty int QtWayland.Compositor::WaylandClient::groupId * \readonly * * This property holds the group id of this WaylandClient. @@ -223,7 +200,7 @@ qint64 QWaylandClient::groupId() const } /*! - * \qmlproperty int QtWaylandCompositor::WaylandClient::processId + * \qmlproperty int QtWayland.Compositor::WaylandClient::processId * \readonly * * This property holds the process id of this WaylandClient. @@ -242,7 +219,7 @@ qint64 QWaylandClient::processId() const } /*! - * \qmlmethod void QtWaylandCompositor::WaylandClient::kill(signal) + * \qmlmethod void QtWayland.Compositor::WaylandClient::kill(signal) * * Kills the client with the specified \a signal. */ @@ -258,7 +235,7 @@ void QWaylandClient::kill(int signal) } /*! - * \qmlmethod void QtWaylandCompositor::WaylandClient::close() + * \qmlmethod void QtWayland.Compositor::WaylandClient::close() * * Closes the client */ @@ -272,4 +249,20 @@ void QWaylandClient::close() d->compositor->destroyClient(this); } +QWaylandClient::TextInputProtocols QWaylandClient::textInputProtocols() const +{ + Q_D(const QWaylandClient); + return d->mTextInputProtocols; +} + +void QWaylandClient::setTextInputProtocols(TextInputProtocols p) +{ + Q_D(QWaylandClient); + if (d->mTextInputProtocols != p) + d->mTextInputProtocols = p; +} + QT_END_NAMESPACE + +#include "moc_qwaylandclient.cpp" + diff --git a/src/compositor/compositor_api/qwaylandclient.h b/src/compositor/compositor_api/qwaylandclient.h index 8f52244c1..fd6172a4f 100644 --- a/src/compositor/compositor_api/qwaylandclient.h +++ b/src/compositor/compositor_api/qwaylandclient.h @@ -1,38 +1,13 @@ -/**************************************************************************** -** -** Copyright (C) 2017 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDCLIENT_H #define QWAYLANDCLIENT_H #include <QtWaylandCompositor/qtwaylandcompositorglobal.h> +#include <QtWaylandCompositor/qtwaylandqmlinclude.h> -#include <QObject> +#include <QtCore/QObject> #include <signal.h> @@ -43,7 +18,7 @@ QT_BEGIN_NAMESPACE class QWaylandClientPrivate; class QWaylandCompositor; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandClient : public QObject +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandClient : public QObject { Q_OBJECT Q_DECLARE_PRIVATE(QWaylandClient) @@ -52,9 +27,30 @@ class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandClient : public QObject Q_PROPERTY(qint64 userId READ userId CONSTANT) Q_PROPERTY(qint64 groupId READ groupId CONSTANT) Q_PROPERTY(qint64 processId READ processId CONSTANT) + Q_MOC_INCLUDE("qwaylandcompositor.h") + + QML_NAMED_ELEMENT(WaylandClient) + QML_ADDED_IN_VERSION(1, 0) + QML_UNCREATABLE("") public: ~QWaylandClient() override; + enum TextInputProtocol { + NoProtocol = 0, + QtTextInputMethodV1 = 1, + TextInputV2 = 2, + TextInputV3 = 4, + + TextInputV4 = TextInputV3, // TextInputV4 was an experimental API that is now deprecated + + QtTextInputMethod = QtTextInputMethodV1, + TextInput = TextInputV2 + }; + Q_DECLARE_FLAGS(TextInputProtocols, TextInputProtocol) + + TextInputProtocols textInputProtocols() const; + void setTextInputProtocols(TextInputProtocols p); + static QWaylandClient *fromWlClient(QWaylandCompositor *compositor, wl_client *wlClient); QWaylandCompositor *compositor() const; diff --git a/src/compositor/compositor_api/qwaylandcompositor.cpp b/src/compositor/compositor_api/qwaylandcompositor.cpp index b75ead7bd..e6f5955b8 100644 --- a/src/compositor/compositor_api/qwaylandcompositor.cpp +++ b/src/compositor/compositor_api/qwaylandcompositor.cpp @@ -1,32 +1,6 @@ -/**************************************************************************** -** -** Copyright (C) 2017 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "qtwaylandcompositorglobal_p.h" #include "qwaylandcompositor.h" @@ -67,6 +41,7 @@ #include <QtCore/QCoreApplication> #include <QtCore/QStringList> #include <QtCore/QSocketNotifier> +#include <QStandardPaths> #include <QtGui/QDesktopServices> #include <QtGui/QScreen> @@ -88,6 +63,7 @@ QT_BEGIN_NAMESPACE Q_LOGGING_CATEGORY(qLcWaylandCompositor, "qt.waylandcompositor") Q_LOGGING_CATEGORY(qLcWaylandCompositorHardwareIntegration, "qt.waylandcompositor.hardwareintegration") Q_LOGGING_CATEGORY(qLcWaylandCompositorInputMethods, "qt.waylandcompositor.inputmethods") +Q_LOGGING_CATEGORY(qLcWaylandCompositorTextInput, "qt.waylandcompositor.textinput") namespace QtWayland { @@ -114,14 +90,25 @@ public: QWaylandKeyboardPrivate *keyb = QWaylandKeyboardPrivate::get(seat->keyboard()); +#if defined(Q_OS_QNX) + // The QNX platform plugin delivers scan codes that haven't been adjusted to be + // xkbcommon compatible. xkbcommon requires that the scan codes be bumped up by + // 8 because that's how evdev/XKB deliver scan codes. You might think that it + // would've been better to remove this (odd) requirement from xkbcommon on QNX + // but it turns out that conforming to it has much less impact. + static int offset = QGuiApplication::platformName() == QStringLiteral("qnx") ? 8 : 0; + ke->nativeScanCode += offset; +#endif uint32_t code = ke->nativeScanCode; + if (code == 0) + code = seat->keyboard()->keyToScanCode(ke->key); bool isDown = ke->keyType == QEvent::KeyPress; #if QT_CONFIG(xkbcommon) xkb_state *xkbState = keyb->xkbState(); - Qt::KeyboardModifiers modifiers = QXkbCommon::modifiers(xkbState); const xkb_keysym_t sym = xkb_state_key_get_one_sym(xkbState, code); + Qt::KeyboardModifiers modifiers = QXkbCommon::modifiers(xkbState, sym); int qtkey = QXkbCommon::keysymToQtKey(sym, modifiers, xkbState, code); QString text = QXkbCommon::lookupString(xkbState, code); @@ -149,6 +136,9 @@ public: QWaylandCompositorPrivate::QWaylandCompositorPrivate(QWaylandCompositor *compositor) { + // Create XDG_RUNTIME_DIR, if it does not already exist + QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation); + if (QGuiApplication::platformNativeInterface()) display = static_cast<wl_display*>(QGuiApplication::platformNativeInterface()->nativeResourceForIntegration("server_wl_display")); @@ -180,8 +170,10 @@ void QWaylandCompositorPrivate::init() const int socketArg = arguments.indexOf(QLatin1String("--wayland-socket-name")); if (socketArg != -1 && socketArg + 1 < arguments.size()) socket_name = arguments.at(socketArg + 1).toLocal8Bit(); + if (socket_name.isEmpty()) + socket_name = qgetenv("WAYLAND_DISPLAY"); } - wl_compositor::init(display, 3); + wl_compositor::init(display, 4); wl_subcompositor::init(display, 1); #if QT_CONFIG(wayland_datadevice) @@ -190,9 +182,9 @@ void QWaylandCompositorPrivate::init() buffer_manager = new QtWayland::BufferManager(q); wl_display_init_shm(display); - const QVector<wl_shm_format> formats = QWaylandSharedMemoryFormatHelper::supportedWaylandFormats(); - for (wl_shm_format format : formats) - wl_display_add_shm_format(display, format); + + for (QWaylandCompositor::ShmFormat format : shmFormats) + wl_display_add_shm_format(display, wl_shm_format(format)); if (!socket_name.isEmpty()) { if (wl_display_add_socket(display, socket_name.constData())) @@ -205,26 +197,29 @@ void QWaylandCompositorPrivate::init() emit q->socketNameChanged(socket_name); } -#if WAYLAND_VERSION_MAJOR >= 1 && (WAYLAND_VERSION_MAJOR != 1 || WAYLAND_VERSION_MINOR >= 10) connectToExternalSockets(); -#endif loop = wl_display_get_event_loop(display); int fd = wl_event_loop_get_fd(loop); QSocketNotifier *sockNot = new QSocketNotifier(fd, QSocketNotifier::Read, q); - QObject::connect(sockNot, SIGNAL(activated(int)), q, SLOT(processWaylandEvents())); + QObject::connect(sockNot, SIGNAL(activated(QSocketDescriptor)), q, SLOT(processWaylandEvents())); QAbstractEventDispatcher *dispatcher = QGuiApplicationPrivate::eventDispatcher; QObject::connect(dispatcher, SIGNAL(aboutToBlock()), q, SLOT(processWaylandEvents())); + QObject::connect(static_cast<QGuiApplication *>(QGuiApplication::instance()), + &QGuiApplication::applicationStateChanged, + q, + &QWaylandCompositor::applicationStateChanged); + initializeHardwareIntegration(); initializeSeats(); initialized = true; - for (const QPointer<QObject> &object : qExchange(polish_objects, {})) { + for (const QPointer<QObject> &object : std::exchange(polish_objects, {})) { if (object) { QEvent polishEvent(QEvent::Polish); QCoreApplication::sendEvent(object.data(), &polishEvent); @@ -236,18 +231,19 @@ void QWaylandCompositorPrivate::init() QWaylandCompositorPrivate::~QWaylandCompositorPrivate() { - qDeleteAll(clients); + // Take copies, since the lists will get modified as elements are deleted + const auto clientsToDelete = clients; + qDeleteAll(clientsToDelete); - qDeleteAll(outputs); + const auto outputsToDelete = outputs; + qDeleteAll(outputsToDelete); #if QT_CONFIG(wayland_datadevice) delete data_device_manager; #endif -#if QT_CONFIG(opengl) // Some client buffer integrations need to clean up before the destroying the wl_display - client_buffer_integration.reset(); -#endif + qDeleteAll(client_buffer_integrations); if (ownsDisplay) wl_display_destroy(display); @@ -296,17 +292,15 @@ void QWaylandCompositorPrivate::addPolishObject(QObject *object) } } -#if WAYLAND_VERSION_MAJOR >= 1 && (WAYLAND_VERSION_MAJOR != 1 || WAYLAND_VERSION_MINOR >= 10) void QWaylandCompositorPrivate::connectToExternalSockets() { // Clear out any backlog of user-supplied external socket descriptors - for (int fd : qAsConst(externally_added_socket_fds)) { + for (int fd : std::as_const(externally_added_socket_fds)) { if (wl_display_add_socket_fd(display, fd) != 0) qWarning() << "Failed to integrate user-supplied socket fd into the Wayland event loop"; } externally_added_socket_fds.clear(); } -#endif void QWaylandCompositorPrivate::compositor_create_surface(wl_compositor::Resource *resource, uint32_t id) { @@ -355,9 +349,28 @@ QWaylandSurface *QWaylandCompositorPrivate::createDefaultSurface() return new QWaylandSurface(); } +class SharedMemoryClientBufferIntegration : public QtWayland::ClientBufferIntegration +{ +public: + void initializeHardware(wl_display *display) override; + QtWayland::ClientBuffer *createBufferFor(wl_resource *buffer) override; +}; + +void SharedMemoryClientBufferIntegration::initializeHardware(wl_display *) +{ +} + +QtWayland::ClientBuffer *SharedMemoryClientBufferIntegration::createBufferFor(wl_resource *buffer) +{ + if (wl_shm_buffer_get(buffer)) + return new QtWayland::SharedMemoryBuffer(buffer); + return nullptr; +} void QWaylandCompositorPrivate::initializeHardwareIntegration() { + client_buffer_integrations.prepend(new SharedMemoryClientBufferIntegration); // TODO: clean up the opengl dependency + #if QT_CONFIG(opengl) Q_Q(QWaylandCompositor); if (use_hw_integration_extension) @@ -365,12 +378,15 @@ void QWaylandCompositorPrivate::initializeHardwareIntegration() loadClientBufferIntegration(); loadServerBufferIntegration(); + + for (auto *integration : std::as_const(client_buffer_integrations)) + integration->initializeHardware(display); #endif } void QWaylandCompositorPrivate::initializeSeats() { - for (QWaylandSeat *seat : qAsConst(seats)) + for (QWaylandSeat *seat : std::as_const(seats)) seat->initialize(); } @@ -379,47 +395,40 @@ void QWaylandCompositorPrivate::loadClientBufferIntegration() #if QT_CONFIG(opengl) Q_Q(QWaylandCompositor); QStringList keys = QtWayland::ClientBufferIntegrationFactory::keys(); - QString targetKey; + QStringList targetKeys; QByteArray clientBufferIntegration = qgetenv("QT_WAYLAND_HARDWARE_INTEGRATION"); if (clientBufferIntegration.isEmpty()) clientBufferIntegration = qgetenv("QT_WAYLAND_CLIENT_BUFFER_INTEGRATION"); - if (keys.contains(QString::fromLocal8Bit(clientBufferIntegration.constData()))) { - targetKey = QString::fromLocal8Bit(clientBufferIntegration.constData()); - } else if (keys.contains(QString::fromLatin1("wayland-egl"))) { - targetKey = QString::fromLatin1("wayland-egl"); - } else if (!keys.isEmpty()) { - targetKey = keys.first(); + + for (auto b : clientBufferIntegration.split(';')) { + QString s = QString::fromLocal8Bit(b); + if (keys.contains(s)) + targetKeys.append(s); } - if (!targetKey.isEmpty()) { - client_buffer_integration.reset(QtWayland::ClientBufferIntegrationFactory::create(targetKey, QStringList())); - if (client_buffer_integration) { - qCDebug(qLcWaylandCompositorHardwareIntegration) << "Loaded client buffer integration:" << targetKey; - client_buffer_integration->setCompositor(q); - if (!client_buffer_integration->initializeHardware(display)) { - qCWarning(qLcWaylandCompositorHardwareIntegration) - << "Failed to initialize hardware for client buffer integration:" << targetKey; - client_buffer_integration.reset(); - } - } else { - qCWarning(qLcWaylandCompositorHardwareIntegration) - << "Failed to load client buffer integration:" << targetKey; + if (targetKeys.isEmpty()) { + if (keys.contains(QString::fromLatin1("wayland-egl"))) { + targetKeys.append(QString::fromLatin1("wayland-egl")); + } else if (!keys.isEmpty()) { + targetKeys.append(keys.first()); } } - if (!client_buffer_integration) { - qCWarning(qLcWaylandCompositorHardwareIntegration) - << "No client buffer integration was loaded, this means that clients will fall back" - << "to use CPU buffers (wl_shm) for transmitting buffers instead of using zero-copy" - << "GPU buffer handles. Expect serious performance impact with OpenGL clients due" - << "to potentially multiple copies between CPU and GPU memory per buffer.\n" - << "See the QtWayland readme for more info about how to build and configure Qt for" - << "your device."; - return; + QString hwIntegrationName; + + for (auto targetKey : std::as_const(targetKeys)) { + auto *integration = QtWayland::ClientBufferIntegrationFactory::create(targetKey, QStringList()); + if (integration) { + integration->setCompositor(q); + client_buffer_integrations.append(integration); + if (hwIntegrationName.isEmpty()) + hwIntegrationName = targetKey; + } } - if (client_buffer_integration && hw_integration) - hw_integration->setClientBufferIntegration(targetKey); + if (hw_integration && !hwIntegrationName.isEmpty()) + hw_integration->setClientBufferIntegrationName(hwIntegrationName); + #endif } @@ -450,12 +459,26 @@ void QWaylandCompositorPrivate::loadServerBufferIntegration() } if (server_buffer_integration && hw_integration) - hw_integration->setServerBufferIntegration(targetKey); + hw_integration->setServerBufferIntegrationName(targetKey); #endif } +QWaylandSeat *QWaylandCompositorPrivate::seatFor(QInputEvent *inputEvent) +{ + QWaylandSeat *dev = nullptr; + for (int i = 0; i < seats.size(); i++) { + QWaylandSeat *candidate = seats.at(i); + if (candidate->isOwner(inputEvent)) { + dev = candidate; + break; + } + } + return dev; +} + /*! \qmltype WaylandCompositor + \instantiates QWaylandCompositor \inqmlmodule QtWayland.Compositor \since 5.8 \brief Manages the Wayland display server. @@ -487,35 +510,37 @@ void QWaylandCompositorPrivate::loadServerBufferIntegration() */ /*! - \qmlsignal void QtWaylandCompositor::WaylandCompositor::surfaceRequested(WaylandClient client, int id, int version) + \qmlsignal void QtWayland.Compositor::WaylandCompositor::surfaceRequested(WaylandClient client, int id, int version) - This signal is emitted when a client has created a surface. - The slot connecting to this signal may create and initialize - a WaylandSurface instance in the scope of the slot. - Otherwise a default surface is created. + This signal is emitted when a \a client has created a surface with id \a id. + The interface \a version is also available. + + The slot connecting to this signal may create and initialize a WaylandSurface + instance in the scope of the slot. Otherwise a default surface is created. */ /*! \fn void QWaylandCompositor::surfaceRequested(QWaylandClient *client, uint id, int version) - This signal is emitted when a client has created a surface. - The slot connecting to this signal may create and initialize - a QWaylandSurface instance in the scope of the slot. - Otherwise a default surface is created. + This signal is emitted when a \a client has created a surface with id \a id. + The interface \a version is also available. + + The slot connecting to this signal may create and initialize a QWaylandSurface + instance in the scope of the slot. Otherwise a default surface is created. Connections to this signal must be of Qt::DirectConnection connection type. */ /*! - \qmlsignal void QtWaylandCompositor::WaylandCompositor::surfaceCreated(QWaylandSurface *surface) + \qmlsignal void QtWayland.Compositor::WaylandCompositor::surfaceCreated(WaylandSurface surface) - This signal is emitted when a new WaylandSurface instance has been created. + This signal is emitted when a new WaylandSurface instance \a surface has been created. */ /*! \fn void QWaylandCompositor::surfaceCreated(QWaylandSurface *surface) - This signal is emitted when a new QWaylandSurface instance has been created. + This signal is emitted when a new QWaylandSurface instance \a surface has been created. */ /*! @@ -554,7 +579,7 @@ void QWaylandCompositor::create() } /*! - * \qmlproperty bool QtWaylandCompositor::WaylandCompositor::created + * \qmlproperty bool QtWayland.Compositor::WaylandCompositor::created * * This property is true if WaylandCompositor has been initialized, * otherwise it's false. @@ -573,7 +598,7 @@ bool QWaylandCompositor::isCreated() const } /*! - * \qmlproperty string QtWaylandCompositor::WaylandCompositor::socketName + * \qmlproperty string QtWayland.Compositor::WaylandCompositor::socketName * * This property holds the socket name used by WaylandCompositor to communicate with * clients. It must be set before the component is completed. @@ -616,7 +641,7 @@ QByteArray QWaylandCompositor::socketName() const } /*! - * \qmlmethod QtWaylandCompositor::WaylandCompositor::addSocketDescriptor(fd) + * \qmlmethod QtWayland.Compositor::WaylandCompositor::addSocketDescriptor(fd) * \since 5.12 * * Listen for client connections on a file descriptor, \a fd, referring to a @@ -645,15 +670,10 @@ QByteArray QWaylandCompositor::socketName() const */ void QWaylandCompositor::addSocketDescriptor(int fd) { -#if WAYLAND_VERSION_MAJOR >= 1 && (WAYLAND_VERSION_MAJOR != 1 || WAYLAND_VERSION_MINOR >= 10) Q_D(QWaylandCompositor); d->externally_added_socket_fds.append(fd); if (isCreated()) d->connectToExternalSockets(); -#else - Q_UNUSED(fd); - qWarning() << "QWaylandCompositor::addSocketDescriptor() does nothing on libwayland versions prior to 1.10.0"; -#endif } /*! @@ -684,7 +704,7 @@ QList<QWaylandClient *>QWaylandCompositor::clients() const } /*! - * \qmlmethod QtWaylandCompositor::WaylandCompositor::destroyClientForSurface(surface) + * \qmlmethod QtWayland.Compositor::WaylandCompositor::destroyClientForSurface(surface) * * Destroys the client for the WaylandSurface \a surface. */ @@ -698,7 +718,7 @@ void QWaylandCompositor::destroyClientForSurface(QWaylandSurface *surface) } /*! - * \qmlmethod QtWaylandCompositor::WaylandCompositor::destroyClient(client) + * \qmlmethod QtWayland.Compositor::WaylandCompositor::destroyClient(client) * * Destroys the given WaylandClient \a client. */ @@ -756,7 +776,7 @@ QWaylandOutput *QWaylandCompositor::outputFor(QWindow *window) const } /*! - * \qmlproperty WaylandOutput QtWaylandCompositor::WaylandCompositor::defaultOutput + * \qmlproperty WaylandOutput QtWayland.Compositor::WaylandCompositor::defaultOutput * * This property contains the first in the list of outputs added to the * WaylandCompositor, or null if no outputs have been added. @@ -857,7 +877,7 @@ QWaylandTouch *QWaylandCompositor::createTouchDevice(QWaylandSeat *seat) } /*! - * \qmlproperty bool QtWaylandCompositor::WaylandCompositor::retainedSelection + * \qmlproperty bool QtWayland.Compositor::WaylandCompositor::retainedSelection * * This property holds whether retained selection is enabled. */ @@ -903,7 +923,7 @@ void QWaylandCompositor::overrideSelection(const QMimeData *data) } /*! - * \qmlproperty WaylandSeat QtWaylandCompositor::WaylandCompositor::defaultSeat + * \qmlproperty WaylandSeat QtWayland.Compositor::WaylandCompositor::defaultSeat * * This property contains the default seat for this * WaylandCompositor. @@ -924,27 +944,17 @@ QWaylandSeat *QWaylandCompositor::defaultSeat() const } /*! - * \internal - * - * Currently, Qt only supports a single seat, so this exists for - * future proofing the APIs. + * Select the seat for a given input event \a inputEvent. + * Currently, Qt only supports a single seat. */ QWaylandSeat *QWaylandCompositor::seatFor(QInputEvent *inputEvent) { Q_D(QWaylandCompositor); - QWaylandSeat *dev = nullptr; - for (int i = 0; i < d->seats.size(); i++) { - QWaylandSeat *candidate = d->seats.at(i); - if (candidate->isOwner(inputEvent)) { - dev = candidate; - break; - } - } - return dev; + return d->seatFor(inputEvent); } /*! - * \qmlproperty bool QtWaylandCompositor::WaylandCompositor::useHardwareIntegrationExtension + * \qmlproperty bool QtWayland.Compositor::WaylandCompositor::useHardwareIntegrationExtension * * This property holds whether the hardware integration extension should be enabled for * this WaylandCompositor. @@ -1029,4 +1039,67 @@ void QWaylandCompositor::grabSurface(QWaylandSurfaceGrabber *grabber, const QWay } } +/*! + * \qmlproperty list<enum> QtWayland.Compositor::WaylandCompositor::additionalShmFormats + * + * This property holds the list of additional wl_shm formats advertised as supported by the + * compositor. + * + * By default, only the required ShmFormat_ARGB8888 and ShmFormat_XRGB8888 are listed and this + * list will empty. Additional formats may require conversion internally and can thus affect + * performance. + * + * This property must be set before the compositor component is completed. Subsequent changes + * will have no effect. + * + * \since 6.0 + */ + +/*! + * \property QWaylandCompositor::additionalShmFormats + * + * This property holds the list of additional wl_shm formats advertised as supported by the + * compositor. + * + * By default, only the required ShmFormat_ARGB8888 and ShmFormat_XRGB8888 are listed and this + * list will empty. + * + * This property must be set before the compositor is \l{create()}{created}. Subsequent changes + * will have no effect. + * + * \since 6.0 + */ +void QWaylandCompositor::setAdditionalShmFormats(const QVector<ShmFormat> &additionalShmFormats) +{ + Q_D(QWaylandCompositor); + if (d->initialized) + qCWarning(qLcWaylandCompositorHardwareIntegration) << "Setting QWaylandCompositor::additionalShmFormats after initialization has no effect"; + + d->shmFormats = additionalShmFormats; + emit additionalShmFormatsChanged(); +} + +QVector<QWaylandCompositor::ShmFormat> QWaylandCompositor::additionalShmFormats() const +{ + Q_D(const QWaylandCompositor); + return d->shmFormats; +} + +void QWaylandCompositor::applicationStateChanged(Qt::ApplicationState state) +{ +#if QT_CONFIG(xkbcommon) + if (state == Qt::ApplicationInactive) { + auto *seat = defaultSeat(); + if (seat != nullptr) { + QWaylandKeyboardPrivate *keyb = QWaylandKeyboardPrivate::get(seat->keyboard()); + keyb->resetKeyboardState(); + } + } +#else + Q_UNUSED(state); +#endif +} + QT_END_NAMESPACE + +#include "moc_qwaylandcompositor.cpp" diff --git a/src/compositor/compositor_api/qwaylandcompositor.h b/src/compositor/compositor_api/qwaylandcompositor.h index dfe14293d..1dee5cad1 100644 --- a/src/compositor/compositor_api/qwaylandcompositor.h +++ b/src/compositor/compositor_api/qwaylandcompositor.h @@ -1,43 +1,18 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDCOMPOSITOR_H #define QWAYLANDCOMPOSITOR_H #include <QtWaylandCompositor/qtwaylandcompositorglobal.h> +#include <QtWaylandCompositor/qtwaylandqmlinclude.h> #include <QtWaylandCompositor/qwaylandcompositorextension.h> #include <QtWaylandCompositor/QWaylandOutput> -#include <QObject> -#include <QImage> -#include <QRect> -#include <QLoggingCategory> +#include <QtCore/QObject> +#include <QtGui/QImage> +#include <QtCore/QRect> +#include <QtCore/QLoggingCategory> struct wl_display; @@ -52,7 +27,6 @@ class QWaylandCompositorPrivate; class QWaylandClient; class QWaylandSurface; class QWaylandSeat; -class QWaylandGlobalInterface; class QWaylandView; class QWaylandPointer; class QWaylandKeyboard; @@ -60,11 +34,12 @@ class QWaylandTouch; class QWaylandSurfaceGrabber; class QWaylandBufferRef; -Q_WAYLAND_COMPOSITOR_EXPORT Q_DECLARE_LOGGING_CATEGORY(qLcWaylandCompositor) -Q_WAYLAND_COMPOSITOR_EXPORT Q_DECLARE_LOGGING_CATEGORY(qLcWaylandCompositorHardwareIntegration) +Q_WAYLANDCOMPOSITOR_EXPORT Q_DECLARE_LOGGING_CATEGORY(qLcWaylandCompositor) +Q_WAYLANDCOMPOSITOR_EXPORT Q_DECLARE_LOGGING_CATEGORY(qLcWaylandCompositorHardwareIntegration) Q_DECLARE_LOGGING_CATEGORY(qLcWaylandCompositorInputMethods) +Q_DECLARE_LOGGING_CATEGORY(qLcWaylandCompositorTextInput) -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandCompositor : public QWaylandObject +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandCompositor : public QWaylandObject { Q_OBJECT Q_DECLARE_PRIVATE(QWaylandCompositor) @@ -74,8 +49,32 @@ class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandCompositor : public QWaylandObject Q_PROPERTY(QWaylandOutput *defaultOutput READ defaultOutput WRITE setDefaultOutput NOTIFY defaultOutputChanged) Q_PROPERTY(bool useHardwareIntegrationExtension READ useHardwareIntegrationExtension WRITE setUseHardwareIntegrationExtension NOTIFY useHardwareIntegrationExtensionChanged) Q_PROPERTY(QWaylandSeat *defaultSeat READ defaultSeat NOTIFY defaultSeatChanged) - + Q_PROPERTY(QVector<ShmFormat> additionalShmFormats READ additionalShmFormats WRITE setAdditionalShmFormats NOTIFY additionalShmFormatsChanged REVISION(6, 0)) + Q_MOC_INCLUDE("qwaylandseat.h") + QML_NAMED_ELEMENT(WaylandCompositorBase) + QML_UNCREATABLE("Cannot create instance of WaylandCompositorBase, use WaylandCompositor instead") + QML_ADDED_IN_VERSION(1, 0) public: + // Duplicates subset of supported values wl_shm_format enum + enum ShmFormat { + ShmFormat_ARGB8888 = 0, + ShmFormat_XRGB8888 = 1, + ShmFormat_C8 = 0x20203843, + ShmFormat_XRGB4444 = 0x32315258, + ShmFormat_ARGB4444 = 0x32315241, + ShmFormat_XRGB1555 = 0x35315258, + ShmFormat_RGB565 = 0x36314752, + ShmFormat_RGB888 = 0x34324752, + ShmFormat_XBGR8888 = 0x34324258, + ShmFormat_ABGR8888 = 0x34324241, + ShmFormat_BGR888 = 0x34324742, + ShmFormat_XRGB2101010 = 0x30335258, + ShmFormat_XBGR2101010 = 0x30334258, + ShmFormat_ARGB2101010 = 0x30335241, + ShmFormat_ABGR2101010 = 0x30334241 + }; + Q_ENUM(ShmFormat) + QWaylandCompositor(QObject *parent = nullptr); ~QWaylandCompositor() override; @@ -116,11 +115,17 @@ public: bool useHardwareIntegrationExtension() const; void setUseHardwareIntegrationExtension(bool use); + QVector<ShmFormat> additionalShmFormats() const; + void setAdditionalShmFormats(const QVector<ShmFormat> &additionalShmFormats); + virtual void grabSurface(QWaylandSurfaceGrabber *grabber, const QWaylandBufferRef &buffer); public Q_SLOTS: void processWaylandEvents(); +private Q_SLOTS: + void applicationStateChanged(Qt::ApplicationState state); + Q_SIGNALS: void createdChanged(); void socketNameChanged(const QByteArray &socketName); @@ -139,6 +144,8 @@ Q_SIGNALS: void outputAdded(QWaylandOutput *output); void outputRemoved(QWaylandOutput *output); + void additionalShmFormatsChanged(); + protected: virtual void retainedSelectionReceived(QMimeData *mimeData); virtual QWaylandSeat *createSeat(); diff --git a/src/compositor/compositor_api/qwaylandcompositor_p.h b/src/compositor/compositor_api/qwaylandcompositor_p.h index 6dec044f8..a8da8b8c4 100644 --- a/src/compositor/compositor_api/qwaylandcompositor_p.h +++ b/src/compositor/compositor_api/qwaylandcompositor_p.h @@ -1,32 +1,6 @@ -/**************************************************************************** -** -** Copyright (C) 2017-2015 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017-2015 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDCOMPOSITOR_P_H #define QWAYLANDCOMPOSITOR_P_H @@ -50,10 +24,12 @@ #include <QtWaylandCompositor/private/qwayland-server-wayland.h> +#include <QtCore/qpointer.h> + #include <vector> #if QT_CONFIG(xkbcommon) -#include <QtXkbCommonSupport/private/qxkbcommon_p.h> +#include <QtGui/private/qxkbcommon_p.h> #endif QT_BEGIN_NAMESPACE @@ -69,7 +45,7 @@ namespace QtWayland { class QWindowSystemEventHandler; class QWaylandSurface; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandCompositorPrivate : public QObjectPrivate, public QtWaylandServer::wl_compositor, public QtWaylandServer::wl_subcompositor +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandCompositorPrivate : public QObjectPrivate, public QtWaylandServer::wl_compositor, public QtWaylandServer::wl_subcompositor { public: static QWaylandCompositorPrivate *get(QWaylandCompositor *compositor) { return compositor->d_func(); } @@ -89,7 +65,7 @@ public: QWaylandOutput *defaultOutput() const { return outputs.size() ? outputs.first() : nullptr; } - inline QtWayland::ClientBufferIntegration *clientBufferIntegration() const; + inline const QList<QtWayland::ClientBufferIntegration *> clientBufferIntegrations() const; inline QtWayland::ServerBufferIntegration *serverBufferIntegration() const; #if QT_CONFIG(wayland_datadevice) @@ -113,9 +89,9 @@ public: inline void addOutput(QWaylandOutput *output); inline void removeOutput(QWaylandOutput *output); -#if WAYLAND_VERSION_MAJOR >= 1 && (WAYLAND_VERSION_MAJOR != 1 || WAYLAND_VERSION_MINOR >= 10) void connectToExternalSockets(); -#endif + + virtual QWaylandSeat *seatFor(QInputEvent *inputEvent); protected: void compositor_create_surface(wl_compositor::Resource *resource, uint32_t id) override; @@ -133,11 +109,10 @@ protected: void loadServerBufferIntegration(); QByteArray socket_name; -#if WAYLAND_VERSION_MAJOR >= 1 && (WAYLAND_VERSION_MAJOR != 1 || WAYLAND_VERSION_MINOR >= 10) QList<int> externally_added_socket_fds; -#endif struct wl_display *display = nullptr; bool ownsDisplay = false; + QVector<QWaylandCompositor::ShmFormat> shmFormats; QList<QWaylandSeat *> seats; QList<QWaylandOutput *> outputs; @@ -158,9 +133,9 @@ protected: #if QT_CONFIG(opengl) bool use_hw_integration_extension = true; QScopedPointer<QtWayland::HardwareIntegration> hw_integration; - QScopedPointer<QtWayland::ClientBufferIntegration> client_buffer_integration; QScopedPointer<QtWayland::ServerBufferIntegration> server_buffer_integration; #endif + QList<QtWayland::ClientBufferIntegration*> client_buffer_integrations; QScopedPointer<QWindowSystemEventHandler> eventHandler; @@ -177,13 +152,9 @@ protected: Q_DISABLE_COPY(QWaylandCompositorPrivate) }; -QtWayland::ClientBufferIntegration * QWaylandCompositorPrivate::clientBufferIntegration() const +const QList<QtWayland::ClientBufferIntegration *> QWaylandCompositorPrivate::clientBufferIntegrations() const { -#if QT_CONFIG(opengl) - return client_buffer_integration.data(); -#else - return 0; -#endif + return client_buffer_integrations; } QtWayland::ServerBufferIntegration * QWaylandCompositorPrivate::serverBufferIntegration() const diff --git a/src/compositor/compositor_api/qwaylandcompositorquickextensions.cpp b/src/compositor/compositor_api/qwaylandcompositorquickextensions.cpp new file mode 100644 index 000000000..43fb3b2f9 --- /dev/null +++ b/src/compositor/compositor_api/qwaylandcompositorquickextensions.cpp @@ -0,0 +1,10 @@ +// Copyright (C) 2022 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#include "qwaylandcompositorquickextensions_p.h" + +QT_BEGIN_NAMESPACE + +QT_END_NAMESPACE + +#include "moc_qwaylandcompositorquickextensions_p.cpp" diff --git a/src/compositor/compositor_api/qwaylandcompositorquickextensions_p.h b/src/compositor/compositor_api/qwaylandcompositorquickextensions_p.h new file mode 100644 index 000000000..7e59a5d6e --- /dev/null +++ b/src/compositor/compositor_api/qwaylandcompositorquickextensions_p.h @@ -0,0 +1,94 @@ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#ifndef QWAYLANDCOMPOSITORQUICKEXTENSIONS_P_H +#define QWAYLANDCOMPOSITORQUICKEXTENSIONS_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtQml/qqml.h> +#include <QtWaylandCompositor/qtwaylandcompositorglobal.h> +#include <QtWaylandCompositor/qwaylandquickextension.h> + +#include <QtWaylandCompositor/qwaylandcompositor.h> +#include <QtWaylandCompositor/qwaylandquickcompositor.h> +#include <QtWaylandCompositor/qwaylandqtwindowmanager.h> +#include <QtWaylandCompositor/qwaylandtextinputmanager.h> +#include <QtCore/private/qglobal_p.h> +#include <QtWaylandCompositor/qwaylandtextinputmanagerv3.h> +#include <QtWaylandCompositor/qwaylandqttextinputmethodmanager.h> +#include <QtWaylandCompositor/qwaylandidleinhibitv1.h> + +QT_BEGIN_NAMESPACE + +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandQuickCompositorQuickExtensionContainer : public QWaylandQuickCompositor +{ + Q_OBJECT + Q_PROPERTY(QQmlListProperty<QWaylandCompositorExtension> extensions READ extensions) + Q_PROPERTY(QQmlListProperty<QObject> data READ data DESIGNABLE false) + Q_CLASSINFO("DefaultProperty", "data") + QML_NAMED_ELEMENT(WaylandCompositor) + QML_ADDED_IN_VERSION(1, 0) +public: + QQmlListProperty<QObject> data() + { + return QQmlListProperty<QObject>(this, &m_objects); + } + + QQmlListProperty<QWaylandCompositorExtension> extensions() + { + return QQmlListProperty<QWaylandCompositorExtension>(this, this, + &append_extension, + &countFunction, + &atFunction, + &clearFunction); + } + + static qsizetype countFunction(QQmlListProperty<QWaylandCompositorExtension> *list) + { + return static_cast<QWaylandQuickCompositorQuickExtensionContainer *>(list->data)->extension_vector.size(); + } + + static QWaylandCompositorExtension *atFunction(QQmlListProperty<QWaylandCompositorExtension> *list, qsizetype index) + { + return static_cast<QWaylandQuickCompositorQuickExtensionContainer *>(list->data)->extension_vector.at(index); + } + + static void append_extension(QQmlListProperty<QWaylandCompositorExtension> *list, QWaylandCompositorExtension *extension) + { + QWaylandQuickCompositorQuickExtensionContainer *quickExtObj = static_cast<QWaylandQuickCompositorQuickExtensionContainer *>(list->data); + extension->setExtensionContainer(quickExtObj); + } + + static void clearFunction(QQmlListProperty<QWaylandCompositorExtension> *list) + { + static_cast<QWaylandQuickCompositorQuickExtensionContainer *>(list->data)->extension_vector.clear(); + } + +private: + QList<QObject *> m_objects; +}; + + +// Note: These have to be in a header with a Q_OBJECT macro, otherwise we won't run moc on it +Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_NAMED_ELEMENT(QWaylandQtWindowManager, QtWindowManager, 1, 0) +Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_NAMED_ELEMENT(QWaylandIdleInhibitManagerV1, + IdleInhibitManagerV1, 1, 0) +Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_NAMED_ELEMENT(QWaylandTextInputManager, TextInputManager, 1, 0) +Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_NAMED_ELEMENT(QWaylandTextInputManagerV3, TextInputManagerV3, + 1, 0) +Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_NAMED_ELEMENT(QWaylandQtTextInputMethodManager, + QtTextInputMethodManager, 1, 0) + +QT_END_NAMESPACE + +#endif // QWAYLANDCOMPOSITORQUICKEXTENSIONS_P_H diff --git a/src/compositor/compositor_api/qwaylanddestroylistener.cpp b/src/compositor/compositor_api/qwaylanddestroylistener.cpp index 958ea311c..26c2ff69e 100644 --- a/src/compositor/compositor_api/qwaylanddestroylistener.cpp +++ b/src/compositor/compositor_api/qwaylanddestroylistener.cpp @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 Jolla Ltd, author: <giulio.camuffo@jollamobile.com> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 Jolla Ltd, author: <giulio.camuffo@jollamobile.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "qwaylanddestroylistener.h" #include "qwaylanddestroylistener_p.h" @@ -63,3 +37,5 @@ void QWaylandDestroyListenerPrivate::handler(wl_listener *listener, void *data) } QT_END_NAMESPACE + +#include "moc_qwaylanddestroylistener.cpp" diff --git a/src/compositor/compositor_api/qwaylanddestroylistener.h b/src/compositor/compositor_api/qwaylanddestroylistener.h index f82775dac..e1307b2ca 100644 --- a/src/compositor/compositor_api/qwaylanddestroylistener.h +++ b/src/compositor/compositor_api/qwaylanddestroylistener.h @@ -1,32 +1,6 @@ -/**************************************************************************** -** -** Copyright (C) 2017 Jolla Ltd, author: <giulio.camuffo@jollamobile.com> -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 Jolla Ltd, author: <giulio.camuffo@jollamobile.com> +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDDESTROYLISTENER_H #define QWAYLANDDESTROYLISTENER_H @@ -40,7 +14,7 @@ QT_BEGIN_NAMESPACE class QWaylandDestroyListenerPrivate; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandDestroyListener : public QObject +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandDestroyListener : public QObject { Q_OBJECT Q_DECLARE_PRIVATE(QWaylandDestroyListener) diff --git a/src/compositor/compositor_api/qwaylanddestroylistener_p.h b/src/compositor/compositor_api/qwaylanddestroylistener_p.h index 1ff625dd3..baefc8171 100644 --- a/src/compositor/compositor_api/qwaylanddestroylistener_p.h +++ b/src/compositor/compositor_api/qwaylanddestroylistener_p.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 Jolla Ltd, author: <giulio.camuffo@jollamobile.com> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 Jolla Ltd, author: <giulio.camuffo@jollamobile.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QTWAYLAND_QWLLISTENER_H #define QTWAYLAND_QWLLISTENER_H diff --git a/src/compositor/compositor_api/qwaylanddrag.cpp b/src/compositor/compositor_api/qwaylanddrag.cpp index 2108c3906..2cd391218 100644 --- a/src/compositor/compositor_api/qwaylanddrag.cpp +++ b/src/compositor/compositor_api/qwaylanddrag.cpp @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 Klarälvdalens Datakonsult AB (KDAB). -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 Klarälvdalens Datakonsult AB (KDAB). +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "qwaylanddrag.h" @@ -130,3 +104,5 @@ void QWaylandDrag::cancelDrag() } QT_END_NAMESPACE + +#include "moc_qwaylanddrag.cpp" diff --git a/src/compositor/compositor_api/qwaylanddrag.h b/src/compositor/compositor_api/qwaylanddrag.h index 71ff723b2..599b79c98 100644 --- a/src/compositor/compositor_api/qwaylanddrag.h +++ b/src/compositor/compositor_api/qwaylanddrag.h @@ -1,36 +1,11 @@ -/**************************************************************************** -** -** Copyright (C) 2017 Klarälvdalens Datakonsult AB (KDAB). -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 Klarälvdalens Datakonsult AB (KDAB). +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDDRAG_H #define QWAYLANDDRAG_H #include <QtWaylandCompositor/qtwaylandcompositorglobal.h> +#include <QtWaylandCompositor/qtwaylandqmlinclude.h> #include <QtCore/QObject> #include <QtCore/QPointF> @@ -43,14 +18,18 @@ class QWaylandDragPrivate; class QWaylandSurface; class QWaylandSeat; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandDrag : public QObject +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandDrag : public QObject { Q_OBJECT Q_DECLARE_PRIVATE(QWaylandDrag) Q_PROPERTY(QWaylandSurface *icon READ icon NOTIFY iconChanged) Q_PROPERTY(bool visible READ visible NOTIFY iconChanged) + Q_MOC_INCLUDE("qwaylandsurface.h") + QML_NAMED_ELEMENT(WaylandDrag) + QML_ADDED_IN_VERSION(1, 0) + QML_UNCREATABLE("") public: explicit QWaylandDrag(QWaylandSeat *seat); diff --git a/src/compositor/compositor_api/qwaylandinputmethodcontrol.cpp b/src/compositor/compositor_api/qwaylandinputmethodcontrol.cpp index 5ecb9dfa0..e9a962d28 100644 --- a/src/compositor/compositor_api/qwaylandinputmethodcontrol.cpp +++ b/src/compositor/compositor_api/qwaylandinputmethodcontrol.cpp @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "qwaylandinputmethodcontrol.h" #include "qwaylandinputmethodcontrol_p.h" @@ -35,6 +9,8 @@ #include "qwaylandsurface.h" #include "qwaylandview.h" #include "qwaylandtextinput.h" +#include "qwaylandtextinputv3.h" +#include "qwaylandqttextinputmethod.h" #include <QtGui/QInputMethodEvent> @@ -43,11 +19,21 @@ QWaylandInputMethodControl::QWaylandInputMethodControl(QWaylandSurface *surface) { connect(d_func()->compositor, &QWaylandCompositor::defaultSeatChanged, this, &QWaylandInputMethodControl::defaultSeatChanged); - QWaylandTextInput *textInput = d_func()->textInput(); - if (textInput) { - connect(textInput, &QWaylandTextInput::surfaceEnabled, this, &QWaylandInputMethodControl::surfaceEnabled); - connect(textInput, &QWaylandTextInput::surfaceDisabled, this, &QWaylandInputMethodControl::surfaceDisabled); - connect(textInput, &QWaylandTextInput::updateInputMethod, this, &QWaylandInputMethodControl::updateInputMethod); + + updateTextInput(); + + QWaylandTextInputV3 *textInputV3 = d_func()->textInputV3(); + if (textInputV3) { + connect(textInputV3, &QWaylandTextInputV3::surfaceEnabled, this, &QWaylandInputMethodControl::surfaceEnabled); + connect(textInputV3, &QWaylandTextInputV3::surfaceDisabled, this, &QWaylandInputMethodControl::surfaceDisabled); + connect(textInputV3, &QWaylandTextInputV3::updateInputMethod, this, &QWaylandInputMethodControl::updateInputMethod); + } + + QWaylandQtTextInputMethod *textInputMethod = d_func()->textInputMethod(); + if (textInputMethod) { + connect(textInputMethod, &QWaylandQtTextInputMethod::surfaceEnabled, this, &QWaylandInputMethodControl::surfaceEnabled); + connect(textInputMethod, &QWaylandQtTextInputMethod::surfaceDisabled, this, &QWaylandInputMethodControl::surfaceDisabled); + connect(textInputMethod, &QWaylandQtTextInputMethod::updateInputMethod, this, &QWaylandInputMethodControl::updateInputMethod); } } @@ -56,10 +42,16 @@ QVariant QWaylandInputMethodControl::inputMethodQuery(Qt::InputMethodQuery query Q_D(const QWaylandInputMethodControl); QWaylandTextInput *textInput = d->textInput(); - - if (textInput && textInput->focus() == d->surface) { + if (textInput != nullptr && textInput->focus() == d->surface) return textInput->inputMethodQuery(query, argument); - } + + QWaylandTextInputV3 *textInputV3 = d->textInputV3(); + if (textInputV3 != nullptr && textInputV3->focus() == d->surface) + return textInputV3->inputMethodQuery(query, argument); + + QWaylandQtTextInputMethod *textInputMethod = d_func()->textInputMethod(); + if (textInputMethod && textInputMethod->focusedSurface() == d->surface) + return textInputMethod->inputMethodQuery(query, argument); return QVariant(); } @@ -68,9 +60,12 @@ void QWaylandInputMethodControl::inputMethodEvent(QInputMethodEvent *event) { Q_D(QWaylandInputMethodControl); - QWaylandTextInput *textInput = d->textInput(); - if (textInput) { + if (QWaylandTextInput *textInput = d->textInput()) { textInput->sendInputMethodEvent(event); + } else if (QWaylandTextInputV3 *textInputV3 = d->textInputV3()) { + textInputV3->sendInputMethodEvent(event); + } else if (QWaylandQtTextInputMethod *textInputMethod = d->textInputMethod()) { + textInputMethod->sendInputMethodEvent(event); } else { event->ignore(); } @@ -121,7 +116,22 @@ void QWaylandInputMethodControl::setSurface(QWaylandSurface *surface) d->surface = surface; QWaylandTextInput *textInput = d->textInput(); - setEnabled(textInput && textInput->isSurfaceEnabled(d->surface)); + QWaylandTextInputV3 *textInputV3 = d->textInputV3(); + QWaylandQtTextInputMethod *textInputMethod = d->textInputMethod(); + setEnabled((textInput && textInput->isSurfaceEnabled(d->surface)) + || (textInputV3 && textInputV3->isSurfaceEnabled(d->surface)) + || (textInputMethod && textInputMethod->isSurfaceEnabled(d->surface))); +} + +void QWaylandInputMethodControl::updateTextInput() +{ + QWaylandTextInput *textInput = d_func()->textInput(); + + if (textInput) { + connect(textInput, &QWaylandTextInput::surfaceEnabled, this, &QWaylandInputMethodControl::surfaceEnabled, Qt::UniqueConnection); + connect(textInput, &QWaylandTextInput::surfaceDisabled, this, &QWaylandInputMethodControl::surfaceDisabled, Qt::UniqueConnection); + connect(textInput, &QWaylandTextInput::updateInputMethod, this, &QWaylandInputMethodControl::updateInputMethod, Qt::UniqueConnection); + } } void QWaylandInputMethodControl::defaultSeatChanged() @@ -129,14 +139,32 @@ void QWaylandInputMethodControl::defaultSeatChanged() Q_D(QWaylandInputMethodControl); disconnect(d->textInput(), nullptr, this, nullptr); + disconnect(d->textInputV3(), nullptr, this, nullptr); + disconnect(d->textInputMethod(), nullptr, this, nullptr); d->seat = d->compositor->defaultSeat(); QWaylandTextInput *textInput = d->textInput(); + QWaylandTextInputV3 *textInputV3 = d->textInputV3(); + QWaylandQtTextInputMethod *textInputMethod = d->textInputMethod(); + + if (textInput) { + connect(textInput, &QWaylandTextInput::surfaceEnabled, this, &QWaylandInputMethodControl::surfaceEnabled); + connect(textInput, &QWaylandTextInput::surfaceDisabled, this, &QWaylandInputMethodControl::surfaceDisabled); + } + + if (textInputV3) { + connect(textInputV3, &QWaylandTextInputV3::surfaceEnabled, this, &QWaylandInputMethodControl::surfaceEnabled); + connect(textInputV3, &QWaylandTextInputV3::surfaceDisabled, this, &QWaylandInputMethodControl::surfaceDisabled); + } - connect(textInput, &QWaylandTextInput::surfaceEnabled, this, &QWaylandInputMethodControl::surfaceEnabled); - connect(textInput, &QWaylandTextInput::surfaceDisabled, this, &QWaylandInputMethodControl::surfaceDisabled); + if (textInputMethod) { + connect(textInputMethod, &QWaylandQtTextInputMethod::surfaceEnabled, this, &QWaylandInputMethodControl::surfaceEnabled); + connect(textInputMethod, &QWaylandQtTextInputMethod::surfaceDisabled, this, &QWaylandInputMethodControl::surfaceDisabled); + } - setEnabled(textInput && textInput->isSurfaceEnabled(d->surface)); + setEnabled((textInput && textInput->isSurfaceEnabled(d->surface)) + || (textInputV3 && textInputV3->isSurfaceEnabled(d->surface)) + || (textInputMethod && textInputMethod->isSurfaceEnabled(d->surface))); } QWaylandInputMethodControlPrivate::QWaylandInputMethodControlPrivate(QWaylandSurface *surface) @@ -146,7 +174,23 @@ QWaylandInputMethodControlPrivate::QWaylandInputMethodControlPrivate(QWaylandSur { } +QWaylandQtTextInputMethod *QWaylandInputMethodControlPrivate::textInputMethod() const +{ + if (!surface->client() || !surface->client()->textInputProtocols().testFlag(QWaylandClient::TextInputProtocol::QtTextInputMethodV1)) + return nullptr; + return QWaylandQtTextInputMethod::findIn(seat); +} + QWaylandTextInput *QWaylandInputMethodControlPrivate::textInput() const { + if (!surface->client() || !surface->client()->textInputProtocols().testFlag(QWaylandClient::TextInputProtocol::TextInputV2)) + return nullptr; return QWaylandTextInput::findIn(seat); } + +QWaylandTextInputV3 *QWaylandInputMethodControlPrivate::textInputV3() const +{ + return QWaylandTextInputV3::findIn(seat); +} + +#include "moc_qwaylandinputmethodcontrol.cpp" diff --git a/src/compositor/compositor_api/qwaylandinputmethodcontrol.h b/src/compositor/compositor_api/qwaylandinputmethodcontrol.h index 8cb4a2ea6..3b4d74870 100644 --- a/src/compositor/compositor_api/qwaylandinputmethodcontrol.h +++ b/src/compositor/compositor_api/qwaylandinputmethodcontrol.h @@ -1,37 +1,11 @@ -/**************************************************************************** -** -** Copyright (C) 2017 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDINPUTMETHODCONTROL_H #define QWAYLANDINPUTMETHODCONTROL_H #include <QtGui/qtguiglobal.h> -#include <QObject> +#include <QtCore/QObject> QT_BEGIN_NAMESPACE @@ -39,6 +13,7 @@ class QWaylandCompositor; class QWaylandInputMethodControlPrivate; class QWaylandSurface; class QInputMethodEvent; +class QWaylandTextInput; class QWaylandInputMethodControl : public QObject { @@ -58,6 +33,7 @@ public: void setEnabled(bool enabled); void setSurface(QWaylandSurface *surface); + void updateTextInput(); Q_SIGNALS: void enabledChanged(bool enabled); diff --git a/src/compositor/compositor_api/qwaylandinputmethodcontrol_p.h b/src/compositor/compositor_api/qwaylandinputmethodcontrol_p.h index 4c20f3e3c..36a0db0c4 100644 --- a/src/compositor/compositor_api/qwaylandinputmethodcontrol_p.h +++ b/src/compositor/compositor_api/qwaylandinputmethodcontrol_p.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDINPUTMETHODCONTROL_P_H #define QWAYLANDINPUTMETHODCONTROL_P_H @@ -52,8 +26,10 @@ class QWaylandCompositor; class QWaylandSeat; class QWaylandSurface; class QWaylandTextInput; +class QWaylandTextInputV3; +class QWaylandQtTextInputMethod; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandInputMethodControlPrivate : public QObjectPrivate +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandInputMethodControlPrivate : public QObjectPrivate { Q_DECLARE_PUBLIC(QWaylandInputMethodControl) @@ -61,6 +37,8 @@ public: explicit QWaylandInputMethodControlPrivate(QWaylandSurface *surface); QWaylandTextInput *textInput() const; + QWaylandTextInputV3 *textInputV3() const; + QWaylandQtTextInputMethod *textInputMethod() const; QWaylandCompositor *compositor = nullptr; QWaylandSeat *seat = nullptr; diff --git a/src/compositor/compositor_api/qwaylandkeyboard.cpp b/src/compositor/compositor_api/qwaylandkeyboard.cpp index 210b683ff..8af7fbd8c 100644 --- a/src/compositor/compositor_api/qwaylandkeyboard.cpp +++ b/src/compositor/compositor_api/qwaylandkeyboard.cpp @@ -1,32 +1,6 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Copyright (C) 2017 Klarälvdalens Datakonsult AB (KDAB). -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// Copyright (C) 2017 Klarälvdalens Datakonsult AB (KDAB). +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "qtwaylandcompositorglobal_p.h" #include "qwaylandkeyboard.h" @@ -39,11 +13,13 @@ #include <QtCore/QFile> #include <QtCore/QStandardPaths> +#include <QKeyEvent> #include <fcntl.h> #include <unistd.h> #if QT_CONFIG(xkbcommon) #include <sys/mman.h> #include <sys/types.h> +#include <xkbcommon/xkbcommon-names.h> #endif QT_BEGIN_NAMESPACE @@ -187,11 +163,27 @@ void QWaylandKeyboardPrivate::maybeUpdateXkbScanCodeTable() continue; Qt::KeyboardModifiers mods = {}; - int qtKey = QXkbCommon::keysymToQtKey(syms[0], mods); + int qtKey = QXkbCommon::keysymToQtKey(syms[0], mods, nullptr, 0, false, false); if (qtKey != 0) scanCodesByQtKey->insert({layout, qtKey}, keycode); } }, &scanCodesByQtKey); + + shiftIndex = xkb_keymap_mod_get_index(keymap, XKB_MOD_NAME_SHIFT); + controlIndex = xkb_keymap_mod_get_index(keymap, XKB_MOD_NAME_CTRL); + altIndex = xkb_keymap_mod_get_index(keymap, XKB_MOD_NAME_ALT); + } +} + +void QWaylandKeyboardPrivate::resetKeyboardState() +{ + if (!xkbContext()) + return; + + while (!keys.isEmpty()) { + uint32_t code = fromWaylandKey(keys.first()); + keyEvent(code, WL_KEYBOARD_KEY_STATE_RELEASED); + updateModifierState(code, WL_KEYBOARD_KEY_STATE_RELEASED); } } #endif @@ -223,6 +215,15 @@ void QWaylandKeyboardPrivate::updateModifierState(uint code, uint32_t state) if (focusResource) { send_modifiers(focusResource->handle, compositor()->nextSerial(), modsDepressed, modsLatched, modsLocked, group); + + Qt::KeyboardModifiers currentState = Qt::NoModifier; + if (xkb_state_mod_index_is_active(xkbState(), shiftIndex, XKB_STATE_MODS_EFFECTIVE) == 1) + currentState |= Qt::ShiftModifier; + if (xkb_state_mod_index_is_active(xkbState(), controlIndex, XKB_STATE_MODS_EFFECTIVE) == 1) + currentState |= Qt::ControlModifier; + if (xkb_state_mod_index_is_active(xkbState(), altIndex, XKB_STATE_MODS_EFFECTIVE) == 1) + currentState |= Qt::AltModifier; + currentModifierState = currentState; } #else Q_UNUSED(code); @@ -262,17 +263,29 @@ void QWaylandKeyboardPrivate::maybeUpdateKeymap() #endif } +// In all current XKB keymaps there's a constant offset of 8 (for historical +// reasons) from hardware/evdev scancodes to XKB keycodes. On X11, we pass +// XKB keycodes (as sent by X server) via QKeyEvent::nativeScanCode. eglfs+evdev +// adds 8 for consistency, see qtbase/05c07c7636012ebb4131ca099ca4ea093af76410. +// eglfs+libinput also adds 8, for the same reason. Wayland protocol uses +// hardware/evdev scancodes, thus we need to subtract 8 before sending the event +// out and add it when mapping back. +#define QTWAYLANDKEYBOARD_XKB_HISTORICAL_OFFSET 8 + +uint QWaylandKeyboardPrivate::fromWaylandKey(const uint key) +{ +#if QT_CONFIG(xkbcommon) + const uint offset = QTWAYLANDKEYBOARD_XKB_HISTORICAL_OFFSET; + return key + offset; +#else + return key; +#endif +} + uint QWaylandKeyboardPrivate::toWaylandKey(const uint nativeScanCode) { #if QT_CONFIG(xkbcommon) - // In all current XKB keymaps there's a constant offset of 8 (for historical - // reasons) from hardware/evdev scancodes to XKB keycodes. On X11, we pass - // XKB keycodes (as sent by X server) via QKeyEvent::nativeScanCode. eglfs+evdev - // adds 8 for consistency, see qtbase/05c07c7636012ebb4131ca099ca4ea093af76410. - // eglfs+libinput also adds 8, for the same reason. Wayland protocol uses - // hardware/evdev scancodes, thus we need to minus 8 before sending the event - // out. - const uint offset = 8; + const uint offset = QTWAYLANDKEYBOARD_XKB_HISTORICAL_OFFSET; Q_ASSERT(nativeScanCode >= offset); return nativeScanCode - offset; #else @@ -498,6 +511,38 @@ void QWaylandKeyboard::sendKeyReleaseEvent(uint code) d->sendKeyEvent(code, WL_KEYBOARD_KEY_STATE_RELEASED); } +void QWaylandKeyboardPrivate::checkAndRepairModifierState(QKeyEvent *ke) +{ +#if QT_CONFIG(xkbcommon) + if (ke->modifiers() != currentModifierState) { + if (focusResource && ke->key() != Qt::Key_Shift + && ke->key() != Qt::Key_Control && ke->key() != Qt::Key_Alt) { + // Only repair the state for non-modifier keys + // ### slightly awkward because the standard modifier handling + // is done by QtWayland::WindowSystemEventHandler after the + // key event is delivered + uint32_t mods = 0; + + if (shiftIndex == 0 && controlIndex == 0) + maybeUpdateXkbScanCodeTable(); + + if (ke->modifiers() & Qt::ShiftModifier) + mods |= 1 << shiftIndex; + if (ke->modifiers() & Qt::ControlModifier) + mods |= 1 << controlIndex; + if (ke->modifiers() & Qt::AltModifier) + mods |= 1 << altIndex; + qCDebug(qLcWaylandCompositor) << "Keyboard modifier state mismatch detected for event" << ke << "state:" << currentModifierState << "repaired:" << Qt::hex << mods; + send_modifiers(focusResource->handle, compositor()->nextSerial(), mods, + 0, 0, group); + currentModifierState = ke->modifiers(); + } + } +#else + Q_UNUSED(ke); +#endif +} + /*! * Returns the current repeat rate. */ @@ -589,3 +634,5 @@ uint QWaylandKeyboard::keyToScanCode(int qtKey) const } QT_END_NAMESPACE + +#include "moc_qwaylandkeyboard.cpp" diff --git a/src/compositor/compositor_api/qwaylandkeyboard.h b/src/compositor/compositor_api/qwaylandkeyboard.h index 7c450164a..ebefcd2a2 100644 --- a/src/compositor/compositor_api/qwaylandkeyboard.h +++ b/src/compositor/compositor_api/qwaylandkeyboard.h @@ -1,32 +1,6 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Copyright (C) 2017 Klarälvdalens Datakonsult AB (KDAB). -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// Copyright (C) 2017 Klarälvdalens Datakonsult AB (KDAB). +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDKEYBOARD_H #define QWAYLANDKEYBOARD_H @@ -43,7 +17,7 @@ class QWaylandKeyboardPrivate; class QWaylandSeat; class QWaylandKeymap; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandKeyboard : public QWaylandObject +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandKeyboard : public QWaylandObject { Q_OBJECT Q_DECLARE_PRIVATE(QWaylandKeyboard) diff --git a/src/compositor/compositor_api/qwaylandkeyboard_p.h b/src/compositor/compositor_api/qwaylandkeyboard_p.h index 96d174310..a91c60e43 100644 --- a/src/compositor/compositor_api/qwaylandkeyboard_p.h +++ b/src/compositor/compositor_api/qwaylandkeyboard_p.h @@ -1,32 +1,6 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Copyright (C) 2017 Klarälvdalens Datakonsult AB (KDAB). -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// Copyright (C) 2017 Klarälvdalens Datakonsult AB (KDAB). +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QTWAYLAND_QWLKEYBOARD_P_H #define QTWAYLAND_QWLKEYBOARD_P_H @@ -51,17 +25,17 @@ #include <QtCore/private/qobject_p.h> #include <QtWaylandCompositor/private/qwayland-server-wayland.h> -#include <QtCore/QVector> +#include <QtCore/QList> #if QT_CONFIG(xkbcommon) #include <xkbcommon/xkbcommon.h> -#include <QtXkbCommonSupport/private/qxkbcommon_p.h> +#include <QtGui/private/qxkbcommon_p.h> #endif QT_BEGIN_NAMESPACE -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandKeyboardPrivate : public QObjectPrivate +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandKeyboardPrivate : public QObjectPrivate , public QtWaylandServer::wl_keyboard { public: @@ -83,11 +57,13 @@ public: } uint32_t xkbModsMask() const { return modsDepressed | modsLatched | modsLocked; } void maybeUpdateXkbScanCodeTable(); + void resetKeyboardState(); #endif void keyEvent(uint code, uint32_t state); void sendKeyEvent(uint code, uint32_t state); void updateModifierState(uint code, uint32_t state); + void checkAndRepairModifierState(QKeyEvent *ke); void maybeUpdateKeymap(); void checkFocusResource(Resource *resource); @@ -104,6 +80,7 @@ private: void createXKBState(xkb_keymap *keymap); #endif static uint toWaylandKey(const uint nativeScanCode); + static uint fromWaylandKey(const uint key); void sendRepeatInfo(); @@ -113,12 +90,18 @@ private: Resource *focusResource = nullptr; QWaylandDestroyListener focusDestroyListener; - QVector<uint32_t> keys; + QList<uint32_t> keys; uint32_t modsDepressed = 0; uint32_t modsLatched = 0; uint32_t modsLocked = 0; uint32_t group = 0; + uint32_t shiftIndex = 0; + uint32_t controlIndex = 0; + uint32_t altIndex = 0; + + Qt::KeyboardModifiers currentModifierState; + bool pendingKeymap = false; #if QT_CONFIG(xkbcommon) size_t keymap_size; diff --git a/src/compositor/compositor_api/qwaylandkeymap.cpp b/src/compositor/compositor_api/qwaylandkeymap.cpp index bd58a84e1..160693532 100644 --- a/src/compositor/compositor_api/qwaylandkeymap.cpp +++ b/src/compositor/compositor_api/qwaylandkeymap.cpp @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "qwaylandkeymap.h" #include "qwaylandkeymap_p.h" @@ -120,3 +94,5 @@ QWaylandKeymapPrivate::QWaylandKeymapPrivate(const QString &layout, const QStrin } QT_END_NAMESPACE + +#include "moc_qwaylandkeymap.cpp" diff --git a/src/compositor/compositor_api/qwaylandkeymap.h b/src/compositor/compositor_api/qwaylandkeymap.h index 30034e664..a919160b2 100644 --- a/src/compositor/compositor_api/qwaylandkeymap.h +++ b/src/compositor/compositor_api/qwaylandkeymap.h @@ -1,53 +1,34 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDKEYMAP_H #define QWAYLANDKEYMAP_H #include <QtCore/QObject> #include <QtWaylandCompositor/qtwaylandcompositorglobal.h> +#include <QtWaylandCompositor/qtwaylandqmlinclude.h> +#if QT_CONFIG(wayland_compositor_quick) #include <QtWaylandCompositor/qwaylandquickchildren.h> +#endif QT_BEGIN_NAMESPACE class QWaylandKeymapPrivate; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandKeymap : public QObject +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandKeymap : public QObject { Q_OBJECT Q_DECLARE_PRIVATE(QWaylandKeymap) +#if QT_CONFIG(wayland_compositor_quick) Q_WAYLAND_COMPOSITOR_DECLARE_QUICK_CHILDREN(QWaylandKeymap) +#endif Q_PROPERTY(QString layout READ layout WRITE setLayout NOTIFY layoutChanged) Q_PROPERTY(QString variant READ variant WRITE setVariant NOTIFY variantChanged) Q_PROPERTY(QString options READ options WRITE setOptions NOTIFY optionsChanged) Q_PROPERTY(QString rules READ rules WRITE setRules NOTIFY rulesChanged) Q_PROPERTY(QString model READ model WRITE setModel NOTIFY modelChanged) + QML_NAMED_ELEMENT(WaylandKeymap) + QML_ADDED_IN_VERSION(1, 0) public: QWaylandKeymap(const QString &layout = QString(), const QString &variant = QString(), const QString &options = QString(), const QString &model = QString(), const QString &rules = QString(), QObject *parent = nullptr); diff --git a/src/compositor/compositor_api/qwaylandkeymap_p.h b/src/compositor/compositor_api/qwaylandkeymap_p.h index fc58f548f..a27500c46 100644 --- a/src/compositor/compositor_api/qwaylandkeymap_p.h +++ b/src/compositor/compositor_api/qwaylandkeymap_p.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDKEYMAP_P_H #define QWAYLANDKEYMAP_P_H @@ -46,7 +20,7 @@ QT_BEGIN_NAMESPACE -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandKeymapPrivate : public QObjectPrivate +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandKeymapPrivate : public QObjectPrivate { Q_DECLARE_PUBLIC(QWaylandKeymap) public: diff --git a/src/compositor/compositor_api/qwaylandmousetracker.cpp b/src/compositor/compositor_api/qwaylandmousetracker.cpp new file mode 100644 index 000000000..efc539779 --- /dev/null +++ b/src/compositor/compositor_api/qwaylandmousetracker.cpp @@ -0,0 +1,143 @@ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#include "qwaylandmousetracker_p.h" + +#include <QtQuick/private/qquickitem_p.h> + +QT_BEGIN_NAMESPACE + +class QWaylandMouseTrackerPrivate : public QQuickItemPrivate +{ + Q_DECLARE_PUBLIC(QWaylandMouseTracker) +public: + QWaylandMouseTrackerPrivate() + { + QImage cursorImage(64,64,QImage::Format_ARGB32); + cursorImage.fill(Qt::transparent); + cursorPixmap = QPixmap::fromImage(cursorImage); + } + void handleMousePos(const QPointF &mousePos) + { + Q_Q(QWaylandMouseTracker); + bool xChanged = mousePos.x() != this->mousePos.x(); + bool yChanged = mousePos.y() != this->mousePos.y(); + if (xChanged || yChanged) { + this->mousePos = mousePos; + if (xChanged) + emit q->mouseXChanged(); + if (yChanged) + emit q->mouseYChanged(); + } + } + + void setHovered(bool hovered) + { + Q_Q(QWaylandMouseTracker); + if (this->hovered == hovered) + return; + this->hovered = hovered; + emit q->hoveredChanged(); + } + + QPointF mousePos; + bool windowSystemCursorEnabled = false; + QPixmap cursorPixmap; + bool hovered = false; +}; + +QWaylandMouseTracker::QWaylandMouseTracker(QQuickItem *parent) + : QQuickItem(*(new QWaylandMouseTrackerPrivate), parent) +{ + Q_D(QWaylandMouseTracker); + setFiltersChildMouseEvents(true); + setAcceptHoverEvents(true); + setAcceptedMouseButtons(Qt::AllButtons); +#if QT_CONFIG(cursor) + setCursor(QCursor(d->cursorPixmap)); +#endif +} + +qreal QWaylandMouseTracker::mouseX() const +{ + Q_D(const QWaylandMouseTracker); + return d->mousePos.x(); +} +qreal QWaylandMouseTracker::mouseY() const +{ + Q_D(const QWaylandMouseTracker); + return d->mousePos.y(); +} + +#if QT_CONFIG(cursor) +void QWaylandMouseTracker::setWindowSystemCursorEnabled(bool enable) +{ + Q_D(QWaylandMouseTracker); + if (d->windowSystemCursorEnabled != enable) { + d->windowSystemCursorEnabled = enable; + if (enable) { + unsetCursor(); + } else { + setCursor(QCursor(d->cursorPixmap)); + } + emit windowSystemCursorEnabledChanged(); + } +} + +bool QWaylandMouseTracker::windowSystemCursorEnabled() const +{ + Q_D(const QWaylandMouseTracker); + return d->windowSystemCursorEnabled; +} +#endif + +bool QWaylandMouseTracker::hovered() const +{ + Q_D(const QWaylandMouseTracker); + return d->hovered; +} + +bool QWaylandMouseTracker::childMouseEventFilter(QQuickItem *item, QEvent *event) +{ + Q_D(QWaylandMouseTracker); + if (event->type() == QEvent::MouseMove) { + QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event); + d->handleMousePos(mapFromItem(item, mouseEvent->position())); + } else if (event->type() == QEvent::HoverMove) { + QHoverEvent *hoverEvent = static_cast<QHoverEvent *>(event); + d->handleMousePos(mapFromItem(item, hoverEvent->position())); + } + return false; +} + +void QWaylandMouseTracker::mouseMoveEvent(QMouseEvent *event) +{ + Q_D(QWaylandMouseTracker); + QQuickItem::mouseMoveEvent(event); + d->handleMousePos(event->position()); +} + +void QWaylandMouseTracker::hoverMoveEvent(QHoverEvent *event) +{ + Q_D(QWaylandMouseTracker); + QQuickItem::hoverMoveEvent(event); + d->handleMousePos(event->position()); +} + +void QWaylandMouseTracker::hoverEnterEvent(QHoverEvent *event) +{ + Q_D(QWaylandMouseTracker); + Q_UNUSED(event); + d->setHovered(true); +} + +void QWaylandMouseTracker::hoverLeaveEvent(QHoverEvent *event) +{ + Q_D(QWaylandMouseTracker); + Q_UNUSED(event); + d->setHovered(false); +} + +QT_END_NAMESPACE + +#include "moc_qwaylandmousetracker_p.cpp" diff --git a/src/compositor/compositor_api/qwaylandmousetracker_p.h b/src/compositor/compositor_api/qwaylandmousetracker_p.h new file mode 100644 index 000000000..efc49c3f5 --- /dev/null +++ b/src/compositor/compositor_api/qwaylandmousetracker_p.h @@ -0,0 +1,63 @@ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#ifndef QWAYLANDMOUSETRACKER_P_H +#define QWAYLANDMOUSETRACKER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtQuick/private/qquickmousearea_p.h> + +#include <QtWaylandCompositor/qtwaylandcompositorglobal.h> + +QT_BEGIN_NAMESPACE + +class QWaylandMouseTrackerPrivate; + +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandMouseTracker : public QQuickItem +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QWaylandMouseTracker) + Q_PROPERTY(qreal mouseX READ mouseX NOTIFY mouseXChanged) + Q_PROPERTY(qreal mouseY READ mouseY NOTIFY mouseYChanged) + Q_PROPERTY(bool containsMouse READ hovered NOTIFY hoveredChanged) + + Q_PROPERTY(bool windowSystemCursorEnabled READ windowSystemCursorEnabled WRITE setWindowSystemCursorEnabled NOTIFY windowSystemCursorEnabledChanged) + QML_NAMED_ELEMENT(WaylandMouseTracker) + QML_ADDED_IN_VERSION(1, 0) +public: + QWaylandMouseTracker(QQuickItem *parent = nullptr); + + qreal mouseX() const; + qreal mouseY() const; + + void setWindowSystemCursorEnabled(bool enable); + bool windowSystemCursorEnabled() const; + bool hovered() const; + +Q_SIGNALS: + void mouseXChanged(); + void mouseYChanged(); + void windowSystemCursorEnabledChanged(); + void hoveredChanged(); + +protected: + bool childMouseEventFilter(QQuickItem *item, QEvent *event) override; + void mouseMoveEvent(QMouseEvent *event) override; + void hoverMoveEvent(QHoverEvent *event) override; + void hoverEnterEvent(QHoverEvent *event) override; + void hoverLeaveEvent(QHoverEvent *event) override; +}; + +QT_END_NAMESPACE + +#endif /*QWAYLANDMOUSETRACKER_P_H*/ diff --git a/src/compositor/compositor_api/qwaylandoutput.cpp b/src/compositor/compositor_api/qwaylandoutput.cpp index 0f5e79d83..c19e2bd94 100644 --- a/src/compositor/compositor_api/qwaylandoutput.cpp +++ b/src/compositor/compositor_api/qwaylandoutput.cpp @@ -1,32 +1,6 @@ -/**************************************************************************** -** -** Copyright (C) 2017-2016 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> -** Copyright (C) 2017 Klarälvdalens Datakonsult AB (KDAB). -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017-2016 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> +// Copyright (C) 2017 Klarälvdalens Datakonsult AB (KDAB). +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "qwaylandoutput.h" #include "qwaylandoutput_p.h" @@ -249,6 +223,7 @@ QWaylandOutput::QWaylandOutput() /*! \qmltype WaylandOutput + \instantiates QWaylandOutput \inqmlmodule QtWayland.Compositor \since 5.8 \brief Provides access to a displayable area managed by the compositor. @@ -258,6 +233,9 @@ QWaylandOutput::QWaylandOutput() a screen managed by the WaylandCompositor. The type corresponds to the \c wl_output interface in the Wayland protocol. + + \note If the compositor has multiple Wayland outputs, the \l Qt::AA_ShareOpenGLContexts + attribute must be set before the \l QGuiApplication object is constructed. */ /*! @@ -380,7 +358,7 @@ void QWaylandOutput::update() } /*! - * \qmlproperty WaylandCompositor QtWaylandCompositor::WaylandOutput::compositor + * \qmlproperty WaylandCompositor QtWayland.Compositor::WaylandOutput::compositor * * This property holds the compositor displaying content on this WaylandOutput. * @@ -420,7 +398,7 @@ void QWaylandOutput::setCompositor(QWaylandCompositor *compositor) } /*! - * \qmlproperty string QtWaylandCompositor::WaylandOutput::manufacturer + * \qmlproperty string QtWayland.Compositor::WaylandOutput::manufacturer * * This property holds a textual description of the manufacturer of this WaylandOutput. */ @@ -448,7 +426,7 @@ void QWaylandOutput::setManufacturer(const QString &manufacturer) } /*! - * \qmlproperty string QtWaylandCompositor::WaylandOutput::model + * \qmlproperty string QtWayland.Compositor::WaylandOutput::model * * This property holds a textual description of the model of this WaylandOutput. */ @@ -476,7 +454,7 @@ void QWaylandOutput::setModel(const QString &model) } /*! - * \qmlproperty point QtWaylandCompositor::WaylandOutput::position + * \qmlproperty point QtWayland.Compositor::WaylandOutput::position * * This property holds the position of this WaylandOutput in the compositor's coordinate system. */ @@ -528,7 +506,8 @@ void QWaylandOutput::addMode(const QWaylandOutputMode &mode, bool preferred) return; } - d->modes.append(mode); + if (d->modes.indexOf(mode) < 0) + d->modes.append(mode); if (preferred) d->preferredMode = d->modes.indexOf(mode); @@ -580,7 +559,7 @@ void QWaylandOutput::setCurrentMode(const QWaylandOutputMode &mode) } /*! - * \qmlproperty rect QtWaylandCompositor::WaylandOutput::geometry + * \qmlproperty rect QtWayland.Compositor::WaylandOutput::geometry * * This property holds the geometry of the WaylandOutput. */ @@ -599,7 +578,7 @@ QRect QWaylandOutput::geometry() const } /*! - * \qmlproperty rect QtWaylandCompositor::WaylandOutput::availableGeometry + * \qmlproperty rect QtWayland.Compositor::WaylandOutput::availableGeometry * * This property holds the geometry of the WaylandOutput available for displaying content. * The available geometry is in output coordinates space, starts from 0,0 and it's as big @@ -642,7 +621,7 @@ void QWaylandOutput::setAvailableGeometry(const QRect &availableGeometry) } /*! - * \qmlproperty size QtWaylandCompositor::WaylandOutput::physicalSize + * \qmlproperty size QtWayland.Compositor::WaylandOutput::physicalSize * * This property holds the physical size of the WaylandOutput in millimeters. * @@ -690,7 +669,7 @@ void QWaylandOutput::setPhysicalSize(const QSize &size) */ /*! - * \qmlproperty enum QtWaylandCompositor::WaylandOutput::subpixel + * \qmlproperty enum QtWayland.Compositor::WaylandOutput::subpixel * * This property holds the subpixel arrangement of this WaylandOutput. * @@ -747,7 +726,7 @@ void QWaylandOutput::setSubpixel(const Subpixel &subpixel) */ /*! - * \qmlproperty enum QtWaylandCompositor::WaylandOutput::transform + * \qmlproperty enum QtWayland.Compositor::WaylandOutput::transform * * This property holds the transformation that the QWaylandCompositor applies to a surface * to compensate for the orientation of the QWaylandOutput. @@ -793,7 +772,7 @@ void QWaylandOutput::setTransform(const Transform &transform) } /*! - * \qmlproperty int QtWaylandCompositor::WaylandOutput::scaleFactor + * \qmlproperty int QtWayland.Compositor::WaylandOutput::scaleFactor * * This property holds the factor by which the WaylandCompositor scales surface buffers * before they are displayed. It is used on high density output devices where unscaled content @@ -843,7 +822,7 @@ void QWaylandOutput::setScaleFactor(int scale) } /*! - * \qmlproperty bool QtWaylandCompositor::WaylandOutput::sizeFollowsWindow + * \qmlproperty bool QtWayland.Compositor::WaylandOutput::sizeFollowsWindow * * This property controls whether the size of the WaylandOutput matches the * size of its window. @@ -881,7 +860,7 @@ void QWaylandOutput::setSizeFollowsWindow(bool follow) } /*! - * \qmlproperty Window QtWaylandCompositor::WaylandOutput::window + * \qmlproperty Window QtWayland.Compositor::WaylandOutput::window * * This property holds the Window for this WaylandOutput. * diff --git a/src/compositor/compositor_api/qwaylandoutput.h b/src/compositor/compositor_api/qwaylandoutput.h index c8fdcf515..a45fa5756 100644 --- a/src/compositor/compositor_api/qwaylandoutput.h +++ b/src/compositor/compositor_api/qwaylandoutput.h @@ -1,43 +1,16 @@ -/**************************************************************************** -** -** Copyright (C) 2017-2016 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> -** Copyright (C) 2017 Klarälvdalens Datakonsult AB (KDAB). -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017-2016 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> +// Copyright (C) 2017 Klarälvdalens Datakonsult AB (KDAB). +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDOUTPUT_H #define QWAYLANDOUTPUT_H +#include <QtWaylandCompositor/qtwaylandqmlinclude.h> #include <QtWaylandCompositor/qwaylandcompositorextension.h> #include <QtWaylandCompositor/QWaylandOutputMode> #include <QtCore/QObject> - -#include <QObject> -#include <QRect> -#include <QSize> +#include <QtCore/QRect> +#include <QtCore/QSize> struct wl_resource; @@ -49,9 +22,8 @@ class QWindow; class QWaylandSurface; class QWaylandView; class QWaylandClient; -class QWaylandOutputSpace; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandOutput : public QWaylandObject +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandOutput : public QWaylandObject { Q_OBJECT Q_DECLARE_PRIVATE(QWaylandOutput) @@ -67,8 +39,10 @@ class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandOutput : public QWaylandObject Q_PROPERTY(QWaylandOutput::Transform transform READ transform WRITE setTransform NOTIFY transformChanged) Q_PROPERTY(int scaleFactor READ scaleFactor WRITE setScaleFactor NOTIFY scaleFactorChanged) Q_PROPERTY(bool sizeFollowsWindow READ sizeFollowsWindow WRITE setSizeFollowsWindow NOTIFY sizeFollowsWindowChanged) - Q_ENUMS(Subpixel Transform) + QML_NAMED_ELEMENT(WaylandOutputBase) + QML_ADDED_IN_VERSION(1, 0) + QML_UNCREATABLE("Cannot create instance of WaylandOutputBase, use WaylandOutput instead") public: enum Subpixel { SubpixelUnknown = 0, diff --git a/src/compositor/compositor_api/qwaylandoutput_p.h b/src/compositor/compositor_api/qwaylandoutput_p.h index d06d14178..f62def16c 100644 --- a/src/compositor/compositor_api/qwaylandoutput_p.h +++ b/src/compositor/compositor_api/qwaylandoutput_p.h @@ -1,33 +1,7 @@ -/**************************************************************************** -** -** Copyright (C) 2017-2016 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> -** Copyright (C) 2017 Klarälvdalens Datakonsult AB (KDAB). -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017-2016 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> +// Copyright (C) 2017 Klarälvdalens Datakonsult AB (KDAB). +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDOUTPUT_P_H #define QWAYLANDOUTPUT_P_H @@ -51,10 +25,11 @@ #include <QtWaylandCompositor/private/qwayland-server-wayland.h> +#include <QtCore/QList> #include <QtCore/QRect> -#include <QtCore/QVector> #include <QtCore/private/qobject_p.h> +#include <QtCore/qpointer.h> QT_BEGIN_NAMESPACE @@ -78,13 +53,15 @@ struct QWaylandSurfaceViewMapper } QWaylandSurface *surface = nullptr; - QVector<QWaylandView *> views; + QList<QWaylandView *> views; bool has_entered = false; }; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandOutputPrivate : public QObjectPrivate, public QtWaylandServer::wl_output +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandOutputPrivate : public QObjectPrivate, public QtWaylandServer::wl_output { public: + Q_DECLARE_PUBLIC(QWaylandOutput) + QWaylandOutputPrivate(); ~QWaylandOutputPrivate() override; @@ -115,11 +92,11 @@ private: QString manufacturer; QString model; QPoint position; - QVector<QWaylandOutputMode> modes; + QList<QWaylandOutputMode> modes; int currentMode = -1; int preferredMode = -1; QRect availableGeometry; - QVector<QWaylandSurfaceViewMapper> surfaceViews; + QList<QWaylandSurfaceViewMapper> surfaceViews; QSize physicalSize; QWaylandOutput::Subpixel subpixel = QWaylandOutput::SubpixelUnknown; QWaylandOutput::Transform transform = QWaylandOutput::TransformNormal; @@ -128,7 +105,6 @@ private: bool initialized = false; QSize windowPixelSize; - Q_DECLARE_PUBLIC(QWaylandOutput) Q_DISABLE_COPY(QWaylandOutputPrivate) friend class QWaylandXdgOutputManagerV1Private; diff --git a/src/compositor/compositor_api/qwaylandoutputmode.cpp b/src/compositor/compositor_api/qwaylandoutputmode.cpp index e1326c6cd..04e738aec 100644 --- a/src/compositor/compositor_api/qwaylandoutputmode.cpp +++ b/src/compositor/compositor_api/qwaylandoutputmode.cpp @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "qwaylandoutputmode.h" #include "qwaylandoutputmode_p.h" diff --git a/src/compositor/compositor_api/qwaylandoutputmode.h b/src/compositor/compositor_api/qwaylandoutputmode.h index 0b0851ea0..90238b121 100644 --- a/src/compositor/compositor_api/qwaylandoutputmode.h +++ b/src/compositor/compositor_api/qwaylandoutputmode.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDOUTPUTMODE_H #define QWAYLANDOUTPUTMODE_H @@ -35,7 +9,7 @@ QT_BEGIN_NAMESPACE -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandOutputMode +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandOutputMode { public: explicit QWaylandOutputMode(); diff --git a/src/compositor/compositor_api/qwaylandoutputmode_p.h b/src/compositor/compositor_api/qwaylandoutputmode_p.h index 30f84a813..232399c2c 100644 --- a/src/compositor/compositor_api/qwaylandoutputmode_p.h +++ b/src/compositor/compositor_api/qwaylandoutputmode_p.h @@ -1,36 +1,11 @@ -/**************************************************************************** -** -** Copyright (C) 2017 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDOUTPUTMODE_P_H #define QWAYLANDOUTPUTMODE_P_H #include <QtWaylandCompositor/QWaylandOutput> +#include <QtCore/private/qglobal_p.h> // // W A R N I N G @@ -45,7 +20,7 @@ QT_BEGIN_NAMESPACE -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandOutputModePrivate +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandOutputModePrivate { public: QWaylandOutputModePrivate() {} diff --git a/src/compositor/compositor_api/qwaylandpointer.cpp b/src/compositor/compositor_api/qwaylandpointer.cpp index 38cb5d7f2..ee2c79a69 100644 --- a/src/compositor/compositor_api/qwaylandpointer.cpp +++ b/src/compositor/compositor_api/qwaylandpointer.cpp @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "qwaylandpointer.h" #include "qwaylandpointer_p.h" @@ -90,9 +64,9 @@ void QWaylandPointerPrivate::sendLeave() uint32_t serial = compositor()->nextSerial(); for (auto resource : resourceMap().values(enteredSurface->waylandClient())) send_leave(resource->handle, serial, enteredSurface->resource()); - enteredSurface = nullptr; localPosition = QPointF(); enteredSurfaceDestroyListener.reset(); + enteredSurface = nullptr; } void QWaylandPointerPrivate::ensureEntered(QWaylandSurface *surface) @@ -114,11 +88,10 @@ void QWaylandPointerPrivate::pointer_release(wl_pointer::Resource *resource) void QWaylandPointerPrivate::pointer_set_cursor(wl_pointer::Resource *resource, uint32_t serial, wl_resource *surface, int32_t hotspot_x, int32_t hotspot_y) { - Q_UNUSED(resource); Q_UNUSED(serial); if (!surface) { - seat->cursorSurfaceRequest(nullptr, 0, 0); + seat->cursorSurfaceRequested(nullptr, 0, 0, QWaylandClient::fromWlClient(compositor(), resource->client())); return; } @@ -133,7 +106,7 @@ void QWaylandPointerPrivate::pointer_set_cursor(wl_pointer::Resource *resource, wl_resource *displayRes = wl_client_get_object(resource->client(), 1); if (s->setRole(&QWaylandPointerPrivate::s_role, displayRes, WL_DISPLAY_ERROR_INVALID_OBJECT)) { s->markAsCursorSurface(true); - seat->cursorSurfaceRequest(s, hotspot_x, hotspot_y); + seat->cursorSurfaceRequested(s, hotspot_x, hotspot_y, QWaylandClient::fromWlClient(compositor(), resource->client())); } } @@ -392,7 +365,7 @@ uint32_t QWaylandPointer::toWaylandButton(Qt::MouseButton button) void QWaylandPointer::enteredSurfaceDestroyed(void *data) { Q_D(QWaylandPointer); - Q_UNUSED(data) + Q_UNUSED(data); d->enteredSurfaceDestroyListener.reset(); d->enteredSurface = nullptr; @@ -417,3 +390,5 @@ void QWaylandPointer::pointerFocusChanged(QWaylandView *newFocus, QWaylandView * } QT_END_NAMESPACE + +#include "moc_qwaylandpointer.cpp" diff --git a/src/compositor/compositor_api/qwaylandpointer.h b/src/compositor/compositor_api/qwaylandpointer.h index 26d9f124f..7d5a96b6e 100644 --- a/src/compositor/compositor_api/qwaylandpointer.h +++ b/src/compositor/compositor_api/qwaylandpointer.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDPOINTER_H #define QWAYLANDPOINTER_H @@ -43,7 +17,7 @@ class QWaylandView; class QWaylandOutput; class QWaylandClient; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandPointer : public QWaylandObject +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandPointer : public QWaylandObject { Q_OBJECT Q_DECLARE_PRIVATE(QWaylandPointer) diff --git a/src/compositor/compositor_api/qwaylandpointer_p.h b/src/compositor/compositor_api/qwaylandpointer_p.h index 43090bf50..71970351b 100644 --- a/src/compositor/compositor_api/qwaylandpointer_p.h +++ b/src/compositor/compositor_api/qwaylandpointer_p.h @@ -1,32 +1,6 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Copyright (C) 2017 Klarälvdalens Datakonsult AB (KDAB). -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// Copyright (C) 2017 Klarälvdalens Datakonsult AB (KDAB). +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDPOINTER_P_H #define QWAYLANDPOINTER_P_H @@ -56,13 +30,15 @@ #include <QtWaylandCompositor/QWaylandSurface> #include <QtWaylandCompositor/QWaylandSeat> +#include <QtCore/qpointer.h> + #include <stdint.h> QT_BEGIN_NAMESPACE class QWaylandView; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandPointerPrivate : public QObjectPrivate +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandPointerPrivate : public QObjectPrivate , public QtWaylandServer::wl_pointer { Q_DECLARE_PUBLIC(QWaylandPointer) diff --git a/src/compositor/compositor_api/qwaylandquickchildren.h b/src/compositor/compositor_api/qwaylandquickchildren.h index ecf382d01..5024b322e 100644 --- a/src/compositor/compositor_api/qwaylandquickchildren.h +++ b/src/compositor/compositor_api/qwaylandquickchildren.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDQUICKCHILDREN_H #define QWAYLANDQUICKCHILDREN_H @@ -44,7 +18,7 @@ #include <QtWaylandCompositor/qtwaylandcompositorglobal.h> #if QT_CONFIG(wayland_compositor_quick) #include <QtQml/QQmlListProperty> -#include <QtCore/QVector> +#include <QtCore/QList> #endif QT_BEGIN_NAMESPACE @@ -66,11 +40,11 @@ QT_BEGIN_NAMESPACE { \ static_cast<className *>(list->data)->m_children.append(object); \ } \ - static int countFunction(QQmlListProperty<QObject> *list) \ + static qsizetype countFunction(QQmlListProperty<QObject> *list) \ { \ return static_cast<className *>(list->data)->m_children.size(); \ } \ - static QObject *atFunction(QQmlListProperty<QObject> *list, int index) \ + static QObject *atFunction(QQmlListProperty<QObject> *list, qsizetype index) \ { \ return static_cast<className *>(list->data)->m_children.at(index); \ } \ @@ -79,7 +53,7 @@ QT_BEGIN_NAMESPACE static_cast<className *>(list->data)->m_children.clear(); \ } \ private: \ - QVector<QObject *> m_children; + QList<QObject *> m_children; #else #define Q_WAYLAND_COMPOSITOR_DECLARE_QUICK_CHILDREN(className) #endif diff --git a/src/compositor/compositor_api/qwaylandquickcompositor.cpp b/src/compositor/compositor_api/qwaylandquickcompositor.cpp index 2b0258488..43cc8c3e2 100644 --- a/src/compositor/compositor_api/qwaylandquickcompositor.cpp +++ b/src/compositor/compositor_api/qwaylandquickcompositor.cpp @@ -1,38 +1,14 @@ -/**************************************************************************** -** -** Copyright (C) 2017 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> -** Copyright (C) 2017 Jolla Ltd, author: <giulio.camuffo@jollamobile.com> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> +// Copyright (C) 2017 Jolla Ltd, author: <giulio.camuffo@jollamobile.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <QtQml/QQmlEngine> #include <QQuickWindow> -#include <QOpenGLTextureBlitter> -#include <QOpenGLTexture> -#include <QOpenGLFramebufferObject> +#if QT_CONFIG(opengl) +# include <QOpenGLTextureBlitter> +# include <QOpenGLTexture> +# include <QOpenGLFramebufferObject> +#endif #include <QMatrix4x4> #include <QRunnable> @@ -71,7 +47,7 @@ QWaylandQuickCompositor::QWaylandQuickCompositor(QObject *parent) } /*! - * \qmlproperty list QtWaylandCompositor::WaylandCompositor::extensions + * \qmlproperty list QtWayland.Compositor::WaylandCompositor::extensions * * A list of extensions that the compositor advertises to its clients. For * any Wayland extension the compositor should support, instantiate its component, @@ -80,8 +56,8 @@ QWaylandQuickCompositor::QWaylandQuickCompositor(QObject *parent) * For instance, the following code would allow the clients to request \c wl_shell * surfaces in the compositor using the \c wl_shell interface. * - * \qml \QtMinorVersion - * import QtWayland.Compositor 1.\1 + * \qml + * import QtWayland.Compositor * * WaylandCompositor { * WlShell { @@ -159,10 +135,12 @@ void QWaylandQuickCompositor::grabSurface(QWaylandSurfaceGrabber *grabber, const GrabState *state = new GrabState; state->grabber = grabber; state->buffer = buffer; - static_cast<QQuickWindow *>(output->window())->scheduleRenderJob(state, QQuickWindow::NoStage); + static_cast<QQuickWindow *>(output->window())->scheduleRenderJob(state, QQuickWindow::AfterRenderingStage); #else emit grabber->failed(QWaylandSurfaceGrabber::UnknownBufferType); #endif } QT_END_NAMESPACE + +#include "moc_qwaylandquickcompositor.cpp" diff --git a/src/compositor/compositor_api/qwaylandquickcompositor.h b/src/compositor/compositor_api/qwaylandquickcompositor.h index 873183670..921f1fefb 100644 --- a/src/compositor/compositor_api/qwaylandquickcompositor.h +++ b/src/compositor/compositor_api/qwaylandquickcompositor.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 Jolla Ltd, author: <giulio.camuffo@jollamobile.com> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 Jolla Ltd, author: <giulio.camuffo@jollamobile.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDQUICKCOMPOSITOR_H #define QWAYLANDQUICKCOMPOSITOR_H @@ -33,13 +7,15 @@ #include <QtWaylandCompositor/qwaylandcompositor.h> #include <QtQml/QQmlParserStatus> +QT_REQUIRE_CONFIG(wayland_compositor_quick); + QT_BEGIN_NAMESPACE class QQuickWindow; class QWaylandQuickCompositorPrivate; class QWaylandView; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandQuickCompositor : public QWaylandCompositor, public QQmlParserStatus +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandQuickCompositor : public QWaylandCompositor, public QQmlParserStatus { Q_INTERFACES(QQmlParserStatus) Q_OBJECT diff --git a/src/compositor/compositor_api/qwaylandquickhardwarelayer.cpp b/src/compositor/compositor_api/qwaylandquickhardwarelayer.cpp index 55ac61cfa..9cf36b36f 100644 --- a/src/compositor/compositor_api/qwaylandquickhardwarelayer.cpp +++ b/src/compositor/compositor_api/qwaylandquickhardwarelayer.cpp @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "qwaylandquickhardwarelayer_p.h" @@ -105,7 +79,7 @@ QWaylandQuickHardwareLayer::~QWaylandQuickHardwareLayer() } /*! - * \qmlproperty int QtWaylandCompositor::WaylandHardwareLayer::stackingLevel + * \qmlproperty int QtWayland.Compositor::WaylandHardwareLayer::stackingLevel * * This property holds the stacking level of this hardware layer relative to other hardware layers, * and can be used to sort hardware layers. I.e. a layer with a higher level is rendered on top of @@ -160,9 +134,18 @@ void QWaylandQuickHardwareLayer::componentComplete() qWarning() << "No hardware layer integration. WaylandHarwareLayer has no effect."; } -void QWaylandQuickHardwareLayer::disableSceneGraphPainting() +void QWaylandQuickHardwareLayer::setSceneGraphPainting(bool enable) { - waylandItem()->setPaintEnabled(false); + waylandItem()->setPaintEnabled(enable); +} + +// This should be called if QWaylandQuickHardwareLayer used as a native instance, not a qml component. +void QWaylandQuickHardwareLayer::initialize() +{ + classBegin(); + componentComplete(); } QT_END_NAMESPACE + +#include "moc_qwaylandquickhardwarelayer_p.cpp" diff --git a/src/compositor/compositor_api/qwaylandquickhardwarelayer_p.h b/src/compositor/compositor_api/qwaylandquickhardwarelayer_p.h index 594ed490d..d33a8c0d7 100644 --- a/src/compositor/compositor_api/qwaylandquickhardwarelayer_p.h +++ b/src/compositor/compositor_api/qwaylandquickhardwarelayer_p.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDQUICKHARDWARELAYER_P_H #define QWAYLANDQUICKHARDWARELAYER_P_H @@ -42,17 +16,20 @@ // #include <QtWaylandCompositor/QWaylandQuickItem> +#include <QtCore/private/qglobal_p.h> QT_BEGIN_NAMESPACE class QWaylandQuickHardwareLayerPrivate; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandQuickHardwareLayer : public QObject, public QQmlParserStatus +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandQuickHardwareLayer : public QObject, public QQmlParserStatus { Q_OBJECT Q_INTERFACES(QQmlParserStatus) Q_DECLARE_PRIVATE(QWaylandQuickHardwareLayer) Q_PROPERTY(int stackingLevel READ stackingLevel WRITE setStackingLevel NOTIFY stackingLevelChanged) + QML_NAMED_ELEMENT(WaylandHardwareLayer) + QML_ADDED_IN_VERSION(1, 2) public: explicit QWaylandQuickHardwareLayer(QObject *parent = nullptr); ~QWaylandQuickHardwareLayer() override; @@ -65,7 +42,8 @@ public: void classBegin() override; void componentComplete() override; - void disableSceneGraphPainting(); + void setSceneGraphPainting(bool); + void initialize(); Q_SIGNALS: void stackingLevelChanged(); diff --git a/src/compositor/compositor_api/qwaylandquickitem.cpp b/src/compositor/compositor_api/qwaylandquickitem.cpp index 80e84a884..c643598be 100644 --- a/src/compositor/compositor_api/qwaylandquickitem.cpp +++ b/src/compositor/compositor_api/qwaylandquickitem.cpp @@ -1,37 +1,13 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "qwaylandquickitem.h" #include "qwaylandquickitem_p.h" #include "qwaylandquicksurface.h" #include "qwaylandinputmethodcontrol.h" #include "qwaylandtextinput.h" +#include "qwaylandtextinputv3.h" +#include "qwaylandqttextinputmethod.h" #include "qwaylandquickoutput.h" #include <QtWaylandCompositor/qwaylandcompositor.h> #include <QtWaylandCompositor/qwaylandseat.h> @@ -42,21 +18,30 @@ #include <QtWaylandCompositor/private/qwlclientbufferintegration_p.h> #include <QtWaylandCompositor/private/qwaylandsurface_p.h> +#if QT_CONFIG(opengl) +# include <QtOpenGL/QOpenGLTexture> +# include <QtGui/QOpenGLFunctions> +#endif + #include <QtGui/QKeyEvent> #include <QtGui/QGuiApplication> #include <QtGui/QScreen> -#include <QtGui/QOpenGLFunctions> -#include <QtGui/QOpenGLTexture> #include <QtQuick/QSGSimpleTextureNode> #include <QtQuick/QQuickWindow> +#include <QtQuick/qsgtexture.h> +#include <QtCore/QFile> #include <QtCore/QMutexLocker> #include <QtCore/QMutex> #include <wayland-server-core.h> #include <QThread> +#if QT_CONFIG(opengl) +#include <QtGui/private/qshaderdescription_p.h> +#endif + #ifndef GL_TEXTURE_EXTERNAL_OES #define GL_TEXTURE_EXTERNAL_OES 0x8D65 #endif @@ -67,126 +52,219 @@ QT_BEGIN_NAMESPACE static const struct { const char * const vertexShaderSourceFile; const char * const fragmentShaderSourceFile; - GLenum textureTarget; int planeCount; bool canProvideTexture; QSGMaterial::Flags materialFlags; QSGMaterialType materialType; } bufferTypes[] = { // BufferFormatEgl_Null - { "", "", 0, 0, false, 0, {} }, + { "", "", 0, false, {}, {} }, - // BufferFormatEgl_RGB + // BufferFormatEgl_RGB (GL_TEXTURE_2D) { - ":/qt-project.org/wayland/compositor/shaders/surface.vert", - ":/qt-project.org/wayland/compositor/shaders/surface_rgbx.frag", - GL_TEXTURE_2D, 1, true, + ":/qt-project.org/wayland/compositor/shaders/surface.vert.qsb", + ":/qt-project.org/wayland/compositor/shaders/surface_rgbx.frag.qsb", + 1, true, QSGMaterial::Blending, {} }, - // BufferFormatEgl_RGBA + // BufferFormatEgl_RGBA (GL_TEXTURE_2D) { - ":/qt-project.org/wayland/compositor/shaders/surface.vert", - ":/qt-project.org/wayland/compositor/shaders/surface_rgba.frag", - GL_TEXTURE_2D, 1, true, + ":/qt-project.org/wayland/compositor/shaders/surface.vert.qsb", + ":/qt-project.org/wayland/compositor/shaders/surface_rgba.frag.qsb", + 1, true, QSGMaterial::Blending, {} }, - // BufferFormatEgl_EXTERNAL_OES + // BufferFormatEgl_EXTERNAL_OES (GL_TEXTURE_EXTERNAL_OES) { - ":/qt-project.org/wayland/compositor/shaders/surface.vert", + ":/qt-project.org/wayland/compositor/shaders/surface.vert.qsb", ":/qt-project.org/wayland/compositor/shaders/surface_oes_external.frag", - GL_TEXTURE_EXTERNAL_OES, 1, false, + 1, false, QSGMaterial::Blending, {} }, - // BufferFormatEgl_Y_U_V + // BufferFormatEgl_Y_U_V (GL_TEXTURE_2D) { - ":/qt-project.org/wayland/compositor/shaders/surface.vert", - ":/qt-project.org/wayland/compositor/shaders/surface_y_u_v.frag", - GL_TEXTURE_2D, 3, false, + ":/qt-project.org/wayland/compositor/shaders/surface.vert.qsb", + ":/qt-project.org/wayland/compositor/shaders/surface_y_u_v.frag.qsb", + 3, false, QSGMaterial::Blending, {} }, - // BufferFormatEgl_Y_UV + // BufferFormatEgl_Y_UV (GL_TEXTURE_2D) { - ":/qt-project.org/wayland/compositor/shaders/surface.vert", - ":/qt-project.org/wayland/compositor/shaders/surface_y_uv.frag", - GL_TEXTURE_2D, 2, false, + ":/qt-project.org/wayland/compositor/shaders/surface.vert.qsb", + ":/qt-project.org/wayland/compositor/shaders/surface_y_uv.frag.qsb", + 2, false, QSGMaterial::Blending, {} }, - // BufferFormatEgl_Y_XUXV + // BufferFormatEgl_Y_XUXV (GL_TEXTURE_2D) { - ":/qt-project.org/wayland/compositor/shaders/surface.vert", - ":/qt-project.org/wayland/compositor/shaders/surface_y_xuxv.frag", - GL_TEXTURE_2D, 2, false, + ":/qt-project.org/wayland/compositor/shaders/surface.vert.qsb", + ":/qt-project.org/wayland/compositor/shaders/surface_y_xuxv.frag.qsb", + 2, false, QSGMaterial::Blending, {} } }; QWaylandBufferMaterialShader::QWaylandBufferMaterialShader(QWaylandBufferRef::BufferFormatEgl format) - : m_format(format) { - setShaderSourceFile(QOpenGLShader::Vertex, QString::fromLatin1(bufferTypes[format].vertexShaderSourceFile)); - setShaderSourceFile(QOpenGLShader::Fragment, QString::fromLatin1(bufferTypes[format].fragmentShaderSourceFile)); + Q_UNUSED(format); + setShaderFileName(VertexStage, QString::fromLatin1(bufferTypes[format].vertexShaderSourceFile)); + auto fragmentShaderSourceFile = QString::fromLatin1(bufferTypes[format].fragmentShaderSourceFile); + + if (format == QWaylandBufferRef::BufferFormatEgl_EXTERNAL_OES) + setupExternalOESShader(fragmentShaderSourceFile); + else + setShaderFileName(FragmentStage, fragmentShaderSourceFile); } -void QWaylandBufferMaterialShader::updateState(const QSGMaterialShader::RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect) +void QWaylandBufferMaterialShader::setupExternalOESShader(const QString &shaderFilename) { - QSGMaterialShader::updateState(state, newEffect, oldEffect); +#if QT_CONFIG(opengl) + QFile shaderFile(shaderFilename); + if (!shaderFile.open(QIODevice::ReadOnly)) { + qCWarning(qLcWaylandCompositor) << "Cannot find external OES shader file:" << shaderFilename; + return; + } + QByteArray FS = shaderFile.readAll(); + + static const char *FS_GLES_PREAMBLE = + "#extension GL_OES_EGL_image_external : require\n" + "precision highp float;\n"; + static const char *FS_GL_PREAMBLE = + "#version 120\n" + "#extension GL_OES_EGL_image_external : require\n"; + QByteArray fsGLES = FS_GLES_PREAMBLE + FS; + QByteArray fsGL = FS_GL_PREAMBLE + FS; + + QShaderDescription desc; + QShaderDescriptionPrivate *descData = QShaderDescriptionPrivate::get(&desc); + + QShaderDescription::InOutVariable texCoordInput; + texCoordInput.name = "v_texcoord"; + texCoordInput.type = QShaderDescription::Vec2; + texCoordInput.location = 0; + + descData->inVars = { texCoordInput }; + + QShaderDescription::InOutVariable fragColorOutput; + fragColorOutput.name = "gl_FragColor"; + fragColorOutput.type = QShaderDescription::Vec4; + fragColorOutput.location = 0; + + descData->outVars = { fragColorOutput }; + + QShaderDescription::BlockVariable matrixBlockVar; + matrixBlockVar.name = "qt_Matrix"; + matrixBlockVar.type = QShaderDescription::Mat4; + matrixBlockVar.offset = 0; + matrixBlockVar.size = 64; + + QShaderDescription::BlockVariable opacityBlockVar; + opacityBlockVar.name = "qt_Opacity"; + opacityBlockVar.type = QShaderDescription::Float; + opacityBlockVar.offset = 64; + opacityBlockVar.size = 4; + + QShaderDescription::UniformBlock ubufStruct; + ubufStruct.blockName = "buf"; + ubufStruct.structName = "ubuf"; + ubufStruct.size = 64 + 4; + ubufStruct.binding = 0; + ubufStruct.members = { matrixBlockVar, opacityBlockVar }; + + descData->uniformBlocks = { ubufStruct }; + + QShaderDescription::InOutVariable samplerTex0; + samplerTex0.name = "tex0"; + samplerTex0.type = QShaderDescription::SamplerExternalOES; + samplerTex0.binding = 1; + + descData->combinedImageSamplers = { samplerTex0 }; + + QShader shaderPack; + shaderPack.setStage(QShader::FragmentStage); + shaderPack.setDescription(desc); + shaderPack.setShader(QShaderKey(QShader::GlslShader, QShaderVersion(100, QShaderVersion::GlslEs)), QShaderCode(fsGLES)); + shaderPack.setShader(QShaderKey(QShader::GlslShader, QShaderVersion(120)), QShaderCode(fsGL)); + + setShader(FragmentStage, shaderPack); +#else + Q_UNUSED(shaderFilename); +#endif +} - QWaylandBufferMaterial *material = static_cast<QWaylandBufferMaterial *>(newEffect); - material->bind(); +bool QWaylandBufferMaterialShader::updateUniformData(RenderState &state, QSGMaterial *, QSGMaterial *) +{ + bool changed = false; + QByteArray *buf = state.uniformData(); + Q_ASSERT(buf->size() >= 68); - if (state.isMatrixDirty()) - program()->setUniformValue(m_id_matrix, state.combinedMatrix()); + if (state.isMatrixDirty()) { + const QMatrix4x4 m = state.combinedMatrix(); + memcpy(buf->data(), m.constData(), 64); + changed = true; + } - if (state.isOpacityDirty()) - program()->setUniformValue(m_id_opacity, state.opacity()); -} + if (state.isOpacityDirty()) { + const float opacity = state.opacity(); + memcpy(buf->data() + 64, &opacity, 4); + changed = true; + } -const char * const *QWaylandBufferMaterialShader::attributeNames() const -{ - static char const *const attr[] = { "qt_VertexPosition", "qt_VertexTexCoord", nullptr }; - return attr; + return changed; } -void QWaylandBufferMaterialShader::initialize() +void QWaylandBufferMaterialShader::updateSampledImage(RenderState &state, int binding, QSGTexture **texture, + QSGMaterial *newMaterial, QSGMaterial *) { - QSGMaterialShader::initialize(); + Q_UNUSED(state); - m_id_matrix = program()->uniformLocation("qt_Matrix"); - m_id_opacity = program()->uniformLocation("qt_Opacity"); - - for (int i = 0; i < bufferTypes[m_format].planeCount; i++) { - m_id_tex << program()->uniformLocation("tex" + QByteArray::number(i)); - program()->setUniformValue(m_id_tex[i], i); + QWaylandBufferMaterial *material = static_cast<QWaylandBufferMaterial *>(newMaterial); + switch (binding) { + case 1: + *texture = material->m_scenegraphTextures.at(0); + break; + case 2: + *texture = material->m_scenegraphTextures.at(1); + break; + case 3: + *texture = material->m_scenegraphTextures.at(2); + break; + default: + return; } - Q_ASSERT(m_id_tex.size() == bufferTypes[m_format].planeCount); + // This is for the shared memory case, and is a no-op for others, + // this is where the upload from the QImage happens when not yet done. + // ### or is this too late? (if buffer.image() disappears in the meantime then this is the wrong...) + if (*texture) + (*texture)->commitTextureOperations(state.rhi(), state.resourceUpdateBatch()); } QWaylandBufferMaterial::QWaylandBufferMaterial(QWaylandBufferRef::BufferFormatEgl format) : m_format(format) { - QOpenGLFunctions *gl = QOpenGLContext::currentContext()->functions(); - - gl->glBindTexture(bufferTypes[m_format].textureTarget, 0); setFlag(bufferTypes[m_format].materialFlags); } QWaylandBufferMaterial::~QWaylandBufferMaterial() { + qDeleteAll(m_scenegraphTextures); } -void QWaylandBufferMaterial::setTextureForPlane(int plane, QOpenGLTexture *texture) +void QWaylandBufferMaterial::setTextureForPlane(int plane, + QOpenGLTexture *texture, + QSGTexture *scenegraphTexture) { if (plane < 0 || plane >= bufferTypes[m_format].planeCount) { qWarning("plane index is out of range"); @@ -198,10 +276,15 @@ void QWaylandBufferMaterial::setTextureForPlane(int plane, QOpenGLTexture *textu ensureTextures(plane - 1); - if (m_textures.size() <= plane) + if (m_textures.size() <= plane) { m_textures << texture; - else + m_scenegraphTextures << scenegraphTexture; + } else { + delete m_scenegraphTextures[plane]; + m_textures[plane] = texture; + m_scenegraphTextures[plane] = scenegraphTexture; + } } void QWaylandBufferMaterial::bind() @@ -228,8 +311,9 @@ QSGMaterialType *QWaylandBufferMaterial::type() const return const_cast<QSGMaterialType *>(&bufferTypes[m_format].materialType); } -QSGMaterialShader *QWaylandBufferMaterial::createShader() const +QSGMaterialShader *QWaylandBufferMaterial::createShader(QSGRendererInterface::RenderMode renderMode) const { + Q_UNUSED(renderMode); return new QWaylandBufferMaterialShader(m_format); } @@ -248,8 +332,38 @@ void QWaylandBufferMaterial::ensureTextures(int count) { for (int plane = m_textures.size(); plane < count; plane++) { m_textures << nullptr; + m_scenegraphTextures << nullptr; } } + +void QWaylandBufferMaterial::setBufferRef(QWaylandQuickItem *surfaceItem, const QWaylandBufferRef &ref) +{ + m_bufferRef = ref; + for (int plane = 0; plane < bufferTypes[ref.bufferFormatEgl()].planeCount; plane++) { + if (auto texture = ref.toOpenGLTexture(plane)) { + QQuickWindow::CreateTextureOptions opt; + QWaylandQuickSurface *waylandSurface = qobject_cast<QWaylandQuickSurface *>(surfaceItem->surface()); + if (waylandSurface != nullptr && waylandSurface->useTextureAlpha() && !waylandSurface->isOpaque()) + opt |= QQuickWindow::TextureHasAlphaChannel; + QSGTexture *scenegraphTexture; + if (ref.bufferFormatEgl() == QWaylandBufferRef::BufferFormatEgl_EXTERNAL_OES) { + scenegraphTexture = QNativeInterface::QSGOpenGLTexture::fromNativeExternalOES(texture->textureId(), + surfaceItem->window(), + ref.size(), + opt); + } else { + scenegraphTexture = QNativeInterface::QSGOpenGLTexture::fromNative(texture->textureId(), + surfaceItem->window(), + ref.size(), + opt); + } + scenegraphTexture->setFiltering(surfaceItem->smooth() ? QSGTexture::Linear : QSGTexture::Nearest); + setTextureForPlane(plane, texture, scenegraphTexture); + } + } + + bind(); +} #endif // QT_CONFIG(opengl) QMutex *QWaylandQuickItemPrivate::mutex = nullptr; @@ -263,8 +377,7 @@ public: ~QWaylandSurfaceTextureProvider() override { - if (m_sgTex) - m_sgTex->deleteLater(); + delete m_sgTex; } void setBufferRef(QWaylandQuickItem *surfaceItem, const QWaylandBufferRef &buffer) @@ -276,21 +389,18 @@ public: if (m_ref.hasBuffer()) { if (buffer.isSharedMemory()) { m_sgTex = surfaceItem->window()->createTextureFromImage(buffer.image()); -#if QT_CONFIG(opengl) - if (m_sgTex) - m_sgTex->bind(); -#endif } else { #if QT_CONFIG(opengl) QQuickWindow::CreateTextureOptions opt; QWaylandQuickSurface *surface = qobject_cast<QWaylandQuickSurface *>(surfaceItem->surface()); - if (surface && surface->useTextureAlpha()) { + if (surface && surface->useTextureAlpha() && !surface->isOpaque()) { opt |= QQuickWindow::TextureHasAlphaChannel; } auto texture = buffer.toOpenGLTexture(); + GLuint textureId = texture->textureId(); auto size = surface->bufferSize(); - m_sgTex = surfaceItem->window()->createTextureFromId(texture->textureId(), size, opt); + m_sgTex = QNativeInterface::QSGOpenGLTexture::fromNative(textureId, surfaceItem->window(), size, opt); #else qCWarning(qLcWaylandCompositor) << "Without OpenGL support only shared memory textures are supported"; #endif @@ -315,6 +425,7 @@ private: /*! * \qmltype WaylandQuickItem + * \instantiates QWaylandQuickItem * \inqmlmodule QtWayland.Compositor * \since 5.8 * \brief Provides a Qt Quick item that represents a WaylandView. @@ -339,9 +450,8 @@ private: * Constructs a QWaylandQuickItem with the given \a parent. */ QWaylandQuickItem::QWaylandQuickItem(QQuickItem *parent) - : QQuickItem(*new QWaylandQuickItemPrivate(), parent) + : QWaylandQuickItem(*new QWaylandQuickItemPrivate(), parent) { - d_func()->init(); } /*! @@ -351,6 +461,7 @@ QWaylandQuickItem::QWaylandQuickItem(QWaylandQuickItemPrivate &dd, QQuickItem *p : QQuickItem(dd, parent) { d_func()->init(); + connect(this, &QQuickItem::activeFocusChanged, this, &QWaylandQuickItem::updateFocus); } /*! @@ -360,13 +471,16 @@ QWaylandQuickItem::~QWaylandQuickItem() { Q_D(QWaylandQuickItem); disconnect(this, &QQuickItem::windowChanged, this, &QWaylandQuickItem::updateWindow); + disconnect(this, &QQuickItem::activeFocusChanged, this, &QWaylandQuickItem::updateFocus); QMutexLocker locker(d->mutex); - if (d->provider) + if (d->provider) { + disconnect(d->texProviderConnection); d->provider->deleteLater(); + } } /*! - * \qmlproperty WaylandCompositor QtWaylandCompositor::WaylandQuickItem::compositor + * \qmlproperty WaylandCompositor QtWayland.Compositor::WaylandQuickItem::compositor * * This property holds the compositor for the surface rendered by this WaylandQuickItem. */ @@ -392,7 +506,7 @@ QWaylandView *QWaylandQuickItem::view() const } /*! - * \qmlproperty WaylandSurface QtWaylandCompositor::WaylandQuickItem::surface + * \qmlproperty WaylandSurface QtWayland.Compositor::WaylandQuickItem::surface * * This property holds the surface rendered by this WaylandQuickItem. */ @@ -412,16 +526,21 @@ QWaylandSurface *QWaylandQuickItem::surface() const void QWaylandQuickItem::setSurface(QWaylandSurface *surface) { Q_D(QWaylandQuickItem); + QWaylandSurface *oldSurf = d->view->surface(); QWaylandCompositor *oldComp = d->view->surface() ? d->view->surface()->compositor() : nullptr; d->view->setSurface(surface); QWaylandCompositor *newComp = d->view->surface() ? d->view->surface()->compositor() : nullptr; if (oldComp != newComp) emit compositorChanged(); + if (oldSurf != surface) + emit surfaceChanged(); + + updateFocus(); update(); } /*! - * \qmlproperty enum QtWaylandCompositor::WaylandQuickItem::origin + * \qmlproperty enum QtWayland.Compositor::WaylandQuickItem::origin * * This property holds the origin of the QWaylandQuickItem. */ @@ -467,7 +586,7 @@ void QWaylandQuickItem::mousePressEvent(QMouseEvent *event) return; } - if (!inputRegionContains(event->localPos())) { + if (!inputRegionContains(event->position())) { event->ignore(); return; } @@ -477,9 +596,9 @@ void QWaylandQuickItem::mousePressEvent(QMouseEvent *event) if (d->focusOnClick) takeFocus(seat); - seat->sendMouseMoveEvent(d->view.data(), mapToSurface(event->localPos()), event->windowPos()); + seat->sendMouseMoveEvent(d->view.data(), mapToSurface(event->position()), event->scenePosition()); seat->sendMousePressEvent(event->button()); - d->hoverPos = event->localPos(); + d->hoverPos = event->position(); } /*! @@ -494,21 +613,21 @@ void QWaylandQuickItem::mouseMoveEvent(QMouseEvent *event) if (d->isDragging) { QWaylandQuickOutput *currentOutput = qobject_cast<QWaylandQuickOutput *>(view()->output()); //TODO: also check if dragging onto other outputs - QWaylandQuickItem *targetItem = qobject_cast<QWaylandQuickItem *>(currentOutput->pickClickableItem(mapToScene(event->localPos()))); + QWaylandQuickItem *targetItem = qobject_cast<QWaylandQuickItem *>(currentOutput->pickClickableItem(mapToScene(event->position()))); QWaylandSurface *targetSurface = targetItem ? targetItem->surface() : nullptr; if (targetSurface) { - QPointF position = mapToItem(targetItem, event->localPos()); + QPointF position = mapToItem(targetItem, event->position()); QPointF surfacePosition = targetItem->mapToSurface(position); seat->drag()->dragMove(targetSurface, surfacePosition); } } else #endif // QT_CONFIG(draganddrop) { - seat->sendMouseMoveEvent(d->view.data(), mapToSurface(event->localPos()), event->windowPos()); - d->hoverPos = event->localPos(); + seat->sendMouseMoveEvent(d->view.data(), mapToSurface(event->position()), event->scenePosition()); + d->hoverPos = event->position(); } } else { - emit mouseMove(event->windowPos()); + emit mouseMove(event->scenePosition()); event->ignore(); } } @@ -542,14 +661,14 @@ void QWaylandQuickItem::mouseReleaseEvent(QMouseEvent *event) void QWaylandQuickItem::hoverEnterEvent(QHoverEvent *event) { Q_D(QWaylandQuickItem); - if (!inputRegionContains(event->posF())) { + if (!inputRegionContains(event->position())) { event->ignore(); return; } if (d->shouldSendInputEvents()) { QWaylandSeat *seat = compositor()->seatFor(event); - seat->sendMouseMoveEvent(d->view.data(), event->posF(), mapToScene(event->posF())); - d->hoverPos = event->posF(); + seat->sendMouseMoveEvent(d->view.data(), event->position(), mapToScene(event->position())); + d->hoverPos = event->position(); } else { event->ignore(); } @@ -562,16 +681,16 @@ void QWaylandQuickItem::hoverMoveEvent(QHoverEvent *event) { Q_D(QWaylandQuickItem); if (surface()) { - if (!inputRegionContains(event->posF())) { + if (!inputRegionContains(event->position())) { event->ignore(); return; } } if (d->shouldSendInputEvents()) { QWaylandSeat *seat = compositor()->seatFor(event); - if (event->posF() != d->hoverPos) { - seat->sendMouseMoveEvent(d->view.data(), mapToSurface(event->posF()), mapToScene(event->posF())); - d->hoverPos = event->posF(); + if (event->position() != d->hoverPos) { + seat->sendMouseMoveEvent(d->view.data(), mapToSurface(event->position()), mapToScene(event->position())); + d->hoverPos = event->position(); } } else { event->ignore(); @@ -640,7 +759,7 @@ void QWaylandQuickItem::keyPressEvent(QKeyEvent *event) void QWaylandQuickItem::keyReleaseEvent(QKeyEvent *event) { Q_D(QWaylandQuickItem); - if (d->shouldSendInputEvents() && hasFocus()) { + if (d->shouldSendInputEvents()) { QWaylandSeat *seat = compositor()->seatFor(event); seat->sendFullKeyEvent(event); } else { @@ -658,9 +777,9 @@ void QWaylandQuickItem::touchEvent(QTouchEvent *event) QWaylandSeat *seat = compositor()->seatFor(event); QPointF pointPos; - const QList<QTouchEvent::TouchPoint> &points = event->touchPoints(); + const QList<QTouchEvent::TouchPoint> &points = event->points(); if (!points.isEmpty()) - pointPos = points.at(0).pos(); + pointPos = points.at(0).position(); if (event->type() == QEvent::TouchBegin && !inputRegionContains(pointPos)) { event->ignore(); @@ -729,10 +848,16 @@ void QWaylandQuickItem::handleSubsurfaceAdded(QWaylandSurface *childSurface) childItem->setSurface(childSurface); childItem->setVisible(true); childItem->setParentItem(this); + childItem->setParent(this); connect(childSurface, &QWaylandSurface::subsurfacePositionChanged, childItem, &QWaylandQuickItem::handleSubsurfacePosition); + connect(childSurface, &QWaylandSurface::destroyed, childItem, &QObject::deleteLater); } else { bool success = QMetaObject::invokeMethod(d->subsurfaceHandler, "handleSubsurfaceAdded", Q_ARG(QWaylandSurface *, childSurface)); if (!success) + success = QMetaObject::invokeMethod(d->subsurfaceHandler, "handleSubsurfaceAdded", + Q_ARG(QVariant, QVariant::fromValue(childSurface))); + + if (!success) qWarning("QWaylandQuickItem: subsurfaceHandler does not implement handleSubsurfaceAdded()"); } } @@ -771,8 +896,15 @@ void QWaylandQuickItem::handlePlaceBelow(QWaylandSurface *referenceSurface) } } +void QWaylandQuickItem::updateFocus() +{ + Q_D(const QWaylandQuickItem); + if (hasActiveFocus() && compositor()) + compositor()->defaultSeat()->setKeyboardFocus(d->view->surface()); +} + /*! - \qmlproperty object QtWaylandCompositor::WaylandQuickItem::subsurfaceHandler + \qmlproperty object QtWayland.Compositor::WaylandQuickItem::subsurfaceHandler This property provides a way to override the default subsurface behavior. @@ -784,8 +916,9 @@ void QWaylandQuickItem::handlePlaceBelow(QWaylandSurface *referenceSurface) \code ShellSurfaceItem { subsurfaceHandler: QtObject { - function handleSubsurfaceAdded(child) { - //create custom surface item, and connect the subsurfacePositionChanged signal + function handleSubsurfaceAdded(child) { + // create custom surface item, and connect the subsurfacePositionChanged signal + } } } \endcode @@ -810,6 +943,11 @@ void QWaylandQuickItem::setSubsurfaceHandler(QObject *handler) } /*! + * \qmlproperty WaylandOutput QtWayland.Compositor::WaylandQuickItem::output + * + * This property holds the output on which this item is displayed. + */ +/*! * \property QWaylandQuickItem::output * * This property holds the output on which this item is displayed. @@ -827,7 +965,7 @@ void QWaylandQuickItem::setOutput(QWaylandOutput *output) } /*! - * \qmlproperty bool QtWaylandCompositor::WaylandQuickItem::bufferLocked + * \qmlproperty bool QtWayland.Compositor::WaylandQuickItem::bufferLocked * * This property holds whether the item's buffer is currently locked. As long as * the buffer is locked, it will not be released and returned to the client. @@ -852,6 +990,10 @@ void QWaylandQuickItem::setBufferLocked(bool locked) { Q_D(QWaylandQuickItem); d->view->setBufferLocked(locked); + + // Apply the latest surface size + if (!locked) + updateSize(); } /*! @@ -961,7 +1103,7 @@ void QWaylandQuickItem::takeFocus(QWaylandSeat *device) { forceActiveFocus(); - if (!surface()) + if (!surface() || !surface()->client()) return; QWaylandSeat *target = device; @@ -969,9 +1111,27 @@ void QWaylandQuickItem::takeFocus(QWaylandSeat *device) target = compositor()->defaultSeat(); } target->setKeyboardFocus(surface()); - QWaylandTextInput *textInput = QWaylandTextInput::findIn(target); - if (textInput) - textInput->setFocus(surface()); + + qCDebug(qLcWaylandCompositorInputMethods) << Q_FUNC_INFO << " surface:" << surface() + << ", client:" << surface()->client() + << ", textinputprotocol:" << (int)(surface()->client()->textInputProtocols()); + if (surface()->client()->textInputProtocols().testFlag(QWaylandClient::TextInputProtocol::TextInputV2)) { + QWaylandTextInput *textInput = QWaylandTextInput::findIn(target); + if (textInput) + textInput->setFocus(surface()); + } + + if (surface()->client()->textInputProtocols().testFlag(QWaylandClient::TextInputProtocol::TextInputV3)) { + QWaylandTextInputV3 *textInputV3 = QWaylandTextInputV3::findIn(target); + if (textInputV3) + textInputV3->setFocus(surface()); + } + + if (surface()->client()->textInputProtocols().testFlag(QWaylandClient::TextInputProtocol::QtTextInputMethodV1)) { + QWaylandQtTextInputMethod *textInputMethod = QWaylandQtTextInputMethod::findIn(target); + if (textInputMethod) + textInputMethod->setFocus(surface()); + } } /*! @@ -1004,17 +1164,21 @@ void QWaylandQuickItem::updateSize() { Q_D(QWaylandQuickItem); + // No resize if buffer is locked + if (isBufferLocked()) { + qWarning() << "No update on item size as the buffer is currently locked"; + return; + } + QSize size(0, 0); if (surface()) size = surface()->destinationSize() * d->scaleFactor(); setImplicitSize(size.width(), size.height()); - if (d->sizeFollowsSurface) - setSize(size); } /*! - * \qmlproperty bool QtWaylandCompositor::WaylandQuickItem::focusOnClick + * \qmlproperty bool QtWayland.Compositor::WaylandQuickItem::focusOnClick * * This property specifies whether the WaylandQuickItem should take focus when * it is clicked or touched. @@ -1057,16 +1221,6 @@ bool QWaylandQuickItem::inputRegionContains(const QPointF &localPosition) const return false; } -// Qt 6: Remove the non-const version -/*! - * Returns \c true if the input region of this item's surface contains the - * position given by \a localPosition. - */ -bool QWaylandQuickItem::inputRegionContains(const QPointF &localPosition) -{ - return const_cast<const QWaylandQuickItem *>(this)->inputRegionContains(localPosition); -} - /*! * \qmlmethod point WaylandQuickItem::mapToSurface(point point) * @@ -1118,41 +1272,6 @@ QPointF QWaylandQuickItem::mapFromSurface(const QPointF &point) const return QPointF(point.x() * xScale, point.y() * yScale); } -/*! - * \qmlproperty bool QtWaylandCompositor::WaylandQuickItem::sizeFollowsSurface - * - * This property specifies whether the size of the item should always match - * the size of its surface. - * - * The default is \c true. - */ - -/*! - * \property QWaylandQuickItem::sizeFollowsSurface - * - * This property specifies whether the size of the item should always match - * the size of its surface. - * - * The default is \c true. - */ -bool QWaylandQuickItem::sizeFollowsSurface() const -{ - Q_D(const QWaylandQuickItem); - return d->sizeFollowsSurface; -} - -//TODO: sizeFollowsSurface became obsolete when we added an implementation for -//implicit size. The property is here for compatibility reasons only and should -//be removed or at least default to false in Qt 6. -void QWaylandQuickItem::setSizeFollowsSurface(bool sizeFollowsSurface) -{ - Q_D(QWaylandQuickItem); - if (d->sizeFollowsSurface == sizeFollowsSurface) - return; - d->sizeFollowsSurface = sizeFollowsSurface; - emit sizeFollowsSurfaceChanged(); -} - #if QT_CONFIG(im) QVariant QWaylandQuickItem::inputMethodQuery(Qt::InputMethodQuery query) const { @@ -1174,7 +1293,7 @@ QVariant QWaylandQuickItem::inputMethodQuery(Qt::InputMethodQuery query, QVarian #endif /*! - \qmlproperty bool QtWaylandCompositor::WaylandQuickItem::paintEnabled + \qmlproperty bool QtWayland.Compositor::WaylandQuickItem::paintEnabled Returns true if the item is hidden, though the texture is still updated. As opposed to hiding the item by @@ -1183,12 +1302,14 @@ QVariant QWaylandQuickItem::inputMethodQuery(Qt::InputMethodQuery query, QVarian */ /*! - Returns true if the item is hidden, though the texture + \property QWaylandQuickItem::paintEnabled + + Holds \c true if the item is hidden, though the texture is still updated. As opposed to hiding the item by - setting \l{Item::visible}{visible} to \c false, setting this property to \c false + setting \l{QQuickItem::}{visible} to \c false, setting this property to \c false will not prevent mouse or keyboard input from reaching item. */ -bool QWaylandQuickItem::paintEnabled() const +bool QWaylandQuickItem::isPaintEnabled() const { Q_D(const QWaylandQuickItem); return d->paintEnabled; @@ -1197,10 +1318,28 @@ bool QWaylandQuickItem::paintEnabled() const void QWaylandQuickItem::setPaintEnabled(bool enabled) { Q_D(QWaylandQuickItem); - d->paintEnabled = enabled; + + if (enabled != d->paintEnabled) { + d->paintEnabled = enabled; + emit paintEnabledChanged(); + } + update(); } +/*! + \qmlproperty bool QtWayland.Compositor::WaylandQuickItem::touchEventsEnabled + + This property holds \c true if touch events are forwarded to the client + surface, \c false otherwise. +*/ + +/*! + \property QWaylandQuickItem::touchEventsEnabled + + This property holds \c true if touch events are forwarded to the client + surface, \c false otherwise. +*/ bool QWaylandQuickItem::touchEventsEnabled() const { Q_D(const QWaylandQuickItem); @@ -1235,15 +1374,15 @@ void QWaylandQuickItem::updateWindow() if (d->connectedWindow) { connect(d->connectedWindow, &QQuickWindow::beforeSynchronizing, this, &QWaylandQuickItem::beforeSync, Qt::DirectConnection); connect(d->connectedWindow, &QQuickWindow::screenChanged, this, &QWaylandQuickItem::updateSize); // new screen may have new dpr - } - if (compositor() && d->connectedWindow) { - QWaylandOutput *output = compositor()->outputFor(d->connectedWindow); - Q_ASSERT(output); - d->view->setOutput(output); - } + if (compositor()) { + QWaylandOutput *output = compositor()->outputFor(d->connectedWindow); + Q_ASSERT(output); + d->view->setOutput(output); + } - updateSize(); // because scaleFactor depends on devicePixelRatio, which may be different for the new window + updateSize(); // because scaleFactor depends on devicePixelRatio, which may be different for the new window + } } void QWaylandQuickItem::updateOutput() @@ -1284,7 +1423,7 @@ void QWaylandQuickItem::updateInputMethod(Qt::InputMethodQueries queries) #endif /*! - * \qmlsignal void QtWaylandCompositor::WaylandQuickItem::surfaceDestroyed() + * \qmlsignal void QtWayland.Compositor::WaylandQuickItem::surfaceDestroyed() * * This signal is emitted when the client has destroyed the \c wl_surface associated * with the WaylandQuickItem. The handler for this signal is expected to either destroy the @@ -1315,7 +1454,7 @@ QSGNode *QWaylandQuickItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeDat d->lastMatrix = data->transformNode->combinedMatrix(); const bool bufferHasContent = d->view->currentBuffer().hasContent(); - if (d->view->isBufferLocked() && !bufferHasContent && d->paintEnabled) + if (d->view->isBufferLocked() && d->paintEnabled) return oldNode; if (!bufferHasContent || !d->paintEnabled || !surface()) { @@ -1333,16 +1472,42 @@ QSGNode *QWaylandQuickItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeDat || bufferTypes[ref.bufferFormatEgl()].canProvideTexture #endif ) { +#if QT_CONFIG(opengl) + if (oldNode && !d->paintByProvider) { + // Need to re-create a node + delete oldNode; + oldNode = nullptr; + } + d->paintByProvider = true; +#endif // This case could covered by the more general path below, but this is more efficient (especially when using ShaderEffect items). QSGSimpleTextureNode *node = static_cast<QSGSimpleTextureNode *>(oldNode); if (!node) { node = new QSGSimpleTextureNode(); + if (smooth()) + node->setFiltering(QSGTexture::Linear); d->newTexture = true; } - if (!d->provider) + if (!d->provider) { d->provider = new QWaylandSurfaceTextureProvider(); + if (compositor()) { + d->texProviderConnection = + QObject::connect( + compositor(), + &QObject::destroyed, + this, + [this](QObject*) { + auto *itemPriv = QWaylandQuickItemPrivate::get(this); + if (itemPriv->provider) { + itemPriv->provider->deleteLater(); + itemPriv->provider = nullptr; + } + disconnect(itemPriv->texProviderConnection); } + ); + } + } if (d->newTexture) { d->newTexture = false; @@ -1363,6 +1528,13 @@ QSGNode *QWaylandQuickItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeDat #if QT_CONFIG(opengl) Q_ASSERT(!d->provider); + if (oldNode && d->paintByProvider) { + // Need to re-create a node + delete oldNode; + oldNode = nullptr; + } + d->paintByProvider = false; + QSGGeometryNode *node = static_cast<QSGGeometryNode *>(oldNode); if (!node) { @@ -1381,13 +1553,20 @@ QSGNode *QWaylandQuickItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeDat if (d->newTexture) { d->newTexture = false; - for (int plane = 0; plane < bufferTypes[ref.bufferFormatEgl()].planeCount; plane++) - if (auto texture = ref.toOpenGLTexture(plane)) - material->setTextureForPlane(plane, texture); - material->bind(); + material->setBufferRef(this, ref); } - QSGGeometry::updateTexturedRectGeometry(geometry, rect, QRectF(0, 0, 1, 1)); + const QSize surfaceSize = ref.size() / surface()->bufferScale(); + const QRectF sourceGeometry = surface()->sourceGeometry(); + const QRectF normalizedCoordinates = + sourceGeometry.isValid() + ? QRectF(sourceGeometry.x() / surfaceSize.width(), + sourceGeometry.y() / surfaceSize.height(), + sourceGeometry.width() / surfaceSize.width(), + sourceGeometry.height() / surfaceSize.height()) + : QRectF(0, 0, 1, 1); + + QSGGeometry::updateTexturedRectGeometry(geometry, rect, normalizedCoordinates); node->setGeometry(geometry); node->setFlag(QSGNode::OwnsGeometry, true); @@ -1430,20 +1609,34 @@ void QWaylandQuickItem::setInputEventsEnabled(bool enabled) void QWaylandQuickItem::lower() { - QQuickItem *parent = parentItem(); + Q_D(QWaylandQuickItem); + d->lower(); +} + +void QWaylandQuickItemPrivate::lower() +{ + Q_Q(QWaylandQuickItem); + QQuickItem *parent = q->parentItem(); Q_ASSERT(parent); - QQuickItem *bottom = parent->childItems().first(); - if (this != bottom) - stackBefore(bottom); + QQuickItem *bottom = parent->childItems().constFirst(); + if (q != bottom) + q->stackBefore(bottom); } void QWaylandQuickItem::raise() { - QQuickItem *parent = parentItem(); + Q_D(QWaylandQuickItem); + d->raise(); +} + +void QWaylandQuickItemPrivate::raise() +{ + Q_Q(QWaylandQuickItem); + QQuickItem *parent = q->parentItem(); Q_ASSERT(parent); - QQuickItem *top = parent->childItems().last(); - if (this != top) - stackAfter(top); + QQuickItem *top = parent->childItems().constLast(); + if (q != top) + q->stackAfter(top); } void QWaylandQuickItem::sendMouseMoveEvent(const QPointF &position, QWaylandSeat *seat) @@ -1573,3 +1766,5 @@ void QWaylandQuickItemPrivate::placeBelowParent() } QT_END_NAMESPACE + +#include "moc_qwaylandquickitem.cpp" diff --git a/src/compositor/compositor_api/qwaylandquickitem.h b/src/compositor/compositor_api/qwaylandquickitem.h index 7731933e7..d30528a8a 100644 --- a/src/compositor/compositor_api/qwaylandquickitem.h +++ b/src/compositor/compositor_api/qwaylandquickitem.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDSURFACEITEM_H #define QWAYLANDSURFACEITEM_H @@ -42,27 +16,33 @@ Q_DECLARE_METATYPE(QWaylandQuickSurface*) +QT_REQUIRE_CONFIG(wayland_compositor_quick); + QT_BEGIN_NAMESPACE class QWaylandSeat; class QWaylandQuickItemPrivate; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandQuickItem : public QQuickItem +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandQuickItem : public QQuickItem { Q_OBJECT Q_DECLARE_PRIVATE(QWaylandQuickItem) Q_PROPERTY(QWaylandCompositor *compositor READ compositor NOTIFY compositorChanged) Q_PROPERTY(QWaylandSurface *surface READ surface WRITE setSurface NOTIFY surfaceChanged) - Q_PROPERTY(bool paintEnabled READ paintEnabled WRITE setPaintEnabled) + Q_PROPERTY(bool paintEnabled READ isPaintEnabled WRITE setPaintEnabled NOTIFY paintEnabledChanged) Q_PROPERTY(bool touchEventsEnabled READ touchEventsEnabled WRITE setTouchEventsEnabled NOTIFY touchEventsEnabledChanged) Q_PROPERTY(QWaylandSurface::Origin origin READ origin NOTIFY originChanged) Q_PROPERTY(bool inputEventsEnabled READ inputEventsEnabled WRITE setInputEventsEnabled NOTIFY inputEventsEnabledChanged) Q_PROPERTY(bool focusOnClick READ focusOnClick WRITE setFocusOnClick NOTIFY focusOnClickChanged) - Q_PROPERTY(bool sizeFollowsSurface READ sizeFollowsSurface WRITE setSizeFollowsSurface NOTIFY sizeFollowsSurfaceChanged) Q_PROPERTY(QObject *subsurfaceHandler READ subsurfaceHandler WRITE setSubsurfaceHandler NOTIFY subsurfaceHandlerChanged) Q_PROPERTY(QWaylandOutput *output READ output WRITE setOutput NOTIFY outputChanged) Q_PROPERTY(bool bufferLocked READ isBufferLocked WRITE setBufferLocked NOTIFY bufferLockedChanged) Q_PROPERTY(bool allowDiscardFrontBuffer READ allowDiscardFrontBuffer WRITE setAllowDiscardFrontBuffer NOTIFY allowDiscardFrontBufferChanged) + Q_MOC_INCLUDE("qwaylandcompositor.h") + Q_MOC_INCLUDE("qwaylandseat.h") + Q_MOC_INCLUDE("qwaylanddrag.h") + QML_NAMED_ELEMENT(WaylandQuickItem) + QML_ADDED_IN_VERSION(1, 0) public: QWaylandQuickItem(QQuickItem *parent = nullptr); ~QWaylandQuickItem() override; @@ -78,7 +58,7 @@ public: bool isTextureProvider() const override; QSGTextureProvider *textureProvider() const override; - bool paintEnabled() const; + bool isPaintEnabled() const; bool touchEventsEnabled() const; void setTouchEventsEnabled(bool enabled); @@ -90,12 +70,8 @@ public: void setFocusOnClick(bool focus); bool inputRegionContains(const QPointF &localPosition) const; - bool inputRegionContains(const QPointF &localPosition); Q_INVOKABLE QPointF mapToSurface(const QPointF &point) const; - Q_REVISION(13) Q_INVOKABLE QPointF mapFromSurface(const QPointF &point) const; - - bool sizeFollowsSurface() const; - void setSizeFollowsSurface(bool sizeFollowsSurface); + Q_REVISION(1, 13) Q_INVOKABLE QPointF mapFromSurface(const QPointF &point) const; #if QT_CONFIG(im) QVariant inputMethodQuery(Qt::InputMethodQuery query) const override; @@ -164,10 +140,12 @@ private Q_SLOTS: #if QT_CONFIG(im) void updateInputMethod(Qt::InputMethodQueries queries); #endif + void updateFocus(); Q_SIGNALS: void surfaceChanged(); void compositorChanged(); + void paintEnabledChanged(); void touchEventsEnabledChanged(); void originChanged(); void surfaceDestroyed(); @@ -175,7 +153,6 @@ Q_SIGNALS: void focusOnClickChanged(); void mouseMove(const QPointF &windowPosition); void mouseRelease(); - void sizeFollowsSurfaceChanged(); void subsurfaceHandlerChanged(); void outputChanged(); void bufferLockedChanged(); diff --git a/src/compositor/compositor_api/qwaylandquickitem_p.h b/src/compositor/compositor_api/qwaylandquickitem_p.h index a75cdb2ba..0ddabc7da 100644 --- a/src/compositor/compositor_api/qwaylandquickitem_p.h +++ b/src/compositor/compositor_api/qwaylandquickitem_p.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDQUICKITEM_P_H #define QWAYLANDQUICKITEM_P_H @@ -48,6 +22,8 @@ #include <QtWaylandCompositor/QWaylandQuickItem> #include <QtWaylandCompositor/QWaylandOutput> +#include <QtCore/qpointer.h> + QT_BEGIN_NAMESPACE class QWaylandSurfaceTextureProvider; @@ -60,17 +36,11 @@ class QWaylandBufferMaterialShader : public QSGMaterialShader public: QWaylandBufferMaterialShader(QWaylandBufferRef::BufferFormatEgl format); - void updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect) override; - char const *const *attributeNames() const override; - -protected: - void initialize() override; - -private: - const QWaylandBufferRef::BufferFormatEgl m_format; - int m_id_matrix; - int m_id_opacity; - QVarLengthArray<int, 3> m_id_tex; + bool updateUniformData(RenderState &state, + QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override; + void updateSampledImage(RenderState &state, int binding, QSGTexture **texture, + QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override; + void setupExternalOESShader(const QString &shaderFilename); }; class QWaylandBufferMaterial : public QSGMaterial @@ -79,19 +49,25 @@ public: QWaylandBufferMaterial(QWaylandBufferRef::BufferFormatEgl format); ~QWaylandBufferMaterial() override; - void setTextureForPlane(int plane, QOpenGLTexture *texture); + void setTextureForPlane(int plane, QOpenGLTexture *texture, QSGTexture *scenegraphTexture); + void setBufferRef(QWaylandQuickItem *surfaceItem, const QWaylandBufferRef &ref); void bind(); + void updateScenegraphTextures(QRhi *rhi); QSGMaterialType *type() const override; - QSGMaterialShader *createShader() const override; + QSGMaterialShader *createShader(QSGRendererInterface::RenderMode renderMode) const override; private: + friend QWaylandBufferMaterialShader; + void setTextureParameters(GLenum target); void ensureTextures(int count); const QWaylandBufferRef::BufferFormatEgl m_format; QVarLengthArray<QOpenGLTexture*, 3> m_textures; + QVarLengthArray<QSGTexture*, 3> m_scenegraphTextures; + QWaylandBufferRef m_bufferRef; }; #endif // QT_CONFIG(opengl) @@ -137,6 +113,7 @@ public: Qt::ExtraButton5 | Qt::ExtraButton6 | Qt::ExtraButton7 | Qt::ExtraButton8 | Qt::ExtraButton9 | Qt::ExtraButton10 | Qt::ExtraButton11 | Qt::ExtraButton12 | Qt::ExtraButton13) : Qt::NoButton); + q->setAcceptTouchEvents(enable); q->setAcceptHoverEvents(enable); inputEventsEnabled = enable; } @@ -150,19 +127,25 @@ public: void placeAboveParent(); void placeBelowParent(); + virtual void raise(); + virtual void lower(); + static QMutex *mutex; QScopedPointer<QWaylandView> view; QPointer<QWaylandSurface> oldSurface; mutable QWaylandSurfaceTextureProvider *provider = nullptr; + QMetaObject::Connection texProviderConnection; bool paintEnabled = true; bool touchEventsEnabled = true; bool inputEventsEnabled = true; bool isDragging = false; bool newTexture = false; bool focusOnClick = true; - bool sizeFollowsSurface = true; bool belowParent = false; +#if QT_CONFIG(opengl) + bool paintByProvider = false; +#endif QPointF hoverPos; QMatrix4x4 lastMatrix; @@ -170,7 +153,7 @@ public: QWaylandOutput *connectedOutput = nullptr; QWaylandSurface::Origin origin = QWaylandSurface::OriginTopLeft; QPointer<QObject> subsurfaceHandler; - QVector<QWaylandSeat *> touchingSeats; + QList<QWaylandSeat *> touchingSeats; }; QT_END_NAMESPACE diff --git a/src/compositor/compositor_api/qwaylandquickoutput.cpp b/src/compositor/compositor_api/qwaylandquickoutput.cpp index acb907960..de6c3ede4 100644 --- a/src/compositor/compositor_api/qwaylandquickoutput.cpp +++ b/src/compositor/compositor_api/qwaylandquickoutput.cpp @@ -1,32 +1,6 @@ -/**************************************************************************** -** -** Copyright (C) 2017 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "qwaylandquickoutput.h" #include "qwaylandquickcompositor.h" @@ -86,7 +60,7 @@ void QWaylandQuickOutput::update() } /*! - * \qmlproperty bool QtWaylandCompositor::WaylandOutput::automaticFrameCallback + * \qmlproperty bool QtWayland.Compositor::WaylandOutput::automaticFrameCallback * * This property holds whether the WaylandOutput automatically sends frame * callbacks when rendering. @@ -164,3 +138,5 @@ void QWaylandQuickOutput::doFrameCallbacks() sendFrameCallbacks(); } QT_END_NAMESPACE + +#include "moc_qwaylandquickoutput.cpp" diff --git a/src/compositor/compositor_api/qwaylandquickoutput.h b/src/compositor/compositor_api/qwaylandquickoutput.h index 636dc6d7e..c5fde60ff 100644 --- a/src/compositor/compositor_api/qwaylandquickoutput.h +++ b/src/compositor/compositor_api/qwaylandquickoutput.h @@ -1,32 +1,6 @@ -/**************************************************************************** -** -** Copyright (C) 2017 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDQUICKOUTPUT_H #define QWAYLANDQUICKOUTPUT_H @@ -35,17 +9,21 @@ #include <QtWaylandCompositor/qwaylandoutput.h> #include <QtWaylandCompositor/qwaylandquickchildren.h> +QT_REQUIRE_CONFIG(wayland_compositor_quick); + QT_BEGIN_NAMESPACE class QWaylandQuickCompositor; class QQuickWindow; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandQuickOutput : public QWaylandOutput, public QQmlParserStatus +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandQuickOutput : public QWaylandOutput, public QQmlParserStatus { Q_INTERFACES(QQmlParserStatus) Q_OBJECT Q_WAYLAND_COMPOSITOR_DECLARE_QUICK_CHILDREN(QWaylandQuickOutput) Q_PROPERTY(bool automaticFrameCallback READ automaticFrameCallback WRITE setAutomaticFrameCallback NOTIFY automaticFrameCallbackChanged) + QML_NAMED_ELEMENT(WaylandOutput) + QML_ADDED_IN_VERSION(1, 0) public: QWaylandQuickOutput(); QWaylandQuickOutput(QWaylandCompositor *compositor, QWindow *window); diff --git a/src/compositor/compositor_api/qwaylandquicksurface.cpp b/src/compositor/compositor_api/qwaylandquicksurface.cpp index 8b2f13a30..920415d68 100644 --- a/src/compositor/compositor_api/qwaylandquicksurface.cpp +++ b/src/compositor/compositor_api/qwaylandquicksurface.cpp @@ -1,38 +1,12 @@ -/**************************************************************************** -** -** Copyright (C) 2017 Jolla Ltd, author: <giulio.camuffo@jollamobile.com> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 Jolla Ltd, author: <giulio.camuffo@jollamobile.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <QSGTexture> -#include <QOpenGLTexture> #include <QQuickWindow> #include <QDebug> #include "qwaylandquicksurface.h" +#include "qwaylandquicksurface_p.h" #include "qwaylandquickcompositor.h" #include "qwaylandquickitem.h" #include <QtWaylandCompositor/qwaylandbufferref.h> @@ -41,22 +15,6 @@ QT_BEGIN_NAMESPACE -class QWaylandQuickSurfacePrivate : public QWaylandSurfacePrivate -{ - Q_DECLARE_PUBLIC(QWaylandQuickSurface) -public: - QWaylandQuickSurfacePrivate() - { - } - - ~QWaylandQuickSurfacePrivate() override - { - } - - bool useTextureAlpha = true; - bool clientRenderingEnabled = true; -}; - QWaylandQuickSurface::QWaylandQuickSurface() : QWaylandSurface(* new QWaylandQuickSurfacePrivate()) { @@ -68,13 +26,18 @@ QWaylandQuickSurface::QWaylandQuickSurface(QWaylandCompositor *compositor, QWayl initialize(compositor, client, id, version); } +QWaylandQuickSurface::QWaylandQuickSurface(QWaylandQuickSurfacePrivate &dptr) + : QWaylandSurface(dptr) +{ +} + QWaylandQuickSurface::~QWaylandQuickSurface() { } /*! - * \qmlproperty bool QtWaylandCompositor::WaylandSurface::useTextureAlpha + * \qmlproperty bool QtWayland.Compositor::WaylandSurface::useTextureAlpha * * This property specifies whether the surface should use texture alpha. */ @@ -94,28 +57,6 @@ void QWaylandQuickSurface::setUseTextureAlpha(bool useTextureAlpha) } } -/*! - * \qmlproperty bool QtWaylandCompositor::WaylandSurface::clientRenderingEnabled - * \deprecated - * - * This property used to specify whether client rendering was enabled for the surface. - * It depended on a Wayland extension that was part of the private API. The surface extension - * is not used anymore, so this property does nothing. - */ -bool QWaylandQuickSurface::clientRenderingEnabled() const -{ - Q_D(const QWaylandQuickSurface); - return d->clientRenderingEnabled; -} - -void QWaylandQuickSurface::setClientRenderingEnabled(bool enabled) -{ - Q_D(QWaylandQuickSurface); - qWarning() << Q_FUNC_INFO << "doesn't do anything"; - if (d->clientRenderingEnabled != enabled) { - d->clientRenderingEnabled = enabled; - emit clientRenderingEnabledChanged(); - } -} - QT_END_NAMESPACE + +#include "moc_qwaylandquicksurface.cpp" diff --git a/src/compositor/compositor_api/qwaylandquicksurface.h b/src/compositor/compositor_api/qwaylandquicksurface.h index 394fc8e01..5ed26cfe2 100644 --- a/src/compositor/compositor_api/qwaylandquicksurface.h +++ b/src/compositor/compositor_api/qwaylandquicksurface.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 Jolla Ltd, author: <giulio.camuffo@jollamobile.com> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 Jolla Ltd, author: <giulio.camuffo@jollamobile.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QQUICKWAYLANDSURFACE_H #define QQUICKWAYLANDSURFACE_H @@ -35,18 +9,21 @@ struct wl_client; +QT_REQUIRE_CONFIG(wayland_compositor_quick); + QT_BEGIN_NAMESPACE class QWaylandQuickSurfacePrivate; class QWaylandQuickCompositor; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandQuickSurface : public QWaylandSurface +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandQuickSurface : public QWaylandSurface { Q_OBJECT Q_DECLARE_PRIVATE(QWaylandQuickSurface) Q_WAYLAND_COMPOSITOR_DECLARE_QUICK_CHILDREN(QWaylandQuickSurface) Q_PROPERTY(bool useTextureAlpha READ useTextureAlpha WRITE setUseTextureAlpha NOTIFY useTextureAlphaChanged) - Q_PROPERTY(bool clientRenderingEnabled READ clientRenderingEnabled WRITE setClientRenderingEnabled NOTIFY clientRenderingEnabledChanged) + QML_NAMED_ELEMENT(WaylandSurface) + QML_ADDED_IN_VERSION(1, 0) public: QWaylandQuickSurface(); QWaylandQuickSurface(QWaylandCompositor *compositor, QWaylandClient *client, quint32 id, int version); @@ -55,12 +32,11 @@ public: bool useTextureAlpha() const; void setUseTextureAlpha(bool useTextureAlpha); - Q_DECL_DEPRECATED bool clientRenderingEnabled() const; - Q_DECL_DEPRECATED void setClientRenderingEnabled(bool enabled); +protected: + QWaylandQuickSurface(QWaylandQuickSurfacePrivate &dptr); Q_SIGNALS: void useTextureAlphaChanged(); - void clientRenderingEnabledChanged(); //deprecated }; QT_END_NAMESPACE diff --git a/src/compositor/compositor_api/qwaylandquicksurface_p.h b/src/compositor/compositor_api/qwaylandquicksurface_p.h new file mode 100644 index 000000000..8426276b0 --- /dev/null +++ b/src/compositor/compositor_api/qwaylandquicksurface_p.h @@ -0,0 +1,40 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#ifndef QWAYLANDQUICKSURFACE_P_H +#define QWAYLANDQUICKSURFACE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtWaylandCompositor/private/qwaylandsurface_p.h> + +QT_BEGIN_NAMESPACE + +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandQuickSurfacePrivate : public QWaylandSurfacePrivate +{ + Q_DECLARE_PUBLIC(QWaylandQuickSurface) +public: + QWaylandQuickSurfacePrivate() + { + } + + ~QWaylandQuickSurfacePrivate() override + { + } + + bool useTextureAlpha = true; + bool clientRenderingEnabled = true; +}; + +QT_END_NAMESPACE + +#endif // QWAYLANDQUICKSURFACE_P_H diff --git a/src/compositor/compositor_api/qwaylandresource.cpp b/src/compositor/compositor_api/qwaylandresource.cpp index 585b238cd..fc744c4b6 100644 --- a/src/compositor/compositor_api/qwaylandresource.cpp +++ b/src/compositor/compositor_api/qwaylandresource.cpp @@ -1,43 +1,44 @@ -/**************************************************************************** -** -** Copyright (C) 2017 Klarälvdalens Datakonsult AB (KDAB). -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 Klarälvdalens Datakonsult AB (KDAB). +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "qwaylandresource.h" QT_BEGIN_NAMESPACE +/*! + * \class QWaylandResource + * \inmodule QtWaylandCompositor + * \since 5.8 + * \brief QWaylandResource is a container for a \c wl_resource. + * + * The QWaylandResource is a simple wrapper around the Wayland type \c wl_resource, and makes it + * possible to use wl_resource pointers in Qt Quick APIs. + * + * \sa {Custom Shell} + */ + +/*! + * Constructs an invalid QWaylandResource. The \l{resource()} accessor will return null. + */ QWaylandResource::QWaylandResource() { } +/*! + * Constructs a QWaylandResource which contains \a resource. + */ QWaylandResource::QWaylandResource(wl_resource *resource) : m_resource(resource) { } +/*! + * \fn wl_resource *QWaylandResource::resource() const + * + * \return the wl_resource pointer held by this QWaylandResource. + */ + QT_END_NAMESPACE + +#include "moc_qwaylandresource.cpp" diff --git a/src/compositor/compositor_api/qwaylandresource.h b/src/compositor/compositor_api/qwaylandresource.h index fda1200d3..ab8897700 100644 --- a/src/compositor/compositor_api/qwaylandresource.h +++ b/src/compositor/compositor_api/qwaylandresource.h @@ -1,45 +1,23 @@ -/**************************************************************************** -** -** Copyright (C) 2017 Klarälvdalens Datakonsult AB (KDAB). -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 Klarälvdalens Datakonsult AB (KDAB). +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDRESOURCE_H #define QWAYLANDRESOURCE_H #include <QtCore/QObject> #include <QtWaylandCompositor/qtwaylandcompositorglobal.h> +#include <QtWaylandCompositor/qtwaylandqmlinclude.h> struct wl_resource; QT_BEGIN_NAMESPACE -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandResource +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandResource { Q_GADGET + QML_NAMED_ELEMENT(waylandresource) + QML_UNCREATABLE("") + QML_ADDED_IN_VERSION(1, 0) public: QWaylandResource(); explicit QWaylandResource(wl_resource *resource); diff --git a/src/compositor/compositor_api/qwaylandseat.cpp b/src/compositor/compositor_api/qwaylandseat.cpp index 0be10f450..0e7df0ec0 100644 --- a/src/compositor/compositor_api/qwaylandseat.cpp +++ b/src/compositor/compositor_api/qwaylandseat.cpp @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "qwaylandseat.h" #include "qwaylandseat_p.h" @@ -41,6 +15,7 @@ #include <QtWaylandCompositor/QWaylandKeymap> #include <QtWaylandCompositor/private/qwaylandseat_p.h> #include <QtWaylandCompositor/private/qwaylandcompositor_p.h> +#include <QtWaylandCompositor/private/qwaylandkeyboard_p.h> #if QT_CONFIG(wayland_datadevice) #include <QtWaylandCompositor/private/qwldatadevice_p.h> #endif @@ -48,6 +23,8 @@ #include "extensions/qwlqtkey_p.h" #include "extensions/qwaylandtextinput.h" +#include "extensions/qwaylandtextinputv3.h" +#include "extensions/qwaylandqttextinputmethod.h" QT_BEGIN_NAMESPACE @@ -136,6 +113,7 @@ void QWaylandSeatPrivate::seat_get_touch(wl_seat::Resource *resource, uint32_t i /*! * \qmltype WaylandSeat + * \instantiates QWaylandSeat * \inqmlmodule QtWayland.Compositor * \since 5.8 * \brief Provides access to keyboard, mouse, and touch input. @@ -177,6 +155,9 @@ QWaylandSeat::QWaylandSeat(QWaylandCompositor *compositor, CapabilityFlags capab d->capabilities = capabilityFlags; if (compositor->isCreated()) initialize(); + + // Support deprecated signal for backward compatibility + connect(this, &QWaylandSeat::cursorSurfaceRequested, this, &QWaylandSeat::cursorSurfaceRequest); } /*! @@ -296,7 +277,7 @@ uint QWaylandSeat::sendTouchPointEvent(QWaylandSurface *surface, int id, const Q } /*! - * \qmlmethod uint QtWaylandCompositor::WaylandSeat::sendTouchPointPressed(WaylandSurface surface, int id, point position) + * \qmlmethod uint QtWayland.Compositor::WaylandSeat::sendTouchPointPressed(WaylandSurface surface, int id, point position) * * Sends a touch pressed event for the touch point \a id on \a surface with * position \a position. @@ -330,7 +311,7 @@ uint QWaylandSeat::sendTouchPointPressed(QWaylandSurface *surface, int id, const } /*! - * \qmlmethod void QtWaylandCompositor::WaylandSeat::sendTouchPointReleased(WaylandSurface surface, int id, point position) + * \qmlmethod void QtWayland.Compositor::WaylandSeat::sendTouchPointReleased(WaylandSurface surface, int id, point position) * * Sends a touch released event for the touch point \a id on \a surface with * position \a position. @@ -364,7 +345,7 @@ uint QWaylandSeat::sendTouchPointReleased(QWaylandSurface *surface, int id, cons } /*! - * \qmlmethod void QtWaylandCompositor::WaylandSeat::sendTouchPointMoved(WaylandSurface surface, int id, point position) + * \qmlmethod void QtWayland.Compositor::WaylandSeat::sendTouchPointMoved(WaylandSurface surface, int id, point position) * * Sends a touch moved event for the touch point \a id on \a surface with * position \a position. @@ -398,7 +379,7 @@ uint QWaylandSeat::sendTouchPointMoved(QWaylandSurface *surface, int id, const Q } /*! - * \qmlmethod void QtWaylandCompositor::WaylandSeat::sendTouchFrameEvent(WaylandClient client) + * \qmlmethod void QtWayland.Compositor::WaylandSeat::sendTouchFrameEvent(WaylandClient client) * * Sends a frame event to the touch device of a \a client to indicate the end * of a series of touch up, down, and motion events. @@ -416,7 +397,7 @@ void QWaylandSeat::sendTouchFrameEvent(QWaylandClient *client) } /*! - * \qmlmethod void QtWaylandCompositor::WaylandSeat::sendTouchCancelEvent(WaylandClient client) + * \qmlmethod void QtWayland.Compositor::WaylandSeat::sendTouchCancelEvent(WaylandClient client) * * Sends a cancel event to the touch device of a \a client. */ @@ -434,7 +415,7 @@ void QWaylandSeat::sendTouchCancelEvent(QWaylandClient *client) /*! * Sends the \a event to the specified \a surface on the touch device. * - * \warning This API will automatically map \l QTouchEvent::TouchPoint::id to a + * \warning This API will automatically map \l QEventPoint::id() to a * sequential id before sending it to the client. It should therefore not be * used in combination with the other API using explicit ids, as collisions * might occur. @@ -451,6 +432,11 @@ void QWaylandSeat::sendFullTouchEvent(QWaylandSurface *surface, QTouchEvent *eve /*! * Sends the \a event to the keyboard device. + * + * \note The \a event should correspond to an actual keyboard key in the current mapping. + * For example, \c Qt::Key_Exclam is normally not a separate key: with most keyboards the + * exclamation mark is produced with Shift + 1. In that case, to send an exclamation mark + * key press event, use \c{QKeyEvent(QEvent::KeyPress, Qt::Key_1, Qt::ShiftModifier)}. */ void QWaylandSeat::sendFullKeyEvent(QKeyEvent *event) { @@ -464,10 +450,30 @@ void QWaylandSeat::sendFullKeyEvent(QKeyEvent *event) #if QT_CONFIG(im) if (keyboardFocus()->inputMethodControl()->enabled() && event->nativeScanCode() == 0) { - QWaylandTextInput *textInput = QWaylandTextInput::findIn(this); - if (textInput) { - textInput->sendKeyEvent(event); - return; + if (keyboardFocus()->client()->textInputProtocols().testFlag(QWaylandClient::TextInputProtocol::TextInputV2)) { + QWaylandTextInput *textInput = QWaylandTextInput::findIn(this); + if (textInput) { + textInput->sendKeyEvent(event); + return; + } + } + + if (keyboardFocus()->client()->textInputProtocols().testFlag(QWaylandClient::TextInputProtocol::QtTextInputMethodV1)) { + QWaylandQtTextInputMethod *textInputMethod = QWaylandQtTextInputMethod::findIn(this); + if (textInputMethod) { + textInputMethod->sendKeyEvent(event); + return; + } + } + + if (keyboardFocus()->client()->textInputProtocols().testFlag(QWaylandClient::TextInputProtocol::TextInputV3)) { + QWaylandTextInputV3 *textInputV3 = QWaylandTextInputV3::findIn(this); + if (textInputV3 && !event->text().isEmpty()) { + // it will just commit the text for text-input-unstable-v3 when keyPress + if (event->type() == QEvent::KeyPress) + textInputV3->sendKeyEvent(event); + return; + } } } #endif @@ -487,22 +493,29 @@ void QWaylandSeat::sendFullKeyEvent(QKeyEvent *event) return; } - if (event->type() == QEvent::KeyPress) + if (event->type() == QEvent::KeyPress) { + QWaylandKeyboardPrivate::get(d->keyboard.data())->checkAndRepairModifierState(event); d->keyboard->sendKeyPressEvent(scanCode); - else if (event->type() == QEvent::KeyRelease) + } else if (event->type() == QEvent::KeyRelease) { d->keyboard->sendKeyReleaseEvent(scanCode); + } } } /*! - * \qmlmethod void QtWaylandCompositor::WaylandSeat::sendKeyEvent(int qtKey, bool pressed) + * \qmlmethod void QtWayland.Compositor::WaylandSeat::sendKeyEvent(int qtKey, bool pressed) * \since 5.12 * - * Sends a key press or release to the keyboard device. + * Sends a key press (if \a pressed is \c true) or release (if \a pressed is \c false) + * event of a key \a qtKey to the keyboard device. */ /*! - * Sends a key press or release to the keyboard device. + * Sends a key press (if \a pressed is \c true) or release (if \a pressed is \c false) + * event of a key \a qtKey to the keyboard device. + * + * \note This function does not support key events that require modifiers, such as \c Qt::Key_Exclam. + * Use \l{sendFullKeyEvent} instead. * * \since 5.12 */ @@ -525,6 +538,104 @@ void QWaylandSeat::sendKeyEvent(int qtKey, bool pressed) } /*! + * \qmlmethod void QtWayland.Compositor::WaylandSeat::sendUnicodeKeyPressEvent(uint unicode) + * \since 6.7 + * + * Sends a key press event of a UCS4 \a unicode through a text-input protocol. + * + * \note This function will not work properly if the client does not support the + * text-input protocol that the compositor supports. + */ + +/*! + * Sends a key press event of a UCS4 \a unicode through a text-input protocol. + * + * \note This function will not work properly if the client does not support the + * text-input protocol that the compositor supports. + * + * \sa {sendFullKeyEvent} {sendKeyEvent} + * + * \since 6.7 + */ +void QWaylandSeat::sendUnicodeKeyPressEvent(uint unicode) +{ + sendUnicodeKeyEvent(unicode, QEvent::KeyPress); +} + +/*! + * \qmlmethod void QtWayland.Compositor::WaylandSeat::sendUnicodeKeyReleaseEvent(uint unicode) + * \since 6.7 + * + * Sends a key release event of a UCS4 \a unicode through a text-input protocol. + * + * \note This function will not work properly if the client does not support the + * text-input protocol that the compositor supports. + */ + +/*! + * Sends a key release event of a UCS4 \a unicode through a text-input protocol. + * + * \note This function will not work properly if the client does not support the + * text-input protocol that the compositor supports. + * + * \sa {sendFullKeyEvent} {sendKeyEvent} + * + * \since 6.7 + */ +void QWaylandSeat::sendUnicodeKeyReleaseEvent(uint unicode) +{ + sendUnicodeKeyEvent(unicode, QEvent::KeyRelease); +} + +/*! + * \internal + * + * Sends an \a eventType for the UCS4 \a unicode through a text-input protocol. + */ +void QWaylandSeat::sendUnicodeKeyEvent(uint unicode, QEvent::Type eventType) +{ + if (!keyboardFocus()) { + qWarning("Can't send a unicode key event, no keyboard focus, fix the compositor"); + return; + } +#if QT_CONFIG(im) + QString text; + text += QChar::fromUcs4(static_cast<char32_t>(unicode)); + + QKeyEvent event(eventType, Qt::Key_unknown, Qt::KeyboardModifiers{}, text); + if (keyboardFocus()->client()->textInputProtocols().testFlag(QWaylandClient::TextInputProtocol::TextInputV2)) { + QWaylandTextInput *textInput = QWaylandTextInput::findIn(this); + if (textInput) { + textInput->sendKeyEvent(&event); + return; + } + } + + if (keyboardFocus()->client()->textInputProtocols().testFlag(QWaylandClient::TextInputProtocol::QtTextInputMethodV1)) { + QWaylandQtTextInputMethod *textInputMethod = QWaylandQtTextInputMethod::findIn(this); + if (textInputMethod) { + textInputMethod->sendKeyEvent(&event); + return; + } + } + + if (keyboardFocus()->client()->textInputProtocols().testFlag(QWaylandClient::TextInputProtocol::TextInputV3)) { + QWaylandTextInputV3 *textInputV3 = QWaylandTextInputV3::findIn(this); + if (textInputV3 && !text.isEmpty()) { + // it will just commit the text for text-input-unstable-v3 when keyPress + if (eventType == QEvent::KeyPress) + textInputV3->sendKeyEvent(&event); + return; + } + } +#else + Q_UNUSED(unicode); + Q_UNUSED(eventType); + qWarning() << "Can't send a unicode key event: Unable to find a text-input protocol."; +#endif +} + +/*! * Returns the keyboard for this input device. */ QWaylandKeyboard *QWaylandSeat::keyboard() const @@ -696,7 +807,7 @@ void QWaylandSeat::handleMouseFocusDestroyed() } -/*! \qmlsignal void QtWaylandCompositor::QWaylandSeat::keyboardFocusChanged(QWaylandSurface newFocus, QWaylandSurface oldFocus) +/*! \qmlsignal void QtWayland.Compositor::WaylandSeat::keyboardFocusChanged(QWaylandSurface newFocus, QWaylandSurface oldFocus) * * This signal is emitted when setKeyboardFocus() is called or when a WaylandQuickItem has focus * and the user starts pressing keys. @@ -716,7 +827,7 @@ void QWaylandSeat::handleMouseFocusDestroyed() * \a oldFocus has the surface that lost keyboard focus; or \c nullptr if no surface had focus. */ -/*! \qmlsignal void QtWaylandCompositor::QWaylandSeat::cursorSurfaceRequest(QWaylandSurface surface, int hotspotX, int hotspotY) +/*! \qmlsignal void QtWayland.Compositor::WaylandSeat::cursorSurfaceRequest(QWaylandSurface surface, int hotspotX, int hotspotY) * * This signal is emitted when the client has requested for a specific \a surface to be the mouse * cursor. For example, when the user hovers over a particular surface, and you want the cursor @@ -734,6 +845,10 @@ void QWaylandSeat::handleMouseFocusDestroyed() * This signal is emitted when the client has requested for a specific \a surface to be the mouse * cursor. For example, when the user hovers over a particular surface, and you want the cursor * to change into a resize arrow. + * + * Both \a hotspotX and \a hotspotY are offsets from the top-left of a pointer surface, where a + * click should happen. For example, if the requested cursor surface is an arrow, the parameters + * indicate where the arrow's tip is, on that surface. */ /*! @@ -757,3 +872,5 @@ void QWaylandSeat::handleMouseFocusDestroyed() */ QT_END_NAMESPACE + +#include "moc_qwaylandseat.cpp" diff --git a/src/compositor/compositor_api/qwaylandseat.h b/src/compositor/compositor_api/qwaylandseat.h index 0acaf670a..dd67e83ae 100644 --- a/src/compositor/compositor_api/qwaylandseat.h +++ b/src/compositor/compositor_api/qwaylandseat.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDSEAT_H #define QWAYLANDSEAT_H @@ -35,8 +9,10 @@ #include <QtCore/QString> #include <QtWaylandCompositor/qtwaylandcompositorglobal.h> +#include <QtWaylandCompositor/qtwaylandqmlinclude.h> #include <QtWaylandCompositor/qwaylandcompositorextension.h> #include <QtWaylandCompositor/qwaylandkeyboard.h> +#include <QtWaylandCompositor/qwaylandview.h> QT_BEGIN_NAMESPACE @@ -44,7 +20,6 @@ class QWaylandCompositor; class QWaylandSurface; class QKeyEvent; class QTouchEvent; -class QWaylandView; class QInputEvent; class QWaylandSeatPrivate; class QWaylandDrag; @@ -52,15 +27,22 @@ class QWaylandKeyboard; class QWaylandPointer; class QWaylandTouch; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandSeat : public QWaylandObject +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandSeat : public QWaylandObject { Q_OBJECT Q_DECLARE_PRIVATE(QWaylandSeat) #if QT_CONFIG(draganddrop) Q_PROPERTY(QWaylandDrag *drag READ drag CONSTANT) + Q_MOC_INCLUDE("qwaylanddrag.h") #endif Q_PROPERTY(QWaylandKeymap *keymap READ keymap CONSTANT) + Q_MOC_INCLUDE("qwaylandkeymap.h") + Q_MOC_INCLUDE("qwaylandview.h") + + QML_NAMED_ELEMENT(WaylandSeat) + QML_ADDED_IN_VERSION(1, 0) + QML_UNCREATABLE("") public: enum CapabilityFlag { // The order should match the enum WL_SEAT_CAPABILITY_* @@ -89,6 +71,9 @@ public: void sendFullKeyEvent(QKeyEvent *event); Q_INVOKABLE void sendKeyEvent(int qtKey, bool pressed); + Q_REVISION(6, 7) Q_INVOKABLE void sendUnicodeKeyPressEvent(uint unicode); + Q_REVISION(6, 7) Q_INVOKABLE void sendUnicodeKeyReleaseEvent(uint unicode); + uint sendTouchPointEvent(QWaylandSurface *surface, int id, const QPointF &point, Qt::TouchPointState state); Q_INVOKABLE uint sendTouchPointPressed(QWaylandSurface *surface, int id, const QPointF &position); Q_INVOKABLE uint sendTouchPointReleased(QWaylandSurface *surface, int id, const QPointF &position); @@ -126,9 +111,14 @@ public: Q_SIGNALS: void mouseFocusChanged(QWaylandView *newFocus, QWaylandView *oldFocus); void keyboardFocusChanged(QWaylandSurface *newFocus, QWaylandSurface *oldFocus); +#if QT_DEPRECATED_SINCE(6, 1) void cursorSurfaceRequest(QWaylandSurface *surface, int hotspotX, int hotspotY); +#endif + void cursorSurfaceRequested(QWaylandSurface *surface, int hotspotX, int hotspotY, QWaylandClient *client); private: + void sendUnicodeKeyEvent(uint unicode, QEvent::Type type); + void handleMouseFocusDestroyed(); }; diff --git a/src/compositor/compositor_api/qwaylandseat_p.h b/src/compositor/compositor_api/qwaylandseat_p.h index 200df7493..b82f899a3 100644 --- a/src/compositor/compositor_api/qwaylandseat_p.h +++ b/src/compositor/compositor_api/qwaylandseat_p.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDSEAT_P_H #define QWAYLANDSEAT_P_H @@ -74,7 +48,7 @@ class InputMethod; } -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandSeatPrivate : public QObjectPrivate, public QtWaylandServer::wl_seat +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandSeatPrivate : public QObjectPrivate, public QtWaylandServer::wl_seat { public: Q_DECLARE_PUBLIC(QWaylandSeat) diff --git a/src/compositor/compositor_api/qwaylandsurface.cpp b/src/compositor/compositor_api/qwaylandsurface.cpp index 41a678128..207158bf7 100644 --- a/src/compositor/compositor_api/qwaylandsurface.cpp +++ b/src/compositor/compositor_api/qwaylandsurface.cpp @@ -1,32 +1,6 @@ -/**************************************************************************** -** -** Copyright (C) 2017-2015 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017-2015 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "qwaylandsurface.h" #include "qwaylandsurface_p.h" @@ -127,9 +101,9 @@ QWaylandSurfacePrivate::~QWaylandSurfacePrivate() bufferRef = QWaylandBufferRef(); - for (QtWayland::FrameCallback *c : qAsConst(pendingFrameCallbacks)) + for (QtWayland::FrameCallback *c : std::as_const(pendingFrameCallbacks)) c->destroy(); - for (QtWayland::FrameCallback *c : qAsConst(frameCallbacks)) + for (QtWayland::FrameCallback *c : std::as_const(frameCallbacks)) c->destroy(); } @@ -195,9 +169,20 @@ void QWaylandSurfacePrivate::surface_attach(Resource *, struct wl_resource *buff pending.newlyAttached = true; } +/* + Note: The Wayland protocol specifies that buffer scale and damage can be interleaved, so + we cannot scale the damage region until commit. We assume that clients will either use + surface_damage or surface_damage_buffer within one frame for one surface. +*/ + void QWaylandSurfacePrivate::surface_damage(Resource *, int32_t x, int32_t y, int32_t width, int32_t height) { - pending.damage = pending.damage.united(QRect(x, y, width, height)); + pending.surfaceDamage = pending.surfaceDamage.united(QRect(x, y, width, height)); +} + +void QWaylandSurfacePrivate::surface_damage_buffer(Resource *, int32_t x, int32_t y, int32_t width, int32_t height) +{ + pending.bufferDamage = pending.bufferDamage.united(QRect(x, y, width, height)); } void QWaylandSurfacePrivate::surface_frame(Resource *resource, uint32_t callback) @@ -240,11 +225,36 @@ void QWaylandSurfacePrivate::surface_commit(Resource *) QSize surfaceSize = bufferSize / bufferScale; sourceGeometry = !pending.sourceGeometry.isValid() ? QRect(QPoint(), surfaceSize) : pending.sourceGeometry; destinationSize = pending.destinationSize.isEmpty() ? sourceGeometry.size().toSize() : pending.destinationSize; - damage = pending.damage.intersected(QRect(QPoint(), destinationSize)); + QRect destinationRect(QPoint(), destinationSize); + // pending.damage is already in surface coordinates + damage = pending.surfaceDamage.intersected(destinationRect); + if (!pending.bufferDamage.isNull()) { + if (bufferScale == 1) { + damage |= pending.bufferDamage.intersected(destinationRect); // Already in surface coordinates + } else { + // We must transform pending.damage from buffer coordinate system to surface coordinates + // TODO(QTBUG-85461): Also support wp_viewport setting more complex transformations + auto xform = [](const QRect &r, int scale) -> QRect { + QRect res{ + QPoint{ r.x() / scale, r.y() / scale }, + QPoint{ (r.right() + scale - 1) / scale, (r.bottom() + scale - 1) / scale } + }; + return res; + }; + for (const QRect &r : pending.bufferDamage) + damage |= xform(r, bufferScale).intersected(destinationRect); + } + } hasContent = bufferRef.hasContent(); frameCallbacks << pendingFrameCallbacks; - inputRegion = pending.inputRegion.intersected(QRect(QPoint(), destinationSize)); - opaqueRegion = pending.opaqueRegion.intersected(QRect(QPoint(), destinationSize)); + inputRegion = pending.inputRegion.intersected(destinationRect); + opaqueRegion = pending.opaqueRegion.intersected(destinationRect); + bool becameOpaque = opaqueRegion.boundingRect().contains(destinationRect); + if (becameOpaque != isOpaque) { + isOpaque = becameOpaque; + emit q->isOpaqueChanged(); + } + QPoint offsetForNextFrame = pending.offset; if (viewport) @@ -254,13 +264,14 @@ void QWaylandSurfacePrivate::surface_commit(Resource *) pending.buffer = QWaylandBufferRef(); pending.offset = QPoint(); pending.newlyAttached = false; - pending.damage = QRegion(); + pending.bufferDamage = QRegion(); + pending.surfaceDamage = QRegion(); pendingFrameCallbacks.clear(); // Notify buffers and views if (auto *buffer = bufferRef.buffer()) buffer->setCommitted(damage); - for (auto *view : qAsConst(views)) + for (auto *view : std::as_const(views)) view->bufferCommitted(bufferRef, damage); // Now all double-buffered state has been applied so it's safe to emit general signals @@ -269,12 +280,8 @@ void QWaylandSurfacePrivate::surface_commit(Resource *) emit q->damaged(damage); - if (oldBufferSize != bufferSize) { + if (oldBufferSize != bufferSize) emit q->bufferSizeChanged(); -#if QT_DEPRECATED_SINCE(5, 13) - emit q->sizeChanged(); -#endif - } if (oldBufferScale != bufferScale) emit q->bufferScaleChanged(); @@ -331,7 +338,54 @@ QtWayland::ClientBuffer *QWaylandSurfacePrivate::getBuffer(struct ::wl_resource } /*! + * \class QWaylandSurfaceRole + * \inmodule QtWaylandCompositor + * \since 5.8 + * \brief The QWaylandSurfaceRole class represents the role of the surface in context of wl_surface. + * + * QWaylandSurfaceRole is used to represent the role of a QWaylandSurface. According to the protocol + * specification, the role of a surface is permanent once set, and if the same surface is later + * reused for a different role, this constitutes a protocol error. Setting the surface to the same + * role multiple times is not an error. + * + * As an example, the QWaylandXdgShell can assign either "popup" or "toplevel" roles to surfaces. + * If \c get_toplevel is requested on a surface which has previously received a \c get_popup + * request, then the compositor will issue a protocol error. + * + * Roles are compared by pointer value, so any two objects of QWaylandSurfaceRole will be considered + * different roles, regardless of what their \l{name()}{names} are. A typical way of assigning a + * role is to have a static QWaylandSurfaceRole object to represent it. + * + * \code + * class MyShellSurfaceSubType + * { + * static QWaylandSurfaceRole s_role; + * // ... + * }; + * + * // ... + * + * surface->setRole(&MyShellSurfaceSubType::s_role, resource->handle, MY_ERROR_CODE); + * \endcode + */ + +/*! + * \fn QWaylandSurfaceRole::QWaylandSurfaceRole(const QByteArray &name) + * + * Creates a QWaylandSurfaceRole and assigns it \a name. The name is used in error messages + * involving this QWaylandSurfaceRole. + */ + +/*! + * \fn const QByteArray QWaylandSurfaceRole::name() + * + * Returns the name of the QWaylandSurfaceRole. The name is used in error messages involving this + * QWaylandSurfaceRole, for example if an attempt is made to change the role of a surface. + */ + +/*! * \qmltype WaylandSurface + * \instantiates QWaylandSurface * \inqmlmodule QtWayland.Compositor * \since 5.8 * \brief Represents a rectangular area on an output device. @@ -388,7 +442,7 @@ QWaylandSurface::~QWaylandSurface() } /*! - * \qmlmethod void QtWaylandCompositor::WaylandSurface::initialize(WaylandCompositor compositor, WaylandClient client, int id, int version) + * \qmlmethod void QtWayland.Compositor::WaylandSurface::initialize(WaylandCompositor compositor, WaylandClient client, int id, int version) * * Initializes the WaylandSurface with the given \a compositor and \a client, and with the given \a id * and \a version. @@ -423,7 +477,7 @@ bool QWaylandSurface::isInitialized() const } /*! - * \qmlproperty WaylandClient QtWaylandCompositor::WaylandSurface::client + * \qmlproperty WaylandClient QtWayland.Compositor::WaylandSurface::client * * This property holds the client using this WaylandSurface. */ @@ -454,7 +508,7 @@ QWaylandClient *QWaylandSurface::client() const } /*! - * \qmlproperty bool QtWaylandCompositor::WaylandSurface::hasContent + * \qmlproperty bool QtWayland.Compositor::WaylandSurface::hasContent * * This property holds whether the WaylandSurface has content. */ @@ -471,7 +525,7 @@ bool QWaylandSurface::hasContent() const } /*! - * \qmlproperty rect QtWaylandCompositor::WaylandSurface::sourceGeometry + * \qmlproperty rect QtWayland.Compositor::WaylandSurface::sourceGeometry * \since 5.13 * * This property describes the portion of the attached Wayland buffer that should @@ -502,7 +556,7 @@ QRectF QWaylandSurface::sourceGeometry() const } /*! - * \qmlproperty size QtWaylandCompositor::WaylandSurface::destinationSize + * \qmlproperty size QtWayland.Compositor::WaylandSurface::destinationSize * \since 5.13 * * This property holds the size of this WaylandSurface in surface coordinates. @@ -527,7 +581,7 @@ QSize QWaylandSurface::destinationSize() const } /*! - * \qmlproperty size QtWaylandCompositor::WaylandSurface::bufferSize + * \qmlproperty size QtWayland.Compositor::WaylandSurface::bufferSize * * This property holds the size of the current buffer of this WaylandSurface in pixels, * not in surface coordinates. @@ -555,28 +609,8 @@ QSize QWaylandSurface::bufferSize() const return d->bufferSize; } -#if QT_DEPRECATED_SINCE(5, 13) -/*! - * \qmlproperty size QtWaylandCompositor::WaylandSurface::size - * \obsolete use bufferSize or destinationSize instead - * - * This property has been deprecated, use \l bufferSize or \l destinationSize instead. - */ - -/*! - * \property QWaylandSurface::size - * \obsolete use bufferSize or destinationSize instead - * - * This property has been deprecated, use \l bufferSize or \l destinationSize instead. - */ -QSize QWaylandSurface::size() const -{ - return bufferSize(); -} -#endif - /*! - * \qmlproperty size QtWaylandCompositor::WaylandSurface::bufferScale + * \qmlproperty size QtWayland.Compositor::WaylandSurface::bufferScale * * This property holds the WaylandSurface's buffer scale. The buffer scale lets * a client supply higher resolution buffer data for use on high resolution @@ -597,7 +631,7 @@ int QWaylandSurface::bufferScale() const } /*! - * \qmlproperty enum QtWaylandCompositor::WaylandSurface::contentOrientation + * \qmlproperty enum QtWayland.Compositor::WaylandSurface::contentOrientation * * This property holds the orientation of the WaylandSurface's contents. * @@ -627,7 +661,7 @@ Qt::ScreenOrientation QWaylandSurface::contentOrientation() const */ /*! - * \qmlproperty enum QtWaylandCompositor::WaylandSurface::origin + * \qmlproperty enum QtWayland.Compositor::WaylandSurface::origin * * This property holds the origin of the WaylandSurface's buffer, or * WaylandSurface.OriginTopLeft if the surface has no buffer. @@ -666,7 +700,7 @@ QWaylandCompositor *QWaylandSurface::compositor() const void QWaylandSurface::frameStarted() { Q_D(QWaylandSurface); - for (QtWayland::FrameCallback *c : qAsConst(d->frameCallbacks)) + for (QtWayland::FrameCallback *c : std::as_const(d->frameCallbacks)) c->canSend = true; } @@ -718,7 +752,7 @@ bool QWaylandSurface::inputRegionContains(const QPointF &position) const } /*! - * \qmlmethod void QtWaylandCompositor::WaylandSurface::destroy() + * \qmlmethod void QtWayland.Compositor::WaylandSurface::destroy() * * Destroys the WaylandSurface. */ @@ -733,7 +767,7 @@ void QWaylandSurface::destroy() } /*! - * \qmlmethod bool QtWaylandCompositor::WaylandSurface::isDestroyed() + * \qmlmethod bool QtWayland.Compositor::WaylandSurface::isDestroyed() * * Returns \c true if the WaylandSurface has been destroyed. Otherwise returns \c false. */ @@ -748,7 +782,7 @@ bool QWaylandSurface::isDestroyed() const } /*! - * \qmlproperty bool QtWaylandCompositor::WaylandSurface::cursorSurface + * \qmlproperty bool QtWayland.Compositor::WaylandSurface::cursorSurface * * This property holds whether the WaylandSurface is a cursor surface. */ @@ -775,7 +809,7 @@ bool QWaylandSurface::isCursorSurface() const } /*! - * \qmlproperty bool QtWaylandCompositor::WaylandSurface::inhibitsIdle + * \qmlproperty bool QtWayland.Compositor::WaylandSurface::inhibitsIdle * \since 5.14 * * This property holds whether this surface is intended to inhibit the idle @@ -799,6 +833,27 @@ bool QWaylandSurface::inhibitsIdle() const return !d->idleInhibitors.isEmpty(); } +/*! + * \qmlproperty bool QtWayland.Compositor::WaylandSurface::isOpaque + * \since 6.4 + * + * This property holds whether the surface is fully opaque, as reported by the + * client through the set_opaque_region request. + */ + +/*! + * \property QWaylandSurface::isOpaque + * \since 6.4 + * + * This property holds whether the surface is fully opaque, as reported by the + * client through the set_opaque_region request. + */ +bool QWaylandSurface::isOpaque() const +{ + Q_D(const QWaylandSurface); + return d->isOpaque; +} + #if QT_CONFIG(im) QWaylandInputMethodControl *QWaylandSurface::inputMethodControl() const { @@ -900,10 +955,19 @@ struct wl_resource *QWaylandSurface::resource() const } /*! - * Sets a \a role on the surface. A role defines how a surface will be mapped on screen; without a role - * a surface is supposed to be hidden. Only one role can be set on a surface, at all times. Although - * setting the same role many times is allowed, attempting to change the role of a surface will trigger - * a protocol error to the \a errorResource and send an \a errorCode to the client. + * Sets a \a role on the surface. A role defines how a surface will be mapped on screen; without a + * role a surface is supposed to be hidden. Once a role is assigned to a surface, this becomes its + * permanent role. Any subsequent call to \c setRole() with a different role will trigger a + * protocol error to the \a errorResource and send an \a errorCode to the client. Enforcing this + * requirement is the main purpose of the surface role. + * + * The \a role is compared by pointer value. Any two objects of QWaylandSurfaceRole will be + * considered different roles, regardless of their names. + * + * The surface role is set internally by protocol implementations when a surface is adopted for a + * specific purpose, for example in a \l{Shell Extensions - Qt Wayland Compositor}{shell extension}. + * Unless you are developing extensions which use surfaces in this way, you should not call this + * function. * * Returns true if a role can be assigned; false otherwise. */ @@ -1011,7 +1075,7 @@ void QWaylandSurfacePrivate::Subsurface::subsurface_set_desync(wl_subsurface::Re } /*! - * \qmlsignal QtWaylandCompositor::WaylandSurface::childAdded(WaylandSurface child) + * \qmlsignal QtWayland.Compositor::WaylandSurface::childAdded(WaylandSurface child) * * This signal is emitted when a wl_subsurface, \a child, has been added to the surface. */ @@ -1023,7 +1087,7 @@ void QWaylandSurfacePrivate::Subsurface::subsurface_set_desync(wl_subsurface::Re */ /*! - * \qmlsignal QtWaylandCompositor::WaylandSurface::surfaceDestroyed() + * \qmlsignal QtWayland.Compositor::WaylandSurface::surfaceDestroyed() * * This signal is emitted when the corresponding wl_surface is destroyed. */ @@ -1035,7 +1099,7 @@ void QWaylandSurfacePrivate::Subsurface::subsurface_set_desync(wl_subsurface::Re */ /*! - * \qmlsignal void QtWaylandCompositor::WaylandSurface::dragStarted(WaylandDrag drag) + * \qmlsignal void QtWayland.Compositor::WaylandSurface::dragStarted(WaylandDrag drag) * * This signal is emitted when a \a drag has started from this surface. */ @@ -1064,3 +1128,5 @@ void QWaylandSurfacePrivate::Subsurface::subsurface_set_desync(wl_subsurface::Re */ QT_END_NAMESPACE + +#include "moc_qwaylandsurface.cpp" diff --git a/src/compositor/compositor_api/qwaylandsurface.h b/src/compositor/compositor_api/qwaylandsurface.h index c2ea20059..0494a091e 100644 --- a/src/compositor/compositor_api/qwaylandsurface.h +++ b/src/compositor/compositor_api/qwaylandsurface.h @@ -1,39 +1,15 @@ -/**************************************************************************** -** -** Copyright (C) 2017-2015 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017-2015 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDSURFACE_H #define QWAYLANDSURFACE_H #include <QtWaylandCompositor/qtwaylandcompositorglobal.h> +#include <QtWaylandCompositor/qwaylandcompositor.h> #include <QtWaylandCompositor/qwaylandcompositorextension.h> #include <QtWaylandCompositor/qwaylandclient.h> +#include <QtWaylandCompositor/qwaylanddrag.h> #include <QtCore/QScopedPointer> #include <QtGui/QImage> @@ -46,14 +22,10 @@ struct wl_resource; QT_BEGIN_NAMESPACE class QTouchEvent; -class QWaylandClient; class QWaylandSurfacePrivate; -class QWaylandCompositor; class QWaylandBufferRef; class QWaylandView; -class QWaylandSurfaceOp; class QWaylandInputMethodControl; -class QWaylandDrag; class QWaylandSurfaceRole { @@ -66,24 +38,27 @@ private: QByteArray m_name; }; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandSurface : public QWaylandObject +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandSurface : public QWaylandObject { Q_OBJECT Q_DECLARE_PRIVATE(QWaylandSurface) Q_PROPERTY(QWaylandClient *client READ client CONSTANT) - Q_PROPERTY(QRectF sourceGeometry READ sourceGeometry NOTIFY sourceGeometryChanged REVISION 13) - Q_PROPERTY(QSize destinationSize READ destinationSize NOTIFY destinationSizeChanged REVISION 13) - Q_PROPERTY(QSize bufferSize READ bufferSize NOTIFY bufferSizeChanged REVISION 13) -#if QT_DEPRECATED_SINCE(5, 13) - Q_PROPERTY(QSize size READ size NOTIFY sizeChanged) // Qt 6: Remove -#endif + Q_PROPERTY(QRectF sourceGeometry READ sourceGeometry NOTIFY sourceGeometryChanged REVISION(1, 13)) + Q_PROPERTY(QSize destinationSize READ destinationSize NOTIFY destinationSizeChanged REVISION(1, 13)) + Q_PROPERTY(QSize bufferSize READ bufferSize NOTIFY bufferSizeChanged REVISION(1, 13)) Q_PROPERTY(int bufferScale READ bufferScale NOTIFY bufferScaleChanged) Q_PROPERTY(Qt::ScreenOrientation contentOrientation READ contentOrientation NOTIFY contentOrientationChanged) Q_PROPERTY(QWaylandSurface::Origin origin READ origin NOTIFY originChanged) Q_PROPERTY(bool hasContent READ hasContent NOTIFY hasContentChanged) Q_PROPERTY(bool cursorSurface READ isCursorSurface WRITE markAsCursorSurface NOTIFY cursorSurfaceChanged) - Q_PROPERTY(bool inhibitsIdle READ inhibitsIdle NOTIFY inhibitsIdleChanged REVISION 14) - + Q_PROPERTY(bool inhibitsIdle READ inhibitsIdle NOTIFY inhibitsIdleChanged REVISION(1, 14)) + Q_PROPERTY(bool isOpaque READ isOpaque NOTIFY isOpaqueChanged REVISION(6, 4)) + Q_MOC_INCLUDE("qwaylanddrag.h") + Q_MOC_INCLUDE("qwaylandcompositor.h") + + QML_NAMED_ELEMENT(WaylandSurfaceBase) + QML_ADDED_IN_VERSION(1, 0) + QML_UNCREATABLE("Cannot create instance of WaylandSurfaceBase, use WaylandSurface instead") public: enum Origin { OriginTopLeft, @@ -108,9 +83,6 @@ public: QRectF sourceGeometry() const; QSize destinationSize() const; -#if QT_DEPRECATED_SINCE(5, 13) - QT_DEPRECATED QSize size() const; -#endif QSize bufferSize() const; int bufferScale() const; @@ -141,6 +113,7 @@ public: bool isCursorSurface() const; bool inhibitsIdle() const; + bool isOpaque() const; #if QT_CONFIG(im) QWaylandInputMethodControl *inputMethodControl() const; @@ -159,12 +132,9 @@ Q_SIGNALS: void damaged(const QRegion &rect); void parentChanged(QWaylandSurface *newParent, QWaylandSurface *oldParent); void childAdded(QWaylandSurface *child); - Q_REVISION(13) void sourceGeometryChanged(); - Q_REVISION(13) void destinationSizeChanged(); -#if QT_DEPRECATED_SINCE(5, 13) - QT_DEPRECATED void sizeChanged(); -#endif - Q_REVISION(13) void bufferSizeChanged(); + Q_REVISION(1, 13) void sourceGeometryChanged(); + Q_REVISION(1, 13) void destinationSizeChanged(); + Q_REVISION(1, 13) void bufferSizeChanged(); void bufferScaleChanged(); void offsetForNextFrame(const QPoint &offset); void contentOrientationChanged(); @@ -176,6 +146,7 @@ Q_SIGNALS: void dragStarted(QWaylandDrag *drag); void cursorSurfaceChanged(); Q_REVISION(14) void inhibitsIdleChanged(); + Q_REVISION(6, 4) void isOpaqueChanged(); void configure(bool hasBuffer); void redraw(); diff --git a/src/compositor/compositor_api/qwaylandsurface_p.h b/src/compositor/compositor_api/qwaylandsurface_p.h index db0df8d1a..b4df7498e 100644 --- a/src/compositor/compositor_api/qwaylandsurface_p.h +++ b/src/compositor/compositor_api/qwaylandsurface_p.h @@ -1,32 +1,6 @@ -/**************************************************************************** -** -** Copyright (C) 2017 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> -** Copyright (C) 2017 Jolla Ltd, author: <giulio.camuffo@jollamobile.com> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> +// Copyright (C) 2017 Jolla Ltd, author: <giulio.camuffo@jollamobile.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDSURFACE_P_H #define QWAYLANDSURFACE_P_H @@ -51,7 +25,7 @@ #include <QtWaylandCompositor/private/qwlregion_p.h> -#include <QtCore/QVector> +#include <QtCore/QList> #include <QtCore/QRect> #include <QtGui/QRegion> #include <QtGui/QImage> @@ -66,19 +40,20 @@ #include <QtWaylandCompositor/private/qwaylandviewporter_p.h> #include <QtWaylandCompositor/private/qwaylandidleinhibitv1_p.h> +#include <QtCore/qpointer.h> + QT_BEGIN_NAMESPACE class QWaylandCompositor; class QWaylandSurface; class QWaylandView; -class QWaylandSurfaceInterface; class QWaylandInputMethodControl; namespace QtWayland { class FrameCallback; } -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandSurfacePrivate : public QObjectPrivate, public QtWaylandServer::wl_surface +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandSurfacePrivate : public QObjectPrivate, public QtWaylandServer::wl_surface { public: static QWaylandSurfacePrivate *get(QWaylandSurface *surface); @@ -116,6 +91,7 @@ protected: struct wl_resource *buffer, int x, int y) override; void surface_damage(Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height) override; + void surface_damage_buffer(Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height) override; void surface_frame(Resource *resource, uint32_t callback) override; void surface_set_opaque_region(Resource *resource, @@ -140,7 +116,8 @@ public: //member variables struct { QWaylandBufferRef buffer; - QRegion damage; + QRegion surfaceDamage; + QRegion bufferDamage; QPoint offset; bool newlyAttached = false; QRegion inputRegion; @@ -158,7 +135,7 @@ public: //member variables QList<QPointer<QWaylandSurface>> subsurfaceChildren; - QVector<QWaylandIdleInhibitManagerV1Private::Inhibitor *> idleInhibitors; + QList<QWaylandIdleInhibitManagerV1Private::Inhibitor *> idleInhibitors; QRegion inputRegion; QRegion opaqueRegion; @@ -171,6 +148,7 @@ public: //member variables bool destroyed = false; bool hasContent = false; bool isInitialized = false; + bool isOpaque = false; Qt::ScreenOrientation contentOrientation = Qt::PrimaryOrientation; QWindow::Visibility visibility; #if QT_CONFIG(im) diff --git a/src/compositor/compositor_api/qwaylandsurfacegrabber.cpp b/src/compositor/compositor_api/qwaylandsurfacegrabber.cpp index fd530cba5..5f24d1c77 100644 --- a/src/compositor/compositor_api/qwaylandsurfacegrabber.cpp +++ b/src/compositor/compositor_api/qwaylandsurfacegrabber.cpp @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 Klarälvdalens Datakonsult AB (KDAB). -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 Klarälvdalens Datakonsult AB (KDAB). +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "qwaylandsurfacegrabber.h" @@ -109,3 +83,5 @@ void QWaylandSurfaceGrabber::grab() } QT_END_NAMESPACE + +#include "moc_qwaylandsurfacegrabber.cpp" diff --git a/src/compositor/compositor_api/qwaylandsurfacegrabber.h b/src/compositor/compositor_api/qwaylandsurfacegrabber.h index 869ae70c2..b21572ec0 100644 --- a/src/compositor/compositor_api/qwaylandsurfacegrabber.h +++ b/src/compositor/compositor_api/qwaylandsurfacegrabber.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 Klarälvdalens Datakonsult AB (KDAB). -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 Klarälvdalens Datakonsult AB (KDAB). +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDSURFACEGRABBER_H #define QWAYLANDSURFACEGRABBER_H @@ -38,7 +12,7 @@ QT_BEGIN_NAMESPACE class QWaylandSurface; class QWaylandSurfaceGrabberPrivate; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandSurfaceGrabber : public QObject +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandSurfaceGrabber : public QObject { Q_OBJECT Q_DECLARE_PRIVATE(QWaylandSurfaceGrabber) diff --git a/src/compositor/compositor_api/qwaylandtouch.cpp b/src/compositor/compositor_api/qwaylandtouch.cpp index 87edaf9da..39aeac491 100644 --- a/src/compositor/compositor_api/qwaylandtouch.cpp +++ b/src/compositor/compositor_api/qwaylandtouch.cpp @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "qwaylandtouch.h" #include "qwaylandtouch_p.h" @@ -99,7 +73,7 @@ int QWaylandTouchPrivate::toSequentialWaylandId(int touchId) return availableId; } ids.append(touchId); - return ids.length() - 1; + return ids.size() - 1; } /*! @@ -162,6 +136,9 @@ uint QWaylandTouch::sendTouchPointEvent(QWaylandSurface *surface, int id, const case Qt::TouchPointStationary: // stationary points are not sent through wayland, the client must cache them break; + case Qt::TouchPointUnknownState: + // Ignored + break; } return serial; @@ -208,17 +185,17 @@ void QWaylandTouch::sendFullTouchEvent(QWaylandSurface *surface, QTouchEvent *ev if (ext && ext->postTouchEvent(event, surface)) return; - const QList<QTouchEvent::TouchPoint> points = event->touchPoints(); + const QList<QTouchEvent::TouchPoint> points = event->points(); if (points.isEmpty()) return; - const int pointCount = points.count(); + const int pointCount = points.size(); for (int i = 0; i < pointCount; ++i) { const QTouchEvent::TouchPoint &tp(points.at(i)); // Convert the local pos in the compositor window to surface-relative. const int id = d->toSequentialWaylandId(tp.id()); - sendTouchPointEvent(surface, id, tp.pos(), tp.state()); - if (tp.state() == Qt::TouchPointReleased) + sendTouchPointEvent(surface, id, tp.position(), Qt::TouchPointState(tp.state())); + if (tp.state() == QEventPoint::Released) d->ids[id] = -1; } sendFrameEvent(surface->client()); @@ -234,3 +211,5 @@ void QWaylandTouch::addClient(QWaylandClient *client, uint32_t id, uint32_t vers } QT_END_NAMESPACE + +#include "moc_qwaylandtouch.cpp" diff --git a/src/compositor/compositor_api/qwaylandtouch.h b/src/compositor/compositor_api/qwaylandtouch.h index e32c6aab7..bdaa68eb6 100644 --- a/src/compositor/compositor_api/qwaylandtouch.h +++ b/src/compositor/compositor_api/qwaylandtouch.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDTOUCH_H #define QWAYLANDTOUCH_H @@ -46,7 +20,7 @@ class QWaylandView; class QWaylandClient; class QWaylandSurface; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandTouch : public QWaylandObject +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandTouch : public QWaylandObject { Q_OBJECT Q_DECLARE_PRIVATE(QWaylandTouch) diff --git a/src/compositor/compositor_api/qwaylandtouch_p.h b/src/compositor/compositor_api/qwaylandtouch_p.h index 7638fb6f6..eb5d4e783 100644 --- a/src/compositor/compositor_api/qwaylandtouch_p.h +++ b/src/compositor/compositor_api/qwaylandtouch_p.h @@ -1,32 +1,6 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Copyright (C) 2017 Klarälvdalens Datakonsult AB (KDAB). -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// Copyright (C) 2017 Klarälvdalens Datakonsult AB (KDAB). +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QTWAYLAND_QWLTOUCH_P_H #define QTWAYLAND_QWLTOUCH_P_H @@ -50,13 +24,14 @@ #include <QtWaylandCompositor/QWaylandCompositor> #include <QtCore/QPoint> +#include <QtCore/qvarlengtharray.h> #include <QtCore/private/qobject_p.h> #include <QtWaylandCompositor/private/qwayland-server-wayland.h> QT_BEGIN_NAMESPACE -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandTouchPrivate : public QObjectPrivate, public QtWaylandServer::wl_touch +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandTouchPrivate : public QObjectPrivate, public QtWaylandServer::wl_touch { Q_DECLARE_PUBLIC(QWaylandTouch) public: diff --git a/src/compositor/compositor_api/qwaylandview.cpp b/src/compositor/compositor_api/qwaylandview.cpp index 844da7c5d..f8a0f38af 100644 --- a/src/compositor/compositor_api/qwaylandview.cpp +++ b/src/compositor/compositor_api/qwaylandview.cpp @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 Jolla Ltd, author: <giulio.camuffo@jollamobile.com> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 Jolla Ltd, author: <giulio.camuffo@jollamobile.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "qwaylandview.h" #include "qwaylandview_p.h" @@ -37,6 +11,7 @@ #include <QtWaylandCompositor/private/qwaylandoutput_p.h> #include <QtCore/QMutex> +#include <QtCore/qpointer.h> QT_BEGIN_NAMESPACE @@ -54,6 +29,7 @@ void QWaylandViewPrivate::markSurfaceAsDestroyed(QWaylandSurface *surface) /*! * \qmltype WaylandView + * \instantiates QWaylandView * \inqmlmodule QtWayland.Compositor * \since 5.8 * \brief Represents a view of a surface on an output. @@ -109,7 +85,7 @@ QObject *QWaylandView::renderObject() const } /*! - * \qmlproperty WaylandSurface QtWaylandCompositor::WaylandView::surface + * \qmlproperty WaylandSurface QtWayland.Compositor::WaylandView::surface * * This property holds the surface viewed by this WaylandView. */ @@ -168,7 +144,7 @@ void QWaylandView::setSurface(QWaylandSurface *newSurface) } /*! - * \qmlproperty WaylandOutput QtWaylandCompositor::WaylandView::output + * \qmlproperty WaylandOutput QtWayland.Compositor::WaylandView::output * * This property holds the output on which this view displays its surface. */ @@ -283,7 +259,7 @@ QRegion QWaylandView::currentDamage() } /*! - * \qmlproperty bool QtWaylandCompositor::WaylandView::bufferLocked + * \qmlproperty bool QtWayland.Compositor::WaylandView::bufferLocked * * This property holds whether the view's buffer is currently locked. When * the buffer is locked, advance() will not advance to the next buffer and @@ -316,7 +292,7 @@ void QWaylandView::setBufferLocked(bool locked) emit bufferLockedChanged(); } /*! - * \qmlproperty bool QtWaylandCompositor::WaylandView::allowDiscardFrontBuffer + * \qmlproperty bool QtWayland.Compositor::WaylandView::allowDiscardFrontBuffer * * By default, the view locks the current buffer until advance() is called. Set this property * to true to allow Qt to release the buffer when the primary view is no longer using it. @@ -388,3 +364,5 @@ struct wl_resource *QWaylandView::surfaceResource() const } QT_END_NAMESPACE + +#include "moc_qwaylandview.cpp" diff --git a/src/compositor/compositor_api/qwaylandview.h b/src/compositor/compositor_api/qwaylandview.h index dea5be8b2..a48dae5f6 100644 --- a/src/compositor/compositor_api/qwaylandview.h +++ b/src/compositor/compositor_api/qwaylandview.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 Jolla Ltd, author: <giulio.camuffo@jollamobile.com> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 Jolla Ltd, author: <giulio.camuffo@jollamobile.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDSURFACEVIEW_H #define QWAYLANDSURFACEVIEW_H @@ -42,7 +16,7 @@ class QWaylandSurface; class QWaylandViewPrivate; class QWaylandOutput; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandView : public QObject +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandView : public QObject { Q_OBJECT Q_DECLARE_PRIVATE(QWaylandView) @@ -51,6 +25,7 @@ class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandView : public QObject Q_PROPERTY(QWaylandOutput *output READ output WRITE setOutput NOTIFY outputChanged) Q_PROPERTY(bool bufferLocked READ isBufferLocked WRITE setBufferLocked NOTIFY bufferLockedChanged) Q_PROPERTY(bool allowDiscardFrontBuffer READ allowDiscardFrontBuffer WRITE setAllowDiscardFrontBuffer NOTIFY allowDiscardFrontBufferChanged) + Q_MOC_INCLUDE("qwaylandoutput.h") public: QWaylandView(QObject *renderObject = nullptr, QObject *parent = nullptr); ~QWaylandView() override; diff --git a/src/compositor/compositor_api/qwaylandview_p.h b/src/compositor/compositor_api/qwaylandview_p.h index 685705fa7..01f582738 100644 --- a/src/compositor/compositor_api/qwaylandview_p.h +++ b/src/compositor/compositor_api/qwaylandview_p.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDSURFACEVIEW_P_H #define QWAYLANDSURFACEVIEW_P_H diff --git a/src/compositor/configure.cmake b/src/compositor/configure.cmake new file mode 100644 index 000000000..10f1d4a20 --- /dev/null +++ b/src/compositor/configure.cmake @@ -0,0 +1,74 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +#### Inputs + + + +#### Libraries + +if((LINUX) OR QT_FIND_ALL_PACKAGES_ALWAYS) + qt_find_package(Waylandkms PROVIDED_TARGETS PkgConfig::Waylandkms MODULE_NAME waylandcompositor QMAKE_LIB wayland-kms) +endif() +# special case begin + +# Even if libdrm is already found by qtbase we still need to list it as dependency for some of our +# plugins +if(TARGET Libdrm::Libdrm) + qt_internal_disable_find_package_global_promotion(Libdrm::Libdrm) +endif() +qt_find_package(Libdrm PROVIDED_TARGETS Libdrm::Libdrm MODULE_NAME gui QMAKE_LIB drm MARK_OPTIONAL) + + +#### Tests + +# dmabuf-client-buffer +qt_config_compile_test(dmabuf_client_buffer + LABEL "Linux Client dma-buf Buffer Sharing" + LIBRARIES + EGL::EGL + Libdrm::Libdrm + CODE +" +#include <EGL/egl.h> +#include <EGL/eglext.h> +#include <drm_mode.h> +#include <drm_fourcc.h> + +int main(int argc, char **argv) +{ + (void)argc; (void)argv; + /* BEGIN TEST: */ +// test if DMA BUF is supported +#ifndef EGL_LINUX_DMA_BUF_EXT +#error DMA BUF Extension not available +#endif +// test if DMA BUF import modifier extension is supported +#ifndef EGL_EXT_image_dma_buf_import_modifiers +#error DMA BUF Import modifier extension not available +#endif +return 0; + /* END TEST: */ + return 0; +} +") + + +#### Features + +qt_feature("wayland-dmabuf-client-buffer" PRIVATE + LABEL "Linux dma-buf client buffer integration" + CONDITION QT_FEATURE_wayland_server AND QT_FEATURE_opengl AND QT_FEATURE_egl AND TEST_dmabuf_client_buffer +) +qt_feature("wayland-layer-integration-vsp2" PRIVATE + LABEL "VSP2 hardware layer integration" + CONDITION QT_FEATURE_wayland_server AND QT_FEATURE_eglfs_vsp2 AND Waylandkms_FOUND +) +qt_feature("wayland-compositor-quick" PUBLIC + LABEL "QtQuick integration for wayland compositor" + PURPOSE "Allows QtWayland compositor types to be used with QtQuick" + CONDITION QT_FEATURE_wayland_server AND TARGET Qt::Quick +) +qt_configure_add_summary_section(NAME "Qt Wayland Compositor Layer Plugins") +qt_configure_add_summary_entry(ARGS "wayland-layer-integration-vsp2") +qt_configure_end_summary_section() # end of "Qt Wayland Compositor Layer Plugins" section diff --git a/src/compositor/configure.json b/src/compositor/configure.json deleted file mode 100644 index 2af92ea67..000000000 --- a/src/compositor/configure.json +++ /dev/null @@ -1,280 +0,0 @@ -{ - "module": "waylandcompositor", - "condition": "module.gui", - "depends": [ - "gui-private" - ], - "testDir": "../../config.tests", - - "libraries": { - "wayland-server": { - "label": "wayland-server", - "headers": "wayland-version.h", - "test": { - "main": [ - "#if WAYLAND_VERSION_MAJOR < 1", - "# error Wayland 1.8.0 or higher required", - "#endif", - "#if WAYLAND_VERSION_MAJOR == 1", - "# if WAYLAND_VERSION_MINOR < 8", - "# error Wayland 1.8.0 or higher required", - "# endif", - "# if WAYLAND_VERSION_MINOR == 8", - "# if WAYLAND_VERSION_MICRO < 0", - "# error Wayland 1.8.0 or higher required", - "# endif", - "# endif", - "#endif" - ] - }, - "sources": [ - { "type": "pkgConfig", "args": "wayland-server" }, - "-lwayland-server" - ] - }, - "wayland-egl": { - "headers": "wayland-egl.h", - "test": { - "main": "struct wl_egl_window *window = wl_egl_window_create(0, 100, 100);" - }, - "sources": [ - { "type": "pkgConfig", "args": "wayland-egl" }, - "-lwayland-egl", - "-lEGL" - ] - }, - "wayland-kms": { - "label": "wayland-kms", - "test": { - "tail": [ - "extern \"C\" {", - "#include <math.h> /* may fail because of 'private:' in c++ type_traits.h */", - "#define private priv", - "#include <wayland-kms.h>", - "#undef private", - "}" - ], - "main": [ - "struct wl_resource *buffer = nullptr;", - "struct wl_kms_buffer *kmsBuffer = wayland_kms_buffer_get(buffer);" - ] - }, - "sources": [ - { "type": "pkgConfig", "args": "wayland-kms" }, - "-lwayland-kms" - ] - }, - "xcomposite": { - "headers": "X11/extensions/Xcomposite.h", - "test": { - "main": "XCompositeRedirectWindow((Display *)0,(Window) 0, CompositeRedirectManual);" - }, - "sources": [ - { "type": "pkgConfig", "args": "xcomposite" }, - "-lxcomposite" - ] - }, - "glx": { - "headers": "GL/glx.h", - "test": { - "main": [ - "Display *dpy = XOpenDisplay(0);", - "int items = 0;", - "GLXFBConfig *fbc = glXChooseFBConfig(dpy, DefaultScreen(dpy), 0 , &items);" - ] - }, - "sources": [ - { "type": "pkgConfig", "args": "x11 gl" }, - "-lX11 -lGl" - ] - } - }, - - "tests": { - "wayland-scanner": { - "type": "compile", - "test": "wayland_scanner", - "use": "wayland-server" - }, - "drm-egl-server": { - "type": "compile", - "test": { - "include": [ - "EGL/egl.h", - "EGL/eglext.h" - ], - "main": [ - "#ifdef EGL_MESA_drm_image", - "return 0;", - "#else", - "#error Requires EGL_MESA_drm_image to be defined", - "return 1;", - "#endif" - ] - }, - "use": "egl" - }, - "libhybris-egl-server": { - "type": "compile", - "test": { - "include": [ - "EGL/egl.h", - "EGL/eglext.h", - "hybris/eglplatformcommon/hybris_nativebufferext.h" - ], - "main": [ - "#ifdef EGL_HYBRIS_native_buffer", - "return 0;", - "#else", - "#error Requires EGL_HYBRIS_native_buffer to be defined", - "return 1;", - "#endif" - ] - }, - "use": "egl" - }, - "dmabuf-server-buffer": { - "label": "Linux dma-buf Buffer Sharing", - "type": "compile", - "test": { - "include": [ - "EGL/egl.h", - "EGL/eglext.h", - "drm_fourcc.h" - ], - "main": [ - "#ifdef EGL_LINUX_DMA_BUF_EXT", - "return 0;", - "#else", - "#error Requires EGL_LINUX_DMA_BUF_EXT", - "return 1;", - "#endif" - ] - }, - "use": "egl" - }, - "dmabuf-client-buffer": { - "label": "Linux Client dma-buf Buffer Sharing", - "type": "compile", - "test": { - "include": [ - "EGL/egl.h", - "EGL/eglext.h", - "drm_mode.h", - "drm_fourcc.h" - ], - "main": [ - "// test if DMA BUF is supported", - "#ifndef EGL_LINUX_DMA_BUF_EXT", - "#error DMA BUF Extension not available", - "#endif", - "// test if DMA BUF import modifier extension is supported", - "#ifndef EGL_EXT_image_dma_buf_import_modifiers", - "#error DMA BUF Import modifier extension not available", - "#endif", - "return 0;" - ] - }, - "use": "egl" - }, - "vulkan-server-buffer": { - "label": "Vulkan Buffer Sharing", - "type": "compile", - "test": { - "include": [ - "vulkan/vulkan.h" - ], - "main": [ - "VkExportMemoryAllocateInfoKHR exportAllocInfo = {};", - "exportAllocInfo.sType = VK_STRUCTURE_TYPE_EXPORT_MEMORY_ALLOCATE_INFO_KHR;", - "exportAllocInfo.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR;", - "return 0;" - ] - } - } - }, - - "features": { - "wayland-server": { - "label": "Qt Wayland Compositor", - "condition": "!config.win32 && libs.wayland-server && tests.wayland-scanner", - "output": [ "privateFeature" ] - }, - "wayland-datadevice": { - "condition": "features.draganddrop || features.clipboard", - "output": [ "privateFeature" ] - }, - "wayland-egl": { - "label": "EGL", - "condition": "features.wayland-server && features.opengl && features.egl && libs.wayland-egl", - "output": [ "privateFeature" ] - }, - "wayland-brcm": { - "label": "Raspberry Pi", - "condition": "features.wayland-server && features.eglfs_brcm", - "output": [ "privateFeature" ] - }, - "xcomposite-egl": { - "label": "XComposite EGL", - "condition": "features.wayland-server && features.egl && features.opengl && libs.xcomposite", - "output": [ "privateFeature" ] - }, - "xcomposite-glx": { - "label": "XComposite EGL", - "condition": "features.wayland-server && features.opengl && !features.opengles2 && libs.xcomposite && libs.glx", - "output": [ "privateFeature" ] - }, - "wayland-drm-egl-server-buffer": { - "label": "DRM EGL", - "condition": "features.wayland-server && features.opengl && features.egl && tests.drm-egl-server", - "output": [ "privateFeature" ] - }, - "wayland-libhybris-egl-server-buffer": { - "label": "libhybris EGL", - "condition": "features.wayland-server && features.opengl && features.egl && tests.libhybris-egl-server", - "output": [ "privateFeature" ] - }, - "wayland-dmabuf-server-buffer": { - "label": "Linux dma-buf server buffer integration", - "condition": "features.wayland-server && features.opengl && features.egl && tests.dmabuf-server-buffer", - "output": [ "privateFeature" ] - }, - "wayland-dmabuf-client-buffer": { - "label": "Linux dma-buf client buffer integration", - "condition": "features.wayland-server && features.opengl && features.egl && tests.dmabuf-client-buffer", - "output": [ "privateFeature" ] - }, - "wayland-vulkan-server-buffer": { - "label": "Vulkan-based server buffer integration", - "condition": "features.wayland-server && features.opengl && features.egl && tests.vulkan-server-buffer", - "output": [ "privateFeature" ] - }, - "wayland-shm-emulation-server-buffer": { - "label": "Shm emulation server buffer", - "condition": "features.wayland-server && features.opengl", - "output": [ "privateFeature" ] - }, - "wayland-layer-integration-vsp2": { - "label": "VSP2 hardware layer integration", - "condition": "features.wayland-server && features.eglfs_vsp2 && libs.wayland-kms", - "output": [ "privateFeature" ] - }, - "wayland-compositor-quick": { - "label": "QtQuick integration for wayland compositor", - "purpose": "Allows QtWayland compositor types to be used with QtQuick", - "condition": "features.wayland-server && module.quick && features.opengl", - "output": [ "publicFeature" ] - } - }, - - "summary": [ - "wayland-server", - { - "section": "Qt Wayland Compositor Layer Plugins", - "condition": "features.wayland-server", - "entries": [ - "wayland-layer-integration-vsp2" - ] - } - ] -} diff --git a/src/compositor/doc/qtwaylandcompositor.qdocconf b/src/compositor/doc/qtwaylandcompositor.qdocconf index 45928b640..fae83583f 100644 --- a/src/compositor/doc/qtwaylandcompositor.qdocconf +++ b/src/compositor/doc/qtwaylandcompositor.qdocconf @@ -4,6 +4,7 @@ include($QT_INSTALL_DOCS/config/exampleurl-qtwayland.qdocconf) project = QtWaylandCompositor description = Qt Wayland Compositor Reference Documentation version = $QT_VERSION +buildversion = Qt Wayland Compositor | Commercial or GPLv3 qhp.projects = QtWaylandCompositor @@ -12,9 +13,6 @@ qhp.QtWaylandCompositor.namespace = org.qt-project.qtw qhp.QtWaylandCompositor.virtualFolder = qtwaylandcompositor qhp.QtWaylandCompositor.indexTitle = Qt Wayland Compositor qhp.QtWaylandCompositor.indexRoot = -qhp.QtWaylandCompositor.filterAttributes = qtwaylandcompositor $QT_VERSION qtrefdoc -qhp.QtWaylandCompositor.customFilters.Qt.name = QtWaylandCompositor $QT_VERSION -qhp.QtWaylandCompositor.customFilters.Qt.filterAttributes = qtwaylandcompositor $QT_VERSION qhp.QtWaylandCompositor.subprojects = qmltypes classes examples qhp.QtWaylandCompositor.subprojects.qmltypes.title = QML Types @@ -30,18 +28,41 @@ qhp.QtWaylandCompositor.subprojects.examples.indexTitle = Qt Wayland Composi qhp.QtWaylandCompositor.subprojects.examples.selectors = fake:example qhp.QtWaylandCompositor.subprojects.examples.sortPages = true -depends += qtcore qtqml qtquick qtdoc qtquickcontrols qmake qtgui +depends += qtcore \ + qtqml \ + qtquick \ + qtdoc \ + qtquickcontrols \ + qmake \ + qtgui \ + qtqmlmodels \ + qtwidgets \ + qtvirtualkeyboard \ + qtcmake \ + qtopengl \ + qtwaylandclient exampledirs += ../../../examples/wayland -headerdirs += .. -sourcedirs += .. +headerdirs += \ + ../ \ + ../../imports/ +sourcedirs += \ + ../ \ + ../../imports/ imagedirs += images examplesinstallpath = wayland -Cpp.ignoretokens += Q_WAYLAND_COMPOSITOR_EXPORT -Cpp.ignoredirectives += Q_DECLARE_LOGGING_CATEGORY +# Add generic thumbnail for all examples +manifestmeta.thumbnail.names = * + +manifestmeta.highlighted.names = \ + "QtWaylandCompositor/Minimal QML" \ + "QtWaylandCompositor/IVI Compositor" navigation.landingpage = "Qt Wayland Compositor" navigation.qmltypespage = "Qt Wayland Compositor QML Types" navigation.cppclassespage = "Qt Wayland Compositor C++ Classes" + +# Enforce zero documentation warnings +warninglimit = 0 diff --git a/src/compositor/doc/src/cmake/qt_generate_wayland_protocol_server_sources.qdoc b/src/compositor/doc/src/cmake/qt_generate_wayland_protocol_server_sources.qdoc new file mode 100644 index 000000000..5a5849463 --- /dev/null +++ b/src/compositor/doc/src/cmake/qt_generate_wayland_protocol_server_sources.qdoc @@ -0,0 +1,47 @@ +// Copyright (C) 2024 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only + +/*! +\page qt-generate-wayland-protocol-server-sources.html +\ingroup cmake-commands-qtwaylandcompositor + +\title qt_generate_wayland_protocol_server_sources +\keyword qt6_generate_wayland_protocol_server_sources + +\summary {Generates server-side C++ bindings for a Wayland protocol .XML file} + +\cmakecommandsince 6.0 + +The command is defined in the \c WaylandCompositor component of the \c Qt6 package, which +can be loaded like so: + +\badcode +find_package(Qt6 REQUIRED COMPONENTS WaylandCompositor) +\endcode + +\section1 Synopsis + +\badcode +qt_generate_wayland_protocol_server_sources(target + FILES file1.xml [file2.xml ...]) +\endcode + +\versionlessCMakeCommandsNote qt6_generate_wayland_protocol_server_sources() + +\section1 Description + +qt_generate_wayland_protocol_server_sources() creates the build steps to run \c{waylandscanner} and +\c{qtwaylandscanner} on one or more Wayland protocol files. The tools will in turn generate binding +code in C and C++ for implementing the protocols, and the resulting files will be built as part +of the \c target. + +qt_generate_wayland_protocol_server_sources() will trigger generation of the files needed to +implement the compositor side of the protocol. + +\l{qt_generate_wayland_protocol_client_sources}{qt_generate_wayland_protocol_client_sources()} +is the equivalent function for the client. + +See the \l{Custom Shell} or \l{Custom Extension} examples for a demonstration of how to use these +functions. +*/ + diff --git a/src/compositor/doc/src/qt6-changes.qdoc b/src/compositor/doc/src/qt6-changes.qdoc new file mode 100644 index 000000000..7a9a12016 --- /dev/null +++ b/src/compositor/doc/src/qt6-changes.qdoc @@ -0,0 +1,30 @@ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only + +/*! + \page qtwayland-changes-qt6.html + \title Porting to Qt 6 - Qt Wayland Compositor + + Qt 6 is a result of the conscious effort to make the framework more + efficient and easy to use. + + We try to maintain binary and source compatibility for all the public + APIs in each release. But some changes were inevitable in an effort to + make Qt a better framework. + + In this topic we summarize those changes in Qt Wayland Compositor, and + provide guidance to handle them. + + \section1 Import of Shell Classes + + In Qt 5, a few auxiliary classes were available through the Qt Wayland + Compositor namespace. In order to improve the logical separation of + these from the primary functionality of the compositor, they have been + moved into separate imports in Qt 6. + + \list + \li \l WlShell types are now available in \c QtWayland.Compositor.WlShell + \li \l XdgShell types are now available in \c QtWayland.Compositor.XdgShell + \li \l IviApplication types are now available in \c QtWayland.Compositor.IviApplication + \endlist +*/ diff --git a/src/compositor/doc/src/qtwaylandcompositor-cpp.qdoc b/src/compositor/doc/src/qtwaylandcompositor-cpp.qdoc index c406b81e1..a61278d73 100644 --- a/src/compositor/doc/src/qtwaylandcompositor-cpp.qdoc +++ b/src/compositor/doc/src/qtwaylandcompositor-cpp.qdoc @@ -1,49 +1,26 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Free Documentation License Usage -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. Please review the following information to ensure -** the GNU Free Documentation License version 1.3 requirements -** will be met: https://www.gnu.org/licenses/fdl-1.3.html. -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only /*! \module QtWaylandCompositor \title Qt Wayland Compositor C++ Classes \ingroup modules + \qtcmakepackage WaylandCompositor \qtvariable waylandcompositor \brief Provides C++ classes for writing custom Wayland display servers. - To include the definitions of the module's classes, use the following directive: + \section1 Using the Module - \code - #include <QtWaylandCompositor> - \endcode + \include {module-use.qdocinc} {using the c++ api} {WaylandCompositor} - To link against the module, add this line to your \l qmake \c .pro file: + \section2 Building with CMake - \code - QT += waylandcompositor - \endcode + \include {module-use.qdocinc} {building with cmake} {WaylandCompositor} + + \section2 Building with qmake + + \include {module-use.qdocinc} {building_with_qmake} {waylandcompositor} For more information about using these classes in your application, see the \l{Qt Wayland Compositor} documentation. diff --git a/src/compositor/doc/src/qtwaylandcompositor-examples.qdoc b/src/compositor/doc/src/qtwaylandcompositor-examples.qdoc index 560844242..9cc27779e 100644 --- a/src/compositor/doc/src/qtwaylandcompositor-examples.qdoc +++ b/src/compositor/doc/src/qtwaylandcompositor-examples.qdoc @@ -1,29 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Free Documentation License Usage -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. Please review the following information to ensure -** the GNU Free Documentation License version 1.3 requirements -** will be met: https://www.gnu.org/licenses/fdl-1.3.html. -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only /*! \group qtwaylandcompositor-examples diff --git a/src/compositor/doc/src/qtwaylandcompositor-overview.qdoc b/src/compositor/doc/src/qtwaylandcompositor-overview.qdoc index 440a793cb..cf24fbc57 100644 --- a/src/compositor/doc/src/qtwaylandcompositor-overview.qdoc +++ b/src/compositor/doc/src/qtwaylandcompositor-overview.qdoc @@ -1,29 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Free Documentation License Usage -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. Please review the following information to ensure -** the GNU Free Documentation License version 1.3 requirements -** will be met: https://www.gnu.org/licenses/fdl-1.3.html. -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only /*! \page qtwaylandcompositor-index.html @@ -54,7 +30,7 @@ Communication (IPC). Qt provides the APIs that can be used to develop the remaining parts of an application manager in other modules. The \l {https://www.qt.io/qt-automotive-suite/}{Qt Automotive Suite} provides - \l{Qt Application Manager}, which is a complete application manager that + \l{https://doc.qt.io/QtApplicationManager}{Qt Application Manager}, which is a complete application manager that includes a compositor developed using Qt Wayland Compositor. For more information on Wayland, see \l{Wayland and Qt}. @@ -93,6 +69,64 @@ \endlist \endlist + \section1 Running the Wayland compositor + + As long as it does not depend on any unavailable platform-specific features, the compositor can + easily be tested on an X11-based desktop system. This can be useful during development, both for + simplified debugging and efficient turn-around on trying out new features. + + Qt Wayland supports several backends for sharing graphics buffers between clients and the + server. The main one is: + + \list + \li \c{wayland-egl}: This is the default backend and should be preferred whenever possible. + It requires support in the OpenGL driver on the system for this to work. + \endlist + + Other backends may be selected by setting the \c QT_WAYLAND_CLIENT_BUFFER_INTEGRATION environment variable. + + \note If Qt Wayland Compositor is unable to initialize the client buffer backend, then it will + fall back to using the "shared memory" backend (based on \c{wl_shm}) as a fail-safe. This backend + will use CPU memory for sharing the graphics buffers and copy the data back and forth as needed. + This has performance implications, especially on high density screens and limited graphics + hardware. When investigating performance issues with Qt Wayland Compositor, start by checking that + the correct client buffer integration is used. + + Also bear in mind that if your system is already running a Wayland compositor, you may have to set + \c XDG_RUNTIME_DIR to point to a different location. If this is the case, you will see warnings + when starting the compositor. The \c XDG_RUNTIME_DIR can point to any accessible location which + is not already in use. + + For instance, if you want to run the \l{Fancy Compositor}{fancy-compositor} + example with the \c wayland-egl backend, you could use the following command line: + + \code + % XDG_RUNTIME_DIR=~/my_temporary_runtime QT_XCB_GL_INTEGRATION=xcb_egl QT_WAYLAND_CLIENT_BUFFER_INTEGRATION=wayland-egl ./fancy-compositor + \endcode + + The client can subsequently be run on the compositor by setting the same \c XDG_RUNTIME_DIR and + by passing "-platform wayland" as a command line argument. The \c QT_QPA_PLATFORM environment + variable can also be used to select the Wayland QPA plugin on the client side. + + \note In most cases, the client will adapt to the same OpenGL as the server when it connects. + However, when running with the EGL backend on some specific drivers, it is required that the + initialization happens earlier. If you encounter this problem, you may pass + "-platform wayland-egl" instead to pre-initialize the client to EGL. + + \section1 Troubleshooting + + Sometimes, when you are developing a complex compositor, you may encounter issues that require + further investigation. + + Setting the \c WAYLAND_DEBUG environment variable to "1" will enable log output for the Wayland + library itself. This can be very useful, for example, when debugging custom extensions to the + Wayland protocol. It will show you exactly which events and requests are being passed between + the client and the server, as well as timestamps for these. + + In addition, Qt has logging categories \c qt.waylandcompositor.* and \c qt.qpa.wayland.* to + enable additional logging. The latter should be set on the client side, as it enables logging + from the Wayland QPA plugin. + \section1 Examples Take a look at the \l{Qt Wayland Compositor Examples} to learn how these APIs @@ -107,13 +141,24 @@ \li \l{Qt Wayland Compositor C++ Classes} \endlist + In addition, the module provides the CMake function + \l{qt_generate_wayland_protocol_server_sources}{qt_generate_wayland_protocol_server_sources()}. + + \section1 Module Evolution + \l{Porting to Qt 6 - Qt Wayland Compositor} lists important changes in the + module API and functionality that were done for the Qt 6 series of Qt. + \section1 Licenses and Attributions Qt Wayland Compositor and the Qt Wayland integration plugin are available under commercial licenses from \l{The Qt Company}. - In addition, they are available under the - \l{GNU Lesser General Public License, version 3}, or - the \l{GNU General Public License, version 2}. + + In addition, Qt Wayland Compositor is available under the + \l{GNU General Public License, version 3}, while + the Qt Wayland integration plugin is available under the + \l{GNU Lesser General Public License, version 3} or the + \l{GNU General Public License, version 2}. + See \l{Qt Licensing} for further details. Qt Wayland Compositor and the Qt Wayland integration plugin diff --git a/src/compositor/doc/src/qtwaylandcompositor-qmltypes.qdoc b/src/compositor/doc/src/qtwaylandcompositor-qmltypes.qdoc index a89e07d78..a496d3e00 100644 --- a/src/compositor/doc/src/qtwaylandcompositor-qmltypes.qdoc +++ b/src/compositor/doc/src/qtwaylandcompositor-qmltypes.qdoc @@ -1,32 +1,8 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Free Documentation License Usage -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. Please review the following information to ensure -** the GNU Free Documentation License version 1.3 requirements -** will be met: https://www.gnu.org/licenses/fdl-1.3.html. -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only /*! - \qmlmodule QtWayland.Compositor 1.\QtMinorVersion + \qmlmodule QtWayland.Compositor \title Qt Wayland Compositor QML Types \ingroup qmlmodules \brief Provides QML types for writing custom Wayland display servers. @@ -37,14 +13,22 @@ The QML types can be imported into your application using the following import statement: - \qml \QtMinorVersion - import QtWayland.Compositor 1.\1 - \endcode + \section1 Using the Module - To link against the module, add this line to your \l qmake \c .pro file: + \include {module-use.qdocinc} {using the c++ api} {WaylandCompositor} - \code - QT += waylandcompositor + \section2 Building with CMake + + \include {module-use.qdocinc} {building with cmake} {WaylandCompositor} + + \section2 Building with qmake + + \include {module-use.qdocinc} {building_with_qmake} {waylandcompositor} + + \section2 QML import + + \qml + import QtWayland.Compositor \endqml For more information about using these types in your application, diff --git a/src/compositor/doc/src/qtwaylandcompositor-shellextensions.qdoc b/src/compositor/doc/src/qtwaylandcompositor-shellextensions.qdoc new file mode 100644 index 000000000..5494eeda3 --- /dev/null +++ b/src/compositor/doc/src/qtwaylandcompositor-shellextensions.qdoc @@ -0,0 +1,51 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only + +/*! + \page qtwaylandcompositor-shellextensions.html + \title Shell Extensions - Qt Wayland Compositor + + In Wayland, \e{shells} are extensions which provide \e{surface semantics}. This means that they + provide ways for the server and client to communicate about surfaces. Surfaces, in this context, + are often also referred to as "windows", which is typically the representation of the surface in + the compositor. + + Shell extensions provide tools for the client and server to communicate about certain things: + \list + \li They can provide a way for the client to inform the server about the purpose of a surface: + Is it a tool-tip, a pop-up menu, or a regular application window, for instance? Based on + this, the server can decide on the geometry of the window and how the user can interact + with it. + \li They can also provide protocols for manipulating the surface, such as resizing, moving, + and hiding them. + \endlist + + Like other extensions, support for shells is added to a compositor by instantiating them + as direct children of the \l WaylandCompositor top-level object. The shell extensions supported + by Qt are: \l{WlShell}, \l{XdgShell} and \l{IviApplication}. + + \list + \li \l XdgShell is an appropriate shell for desktop-style systems, where any number of + applications can connect and where windows can be manually resized and repositioned by + the user. + \li \l IviApplication is a minimalistic protocol, originally intended for In-vehicle + Infotainment systems. It is useful for embedded systems, where a pre-defined set of + applications can run, often with pre-assigned screen real estate. For some more details + on this protocol, see the \l{IVI Compositor}{IVI Compositor example}. + \li \l QtShell is a specialized shell for Qt applications which supports the window management + features available in Qt. It may be suitable on a platform where both the compositor and + client applications are written with Qt, and where applications are trusted not to abuse + features such as manual window positioning and "bring-to-front". + \li \l WlShell is mostly useful for compatibility with third-party applications. This is also + a desktop-style shell, but it has been deprecated and replaced by \l XdgShell. + \endlist + + When designing an embedded system from the bottom up, there are no rules determining which + shell extension to use. It will typically be either \l XdgShell or \l{IviApplication}. The + decision should be influenced by what features the system will need, and whether there are + applications involved which are not written in Qt and which have their own requirements. + + A Qt Wayland Compositor can also support multiple shell extensions at once. See the + \l{Minimal QML}{Minimal QML example} for an example where all three shell extensions listed + above are supported. +*/ diff --git a/src/compositor/extensions/extensions.pri b/src/compositor/extensions/extensions.pri index 61ab043ea..a3d329b8f 100644 --- a/src/compositor/extensions/extensions.pri +++ b/src/compositor/extensions/extensions.pri @@ -8,15 +8,17 @@ WAYLANDSERVERSOURCES += \ ../extensions/touch-extension.xml \ ../extensions/qt-key-unstable-v1.xml \ ../extensions/qt-windowmanager.xml \ + ../extensions/qt-text-input-method-unstable-v1.xml \ ../3rdparty/protocol/text-input-unstable-v2.xml \ ../3rdparty/protocol/viewporter.xml \ ../3rdparty/protocol/scaler.xml \ - ../3rdparty/protocol/xdg-shell-unstable-v6.xml \ ../3rdparty/protocol/xdg-shell.xml \ ../3rdparty/protocol/xdg-decoration-unstable-v1.xml \ ../3rdparty/protocol/xdg-output-unstable-v1.xml \ ../3rdparty/protocol/ivi-application.xml \ ../3rdparty/protocol/idle-inhibit-unstable-v1.xml \ + ../extensions/qt-texture-sharing-unstable-v1.xml \ + ../3rdparty/protocol/presentation-time.xml \ HEADERS += \ extensions/qwlqttouch_p.h \ @@ -29,16 +31,14 @@ HEADERS += \ extensions/qwaylandtextinput_p.h \ extensions/qwaylandtextinputmanager.h \ extensions/qwaylandtextinputmanager_p.h \ + extensions/qwaylandqttextinputmethodmanager.h \ + extensions/qwaylandqttextinputmethodmanager_p.h \ + extensions/qwaylandqttextinputmethod.h \ + extensions/qwaylandqttextinputmethod_p.h \ extensions/qwaylandqtwindowmanager.h \ extensions/qwaylandqtwindowmanager_p.h \ extensions/qwaylandviewporter.h \ extensions/qwaylandviewporter_p.h \ - extensions/qwaylandwlscaler.h \ - extensions/qwaylandwlscaler_p.h \ - extensions/qwaylandxdgshellv5.h \ - extensions/qwaylandxdgshellv5_p.h \ - extensions/qwaylandxdgshellv6.h \ - extensions/qwaylandxdgshellv6_p.h \ extensions/qwaylandxdgshell.h \ extensions/qwaylandxdgshell_p.h \ extensions/qwaylandxdgdecorationv1.h \ @@ -60,11 +60,10 @@ SOURCES += \ extensions/qwaylandwlshell.cpp \ extensions/qwaylandtextinput.cpp \ extensions/qwaylandtextinputmanager.cpp \ + extensions/qwaylandqttextinputmethodmanager.cpp \ + extensions/qwaylandqttextinputmethod.cpp \ extensions/qwaylandqtwindowmanager.cpp \ extensions/qwaylandviewporter.cpp \ - extensions/qwaylandwlscaler.cpp \ - extensions/qwaylandxdgshellv5.cpp \ - extensions/qwaylandxdgshellv6.cpp \ extensions/qwaylandxdgshell.cpp \ extensions/qwaylandxdgdecorationv1.cpp \ extensions/qwaylandxdgoutputv1.cpp \ @@ -73,7 +72,9 @@ SOURCES += \ extensions/qwaylandiviapplication.cpp \ extensions/qwaylandivisurface.cpp \ -qtHaveModule(quick) { +qtConfig(wayland-compositor-quick) { + QT += quick quick-private + HEADERS += \ extensions/qwaylandquickshellintegration.h \ extensions/qwaylandquickshellsurfaceitem.h \ @@ -81,9 +82,9 @@ qtHaveModule(quick) { extensions/qwaylandivisurfaceintegration_p.h \ extensions/qwaylandwlshellintegration_p.h \ extensions/qwaylandquickxdgoutputv1.h \ - extensions/qwaylandxdgshellv5integration_p.h \ - extensions/qwaylandxdgshellv6integration_p.h \ extensions/qwaylandxdgshellintegration_p.h \ + extensions/qwaylandpresentationtime_p.h \ + extensions/qwaylandpresentationtime_p_p.h \ SOURCES += \ extensions/qwaylandquickshellintegration.cpp \ @@ -91,14 +92,10 @@ qtHaveModule(quick) { extensions/qwaylandivisurfaceintegration.cpp \ extensions/qwaylandwlshellintegration.cpp \ extensions/qwaylandquickxdgoutputv1.cpp \ - extensions/qwaylandxdgshellv5integration.cpp \ - extensions/qwaylandxdgshellv6integration.cpp \ extensions/qwaylandxdgshellintegration.cpp \ + extensions/qwaylandpresentationtime.cpp \ qtConfig(opengl) { - WAYLANDSERVERSOURCES += \ - ../extensions/qt-texture-sharing-unstable-v1.xml - HEADERS += \ extensions/qwltexturesharingextension_p.h @@ -107,6 +104,4 @@ qtHaveModule(quick) { } } -include ($$PWD/pregenerated/xdg-shell-v5.pri) - INCLUDEPATH += extensions diff --git a/src/compositor/extensions/pregenerated/3rdparty/qwayland-server-xdg-shell-unstable-v5.cpp b/src/compositor/extensions/pregenerated/3rdparty/qwayland-server-xdg-shell-unstable-v5.cpp deleted file mode 100644 index 78877171b..000000000 --- a/src/compositor/extensions/pregenerated/3rdparty/qwayland-server-xdg-shell-unstable-v5.cpp +++ /dev/null @@ -1,890 +0,0 @@ -/* - * Copyright © 2008-2013 Kristian Høgsberg - * Copyright © 2013 Rafael Antognolli - * Copyright © 2013 Jasper St. Pierre - * Copyright © 2010-2013 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#include <QtWaylandCompositor/private/qwayland-server-xdg-shell-unstable-v5_p.h> - -QT_BEGIN_NAMESPACE -QT_WARNING_PUSH -QT_WARNING_DISABLE_GCC("-Wmissing-field-initializers") - -namespace QtWaylandServer { - xdg_shell_v5::xdg_shell_v5(struct ::wl_client *client, int id, int version) - : m_resource_map() - , m_resource(nullptr) - , m_global(nullptr) - { - init(client, id, version); - } - - xdg_shell_v5::xdg_shell_v5(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(nullptr) - , m_global(nullptr) - { - init(display, version); - } - - xdg_shell_v5::xdg_shell_v5(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(nullptr) - , m_global(nullptr) - { - init(resource); - } - - xdg_shell_v5::xdg_shell_v5() - : m_resource_map() - , m_resource(nullptr) - , m_global(nullptr) - { - } - - xdg_shell_v5::~xdg_shell_v5() - { - for (auto resource : qAsConst(m_resource_map)) - wl_resource_set_implementation(resource->handle, nullptr, nullptr, nullptr); - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void xdg_shell_v5::init(struct ::wl_client *client, int id, int version) - { - m_resource = bind(client, id, version); - } - - void xdg_shell_v5::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - xdg_shell_v5::Resource *xdg_shell_v5::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(client, resource); - return resource; - } - - xdg_shell_v5::Resource *xdg_shell_v5::add(struct ::wl_client *client, int id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(client, resource); - return resource; - } - - void xdg_shell_v5::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::xdg_shell_v5_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = xdg_shell_v5::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *xdg_shell_v5::interface() - { - return &::xdg_shell_v5_interface; - } - - xdg_shell_v5::Resource *xdg_shell_v5::xdg_shell_allocate() - { - return new Resource; - } - - void xdg_shell_v5::xdg_shell_bind_resource(Resource *) - { - } - - void xdg_shell_v5::xdg_shell_destroy_resource(Resource *) - { - } - - void xdg_shell_v5::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - xdg_shell_v5 *that = static_cast<xdg_shell_v5 *>(data); - that->add(client, id, qMin(that->m_globalVersion, version)); - } - - void xdg_shell_v5::display_destroy_func(struct ::wl_listener *listener, void *data) - { - Q_UNUSED(data); - xdg_shell_v5 *that = static_cast<xdg_shell_v5::DisplayDestroyedListener *>(listener)->parent; - that->m_global = nullptr; - } - - void xdg_shell_v5::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - xdg_shell_v5 *that = resource->xdg_shell_object; - that->m_resource_map.remove(resource->client(), resource); - that->xdg_shell_destroy_resource(resource); - delete resource; - } - - xdg_shell_v5::Resource *xdg_shell_v5::bind(struct ::wl_client *client, uint32_t id, int version) - { - Q_ASSERT_X(!wl_client_get_object(client, id), "QWaylandObject bind", QStringLiteral("binding to object %1 more than once").arg(id).toLocal8Bit().constData()); - struct ::wl_resource *handle = wl_resource_create(client, &::xdg_shell_v5_interface, version, id); - return bind(handle); - } - - xdg_shell_v5::Resource *xdg_shell_v5::bind(struct ::wl_resource *handle) - { - Resource *resource = xdg_shell_allocate(); - resource->xdg_shell_object = this; - - wl_resource_set_implementation(handle, &m_xdg_shell_interface, resource, destroy_func); - resource->handle = handle; - xdg_shell_bind_resource(resource); - return resource; - } - xdg_shell_v5::Resource *xdg_shell_v5::Resource::fromResource(struct ::wl_resource *resource) - { - if (wl_resource_instance_of(resource, &::xdg_shell_v5_interface, &m_xdg_shell_interface)) - return static_cast<Resource *>(resource->data); - return nullptr; - } - - const struct ::xdg_shell_v5_interface xdg_shell_v5::m_xdg_shell_interface = { - xdg_shell_v5::handle_destroy, - xdg_shell_v5::handle_use_unstable_version, - xdg_shell_v5::handle_get_xdg_surface, - xdg_shell_v5::handle_get_xdg_popup, - xdg_shell_v5::handle_pong - }; - - void xdg_shell_v5::xdg_shell_destroy(Resource *) - { - } - - void xdg_shell_v5::xdg_shell_use_unstable_version(Resource *, int32_t ) - { - } - - void xdg_shell_v5::xdg_shell_get_xdg_surface(Resource *, uint32_t, struct ::wl_resource *) - { - } - - void xdg_shell_v5::xdg_shell_get_xdg_popup(Resource *, uint32_t, struct ::wl_resource *, struct ::wl_resource *, struct ::wl_resource *, uint32_t , int32_t , int32_t ) - { - } - - void xdg_shell_v5::xdg_shell_pong(Resource *, uint32_t ) - { - } - - - void xdg_shell_v5::handle_destroy( - ::wl_client *client, - struct wl_resource *resource) - { - Q_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast<xdg_shell_v5 *>(r->xdg_shell_object)->xdg_shell_destroy( - r); - } - - void xdg_shell_v5::handle_use_unstable_version( - ::wl_client *client, - struct wl_resource *resource, - int32_t version) - { - Q_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast<xdg_shell_v5 *>(r->xdg_shell_object)->xdg_shell_use_unstable_version( - r, - version); - } - - void xdg_shell_v5::handle_get_xdg_surface( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id, - struct ::wl_resource *surface) - { - Q_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast<xdg_shell_v5 *>(r->xdg_shell_object)->xdg_shell_get_xdg_surface( - r, - id, - surface); - } - - void xdg_shell_v5::handle_get_xdg_popup( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id, - struct ::wl_resource *surface, - struct ::wl_resource *parent, - struct ::wl_resource *seat, - uint32_t serial, - int32_t x, - int32_t y) - { - Q_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast<xdg_shell_v5 *>(r->xdg_shell_object)->xdg_shell_get_xdg_popup( - r, - id, - surface, - parent, - seat, - serial, - x, - y); - } - - void xdg_shell_v5::handle_pong( - ::wl_client *client, - struct wl_resource *resource, - uint32_t serial) - { - Q_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast<xdg_shell_v5 *>(r->xdg_shell_object)->xdg_shell_pong( - r, - serial); - } - - void xdg_shell_v5::send_ping(uint32_t serial) - { - send_ping( - m_resource->handle, - serial); - } - - void xdg_shell_v5::send_ping(struct ::wl_resource *resource, uint32_t serial) - { - xdg_shell_send_ping( - resource, - serial); - } - - - xdg_surface_v5::xdg_surface_v5(struct ::wl_client *client, int id, int version) - : m_resource_map() - , m_resource(nullptr) - , m_global(nullptr) - { - init(client, id, version); - } - - xdg_surface_v5::xdg_surface_v5(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(nullptr) - , m_global(nullptr) - { - init(display, version); - } - - xdg_surface_v5::xdg_surface_v5(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(nullptr) - , m_global(nullptr) - { - init(resource); - } - - xdg_surface_v5::xdg_surface_v5() - : m_resource_map() - , m_resource(nullptr) - , m_global(nullptr) - { - } - - xdg_surface_v5::~xdg_surface_v5() - { - for (auto resource : qAsConst(m_resource_map)) - wl_resource_set_implementation(resource->handle, nullptr, nullptr, nullptr); - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void xdg_surface_v5::init(struct ::wl_client *client, int id, int version) - { - m_resource = bind(client, id, version); - } - - void xdg_surface_v5::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - xdg_surface_v5::Resource *xdg_surface_v5::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(client, resource); - return resource; - } - - xdg_surface_v5::Resource *xdg_surface_v5::add(struct ::wl_client *client, int id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(client, resource); - return resource; - } - - void xdg_surface_v5::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::xdg_surface_v5_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = xdg_surface_v5::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *xdg_surface_v5::interface() - { - return &::xdg_surface_v5_interface; - } - - xdg_surface_v5::Resource *xdg_surface_v5::xdg_surface_allocate() - { - return new Resource; - } - - void xdg_surface_v5::xdg_surface_bind_resource(Resource *) - { - } - - void xdg_surface_v5::xdg_surface_destroy_resource(Resource *) - { - } - - void xdg_surface_v5::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - xdg_surface_v5 *that = static_cast<xdg_surface_v5 *>(data); - that->add(client, id, qMin(that->m_globalVersion, version)); - } - - void xdg_surface_v5::display_destroy_func(struct ::wl_listener *listener, void *data) - { - Q_UNUSED(data); - xdg_surface_v5 *that = static_cast<xdg_surface_v5::DisplayDestroyedListener *>(listener)->parent; - that->m_global = nullptr; - } - - void xdg_surface_v5::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - xdg_surface_v5 *that = resource->xdg_surface_object; - that->m_resource_map.remove(resource->client(), resource); - that->xdg_surface_destroy_resource(resource); - delete resource; - } - - xdg_surface_v5::Resource *xdg_surface_v5::bind(struct ::wl_client *client, uint32_t id, int version) - { - Q_ASSERT_X(!wl_client_get_object(client, id), "QWaylandObject bind", QStringLiteral("binding to object %1 more than once").arg(id).toLocal8Bit().constData()); - struct ::wl_resource *handle = wl_resource_create(client, &::xdg_surface_v5_interface, version, id); - return bind(handle); - } - - xdg_surface_v5::Resource *xdg_surface_v5::bind(struct ::wl_resource *handle) - { - Resource *resource = xdg_surface_allocate(); - resource->xdg_surface_object = this; - - wl_resource_set_implementation(handle, &m_xdg_surface_interface, resource, destroy_func); - resource->handle = handle; - xdg_surface_bind_resource(resource); - return resource; - } - xdg_surface_v5::Resource *xdg_surface_v5::Resource::fromResource(struct ::wl_resource *resource) - { - if (wl_resource_instance_of(resource, &::xdg_surface_v5_interface, &m_xdg_surface_interface)) - return static_cast<Resource *>(resource->data); - return nullptr; - } - - const struct ::xdg_surface_v5_interface xdg_surface_v5::m_xdg_surface_interface = { - xdg_surface_v5::handle_destroy, - xdg_surface_v5::handle_set_parent, - xdg_surface_v5::handle_set_title, - xdg_surface_v5::handle_set_app_id, - xdg_surface_v5::handle_show_window_menu, - xdg_surface_v5::handle_move, - xdg_surface_v5::handle_resize, - xdg_surface_v5::handle_ack_configure, - xdg_surface_v5::handle_set_window_geometry, - xdg_surface_v5::handle_set_maximized, - xdg_surface_v5::handle_unset_maximized, - xdg_surface_v5::handle_set_fullscreen, - xdg_surface_v5::handle_unset_fullscreen, - xdg_surface_v5::handle_set_minimized - }; - - void xdg_surface_v5::xdg_surface_destroy(Resource *) - { - } - - void xdg_surface_v5::xdg_surface_set_parent(Resource *, struct ::wl_resource *) - { - } - - void xdg_surface_v5::xdg_surface_set_title(Resource *, const QString &) - { - } - - void xdg_surface_v5::xdg_surface_set_app_id(Resource *, const QString &) - { - } - - void xdg_surface_v5::xdg_surface_show_window_menu(Resource *, struct ::wl_resource *, uint32_t , int32_t , int32_t ) - { - } - - void xdg_surface_v5::xdg_surface_move(Resource *, struct ::wl_resource *, uint32_t ) - { - } - - void xdg_surface_v5::xdg_surface_resize(Resource *, struct ::wl_resource *, uint32_t , uint32_t ) - { - } - - void xdg_surface_v5::xdg_surface_ack_configure(Resource *, uint32_t ) - { - } - - void xdg_surface_v5::xdg_surface_set_window_geometry(Resource *, int32_t , int32_t , int32_t , int32_t ) - { - } - - void xdg_surface_v5::xdg_surface_set_maximized(Resource *) - { - } - - void xdg_surface_v5::xdg_surface_unset_maximized(Resource *) - { - } - - void xdg_surface_v5::xdg_surface_set_fullscreen(Resource *, struct ::wl_resource *) - { - } - - void xdg_surface_v5::xdg_surface_unset_fullscreen(Resource *) - { - } - - void xdg_surface_v5::xdg_surface_set_minimized(Resource *) - { - } - - - void xdg_surface_v5::handle_destroy( - ::wl_client *client, - struct wl_resource *resource) - { - Q_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast<xdg_surface_v5 *>(r->xdg_surface_object)->xdg_surface_destroy( - r); - } - - void xdg_surface_v5::handle_set_parent( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *parent) - { - Q_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast<xdg_surface_v5 *>(r->xdg_surface_object)->xdg_surface_set_parent( - r, - parent); - } - - void xdg_surface_v5::handle_set_title( - ::wl_client *client, - struct wl_resource *resource, - const char *title) - { - Q_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast<xdg_surface_v5 *>(r->xdg_surface_object)->xdg_surface_set_title( - r, - QString::fromUtf8(title)); - } - - void xdg_surface_v5::handle_set_app_id( - ::wl_client *client, - struct wl_resource *resource, - const char *app_id) - { - Q_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast<xdg_surface_v5 *>(r->xdg_surface_object)->xdg_surface_set_app_id( - r, - QString::fromUtf8(app_id)); - } - - void xdg_surface_v5::handle_show_window_menu( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *seat, - uint32_t serial, - int32_t x, - int32_t y) - { - Q_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast<xdg_surface_v5 *>(r->xdg_surface_object)->xdg_surface_show_window_menu( - r, - seat, - serial, - x, - y); - } - - void xdg_surface_v5::handle_move( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *seat, - uint32_t serial) - { - Q_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast<xdg_surface_v5 *>(r->xdg_surface_object)->xdg_surface_move( - r, - seat, - serial); - } - - void xdg_surface_v5::handle_resize( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *seat, - uint32_t serial, - uint32_t edges) - { - Q_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast<xdg_surface_v5 *>(r->xdg_surface_object)->xdg_surface_resize( - r, - seat, - serial, - edges); - } - - void xdg_surface_v5::handle_ack_configure( - ::wl_client *client, - struct wl_resource *resource, - uint32_t serial) - { - Q_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast<xdg_surface_v5 *>(r->xdg_surface_object)->xdg_surface_ack_configure( - r, - serial); - } - - void xdg_surface_v5::handle_set_window_geometry( - ::wl_client *client, - struct wl_resource *resource, - int32_t x, - int32_t y, - int32_t width, - int32_t height) - { - Q_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast<xdg_surface_v5 *>(r->xdg_surface_object)->xdg_surface_set_window_geometry( - r, - x, - y, - width, - height); - } - - void xdg_surface_v5::handle_set_maximized( - ::wl_client *client, - struct wl_resource *resource) - { - Q_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast<xdg_surface_v5 *>(r->xdg_surface_object)->xdg_surface_set_maximized( - r); - } - - void xdg_surface_v5::handle_unset_maximized( - ::wl_client *client, - struct wl_resource *resource) - { - Q_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast<xdg_surface_v5 *>(r->xdg_surface_object)->xdg_surface_unset_maximized( - r); - } - - void xdg_surface_v5::handle_set_fullscreen( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *output) - { - Q_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast<xdg_surface_v5 *>(r->xdg_surface_object)->xdg_surface_set_fullscreen( - r, - output); - } - - void xdg_surface_v5::handle_unset_fullscreen( - ::wl_client *client, - struct wl_resource *resource) - { - Q_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast<xdg_surface_v5 *>(r->xdg_surface_object)->xdg_surface_unset_fullscreen( - r); - } - - void xdg_surface_v5::handle_set_minimized( - ::wl_client *client, - struct wl_resource *resource) - { - Q_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast<xdg_surface_v5 *>(r->xdg_surface_object)->xdg_surface_set_minimized( - r); - } - - void xdg_surface_v5::send_configure(int32_t width, int32_t height, const QByteArray &states, uint32_t serial) - { - send_configure( - m_resource->handle, - width, - height, - states, - serial); - } - - void xdg_surface_v5::send_configure(struct ::wl_resource *resource, int32_t width, int32_t height, const QByteArray &states, uint32_t serial) - { - struct wl_array states_data; - states_data.size = states.size(); - states_data.data = static_cast<void *>(const_cast<char *>(states.constData())); - states_data.alloc = 0; - - xdg_surface_send_configure( - resource, - width, - height, - &states_data, - serial); - } - - - void xdg_surface_v5::send_close() - { - send_close( - m_resource->handle); - } - - void xdg_surface_v5::send_close(struct ::wl_resource *resource) - { - xdg_surface_send_close( - resource); - } - - - xdg_popup_v5::xdg_popup_v5(struct ::wl_client *client, int id, int version) - : m_resource_map() - , m_resource(nullptr) - , m_global(nullptr) - { - init(client, id, version); - } - - xdg_popup_v5::xdg_popup_v5(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(nullptr) - , m_global(nullptr) - { - init(display, version); - } - - xdg_popup_v5::xdg_popup_v5(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(nullptr) - , m_global(nullptr) - { - init(resource); - } - - xdg_popup_v5::xdg_popup_v5() - : m_resource_map() - , m_resource(nullptr) - , m_global(nullptr) - { - } - - xdg_popup_v5::~xdg_popup_v5() - { - for (auto resource : qAsConst(m_resource_map)) - wl_resource_set_implementation(resource->handle, nullptr, nullptr, nullptr); - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void xdg_popup_v5::init(struct ::wl_client *client, int id, int version) - { - m_resource = bind(client, id, version); - } - - void xdg_popup_v5::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - xdg_popup_v5::Resource *xdg_popup_v5::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(client, resource); - return resource; - } - - xdg_popup_v5::Resource *xdg_popup_v5::add(struct ::wl_client *client, int id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(client, resource); - return resource; - } - - void xdg_popup_v5::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::xdg_popup_v5_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = xdg_popup_v5::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *xdg_popup_v5::interface() - { - return &::xdg_popup_v5_interface; - } - - xdg_popup_v5::Resource *xdg_popup_v5::xdg_popup_allocate() - { - return new Resource; - } - - void xdg_popup_v5::xdg_popup_bind_resource(Resource *) - { - } - - void xdg_popup_v5::xdg_popup_destroy_resource(Resource *) - { - } - - void xdg_popup_v5::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - xdg_popup_v5 *that = static_cast<xdg_popup_v5 *>(data); - that->add(client, id, qMin(that->m_globalVersion, version)); - } - - void xdg_popup_v5::display_destroy_func(struct ::wl_listener *listener, void *data) - { - Q_UNUSED(data); - xdg_popup_v5 *that = static_cast<xdg_popup_v5::DisplayDestroyedListener *>(listener)->parent; - that->m_global = nullptr; - } - - void xdg_popup_v5::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - xdg_popup_v5 *that = resource->xdg_popup_object; - that->m_resource_map.remove(resource->client(), resource); - that->xdg_popup_destroy_resource(resource); - delete resource; - } - - xdg_popup_v5::Resource *xdg_popup_v5::bind(struct ::wl_client *client, uint32_t id, int version) - { - Q_ASSERT_X(!wl_client_get_object(client, id), "QWaylandObject bind", QStringLiteral("binding to object %1 more than once").arg(id).toLocal8Bit().constData()); - struct ::wl_resource *handle = wl_resource_create(client, &::xdg_popup_v5_interface, version, id); - return bind(handle); - } - - xdg_popup_v5::Resource *xdg_popup_v5::bind(struct ::wl_resource *handle) - { - Resource *resource = xdg_popup_allocate(); - resource->xdg_popup_object = this; - - wl_resource_set_implementation(handle, &m_xdg_popup_interface, resource, destroy_func); - resource->handle = handle; - xdg_popup_bind_resource(resource); - return resource; - } - xdg_popup_v5::Resource *xdg_popup_v5::Resource::fromResource(struct ::wl_resource *resource) - { - if (wl_resource_instance_of(resource, &::xdg_popup_v5_interface, &m_xdg_popup_interface)) - return static_cast<Resource *>(resource->data); - return nullptr; - } - - const struct ::xdg_popup_v5_interface xdg_popup_v5::m_xdg_popup_interface = { - xdg_popup_v5::handle_destroy - }; - - void xdg_popup_v5::xdg_popup_destroy(Resource *) - { - } - - - void xdg_popup_v5::handle_destroy( - ::wl_client *client, - struct wl_resource *resource) - { - Q_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast<xdg_popup_v5 *>(r->xdg_popup_object)->xdg_popup_destroy( - r); - } - - void xdg_popup_v5::send_popup_done() - { - send_popup_done( - m_resource->handle); - } - - void xdg_popup_v5::send_popup_done(struct ::wl_resource *resource) - { - xdg_popup_send_popup_done( - resource); - } - -} - -QT_WARNING_POP -QT_END_NAMESPACE diff --git a/src/compositor/extensions/pregenerated/3rdparty/qwayland-server-xdg-shell-unstable-v5_p.h b/src/compositor/extensions/pregenerated/3rdparty/qwayland-server-xdg-shell-unstable-v5_p.h deleted file mode 100644 index 8124860b9..000000000 --- a/src/compositor/extensions/pregenerated/3rdparty/qwayland-server-xdg-shell-unstable-v5_p.h +++ /dev/null @@ -1,439 +0,0 @@ -/* - * Copyright © 2008-2013 Kristian Høgsberg - * Copyright © 2013 Rafael Antognolli - * Copyright © 2013 Jasper St. Pierre - * Copyright © 2010-2013 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#ifndef QT_WAYLAND_SERVER_XDG_SHELL_UNSTABLE_V5 -#define QT_WAYLAND_SERVER_XDG_SHELL_UNSTABLE_V5 - -#include "wayland-server.h" -#include <QtWaylandCompositor/private/wayland-xdg-shell-unstable-v5-server-protocol_p.h> -#include <QByteArray> -#include <QMultiMap> -#include <QString> - -#ifndef WAYLAND_VERSION_CHECK -#define WAYLAND_VERSION_CHECK(major, minor, micro) \ - ((WAYLAND_VERSION_MAJOR > (major)) || \ - (WAYLAND_VERSION_MAJOR == (major) && WAYLAND_VERSION_MINOR > (minor)) || \ - (WAYLAND_VERSION_MAJOR == (major) && WAYLAND_VERSION_MINOR == (minor) && WAYLAND_VERSION_MICRO >= (micro))) -#endif - -QT_BEGIN_NAMESPACE -QT_WARNING_PUSH -QT_WARNING_DISABLE_GCC("-Wmissing-field-initializers") -QT_WARNING_DISABLE_CLANG("-Wmissing-field-initializers") - -#if !defined(Q_WAYLAND_SERVER_XDG_SHELL_UNSTABLE_V5_EXPORT) -# if defined(QT_SHARED) -# define Q_WAYLAND_SERVER_XDG_SHELL_UNSTABLE_V5_EXPORT Q_DECL_EXPORT -# else -# define Q_WAYLAND_SERVER_XDG_SHELL_UNSTABLE_V5_EXPORT -# endif -#endif - -namespace QtWaylandServer { - class Q_WAYLAND_SERVER_XDG_SHELL_UNSTABLE_V5_EXPORT xdg_shell_v5 - { - public: - xdg_shell_v5(struct ::wl_client *client, int id, int version); - xdg_shell_v5(struct ::wl_display *display, int version); - xdg_shell_v5(struct ::wl_resource *resource); - xdg_shell_v5(); - - virtual ~xdg_shell_v5(); - - class Resource - { - public: - Resource() : xdg_shell_object(nullptr), handle(nullptr) {} - virtual ~Resource() {} - - xdg_shell_v5 *xdg_shell_object; - xdg_shell_v5 *object() { return xdg_shell_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, int id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, int id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, int id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - QMultiMap<struct ::wl_client*, Resource*> resourceMap() { return m_resource_map; } - const QMultiMap<struct ::wl_client*, Resource*> resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != nullptr; } - bool isResource() const { return m_resource != nullptr; } - - static const struct ::wl_interface *interface(); - static QByteArray interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - enum version { - version_current = 5 // Always the latest version - }; - - enum error { - error_role = 0, // given wl_surface has another role - error_defunct_surfaces = 1, // xdg_shell was destroyed before children - error_not_the_topmost_popup = 2, // the client tried to map or destroy a non-topmost popup - error_invalid_popup_parent = 3 // the client specified an invalid popup parent surface - }; - - void send_ping(uint32_t serial); - void send_ping(struct ::wl_resource *resource, uint32_t serial); - - protected: - virtual Resource *xdg_shell_allocate(); - - virtual void xdg_shell_bind_resource(Resource *resource); - virtual void xdg_shell_destroy_resource(Resource *resource); - - virtual void xdg_shell_destroy(Resource *resource); - virtual void xdg_shell_use_unstable_version(Resource *resource, int32_t version); - virtual void xdg_shell_get_xdg_surface(Resource *resource, uint32_t id, struct ::wl_resource *surface); - virtual void xdg_shell_get_xdg_popup(Resource *resource, uint32_t id, struct ::wl_resource *surface, struct ::wl_resource *parent, struct ::wl_resource *seat, uint32_t serial, int32_t x, int32_t y); - virtual void xdg_shell_pong(Resource *resource, uint32_t serial); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::xdg_shell_v5_interface m_xdg_shell_interface; - - static void handle_destroy( - ::wl_client *client, - struct wl_resource *resource); - static void handle_use_unstable_version( - ::wl_client *client, - struct wl_resource *resource, - int32_t version); - static void handle_get_xdg_surface( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id, - struct ::wl_resource *surface); - static void handle_get_xdg_popup( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id, - struct ::wl_resource *surface, - struct ::wl_resource *parent, - struct ::wl_resource *seat, - uint32_t serial, - int32_t x, - int32_t y); - static void handle_pong( - ::wl_client *client, - struct wl_resource *resource, - uint32_t serial); - - QMultiMap<struct ::wl_client*, Resource*> m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - xdg_shell_v5 *parent; - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; - - class Q_WAYLAND_SERVER_XDG_SHELL_UNSTABLE_V5_EXPORT xdg_surface_v5 - { - public: - xdg_surface_v5(struct ::wl_client *client, int id, int version); - xdg_surface_v5(struct ::wl_display *display, int version); - xdg_surface_v5(struct ::wl_resource *resource); - xdg_surface_v5(); - - virtual ~xdg_surface_v5(); - - class Resource - { - public: - Resource() : xdg_surface_object(nullptr), handle(nullptr) {} - virtual ~Resource() {} - - xdg_surface_v5 *xdg_surface_object; - xdg_surface_v5 *object() { return xdg_surface_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, int id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, int id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, int id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - QMultiMap<struct ::wl_client*, Resource*> resourceMap() { return m_resource_map; } - const QMultiMap<struct ::wl_client*, Resource*> resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != nullptr; } - bool isResource() const { return m_resource != nullptr; } - - static const struct ::wl_interface *interface(); - static QByteArray interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - enum resize_edge { - resize_edge_none = 0, - resize_edge_top = 1, - resize_edge_bottom = 2, - resize_edge_left = 4, - resize_edge_top_left = 5, - resize_edge_bottom_left = 6, - resize_edge_right = 8, - resize_edge_top_right = 9, - resize_edge_bottom_right = 10 - }; - - enum state { - state_maximized = 1, // the surface is maximized - state_fullscreen = 2, // the surface is fullscreen - state_resizing = 3, - state_activated = 4 - }; - - void send_configure(int32_t width, int32_t height, const QByteArray &states, uint32_t serial); - void send_configure(struct ::wl_resource *resource, int32_t width, int32_t height, const QByteArray &states, uint32_t serial); - void send_close(); - void send_close(struct ::wl_resource *resource); - - protected: - virtual Resource *xdg_surface_allocate(); - - virtual void xdg_surface_bind_resource(Resource *resource); - virtual void xdg_surface_destroy_resource(Resource *resource); - - virtual void xdg_surface_destroy(Resource *resource); - virtual void xdg_surface_set_parent(Resource *resource, struct ::wl_resource *parent); - virtual void xdg_surface_set_title(Resource *resource, const QString &title); - virtual void xdg_surface_set_app_id(Resource *resource, const QString &app_id); - virtual void xdg_surface_show_window_menu(Resource *resource, struct ::wl_resource *seat, uint32_t serial, int32_t x, int32_t y); - virtual void xdg_surface_move(Resource *resource, struct ::wl_resource *seat, uint32_t serial); - virtual void xdg_surface_resize(Resource *resource, struct ::wl_resource *seat, uint32_t serial, uint32_t edges); - virtual void xdg_surface_ack_configure(Resource *resource, uint32_t serial); - virtual void xdg_surface_set_window_geometry(Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height); - virtual void xdg_surface_set_maximized(Resource *resource); - virtual void xdg_surface_unset_maximized(Resource *resource); - virtual void xdg_surface_set_fullscreen(Resource *resource, struct ::wl_resource *output); - virtual void xdg_surface_unset_fullscreen(Resource *resource); - virtual void xdg_surface_set_minimized(Resource *resource); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::xdg_surface_v5_interface m_xdg_surface_interface; - - static void handle_destroy( - ::wl_client *client, - struct wl_resource *resource); - static void handle_set_parent( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *parent); - static void handle_set_title( - ::wl_client *client, - struct wl_resource *resource, - const char *title); - static void handle_set_app_id( - ::wl_client *client, - struct wl_resource *resource, - const char *app_id); - static void handle_show_window_menu( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *seat, - uint32_t serial, - int32_t x, - int32_t y); - static void handle_move( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *seat, - uint32_t serial); - static void handle_resize( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *seat, - uint32_t serial, - uint32_t edges); - static void handle_ack_configure( - ::wl_client *client, - struct wl_resource *resource, - uint32_t serial); - static void handle_set_window_geometry( - ::wl_client *client, - struct wl_resource *resource, - int32_t x, - int32_t y, - int32_t width, - int32_t height); - static void handle_set_maximized( - ::wl_client *client, - struct wl_resource *resource); - static void handle_unset_maximized( - ::wl_client *client, - struct wl_resource *resource); - static void handle_set_fullscreen( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *output); - static void handle_unset_fullscreen( - ::wl_client *client, - struct wl_resource *resource); - static void handle_set_minimized( - ::wl_client *client, - struct wl_resource *resource); - - QMultiMap<struct ::wl_client*, Resource*> m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - xdg_surface_v5 *parent; - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; - - class Q_WAYLAND_SERVER_XDG_SHELL_UNSTABLE_V5_EXPORT xdg_popup_v5 - { - public: - xdg_popup_v5(struct ::wl_client *client, int id, int version); - xdg_popup_v5(struct ::wl_display *display, int version); - xdg_popup_v5(struct ::wl_resource *resource); - xdg_popup_v5(); - - virtual ~xdg_popup_v5(); - - class Resource - { - public: - Resource() : xdg_popup_object(nullptr), handle(nullptr) {} - virtual ~Resource() {} - - xdg_popup_v5 *xdg_popup_object; - xdg_popup_v5 *object() { return xdg_popup_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, int id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, int id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, int id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - QMultiMap<struct ::wl_client*, Resource*> resourceMap() { return m_resource_map; } - const QMultiMap<struct ::wl_client*, Resource*> resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != nullptr; } - bool isResource() const { return m_resource != nullptr; } - - static const struct ::wl_interface *interface(); - static QByteArray interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - void send_popup_done(); - void send_popup_done(struct ::wl_resource *resource); - - protected: - virtual Resource *xdg_popup_allocate(); - - virtual void xdg_popup_bind_resource(Resource *resource); - virtual void xdg_popup_destroy_resource(Resource *resource); - - virtual void xdg_popup_destroy(Resource *resource); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::xdg_popup_v5_interface m_xdg_popup_interface; - - static void handle_destroy( - ::wl_client *client, - struct wl_resource *resource); - - QMultiMap<struct ::wl_client*, Resource*> m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - xdg_popup_v5 *parent; - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; -} - -QT_WARNING_POP -QT_END_NAMESPACE - -#endif diff --git a/src/compositor/extensions/pregenerated/3rdparty/wayland-xdg-shell-unstable-v5-protocol.c b/src/compositor/extensions/pregenerated/3rdparty/wayland-xdg-shell-unstable-v5-protocol.c deleted file mode 100644 index e2781c994..000000000 --- a/src/compositor/extensions/pregenerated/3rdparty/wayland-xdg-shell-unstable-v5-protocol.c +++ /dev/null @@ -1,126 +0,0 @@ -/* Generated by wayland-scanner 1.15.92 */ -// Hand edited to resolve conflicts with xdg-shell stable - -/* - * Copyright © 2008-2013 Kristian Høgsberg - * Copyright © 2013 Rafael Antognolli - * Copyright © 2013 Jasper St. Pierre - * Copyright © 2010-2013 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#include <stdlib.h> -#include <stdint.h> -#include "wayland-util.h" - -extern const struct wl_interface wl_output_interface; -extern const struct wl_interface wl_seat_interface; -extern const struct wl_interface wl_surface_interface; -extern const struct wl_interface xdg_popup_v5_interface; -extern const struct wl_interface xdg_surface_v5_interface; - -static const struct wl_interface *types[] = { - NULL, - NULL, - NULL, - NULL, - &xdg_surface_v5_interface, - &wl_surface_interface, - &xdg_popup_v5_interface, - &wl_surface_interface, - &wl_surface_interface, - &wl_seat_interface, - NULL, - NULL, - NULL, - &xdg_surface_v5_interface, - &wl_seat_interface, - NULL, - NULL, - NULL, - &wl_seat_interface, - NULL, - &wl_seat_interface, - NULL, - NULL, - &wl_output_interface, -}; - -static const struct wl_message xdg_shell_requests[] = { - { "destroy", "", types + 0 }, - { "use_unstable_version", "i", types + 0 }, - { "get_xdg_surface", "no", types + 4 }, - { "get_xdg_popup", "nooouii", types + 6 }, - { "pong", "u", types + 0 }, -}; - -static const struct wl_message xdg_shell_events[] = { - { "ping", "u", types + 0 }, -}; - -WL_EXPORT const struct wl_interface xdg_shell_v5_interface = { - "xdg_shell", 1, - 5, xdg_shell_requests, - 1, xdg_shell_events, -}; - -static const struct wl_message xdg_surface_requests[] = { - { "destroy", "", types + 0 }, - { "set_parent", "?o", types + 13 }, - { "set_title", "s", types + 0 }, - { "set_app_id", "s", types + 0 }, - { "show_window_menu", "ouii", types + 14 }, - { "move", "ou", types + 18 }, - { "resize", "ouu", types + 20 }, - { "ack_configure", "u", types + 0 }, - { "set_window_geometry", "iiii", types + 0 }, - { "set_maximized", "", types + 0 }, - { "unset_maximized", "", types + 0 }, - { "set_fullscreen", "?o", types + 23 }, - { "unset_fullscreen", "", types + 0 }, - { "set_minimized", "", types + 0 }, -}; - -static const struct wl_message xdg_surface_events[] = { - { "configure", "iiau", types + 0 }, - { "close", "", types + 0 }, -}; - -WL_EXPORT const struct wl_interface xdg_surface_v5_interface = { - "xdg_surface", 1, - 14, xdg_surface_requests, - 2, xdg_surface_events, -}; - -static const struct wl_message xdg_popup_requests[] = { - { "destroy", "", types + 0 }, -}; - -static const struct wl_message xdg_popup_events[] = { - { "popup_done", "", types + 0 }, -}; - -WL_EXPORT const struct wl_interface xdg_popup_v5_interface = { - "xdg_popup", 1, - 1, xdg_popup_requests, - 1, xdg_popup_events, -}; - diff --git a/src/compositor/extensions/pregenerated/3rdparty/wayland-xdg-shell-unstable-v5-server-protocol_p.h b/src/compositor/extensions/pregenerated/3rdparty/wayland-xdg-shell-unstable-v5-server-protocol_p.h deleted file mode 100644 index 493fd52d4..000000000 --- a/src/compositor/extensions/pregenerated/3rdparty/wayland-xdg-shell-unstable-v5-server-protocol_p.h +++ /dev/null @@ -1,905 +0,0 @@ -/* Generated by wayland-scanner 1.15.92 */ -// Hand edited to resolve conflicts with xdg-shell stable - -#ifndef XDG_SHELL_UNSTABLE_V5_SERVER_PROTOCOL_H -#define XDG_SHELL_UNSTABLE_V5_SERVER_PROTOCOL_H - -#include <stdint.h> -#include <stddef.h> -#include "wayland-server-core.h" - -#ifdef __cplusplus -extern "C" { -#endif - -struct wl_client; -struct wl_resource; - -/** - * @page page_xdg_shell_unstable_v5 The xdg_shell_unstable_v5 protocol - * @section page_ifaces_xdg_shell_unstable_v5 Interfaces - * - @subpage page_iface_xdg_shell - create desktop-style surfaces - * - @subpage page_iface_xdg_surface - A desktop window - * - @subpage page_iface_xdg_popup - short-lived, popup surfaces for menus - * @section page_copyright_xdg_shell_unstable_v5 Copyright - * <pre> - * - * Copyright © 2008-2013 Kristian Høgsberg - * Copyright © 2013 Rafael Antognolli - * Copyright © 2013 Jasper St. Pierre - * Copyright © 2010-2013 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * </pre> - */ -struct wl_output; -struct wl_seat; -struct wl_surface; -struct xdg_popup; -struct xdg_shell; -struct xdg_surface; - -/** - * @page page_iface_xdg_shell xdg_shell - * @section page_iface_xdg_shell_desc Description - * - * xdg_shell allows clients to turn a wl_surface into a "real window" - * which can be dragged, resized, stacked, and moved around by the - * user. Everything about this interface is suited towards traditional - * desktop environments. - * @section page_iface_xdg_shell_api API - * See @ref iface_xdg_shell. - */ -/** - * @defgroup iface_xdg_shell The xdg_shell interface - * - * xdg_shell allows clients to turn a wl_surface into a "real window" - * which can be dragged, resized, stacked, and moved around by the - * user. Everything about this interface is suited towards traditional - * desktop environments. - */ -extern const struct wl_interface xdg_shell_v5_interface; -/** - * @page page_iface_xdg_surface xdg_surface - * @section page_iface_xdg_surface_desc Description - * - * An interface that may be implemented by a wl_surface, for - * implementations that provide a desktop-style user interface. - * - * It provides requests to treat surfaces like windows, allowing to set - * properties like maximized, fullscreen, minimized, and to move and resize - * them, and associate metadata like title and app id. - * - * The client must call wl_surface.commit on the corresponding wl_surface - * for the xdg_surface state to take effect. Prior to committing the new - * state, it can set up initial configuration, such as maximizing or setting - * a window geometry. - * - * Even without attaching a buffer the compositor must respond to initial - * committed configuration, for instance sending a configure event with - * expected window geometry if the client maximized its surface during - * initialization. - * - * For a surface to be mapped by the compositor the client must have - * committed both an xdg_surface state and a buffer. - * @section page_iface_xdg_surface_api API - * See @ref iface_xdg_surface. - */ -/** - * @defgroup iface_xdg_surface The xdg_surface interface - * - * An interface that may be implemented by a wl_surface, for - * implementations that provide a desktop-style user interface. - * - * It provides requests to treat surfaces like windows, allowing to set - * properties like maximized, fullscreen, minimized, and to move and resize - * them, and associate metadata like title and app id. - * - * The client must call wl_surface.commit on the corresponding wl_surface - * for the xdg_surface state to take effect. Prior to committing the new - * state, it can set up initial configuration, such as maximizing or setting - * a window geometry. - * - * Even without attaching a buffer the compositor must respond to initial - * committed configuration, for instance sending a configure event with - * expected window geometry if the client maximized its surface during - * initialization. - * - * For a surface to be mapped by the compositor the client must have - * committed both an xdg_surface state and a buffer. - */ -extern const struct wl_interface xdg_surface_v5_interface; -/** - * @page page_iface_xdg_popup xdg_popup - * @section page_iface_xdg_popup_desc Description - * - * A popup surface is a short-lived, temporary surface that can be - * used to implement menus. It takes an explicit grab on the surface - * that will be dismissed when the user dismisses the popup. This can - * be done by the user clicking outside the surface, using the keyboard, - * or even locking the screen through closing the lid or a timeout. - * - * When the popup is dismissed, a popup_done event will be sent out, - * and at the same time the surface will be unmapped. The xdg_popup - * object is now inert and cannot be reactivated, so clients should - * destroy it. Explicitly destroying the xdg_popup object will also - * dismiss the popup and unmap the surface. - * - * Clients will receive events for all their surfaces during this - * grab (which is an "owner-events" grab in X11 parlance). This is - * done so that users can navigate through submenus and other - * "nested" popup windows without having to dismiss the topmost - * popup. - * - * Clients that want to dismiss the popup when another surface of - * their own is clicked should dismiss the popup using the destroy - * request. - * - * The parent surface must have either an xdg_surface or xdg_popup - * role. - * - * Specifying an xdg_popup for the parent means that the popups are - * nested, with this popup now being the topmost popup. Nested - * popups must be destroyed in the reverse order they were created - * in, e.g. the only popup you are allowed to destroy at all times - * is the topmost one. - * - * If there is an existing popup when creating a new popup, the - * parent must be the current topmost popup. - * - * A parent surface must be mapped before the new popup is mapped. - * - * When compositors choose to dismiss a popup, they will likely - * dismiss every nested popup as well. When a compositor dismisses - * popups, it will follow the same dismissing order as required - * from the client. - * - * The x and y arguments passed when creating the popup object specify - * where the top left of the popup should be placed, relative to the - * local surface coordinates of the parent surface. See - * xdg_shell.get_xdg_popup. - * - * The client must call wl_surface.commit on the corresponding wl_surface - * for the xdg_popup state to take effect. - * - * For a surface to be mapped by the compositor the client must have - * committed both the xdg_popup state and a buffer. - * @section page_iface_xdg_popup_api API - * See @ref iface_xdg_popup. - */ -/** - * @defgroup iface_xdg_popup The xdg_popup interface - * - * A popup surface is a short-lived, temporary surface that can be - * used to implement menus. It takes an explicit grab on the surface - * that will be dismissed when the user dismisses the popup. This can - * be done by the user clicking outside the surface, using the keyboard, - * or even locking the screen through closing the lid or a timeout. - * - * When the popup is dismissed, a popup_done event will be sent out, - * and at the same time the surface will be unmapped. The xdg_popup - * object is now inert and cannot be reactivated, so clients should - * destroy it. Explicitly destroying the xdg_popup object will also - * dismiss the popup and unmap the surface. - * - * Clients will receive events for all their surfaces during this - * grab (which is an "owner-events" grab in X11 parlance). This is - * done so that users can navigate through submenus and other - * "nested" popup windows without having to dismiss the topmost - * popup. - * - * Clients that want to dismiss the popup when another surface of - * their own is clicked should dismiss the popup using the destroy - * request. - * - * The parent surface must have either an xdg_surface or xdg_popup - * role. - * - * Specifying an xdg_popup for the parent means that the popups are - * nested, with this popup now being the topmost popup. Nested - * popups must be destroyed in the reverse order they were created - * in, e.g. the only popup you are allowed to destroy at all times - * is the topmost one. - * - * If there is an existing popup when creating a new popup, the - * parent must be the current topmost popup. - * - * A parent surface must be mapped before the new popup is mapped. - * - * When compositors choose to dismiss a popup, they will likely - * dismiss every nested popup as well. When a compositor dismisses - * popups, it will follow the same dismissing order as required - * from the client. - * - * The x and y arguments passed when creating the popup object specify - * where the top left of the popup should be placed, relative to the - * local surface coordinates of the parent surface. See - * xdg_shell.get_xdg_popup. - * - * The client must call wl_surface.commit on the corresponding wl_surface - * for the xdg_popup state to take effect. - * - * For a surface to be mapped by the compositor the client must have - * committed both the xdg_popup state and a buffer. - */ -extern const struct wl_interface xdg_popup_v5_interface; - -#ifndef XDG_SHELL_VERSION_ENUM -#define XDG_SHELL_VERSION_ENUM -/** - * @ingroup iface_xdg_shell - * latest protocol version - * - * The 'current' member of this enum gives the version of the - * protocol. Implementations can compare this to the version - * they implement using static_assert to ensure the protocol and - * implementation versions match. - */ -enum xdg_shell_version { - /** - * Always the latest version - */ - XDG_SHELL_VERSION_CURRENT = 5, -}; -#endif /* XDG_SHELL_VERSION_ENUM */ - -#ifndef XDG_SHELL_ERROR_ENUM -#define XDG_SHELL_ERROR_ENUM -enum xdg_shell_error { - /** - * given wl_surface has another role - */ - XDG_SHELL_ERROR_ROLE = 0, - /** - * xdg_shell was destroyed before children - */ - XDG_SHELL_ERROR_DEFUNCT_SURFACES = 1, - /** - * the client tried to map or destroy a non-topmost popup - */ - XDG_SHELL_ERROR_NOT_THE_TOPMOST_POPUP = 2, - /** - * the client specified an invalid popup parent surface - */ - XDG_SHELL_ERROR_INVALID_POPUP_PARENT = 3, -}; -#endif /* XDG_SHELL_ERROR_ENUM */ - -/** - * @ingroup iface_xdg_shell - * @struct xdg_shell_v5_interface - */ -struct xdg_shell_v5_interface { - /** - * destroy xdg_shell - * - * Destroy this xdg_shell object. - * - * Destroying a bound xdg_shell object while there are surfaces - * still alive created by this xdg_shell object instance is illegal - * and will result in a protocol error. - */ - void (*destroy)(struct wl_client *client, - struct wl_resource *resource); - /** - * enable use of this unstable version - * - * Negotiate the unstable version of the interface. This - * mechanism is in place to ensure client and server agree on the - * unstable versions of the protocol that they speak or exit - * cleanly if they don't agree. This request will go away once the - * xdg-shell protocol is stable. - */ - void (*use_unstable_version)(struct wl_client *client, - struct wl_resource *resource, - int32_t version); - /** - * create a shell surface from a surface - * - * This creates an xdg_surface for the given surface and gives it - * the xdg_surface role. A wl_surface can only be given an - * xdg_surface role once. If get_xdg_surface is called with a - * wl_surface that already has an active xdg_surface associated - * with it, or if it had any other role, an error is raised. - * - * See the documentation of xdg_surface for more details about what - * an xdg_surface is and how it is used. - */ - void (*get_xdg_surface)(struct wl_client *client, - struct wl_resource *resource, - uint32_t id, - struct wl_resource *surface); - /** - * create a popup for a surface - * - * This creates an xdg_popup for the given surface and gives it - * the xdg_popup role. A wl_surface can only be given an xdg_popup - * role once. If get_xdg_popup is called with a wl_surface that - * already has an active xdg_popup associated with it, or if it had - * any other role, an error is raised. - * - * This request must be used in response to some sort of user - * action like a button press, key press, or touch down event. - * - * See the documentation of xdg_popup for more details about what - * an xdg_popup is and how it is used. - * @param seat the wl_seat of the user event - * @param serial the serial of the user event - */ - void (*get_xdg_popup)(struct wl_client *client, - struct wl_resource *resource, - uint32_t id, - struct wl_resource *surface, - struct wl_resource *parent, - struct wl_resource *seat, - uint32_t serial, - int32_t x, - int32_t y); - /** - * respond to a ping event - * - * A client must respond to a ping event with a pong request or - * the client may be deemed unresponsive. - * @param serial serial of the ping event - */ - void (*pong)(struct wl_client *client, - struct wl_resource *resource, - uint32_t serial); -}; - -#define XDG_SHELL_PING 0 - -/** - * @ingroup iface_xdg_shell - */ -#define XDG_SHELL_PING_SINCE_VERSION 1 - -/** - * @ingroup iface_xdg_shell - */ -#define XDG_SHELL_DESTROY_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_shell - */ -#define XDG_SHELL_USE_UNSTABLE_VERSION_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_shell - */ -#define XDG_SHELL_GET_XDG_SURFACE_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_shell - */ -#define XDG_SHELL_GET_XDG_POPUP_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_shell - */ -#define XDG_SHELL_PONG_SINCE_VERSION 1 - -/** - * @ingroup iface_xdg_shell - * Sends an ping event to the client owning the resource. - * @param resource_ The client's resource - * @param serial pass this to the pong request - */ -static inline void -xdg_shell_send_ping(struct wl_resource *resource_, uint32_t serial) -{ - wl_resource_post_event(resource_, XDG_SHELL_PING, serial); -} - -#ifndef XDG_SURFACE_RESIZE_EDGE_ENUM -#define XDG_SURFACE_RESIZE_EDGE_ENUM -/** - * @ingroup iface_xdg_surface - * edge values for resizing - * - * These values are used to indicate which edge of a surface - * is being dragged in a resize operation. - */ -enum xdg_surface_resize_edge { - XDG_SURFACE_RESIZE_EDGE_NONE = 0, - XDG_SURFACE_RESIZE_EDGE_TOP = 1, - XDG_SURFACE_RESIZE_EDGE_BOTTOM = 2, - XDG_SURFACE_RESIZE_EDGE_LEFT = 4, - XDG_SURFACE_RESIZE_EDGE_TOP_LEFT = 5, - XDG_SURFACE_RESIZE_EDGE_BOTTOM_LEFT = 6, - XDG_SURFACE_RESIZE_EDGE_RIGHT = 8, - XDG_SURFACE_RESIZE_EDGE_TOP_RIGHT = 9, - XDG_SURFACE_RESIZE_EDGE_BOTTOM_RIGHT = 10, -}; -#endif /* XDG_SURFACE_RESIZE_EDGE_ENUM */ - -#ifndef XDG_SURFACE_STATE_ENUM -#define XDG_SURFACE_STATE_ENUM -/** - * @ingroup iface_xdg_surface - * types of state on the surface - * - * The different state values used on the surface. This is designed for - * state values like maximized, fullscreen. It is paired with the - * configure event to ensure that both the client and the compositor - * setting the state can be synchronized. - * - * States set in this way are double-buffered. They will get applied on - * the next commit. - * - * Desktop environments may extend this enum by taking up a range of - * values and documenting the range they chose in this description. - * They are not required to document the values for the range that they - * chose. Ideally, any good extensions from a desktop environment should - * make its way into standardization into this enum. - * - * The current reserved ranges are: - * - * 0x0000 - 0x0FFF: xdg-shell core values, documented below. - * 0x1000 - 0x1FFF: GNOME - */ -enum xdg_surface_state { - /** - * the surface is maximized - */ - XDG_SURFACE_STATE_MAXIMIZED = 1, - /** - * the surface is fullscreen - */ - XDG_SURFACE_STATE_FULLSCREEN = 2, - XDG_SURFACE_STATE_RESIZING = 3, - XDG_SURFACE_STATE_ACTIVATED = 4, -}; -#endif /* XDG_SURFACE_STATE_ENUM */ - -/** - * @ingroup iface_xdg_surface - * @struct xdg_surface_v5_interface - */ -struct xdg_surface_v5_interface { - /** - * Destroy the xdg_surface - * - * Unmap and destroy the window. The window will be effectively - * hidden from the user's point of view, and all state like - * maximization, fullscreen, and so on, will be lost. - */ - void (*destroy)(struct wl_client *client, - struct wl_resource *resource); - /** - * set the parent of this surface - * - * Set the "parent" of this surface. This window should be - * stacked above a parent. The parent surface must be mapped as - * long as this surface is mapped. - * - * Parent windows should be set on dialogs, toolboxes, or other - * "auxiliary" surfaces, so that the parent is raised when the - * dialog is raised. - */ - void (*set_parent)(struct wl_client *client, - struct wl_resource *resource, - struct wl_resource *parent); - /** - * set surface title - * - * Set a short title for the surface. - * - * This string may be used to identify the surface in a task bar, - * window list, or other user interface elements provided by the - * compositor. - * - * The string must be encoded in UTF-8. - */ - void (*set_title)(struct wl_client *client, - struct wl_resource *resource, - const char *title); - /** - * set application ID - * - * Set an application identifier for the surface. - * - * The app ID identifies the general class of applications to which - * the surface belongs. The compositor can use this to group - * multiple surfaces together, or to determine how to launch a new - * application. - * - * For D-Bus activatable applications, the app ID is used as the - * D-Bus service name. - * - * The compositor shell will try to group application surfaces - * together by their app ID. As a best practice, it is suggested to - * select app ID's that match the basename of the application's - * .desktop file. For example, "org.freedesktop.FooViewer" where - * the .desktop file is "org.freedesktop.FooViewer.desktop". - * - * See the desktop-entry specification [0] for more details on - * application identifiers and how they relate to well-known D-Bus - * names and .desktop files. - * - * [0] http://standards.freedesktop.org/desktop-entry-spec/ - */ - void (*set_app_id)(struct wl_client *client, - struct wl_resource *resource, - const char *app_id); - /** - * show the window menu - * - * Clients implementing client-side decorations might want to - * show a context menu when right-clicking on the decorations, - * giving the user a menu that they can use to maximize or minimize - * the window. - * - * This request asks the compositor to pop up such a window menu at - * the given position, relative to the local surface coordinates of - * the parent surface. There are no guarantees as to what menu - * items the window menu contains. - * - * This request must be used in response to some sort of user - * action like a button press, key press, or touch down event. - * @param seat the wl_seat of the user event - * @param serial the serial of the user event - * @param x the x position to pop up the window menu at - * @param y the y position to pop up the window menu at - */ - void (*show_window_menu)(struct wl_client *client, - struct wl_resource *resource, - struct wl_resource *seat, - uint32_t serial, - int32_t x, - int32_t y); - /** - * start an interactive move - * - * Start an interactive, user-driven move of the surface. - * - * This request must be used in response to some sort of user - * action like a button press, key press, or touch down event. The - * passed serial is used to determine the type of interactive move - * (touch, pointer, etc). - * - * The server may ignore move requests depending on the state of - * the surface (e.g. fullscreen or maximized), or if the passed - * serial is no longer valid. - * - * If triggered, the surface will lose the focus of the device - * (wl_pointer, wl_touch, etc) used for the move. It is up to the - * compositor to visually indicate that the move is taking place, - * such as updating a pointer cursor, during the move. There is no - * guarantee that the device focus will return when the move is - * completed. - * @param seat the wl_seat of the user event - * @param serial the serial of the user event - */ - void (*move)(struct wl_client *client, - struct wl_resource *resource, - struct wl_resource *seat, - uint32_t serial); - /** - * start an interactive resize - * - * Start a user-driven, interactive resize of the surface. - * - * This request must be used in response to some sort of user - * action like a button press, key press, or touch down event. The - * passed serial is used to determine the type of interactive - * resize (touch, pointer, etc). - * - * The server may ignore resize requests depending on the state of - * the surface (e.g. fullscreen or maximized). - * - * If triggered, the client will receive configure events with the - * "resize" state enum value and the expected sizes. See the - * "resize" enum value for more details about what is required. The - * client must also acknowledge configure events using - * "ack_configure". After the resize is completed, the client will - * receive another "configure" event without the resize state. - * - * If triggered, the surface also will lose the focus of the device - * (wl_pointer, wl_touch, etc) used for the resize. It is up to the - * compositor to visually indicate that the resize is taking place, - * such as updating a pointer cursor, during the resize. There is - * no guarantee that the device focus will return when the resize - * is completed. - * - * The edges parameter specifies how the surface should be resized, - * and is one of the values of the resize_edge enum. The compositor - * may use this information to update the surface position for - * example when dragging the top left corner. The compositor may - * also use this information to adapt its behavior, e.g. choose an - * appropriate cursor image. - * @param seat the wl_seat of the user event - * @param serial the serial of the user event - * @param edges which edge or corner is being dragged - */ - void (*resize)(struct wl_client *client, - struct wl_resource *resource, - struct wl_resource *seat, - uint32_t serial, - uint32_t edges); - /** - * ack a configure event - * - * When a configure event is received, if a client commits the - * surface in response to the configure event, then the client must - * make a ack_configure request before the commit request, passing - * along the serial of the configure event. - * - * For instance, the compositor might use this information to move - * a surface to the top left only when the client has drawn itself - * for the maximized or fullscreen state. - * - * If the client receives multiple configure events before it can - * respond to one, it only has to ack the last configure event. - * @param serial the serial from the configure event - */ - void (*ack_configure)(struct wl_client *client, - struct wl_resource *resource, - uint32_t serial); - /** - * set the new window geometry - * - * The window geometry of a window is its "visible bounds" from - * the user's perspective. Client-side decorations often have - * invisible portions like drop-shadows which should be ignored for - * the purposes of aligning, placing and constraining windows. - * - * The window geometry is double buffered, and will be applied at - * the time wl_surface.commit of the corresponding wl_surface is - * called. - * - * Once the window geometry of the surface is set once, it is not - * possible to unset it, and it will remain the same until - * set_window_geometry is called again, even if a new subsurface or - * buffer is attached. - * - * If never set, the value is the full bounds of the surface, - * including any subsurfaces. This updates dynamically on every - * commit. This unset mode is meant for extremely simple clients. - * - * If responding to a configure event, the window geometry in here - * must respect the sizing negotiations specified by the states in - * the configure event. - * - * The arguments are given in the surface local coordinate space of - * the wl_surface associated with this xdg_surface. - * - * The width and height must be greater than zero. - */ - void (*set_window_geometry)(struct wl_client *client, - struct wl_resource *resource, - int32_t x, - int32_t y, - int32_t width, - int32_t height); - /** - * maximize the window - * - * Maximize the surface. - * - * After requesting that the surface should be maximized, the - * compositor will respond by emitting a configure event with the - * "maximized" state and the required window geometry. The client - * should then update its content, drawing it in a maximized state, - * i.e. without shadow or other decoration outside of the window - * geometry. The client must also acknowledge the configure when - * committing the new content (see ack_configure). - * - * It is up to the compositor to decide how and where to maximize - * the surface, for example which output and what region of the - * screen should be used. - * - * If the surface was already maximized, the compositor will still - * emit a configure event with the "maximized" state. - */ - void (*set_maximized)(struct wl_client *client, - struct wl_resource *resource); - /** - * unmaximize the window - * - * Unmaximize the surface. - * - * After requesting that the surface should be unmaximized, the - * compositor will respond by emitting a configure event without - * the "maximized" state. If available, the compositor will include - * the window geometry dimensions the window had prior to being - * maximized in the configure request. The client must then update - * its content, drawing it in a regular state, i.e. potentially - * with shadow, etc. The client must also acknowledge the configure - * when committing the new content (see ack_configure). - * - * It is up to the compositor to position the surface after it was - * unmaximized; usually the position the surface had before - * maximizing, if applicable. - * - * If the surface was already not maximized, the compositor will - * still emit a configure event without the "maximized" state. - */ - void (*unset_maximized)(struct wl_client *client, - struct wl_resource *resource); - /** - * set the window as fullscreen on a monitor - * - * Make the surface fullscreen. - * - * You can specify an output that you would prefer to be - * fullscreen. If this value is NULL, it's up to the compositor to - * choose which display will be used to map this surface. - * - * If the surface doesn't cover the whole output, the compositor - * will position the surface in the center of the output and - * compensate with black borders filling the rest of the output. - */ - void (*set_fullscreen)(struct wl_client *client, - struct wl_resource *resource, - struct wl_resource *output); - /** - */ - void (*unset_fullscreen)(struct wl_client *client, - struct wl_resource *resource); - /** - * set the window as minimized - * - * Request that the compositor minimize your surface. There is no - * way to know if the surface is currently minimized, nor is there - * any way to unset minimization on this surface. - * - * If you are looking to throttle redrawing when minimized, please - * instead use the wl_surface.frame event for this, as this will - * also work with live previews on windows in Alt-Tab, Expose or - * similar compositor features. - */ - void (*set_minimized)(struct wl_client *client, - struct wl_resource *resource); -}; - -#define XDG_SURFACE_CONFIGURE 0 -#define XDG_SURFACE_CLOSE 1 - -/** - * @ingroup iface_xdg_surface - */ -#define XDG_SURFACE_CONFIGURE_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_surface - */ -#define XDG_SURFACE_CLOSE_SINCE_VERSION 1 - -/** - * @ingroup iface_xdg_surface - */ -#define XDG_SURFACE_DESTROY_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_surface - */ -#define XDG_SURFACE_SET_PARENT_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_surface - */ -#define XDG_SURFACE_SET_TITLE_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_surface - */ -#define XDG_SURFACE_SET_APP_ID_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_surface - */ -#define XDG_SURFACE_SHOW_WINDOW_MENU_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_surface - */ -#define XDG_SURFACE_MOVE_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_surface - */ -#define XDG_SURFACE_RESIZE_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_surface - */ -#define XDG_SURFACE_ACK_CONFIGURE_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_surface - */ -#define XDG_SURFACE_SET_WINDOW_GEOMETRY_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_surface - */ -#define XDG_SURFACE_SET_MAXIMIZED_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_surface - */ -#define XDG_SURFACE_UNSET_MAXIMIZED_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_surface - */ -#define XDG_SURFACE_SET_FULLSCREEN_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_surface - */ -#define XDG_SURFACE_UNSET_FULLSCREEN_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_surface - */ -#define XDG_SURFACE_SET_MINIMIZED_SINCE_VERSION 1 - -/** - * @ingroup iface_xdg_surface - * Sends an configure event to the client owning the resource. - * @param resource_ The client's resource - */ -static inline void -xdg_surface_send_configure(struct wl_resource *resource_, int32_t width, int32_t height, struct wl_array *states, uint32_t serial) -{ - wl_resource_post_event(resource_, XDG_SURFACE_CONFIGURE, width, height, states, serial); -} - -/** - * @ingroup iface_xdg_surface - * Sends an close event to the client owning the resource. - * @param resource_ The client's resource - */ -static inline void -xdg_surface_send_close(struct wl_resource *resource_) -{ - wl_resource_post_event(resource_, XDG_SURFACE_CLOSE); -} - -/** - * @ingroup iface_xdg_popup - * @struct xdg_popup_v5_interface - */ -struct xdg_popup_v5_interface { - /** - * remove xdg_popup interface - * - * This destroys the popup. Explicitly destroying the xdg_popup - * object will also dismiss the popup, and unmap the surface. - * - * If this xdg_popup is not the "topmost" popup, a protocol error - * will be sent. - */ - void (*destroy)(struct wl_client *client, - struct wl_resource *resource); -}; - -#define XDG_POPUP_POPUP_DONE 0 - -/** - * @ingroup iface_xdg_popup - */ -#define XDG_POPUP_POPUP_DONE_SINCE_VERSION 1 - -/** - * @ingroup iface_xdg_popup - */ -#define XDG_POPUP_DESTROY_SINCE_VERSION 1 - -/** - * @ingroup iface_xdg_popup - * Sends an popup_done event to the client owning the resource. - * @param resource_ The client's resource - */ -static inline void -xdg_popup_send_popup_done(struct wl_resource *resource_) -{ - wl_resource_post_event(resource_, XDG_POPUP_POPUP_DONE); -} - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/src/compositor/extensions/pregenerated/xdg-shell-v5.pri b/src/compositor/extensions/pregenerated/xdg-shell-v5.pri deleted file mode 100644 index 48d163f17..000000000 --- a/src/compositor/extensions/pregenerated/xdg-shell-v5.pri +++ /dev/null @@ -1,10 +0,0 @@ -# Putting pregenerated files in a 3rdparty directory to avoid -# qtqa's license checking failing. - -HEADERS += \ - $$PWD/3rdparty/qwayland-server-xdg-shell-unstable-v5_p.h \ - $$PWD/3rdparty/wayland-xdg-shell-unstable-v5-server-protocol_p.h - -SOURCES += \ - $$PWD/3rdparty/qwayland-server-xdg-shell-unstable-v5.cpp \ - $$PWD/3rdparty/wayland-xdg-shell-unstable-v5-protocol.c diff --git a/src/compositor/extensions/qwaylandidleinhibitv1.cpp b/src/compositor/extensions/qwaylandidleinhibitv1.cpp index b97f58130..dc90fb637 100644 --- a/src/compositor/extensions/qwaylandidleinhibitv1.cpp +++ b/src/compositor/extensions/qwaylandidleinhibitv1.cpp @@ -1,38 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2019 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** 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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2019 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <QtWaylandCompositor/QWaylandCompositor> #include <QtWaylandCompositor/private/qwaylandsurface_p.h> @@ -45,7 +12,7 @@ QT_BEGIN_NAMESPACE \class QWaylandIdleInhibitManagerV1 \inmodule QtWaylandCompositor \since 5.14 - \brief Provides an extension that allows to inhibit the idle behavior of the compositor + \brief Provides an extension that allows to inhibit the idle behavior of the compositor. \sa QWaylandSurface::inhibitsIdle The QWaylandIdleInhibitV1 extension provides a way for a client to inhibit the idle behavior of @@ -58,9 +25,10 @@ QT_BEGIN_NAMESPACE /*! \qmltype IdleInhibitManagerV1 + \instantiates QWaylandIdleInhibitManagerV1 \inqmlmodule QtWayland.Compositor \since 5.14 - \brief Provides an extension that allows to inhibit the idle behavior of the compositor + \brief Provides an extension that allows to inhibit the idle behavior of the compositor. \sa WaylandSurface::inhibitsIdle The IdleInhibitManagerV1 extension provides a way for a client to inhibit the idle behavior of @@ -71,8 +39,8 @@ QT_BEGIN_NAMESPACE To provide the functionality of the extension in a compositor, create an instance of the IdleInhibitManagerV1 component and add it to the list of extensions supported by the compositor: - \qml \QtMinorVersion - import QtWayland.Compositor 1.\1 + \qml + import QtWayland.Compositor WaylandCompositor { IdleInhibitManagerV1 { @@ -188,3 +156,5 @@ void QWaylandIdleInhibitManagerV1Private::Inhibitor::zwp_idle_inhibitor_v1_destr } QT_END_NAMESPACE + +#include "moc_qwaylandidleinhibitv1.cpp" diff --git a/src/compositor/extensions/qwaylandidleinhibitv1.h b/src/compositor/extensions/qwaylandidleinhibitv1.h index 53c09d084..5d3dc3eca 100644 --- a/src/compositor/extensions/qwaylandidleinhibitv1.h +++ b/src/compositor/extensions/qwaylandidleinhibitv1.h @@ -1,38 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2019 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** 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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2019 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDIDLEINHIBITV1_H #define QWAYLANDIDLEINHIBITV1_H @@ -43,7 +10,7 @@ QT_BEGIN_NAMESPACE class QWaylandIdleInhibitManagerV1Private; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandIdleInhibitManagerV1 : public QWaylandCompositorExtensionTemplate<QWaylandIdleInhibitManagerV1> +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandIdleInhibitManagerV1 : public QWaylandCompositorExtensionTemplate<QWaylandIdleInhibitManagerV1> { Q_OBJECT Q_DECLARE_PRIVATE(QWaylandIdleInhibitManagerV1) diff --git a/src/compositor/extensions/qwaylandidleinhibitv1_p.h b/src/compositor/extensions/qwaylandidleinhibitv1_p.h index 380551804..1899c109e 100644 --- a/src/compositor/extensions/qwaylandidleinhibitv1_p.h +++ b/src/compositor/extensions/qwaylandidleinhibitv1_p.h @@ -1,38 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2019 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** 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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2019 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDIDLEINHIBITV1_P_H #define QWAYLANDIDLEINHIBITV1_P_H @@ -42,6 +9,8 @@ #include <QtWaylandCompositor/private/qwaylandcompositorextension_p.h> #include <QtWaylandCompositor/private/qwayland-server-idle-inhibit-unstable-v1.h> +#include <QtCore/qpointer.h> + // // W A R N I N G // ------------- @@ -55,7 +24,7 @@ QT_BEGIN_NAMESPACE -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandIdleInhibitManagerV1Private +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandIdleInhibitManagerV1Private : public QWaylandCompositorExtensionPrivate , public QtWaylandServer::zwp_idle_inhibit_manager_v1 { @@ -63,7 +32,7 @@ class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandIdleInhibitManagerV1Private public: explicit QWaylandIdleInhibitManagerV1Private() = default; - class Q_WAYLAND_COMPOSITOR_EXPORT Inhibitor + class Q_WAYLANDCOMPOSITOR_EXPORT Inhibitor : public QtWaylandServer::zwp_idle_inhibitor_v1 { public: diff --git a/src/compositor/extensions/qwaylandiviapplication.cpp b/src/compositor/extensions/qwaylandiviapplication.cpp index d0422a052..db9130829 100644 --- a/src/compositor/extensions/qwaylandiviapplication.cpp +++ b/src/compositor/extensions/qwaylandiviapplication.cpp @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "qwaylandiviapplication.h" #include "qwaylandiviapplication_p.h" @@ -39,7 +13,8 @@ QT_BEGIN_NAMESPACE /*! * \qmltype IviApplication - * \inqmlmodule QtWayland.Compositor + * \instantiates QWaylandIviApplication + * \inqmlmodule QtWayland.Compositor.IviApplication * \since 5.8 * \brief Provides a shell extension for embedded-style user interfaces. * @@ -53,8 +28,8 @@ QT_BEGIN_NAMESPACE * an instance of the IviApplication component and add it to the list of extensions * supported by the compositor: * - * \qml \QtMinorVersion - * import QtWayland.Compositor 1.\1 + * \qml + * import QtWayland.Compositor.IviApplication * * WaylandCompositor { * IviApplication { @@ -131,7 +106,7 @@ QByteArray QWaylandIviApplication::interfaceName() } /*! - * \qmlsignal void QtWaylandCompositor::IviApplication::iviSurfaceRequested(WaylandSurface surface, int iviId, WaylandResource resource) + * \qmlsignal void IviApplication::iviSurfaceRequested(WaylandSurface surface, int iviId, WaylandResource resource) * * This signal is emitted when the client has requested an \c ivi_surface to be associated * with \a surface, which is identified by \a iviId. The handler for this signal is @@ -145,12 +120,12 @@ QByteArray QWaylandIviApplication::interfaceName() * * This signal is emitted when the client has requested an \c ivi_surface to be associated * with \a surface, which is identified by \a iviId. The handler for this signal is - * expected to create the ivi surface and initialize it within the scope of the + * expected to create the ivi surface for \a resource and initialize it within the scope of the * signal emission. If no ivi surface is created, a default one will be created instead. */ /*! - * \qmlsignal void QtWaylandCompositor::IviApplication::iviSurfaceCreated(IviSurface *iviSurface) + * \qmlsignal void IviApplication::iviSurfaceCreated(IviSurface *iviSurface) * * This signal is emitted when an IviSurface has been created. The supplied \a iviSurface is * most commonly used to instantiate a ShellSurfaceItem. @@ -203,3 +178,5 @@ void QWaylandIviApplicationPrivate::ivi_application_surface_create(QtWaylandServ } QT_END_NAMESPACE + +#include "moc_qwaylandiviapplication.cpp" diff --git a/src/compositor/extensions/qwaylandiviapplication.h b/src/compositor/extensions/qwaylandiviapplication.h index d9756811c..5472ff05a 100644 --- a/src/compositor/extensions/qwaylandiviapplication.h +++ b/src/compositor/extensions/qwaylandiviapplication.h @@ -1,46 +1,20 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDIVIAPPLICATION_H #define QWAYLANDIVIAPPLICATION_H #include <QtWaylandCompositor/QWaylandCompositorExtension> +#include <QtWaylandCompositor/QWaylandSurface> +#include <QtWaylandCompositor/QWaylandResource> +#include <QtWaylandCompositor/QWaylandIviSurface> #include <QtCore/QSize> QT_BEGIN_NAMESPACE -class QWaylandIviSurface; -class QWaylandSurface; -class QWaylandResource; class QWaylandIviApplicationPrivate; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandIviApplication : public QWaylandCompositorExtensionTemplate<QWaylandIviApplication> +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandIviApplication : public QWaylandCompositorExtensionTemplate<QWaylandIviApplication> { Q_OBJECT Q_DECLARE_PRIVATE(QWaylandIviApplication) diff --git a/src/compositor/extensions/qwaylandiviapplication_p.h b/src/compositor/extensions/qwaylandiviapplication_p.h index f08f05345..1a2988245 100644 --- a/src/compositor/extensions/qwaylandiviapplication_p.h +++ b/src/compositor/extensions/qwaylandiviapplication_p.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDIVIAPPLICATION_P_H #define QWAYLANDIVIAPPLICATION_P_H @@ -50,7 +24,7 @@ QT_BEGIN_NAMESPACE -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandIviApplicationPrivate +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandIviApplicationPrivate : public QWaylandCompositorExtensionPrivate , public QtWaylandServer::ivi_application { diff --git a/src/compositor/extensions/qwaylandivisurface.cpp b/src/compositor/extensions/qwaylandivisurface.cpp index 81a7da107..493416abf 100644 --- a/src/compositor/extensions/qwaylandivisurface.cpp +++ b/src/compositor/extensions/qwaylandivisurface.cpp @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "qwaylandivisurface.h" #include "qwaylandivisurface_p.h" @@ -45,7 +19,8 @@ QWaylandSurfaceRole QWaylandIviSurfacePrivate::s_role("ivi_surface"); /*! * \qmltype IviSurface - * \inqmlmodule QtWayland.Compositor + * \instantiates QWaylandIviSurface + * \inqmlmodule QtWayland.Compositor.IviApplication * \since 5.8 * \brief Provides a simple way to identify and resize a surface. * @@ -86,7 +61,7 @@ QWaylandIviSurface::QWaylandIviSurface(QWaylandIviApplication *application, QWay } /*! - * \qmlmethod void QtWaylandCompositor::IviSurface::initialize(IviApplication iviApplication, WaylandSurface surface, int iviId, WaylandResource resource) + * \qmlmethod void IviSurface::initialize(IviApplication iviApplication, WaylandSurface surface, int iviId, WaylandResource resource) * * Initializes the IviSurface, associating it with the given \a iviApplication, \a surface, * \a iviId, and \a resource. @@ -114,7 +89,7 @@ void QWaylandIviSurface::initialize(QWaylandIviApplication *iviApplication, QWay } /*! - * \qmlproperty WaylandSurface QtWaylandCompositor::IviSurface::surface + * \qmlproperty WaylandSurface IviSurface::surface * * This property holds the surface associated with this IviSurface. */ @@ -131,7 +106,7 @@ QWaylandSurface *QWaylandIviSurface::surface() const } /*! - * \qmlproperty int QtWaylandCompositor::IviSurface::iviId + * \qmlproperty int IviSurface::iviId * \readonly * * This property holds the ivi id id of this IviSurface. @@ -180,7 +155,7 @@ QWaylandIviSurface *QWaylandIviSurface::fromResource(wl_resource *resource) } /*! - * \qmlmethod int QtWaylandCompositor::IviSurface::sendConfigure(size size) + * \qmlmethod int IviSurface::sendConfigure(size size) * * Sends a configure event to the client, telling it to resize the surface to the given \a size. */ @@ -231,3 +206,5 @@ void QWaylandIviSurfacePrivate::ivi_surface_destroy(QtWaylandServer::ivi_surface } QT_END_NAMESPACE + +#include "moc_qwaylandivisurface.cpp" diff --git a/src/compositor/extensions/qwaylandivisurface.h b/src/compositor/extensions/qwaylandivisurface.h index fa5a7c7e0..09f18c3ed 100644 --- a/src/compositor/extensions/qwaylandivisurface.h +++ b/src/compositor/extensions/qwaylandivisurface.h @@ -1,37 +1,13 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDIVISURFACE_H #define QWAYLANDIVISURFACE_H #include <QtWaylandCompositor/QWaylandShellSurface> +#if QT_CONFIG(wayland_compositor_quick) #include <QtWaylandCompositor/qwaylandquickchildren.h> +#endif struct wl_resource; @@ -43,13 +19,16 @@ class QWaylandIviApplication; class QWaylandSurfaceRole; class QWaylandResource; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandIviSurface : public QWaylandShellSurfaceTemplate<QWaylandIviSurface> +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandIviSurface : public QWaylandShellSurfaceTemplate<QWaylandIviSurface> { Q_OBJECT Q_DECLARE_PRIVATE(QWaylandIviSurface) +#if QT_CONFIG(wayland_compositor_quick) Q_WAYLAND_COMPOSITOR_DECLARE_QUICK_CHILDREN(QWaylandIviSurface) +#endif Q_PROPERTY(QWaylandSurface *surface READ surface NOTIFY surfaceChanged) Q_PROPERTY(uint iviId READ iviId NOTIFY iviIdChanged) + Q_MOC_INCLUDE("qwaylandsurface.h") public: QWaylandIviSurface(); diff --git a/src/compositor/extensions/qwaylandivisurface_p.h b/src/compositor/extensions/qwaylandivisurface_p.h index 2ef66b1ab..d721dff69 100644 --- a/src/compositor/extensions/qwaylandivisurface_p.h +++ b/src/compositor/extensions/qwaylandivisurface_p.h @@ -1,36 +1,10 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDIVISURFACE_P_H #define QWAYLANDIVISURFACE_P_H -#include <QtWaylandCompositor/private/qwaylandcompositorextension_p.h> +#include <QtWaylandCompositor/private/qwaylandshellsurface_p.h> #include <QtWaylandCompositor/private/qwayland-server-ivi-application.h> #include <QtWaylandCompositor/QWaylandIviSurface> @@ -50,8 +24,8 @@ QT_BEGIN_NAMESPACE -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandIviSurfacePrivate - : public QWaylandCompositorExtensionPrivate +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandIviSurfacePrivate + : public QWaylandShellSurfacePrivate , public QtWaylandServer::ivi_surface { Q_DECLARE_PUBLIC(QWaylandIviSurface) diff --git a/src/compositor/extensions/qwaylandivisurfaceintegration.cpp b/src/compositor/extensions/qwaylandivisurfaceintegration.cpp index f8cba9962..8449df684 100644 --- a/src/compositor/extensions/qwaylandivisurfaceintegration.cpp +++ b/src/compositor/extensions/qwaylandivisurfaceintegration.cpp @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "qwaylandivisurfaceintegration_p.h" @@ -60,3 +34,5 @@ void IviSurfaceIntegration::handleIviSurfaceDestroyed() } QT_END_NAMESPACE + +#include "moc_qwaylandivisurfaceintegration_p.cpp" diff --git a/src/compositor/extensions/qwaylandivisurfaceintegration_p.h b/src/compositor/extensions/qwaylandivisurfaceintegration_p.h index be56b4b8c..827d3e9d5 100644 --- a/src/compositor/extensions/qwaylandivisurfaceintegration_p.h +++ b/src/compositor/extensions/qwaylandivisurfaceintegration_p.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDIVISURFACEINTEGRATION_H #define QWAYLANDIVISURFACEINTEGRATION_H diff --git a/src/compositor/extensions/qwaylandpresentationtime.cpp b/src/compositor/extensions/qwaylandpresentationtime.cpp new file mode 100644 index 000000000..637fc5d68 --- /dev/null +++ b/src/compositor/extensions/qwaylandpresentationtime.cpp @@ -0,0 +1,340 @@ +// Copyright (C) 2021 LG Electronics Inc. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#include "qwaylandpresentationtime_p.h" +#include "qwaylandpresentationtime_p_p.h" + +#include <time.h> +#include <QQuickWindow> +#include <QtWaylandCompositor/QWaylandView> +#include <QtWaylandCompositor/QWaylandQuickItem> + +QT_BEGIN_NAMESPACE + +/*! + * \qmltype PresentationTime + * \instantiates QWaylandPresentationTime + * \inqmlmodule QtWayland.Compositor.PresentationTime + * \since 6.3 + * \brief Provides tracking the timing when a frame is presented on screen. + * + * The PresentationTime extension provides a way to track rendering timing + * for a surface. Client can request feedbacks associated with a surface, + * then compositor send events for the feedback with the time when the surface + * is presented on-screen. + * + * PresentationTime corresponds to the Wayland \c wp_presentation interface. + * + * To provide the functionality of the presentationtime extension in a compositor, create + * an instance of the PresentationTime component and add it to the list of extensions + * supported by the compositor: + * + * Then, call sendFeedback() when a surface is presented on screen. + * Usually, the timing can be obtained from drm page flip event. + * + * \qml + * import QtWayland.Compositor.PresentationTime + * + * WaylandCompositor { + * PresentationTime { + * id: presentationTime + * } + * } + * \endqml + */ + +/*! + * \class QWaylandPresentationTime + * \inmodule QtWaylandCompositor + * \since 6.3 + * \brief The QWaylandPresentationTime class is an extension to get timing for on-screen presentation. + * + * The QWaylandPresentationTime extension provides a way to track rendering timing + * for a surface. Client can request feedbacks associated with a surface, + * then compositor send events for the feedback with the time when the surface + * is presented on-screen. + * + * QWaylandPresentationTime corresponds to the Wayland \c wp_presentation interface. + */ + + +/*! + * Constructs a QWaylandPresentationTime object for \a compositor. + */ +QWaylandPresentationTime::QWaylandPresentationTime(QWaylandCompositor *compositor) + : QWaylandCompositorExtensionTemplate(compositor, *new QWaylandPresentationTimePrivate) +{ + +} + +/*! + * Constructs an empty QWaylandPresentationTime object. + */ +QWaylandPresentationTime::QWaylandPresentationTime() + : QWaylandCompositorExtensionTemplate(*new QWaylandPresentationTimePrivate) +{ +} + +/*! + * Initializes the extension. + */ +void QWaylandPresentationTime::initialize() +{ + Q_D(QWaylandPresentationTime); + + if (isInitialized()) { + qWarning() << "QWaylandPresentationTime is already initialized"; + return; + } + + QWaylandCompositor *compositor = this->compositor(); + if (compositor == nullptr) { + qWarning() << "Failed to find QWaylandCompositor when initializing QWaylandPresentationTime"; + return; + } + + QWaylandCompositorExtensionTemplate::initialize(); + + d->init(compositor->display(), /* version */ 1); +} + +QWaylandCompositor *QWaylandPresentationTime::compositor() const +{ + return qobject_cast<QWaylandCompositor *>(extensionContainer()); +} + +/*! + * \qmlmethod void PresentationTime::sendFeedback(Window window, int sequence, int sec, int nsec) + * + * Interface to notify that a frame is presented on screen using \a window. + * If your platform supports DRM events, \c page_flip_handler is the proper timing to send it. + * The \a sequence is the refresh counter. \a sec and \a nsec hold the + * seconds and nanoseconds parts of the presentation timestamp, respectively. + */ + +/*! + * Interface to notify that a frame is presented on screen using \a window. + * If your platform supports DRM events, \c page_flip_handler is the proper timing to send it. + * The \a sequence is the refresh counter. \a tv_sec and \a tv_nsec hold the + * seconds and nanoseconds parts of the presentation timestamp, respectively. + */ +void QWaylandPresentationTime::sendFeedback(QQuickWindow *window, quint64 sequence, quint64 tv_sec, quint32 tv_nsec) +{ + if (!window) + return; + + quint32 refresh_nsec = window->screen()->refreshRate() != 0 ? 1000000000 / window->screen()->refreshRate() : 0; + + emit presented(sequence, tv_sec, tv_nsec, refresh_nsec); +} + +/*! + * Returns the Wayland interface for the QWaylandPresentationTime. + */ +const struct wl_interface *QWaylandPresentationTime::interface() +{ + return QWaylandPresentationTimePrivate::interface(); +} + +/*! + * \internal + */ +QByteArray QWaylandPresentationTime::interfaceName() +{ + return QWaylandPresentationTimePrivate::interfaceName(); +} + +PresentationFeedback::PresentationFeedback(QWaylandPresentationTime *pTime, QWaylandSurface *surface, struct ::wl_client *client, uint32_t id, int version) + : wp_presentation_feedback(client, id, version) + , m_presentationTime(pTime) +{ + setSurface(surface); +} + +void PresentationFeedback::setSurface(QWaylandSurface *qwls) +{ + if (!qwls) { + discard(); + return; + } + + m_surface = qwls; + + connect(qwls, &QWaylandSurface::damaged, this, &PresentationFeedback::onSurfaceCommit); + connect(qwls, &QWaylandSurface::destroyed, this, &PresentationFeedback::discard); + + QWaylandView *view = qwls ? qwls->primaryView() : nullptr; + //The surface has not committed yet. + if (!view) { + connect(qwls, &QWaylandSurface::hasContentChanged, this, &PresentationFeedback::onSurfaceMapped); + return; + } + + maybeConnectToWindow(view); +} + +void PresentationFeedback::onSurfaceCommit() +{ + // There is a new commit before sync so that discard this feedback. + if (m_committed) { + discard(); + return; + } + m_committed = true; +} + +void PresentationFeedback::onSurfaceMapped() +{ + QWaylandView *view = m_surface->primaryView(); + if (!view) { + qWarning() << "The mapped surface has no view"; + discard(); + return; + } + + maybeConnectToWindow(view); +} + +void PresentationFeedback::maybeConnectToWindow(QWaylandView *view) +{ + QWaylandQuickItem *item = view ? qobject_cast<QWaylandQuickItem *>(view->renderObject()) : nullptr; + if (!item) { + qWarning() << "QWaylandPresentationTime only works with QtQuick compositors" << view; + discard(); + return; + } + + connect(item, &QQuickItem::windowChanged, this, &PresentationFeedback::onWindowChanged); + // wait for having window + if (!item->window()) { + return; + } + + connectToWindow(item->window()); +} + +void PresentationFeedback::onWindowChanged() +{ + QWaylandQuickItem *item = qobject_cast<QWaylandQuickItem *>(sender()); + QQuickWindow *window = item ? item->window() : nullptr; + + if (!window) { + qWarning() << "QWaylandPresentationTime only works with QtQuick compositors" << item; + discard(); + /* Actually, the commit is not discarded yet. If the related item has new window, + the commit can be presented on screen. So we can choose not to discard the feedback + until item has new window or the surface is destroyed. */ + return; + } + + // Check if the connected window is changed + if (m_connectedWindow && m_connectedWindow != window) + m_connectedWindow->disconnect(this); + + connectToWindow(window); +} + +void PresentationFeedback::connectToWindow(QQuickWindow *window) +{ + if (!window) { + discard(); + return; + } + + m_connectedWindow = window; + + connect(window, &QQuickWindow::beforeSynchronizing, this, &PresentationFeedback::onSync); + connect(window, &QQuickWindow::afterFrameEnd, this, &PresentationFeedback::onSwapped); +} + +void PresentationFeedback::onSync() +{ + QQuickWindow *window = qobject_cast<QQuickWindow *>(sender()); + + if (m_committed) { + disconnect(m_surface, &QWaylandSurface::damaged, this, &PresentationFeedback::onSurfaceCommit); + disconnect(window, &QQuickWindow::beforeSynchronizing, this, &PresentationFeedback::onSync); + m_sync = true; + } +} + +void PresentationFeedback::onSwapped() +{ + QQuickWindow *window = qobject_cast<QQuickWindow *>(sender()); + + if (m_sync) { + disconnect(window, &QQuickWindow::afterFrameEnd, this, &PresentationFeedback::onSwapped); + connect(m_presentationTime, &QWaylandPresentationTime::presented, this, &PresentationFeedback::sendPresented); + } +} + +void PresentationFeedback::discard() +{ + send_discarded(); + destroy(); +} + +void PresentationFeedback::sendSyncOutput() +{ + QWaylandCompositor *compositor = presentationTime()->compositor(); + if (!compositor) { + qWarning() << "No compositor container to send sync_output"; + return; + } + + QWaylandView *view = surface()->primaryView(); + QWaylandOutput *output = view ? view->output() : nullptr; + struct ::wl_resource *r = output ? output->resourceForClient(QWaylandClient::fromWlClient(compositor, resource()->client())) : nullptr; + + if (r) + send_sync_output(r); +} + +void PresentationFeedback::sendPresented(quint64 sequence, quint64 tv_sec, quint32 tv_nsec, quint32 refresh_nsec) +{ + sendSyncOutput(); + + send_presented(tv_sec >> 32, tv_sec, tv_nsec, refresh_nsec, sequence >> 32, sequence, + QtWaylandServer::wp_presentation_feedback::kind_vsync + | QtWaylandServer::wp_presentation_feedback::kind_hw_clock + | QtWaylandServer::wp_presentation_feedback::kind_hw_completion); + + destroy(); +} + +void PresentationFeedback::destroy() +{ + wl_resource_destroy(resource()->handle); +} + +void PresentationFeedback::wp_presentation_feedback_destroy_resource(Resource *resource) +{ + Q_UNUSED(resource); + delete this; +} + +QWaylandPresentationTimePrivate::QWaylandPresentationTimePrivate() +{ +} + +void QWaylandPresentationTimePrivate::wp_presentation_bind_resource(Resource *resource) +{ + send_clock_id(resource->handle, CLOCK_MONOTONIC); +} + +void QWaylandPresentationTimePrivate::wp_presentation_feedback(Resource *resource, struct ::wl_resource *surface, uint32_t callback) +{ + Q_Q(QWaylandPresentationTime); + + QWaylandSurface *qwls = QWaylandSurface::fromResource(surface); + if (!qwls) + return; + + new PresentationFeedback(q, qwls, resource->client(), callback, /* version */ 1); +} + +QT_END_NAMESPACE + +#include "moc_qwaylandpresentationtime_p_p.cpp" + +#include "moc_qwaylandpresentationtime_p.cpp" diff --git a/src/compositor/extensions/qwaylandpresentationtime_p.h b/src/compositor/extensions/qwaylandpresentationtime_p.h new file mode 100644 index 000000000..c57cd91d2 --- /dev/null +++ b/src/compositor/extensions/qwaylandpresentationtime_p.h @@ -0,0 +1,49 @@ +// Copyright (C) 2021 LG Electronics Inc. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#ifndef QWAYLANDPRESENTATIONTIME_P_H +#define QWAYLANDPRESENTATIONTIME_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QObject> +#include <QtWaylandCompositor/qwaylandcompositorextension.h> +#include <QtCore/private/qglobal_p.h> + +QT_BEGIN_NAMESPACE + +class QQuickWindow; +class QWaylandPresentationTimePrivate; + +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandPresentationTime : public QWaylandCompositorExtensionTemplate<QWaylandPresentationTime> +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QWaylandPresentationTime) +public: + QWaylandPresentationTime(); + QWaylandPresentationTime(QWaylandCompositor *compositor); + + QWaylandCompositor *compositor() const; + void initialize() override; + + Q_INVOKABLE void sendFeedback(QQuickWindow *window, quint64 sequence, quint64 tv_sec, quint32 tv_nsec); + + static const struct wl_interface *interface(); + static QByteArray interfaceName(); + +Q_SIGNALS: + void presented(quint64 sequence, quint64 tv_sec, quint32 tv_nsec, quint32 refresh_nsec); +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/compositor/extensions/qwaylandpresentationtime_p_p.h b/src/compositor/extensions/qwaylandpresentationtime_p_p.h new file mode 100644 index 000000000..8e0cf42af --- /dev/null +++ b/src/compositor/extensions/qwaylandpresentationtime_p_p.h @@ -0,0 +1,82 @@ +// Copyright (C) 2021 LG Electronics Inc. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#ifndef QWAYLANDPRESENTATIONTIME_P_P_H +#define QWAYLANDPRESENTATIONTIME_P_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtWaylandCompositor/private/qwaylandcompositorextension_p.h> +#include <QtWaylandCompositor/private/qwayland-server-presentation-time.h> + +#include <QObject> +#include <QPointer> +#include <QMultiMap> + +QT_BEGIN_NAMESPACE + + +class QWaylandSurface; +class QWaylandView; +class QQuickWindow; + +class PresentationFeedback : public QObject, public QtWaylandServer::wp_presentation_feedback +{ + Q_OBJECT +public: + PresentationFeedback(QWaylandPresentationTime *, QWaylandSurface *, struct ::wl_client *, uint32_t, int); + + void setSurface(QWaylandSurface *); + QWaylandSurface *surface() { return m_surface; } + + void destroy(); + void sendSyncOutput(); + +private Q_SLOTS: + void discard(); + void onSurfaceCommit(); + void onSurfaceMapped(); + void onWindowChanged(); + void onSync(); + void onSwapped(); + void sendPresented(quint64 sequence, quint64 tv_sec, quint32 tv_nsec, quint32 refresh_nsec); + +private: + QWaylandPresentationTime *presentationTime() { return m_presentationTime; } + void maybeConnectToWindow(QWaylandView *); + void connectToWindow(QQuickWindow *); + + void wp_presentation_feedback_destroy_resource(Resource *resource) override; + +public: + QWaylandPresentationTime *m_presentationTime = nullptr; + QWaylandSurface *m_surface = nullptr; + QQuickWindow *m_connectedWindow = nullptr; + + bool m_committed = false; + bool m_sync = false; +}; + +class QWaylandPresentationTimePrivate : public QWaylandCompositorExtensionPrivate, public QtWaylandServer::wp_presentation +{ + Q_DECLARE_PUBLIC(QWaylandPresentationTime) +public: + QWaylandPresentationTimePrivate(); + +protected: + void wp_presentation_feedback(Resource *resource, struct ::wl_resource *surface, uint32_t callback) override; + void wp_presentation_bind_resource(Resource *resource) override; +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/compositor/extensions/qwaylandqttextinputmethod.cpp b/src/compositor/extensions/qwaylandqttextinputmethod.cpp new file mode 100644 index 000000000..edcf28d30 --- /dev/null +++ b/src/compositor/extensions/qwaylandqttextinputmethod.cpp @@ -0,0 +1,435 @@ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#include "qwaylandqttextinputmethod.h" +#include "qwaylandqttextinputmethod_p.h" + +#include <QtGui/qevent.h> +#include <QtGui/qguiapplication.h> +#include <QtGui/qinputmethod.h> +#include <QtGui/qcolor.h> +#include <QtGui/qtextformat.h> + +#include <QtWaylandCompositor/qwaylandcompositor.h> +#include <QtWaylandCompositor/qwaylandsurface.h> + +QT_BEGIN_NAMESPACE + +QWaylandQtTextInputMethodPrivate::QWaylandQtTextInputMethodPrivate(QWaylandCompositor *c) + : compositor(c) +{ +} + +void QWaylandQtTextInputMethodPrivate::text_input_method_v1_enable(Resource *resource, struct ::wl_resource *surface) +{ + Q_Q(QWaylandQtTextInputMethod); + if (this->resource == resource) { + QWaylandSurface *waylandSurface = QWaylandSurface::fromResource(surface); + if (surface != nullptr) { + enabledSurfaces[resource] = waylandSurface; + emit q->surfaceEnabled(waylandSurface); + } + } +} + +void QWaylandQtTextInputMethodPrivate::text_input_method_v1_disable(Resource *resource, struct ::wl_resource *surface) +{ + Q_Q(QWaylandQtTextInputMethod); + if (this->resource == resource) { + QWaylandSurface *waylandSurface = QWaylandSurface::fromResource(surface); + QWaylandSurface *enabledSurface = enabledSurfaces.take(resource); + + if (Q_UNLIKELY(enabledSurface != waylandSurface)) + qCWarning(qLcWaylandCompositorInputMethods) << "Disabled surface does not match the one currently enabled"; + + emit q->surfaceEnabled(waylandSurface); + } +} + +void QWaylandQtTextInputMethodPrivate::text_input_method_v1_destroy(Resource *resource) +{ + if (this->resource == resource) + wl_resource_destroy(resource->handle); +} + +void QWaylandQtTextInputMethodPrivate::text_input_method_v1_reset(Resource *resource) +{ + if (this->resource == resource) + qApp->inputMethod()->reset(); +} + +void QWaylandQtTextInputMethodPrivate::text_input_method_v1_commit(Resource *resource) +{ + if (this->resource == resource) + qApp->inputMethod()->commit(); +} + +void QWaylandQtTextInputMethodPrivate::text_input_method_v1_show_input_panel(Resource *resource) +{ + if (this->resource == resource) + qApp->inputMethod()->show(); +} + +void QWaylandQtTextInputMethodPrivate::text_input_method_v1_hide_input_panel(Resource *resource) +{ + if (this->resource == resource) + qApp->inputMethod()->hide(); +} + +void QWaylandQtTextInputMethodPrivate::text_input_method_v1_invoke_action(Resource *resource, int32_t type, int32_t cursorPosition) +{ + if (this->resource == resource) + qApp->inputMethod()->invokeAction(QInputMethod::Action(type), cursorPosition); +} + +void QWaylandQtTextInputMethodPrivate::text_input_method_v1_update_cursor_rectangle(Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height) +{ + if (this->resource == resource) + cursorRectangle = QRect(x, y, width, height); +} + +void QWaylandQtTextInputMethodPrivate::text_input_method_v1_start_update(Resource *resource, int32_t queries) +{ + if (this->resource == resource) + updatingQueries = Qt::InputMethodQueries(queries); +} + +void QWaylandQtTextInputMethodPrivate::text_input_method_v1_update_hints(Resource *resource, int32_t hints) +{ + if (this->resource == resource) + this->hints = Qt::InputMethodHints(hints); +} + +void QWaylandQtTextInputMethodPrivate::text_input_method_v1_update_anchor_position(Resource *resource, int32_t anchorPosition) +{ + if (this->resource == resource) + this->anchorPosition = anchorPosition; +} + +void QWaylandQtTextInputMethodPrivate::text_input_method_v1_update_cursor_position(Resource *resource, int32_t cursorPosition) +{ + if (this->resource == resource) + this->cursorPosition = cursorPosition; +} + +void QWaylandQtTextInputMethodPrivate::text_input_method_v1_update_surrounding_text(Resource *resource, const QString &surroundingText, int32_t surroundingTextOffset) +{ + if (this->resource == resource) { + this->surroundingText = surroundingText; + this->surroundingTextOffset = surroundingTextOffset; + } +} + +void QWaylandQtTextInputMethodPrivate::text_input_method_v1_update_absolute_position(Resource *resource, int32_t absolutePosition) +{ + if (this->resource == resource) + this->absolutePosition = absolutePosition; +} + +void QWaylandQtTextInputMethodPrivate::text_input_method_v1_update_preferred_language(Resource *resource, const QString &preferredLanguage) +{ + if (this->resource == resource) + this->preferredLanguage = preferredLanguage; +} + +void QWaylandQtTextInputMethodPrivate::text_input_method_v1_end_update(Resource *resource) +{ + Q_Q(QWaylandQtTextInputMethod); + if (this->resource == resource && updatingQueries != 0) { + Qt::InputMethodQueries queries = updatingQueries; + updatingQueries = Qt::InputMethodQueries(); + emit q->updateInputMethod(queries); + } +} + +void QWaylandQtTextInputMethodPrivate::text_input_method_v1_acknowledge_input_method(Resource *resource) +{ + if (this->resource == resource) + waitingForSync = false; +} + +QWaylandQtTextInputMethod::QWaylandQtTextInputMethod(QWaylandObject *container, QWaylandCompositor *compositor) + : QWaylandCompositorExtensionTemplate(container, *new QWaylandQtTextInputMethodPrivate(compositor)) +{ + connect(&d_func()->focusDestroyListener, &QWaylandDestroyListener::fired, + this, &QWaylandQtTextInputMethod::focusSurfaceDestroyed); + + connect(qGuiApp->inputMethod(), &QInputMethod::visibleChanged, this, &QWaylandQtTextInputMethod::sendVisibleChanged); + connect(qGuiApp->inputMethod(), &QInputMethod::keyboardRectangleChanged, this, &QWaylandQtTextInputMethod::sendKeyboardRectangleChanged); + connect(qGuiApp->inputMethod(), &QInputMethod::inputDirectionChanged, this, &QWaylandQtTextInputMethod::sendInputDirectionChanged); + connect(qGuiApp->inputMethod(), &QInputMethod::localeChanged, this, &QWaylandQtTextInputMethod::sendLocaleChanged); +} + + +QWaylandQtTextInputMethod::~QWaylandQtTextInputMethod() +{ +} + +void QWaylandQtTextInputMethod::focusSurfaceDestroyed() +{ + Q_D(QWaylandQtTextInputMethod); + d->focusDestroyListener.reset(); + d->waitingForSync = false; + d->resource = nullptr; + d->focusedSurface = nullptr; +} + +QWaylandSurface *QWaylandQtTextInputMethod::focusedSurface() const +{ + Q_D(const QWaylandQtTextInputMethod); + return d->focusedSurface; +} + +QVariant QWaylandQtTextInputMethod::inputMethodQuery(Qt::InputMethodQuery property, QVariant argument) const +{ + Q_D(const QWaylandQtTextInputMethod); + switch (property) { + case Qt::ImHints: + return int(d->hints); + case Qt::ImCursorRectangle: + return d->cursorRectangle; + case Qt::ImCursorPosition: + return d->cursorPosition; + case Qt::ImSurroundingText: + return d->surroundingText; + case Qt::ImAbsolutePosition: + return d->absolutePosition; + case Qt::ImCurrentSelection: + return d->surroundingText.mid(qMin(d->cursorPosition, d->anchorPosition), + qAbs(d->anchorPosition - d->cursorPosition)); + case Qt::ImAnchorPosition: + return d->anchorPosition; + case Qt::ImTextAfterCursor: + if (argument.isValid()) + return d->surroundingText.mid(d->cursorPosition, argument.toInt()); + return d->surroundingText.mid(d->cursorPosition); + case Qt::ImTextBeforeCursor: + if (argument.isValid()) + return d->surroundingText.left(d->cursorPosition).right(argument.toInt()); + return d->surroundingText.left(d->cursorPosition); + case Qt::ImPreferredLanguage: + return d->preferredLanguage; + + default: + return QVariant(); + } +} + +void QWaylandQtTextInputMethod::sendKeyEvent(QKeyEvent *event) +{ + Q_D(QWaylandQtTextInputMethod); + if (d->resource == nullptr || d->resource->handle == nullptr) + return; + + d->send_key(d->resource->handle, + int(event->type()), + event->key(), + event->modifiers(), + event->isAutoRepeat(), + event->count(), + event->nativeScanCode(), + event->nativeVirtualKey(), + event->nativeModifiers(), + event->text()); +} + +void QWaylandQtTextInputMethod::sendInputMethodEvent(QInputMethodEvent *event) +{ + Q_D(QWaylandQtTextInputMethod); + if (d->resource == nullptr || d->resource->handle == nullptr || d->compositor == nullptr) + return; + + if (d->updatingQueries != 0) { + qCWarning(qLcWaylandCompositorInputMethods) << "Input method event sent while client is updating. Ignored."; + return; + } + + Q_ASSERT(!d->waitingForSync); + + QString oldSurroundText = d->surroundingText; + int oldCursorPosition = d->cursorPosition; + int oldAnchorPosition = d->anchorPosition; + int oldAbsolutePosition = d->absolutePosition; + QRect oldCursorRectangle = d->cursorRectangle; + QString oldPreferredLanguage = d->preferredLanguage; + Qt::InputMethodHints oldHints = d->hints; + + uint serial = d->compositor->nextSerial(); // ### Not needed if we block on this? + d->send_start_input_method_event(d->resource->handle, serial, d->surroundingTextOffset); + for (const QInputMethodEvent::Attribute &attribute : event->attributes()) { + switch (attribute.type) { + case QInputMethodEvent::TextFormat: + { + auto properties = attribute.value.value<QTextFormat>().properties(); + if (properties.size() != 2 || properties.firstKey() != QTextFormat::FontUnderline || properties.lastKey() != QTextFormat::TextUnderlineStyle) { + qCWarning(qLcWaylandCompositorInputMethods()) << "Only underline text formats currently supported"; + } + + d->send_input_method_event_attribute(d->resource->handle, + serial, + attribute.type, + attribute.start, + attribute.length, + QString()); + break; + } + case QInputMethodEvent::Cursor: + d->cursorPosition = attribute.start; + d->send_input_method_event_attribute(d->resource->handle, + serial, + attribute.type, + attribute.start, + attribute.length, + attribute.value.typeId() == QMetaType::QColor ? attribute.value.value<QColor>().name() : QString()); + break; + case QInputMethodEvent::Language: // ### What is the type of value? Is it string? + Q_FALLTHROUGH(); + case QInputMethodEvent::Ruby: + d->send_input_method_event_attribute(d->resource->handle, + serial, + attribute.type, + attribute.start, + attribute.length, + attribute.value.toString()); + break; + case QInputMethodEvent::Selection: + d->send_input_method_event_attribute(d->resource->handle, + serial, + attribute.type, + attribute.start, + attribute.length, + QString()); + break; + } + } + + d->waitingForSync = true; + d->send_end_input_method_event(d->resource->handle, + serial, + event->commitString(), + event->preeditString(), + event->replacementStart(), + event->replacementLength()); + + while (d->waitingForSync) + d->compositor->processWaylandEvents(); + + Qt::InputMethodQueries queries; + if (d->surroundingText != oldSurroundText) + queries |= Qt::ImSurroundingText; + if (d->cursorPosition != oldCursorPosition) + queries |= Qt::ImCursorPosition; + if (d->anchorPosition != oldAnchorPosition) + queries |= Qt::ImAnchorPosition; + if (d->absolutePosition != oldAbsolutePosition) + queries |= Qt::ImAbsolutePosition; + if (d->cursorRectangle != oldCursorRectangle) + queries |= Qt::ImCursorRectangle; + if (d->preferredLanguage != oldPreferredLanguage) + queries |= Qt::ImPreferredLanguage; + if (d->hints != oldHints) + queries |= Qt::ImHints; + if (queries != 0) + emit updateInputMethod(queries); +} + +bool QWaylandQtTextInputMethod::isSurfaceEnabled(QWaylandSurface *surface) const +{ + Q_D(const QWaylandQtTextInputMethod); + return d->enabledSurfaces.values().contains(surface); +} + +void QWaylandQtTextInputMethod::setFocus(QWaylandSurface *surface) +{ + Q_D(QWaylandQtTextInputMethod); + + QWaylandQtTextInputMethodPrivate::Resource *resource = surface != nullptr ? d->resourceMap().value(surface->waylandClient()) : nullptr; + if (d->resource == resource) + return; + + if (d->resource != nullptr && d->focusedSurface != nullptr) { + d->send_leave(d->resource->handle, d->focusedSurface->resource()); + d->focusDestroyListener.reset(); + } + + d->resource = resource; + d->focusedSurface = surface; + + if (d->resource != nullptr && d->focusedSurface != nullptr) { + d->surroundingText.clear(); + d->cursorPosition = 0; + d->anchorPosition = 0; + d->absolutePosition = 0; + d->cursorRectangle = QRect(); + d->preferredLanguage.clear(); + d->hints = Qt::InputMethodHints(); + d->send_enter(d->resource->handle, d->focusedSurface->resource()); + sendInputDirectionChanged(); + sendLocaleChanged(); + sendInputDirectionChanged(); + d->focusDestroyListener.listenForDestruction(surface->resource()); + if (d->inputPanelVisible && d->enabledSurfaces.values().contains(surface)) + qGuiApp->inputMethod()->show(); + } +} + +void QWaylandQtTextInputMethod::sendLocaleChanged() +{ + Q_D(QWaylandQtTextInputMethod); + if (d->resource == nullptr || d->resource->handle == nullptr) + return; + + d->send_locale_changed(d->resource->handle, qGuiApp->inputMethod()->locale().bcp47Name()); +} + +void QWaylandQtTextInputMethod::sendInputDirectionChanged() +{ + Q_D(QWaylandQtTextInputMethod); + if (d->resource == nullptr || d->resource->handle == nullptr) + return; + + d->send_input_direction_changed(d->resource->handle, int(qGuiApp->inputMethod()->inputDirection())); +} + +void QWaylandQtTextInputMethod::sendKeyboardRectangleChanged() +{ + Q_D(QWaylandQtTextInputMethod); + if (d->resource == nullptr || d->resource->handle == nullptr) + return; + + QRectF keyboardRectangle = qGuiApp->inputMethod()->keyboardRectangle(); + d->send_keyboard_rectangle_changed(d->resource->handle, + wl_fixed_from_double(keyboardRectangle.x()), + wl_fixed_from_double(keyboardRectangle.y()), + wl_fixed_from_double(keyboardRectangle.width()), + wl_fixed_from_double(keyboardRectangle.height())); +} + +void QWaylandQtTextInputMethod::sendVisibleChanged() +{ + Q_D(QWaylandQtTextInputMethod); + if (d->resource == nullptr || d->resource->handle == nullptr) + return; + + d->send_visible_changed(d->resource->handle, int(qGuiApp->inputMethod()->isVisible())); +} + +void QWaylandQtTextInputMethod::add(::wl_client *client, uint32_t id, int version) +{ + Q_D(QWaylandQtTextInputMethod); + d->add(client, id, version); +} + +const struct wl_interface *QWaylandQtTextInputMethod::interface() +{ + return QWaylandQtTextInputMethodPrivate::interface(); +} + +QByteArray QWaylandQtTextInputMethod::interfaceName() +{ + return QWaylandQtTextInputMethodPrivate::interfaceName(); +} + +QT_END_NAMESPACE + +#include "moc_qwaylandqttextinputmethod.cpp" diff --git a/src/compositor/extensions/qwaylandqttextinputmethod.h b/src/compositor/extensions/qwaylandqttextinputmethod.h new file mode 100644 index 000000000..99f7cb4b2 --- /dev/null +++ b/src/compositor/extensions/qwaylandqttextinputmethod.h @@ -0,0 +1,55 @@ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#ifndef QWAYLANDQTTEXTINPUTMETHOD_H +#define QWAYLANDQTTEXTINPUTMETHOD_H + +#include <QtWaylandCompositor/qwaylandcompositorextension.h> + +struct wl_client; + +QT_BEGIN_NAMESPACE + +class QWaylandSurface; +class QWaylandQtTextInputMethodPrivate; +class QInputMethodEvent; +class QKeyEvent; + +class QWaylandQtTextInputMethod : public QWaylandCompositorExtensionTemplate<QWaylandQtTextInputMethod> +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QWaylandQtTextInputMethod) +public: + explicit QWaylandQtTextInputMethod(QWaylandObject *container, QWaylandCompositor *compositor); + ~QWaylandQtTextInputMethod() override; + + QWaylandSurface *focusedSurface() const; + void setFocus(QWaylandSurface *surface); + + bool isSurfaceEnabled(QWaylandSurface *surface) const; + + void add(::wl_client *client, uint32_t id, int version); + + static const struct wl_interface *interface(); + static QByteArray interfaceName(); + + QVariant inputMethodQuery(Qt::InputMethodQuery property, QVariant argument) const; + void sendInputMethodEvent(QInputMethodEvent *event); + void sendKeyEvent(QKeyEvent *event); + +Q_SIGNALS: + void updateInputMethod(Qt::InputMethodQueries queries); + void surfaceEnabled(QWaylandSurface *surface); + void surfaceDisabled(QWaylandSurface *surface); + +private Q_SLOTS: + void sendVisibleChanged(); + void sendKeyboardRectangleChanged(); + void sendInputDirectionChanged(); + void sendLocaleChanged(); + void focusSurfaceDestroyed(); +}; + +QT_END_NAMESPACE + +#endif // QWAYLANDQTTEXTINPUTMETHOD_H diff --git a/src/compositor/extensions/qwaylandqttextinputmethod_p.h b/src/compositor/extensions/qwaylandqttextinputmethod_p.h new file mode 100644 index 000000000..2ca1e9213 --- /dev/null +++ b/src/compositor/extensions/qwaylandqttextinputmethod_p.h @@ -0,0 +1,80 @@ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#ifndef QWAYLANDQTTEXTINPUTMETHOD_P_H +#define QWAYLANDQTTEXTINPUTMETHOD_P_H + + +#include "qwaylandqttextinputmethod.h" + +#include <QtWaylandCompositor/private/qwaylandcompositorextension_p.h> +#include <QtWaylandCompositor/private/qwayland-server-qt-text-input-method-unstable-v1.h> +#include <QtWaylandCompositor/qwaylanddestroylistener.h> + +#include <QtCore/qrect.h> +#include <QtCore/qhash.h> + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +QT_BEGIN_NAMESPACE + +class QWaylandCompositor; +class QWaylandSurface; + +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandQtTextInputMethodPrivate : public QWaylandCompositorExtensionPrivate, public QtWaylandServer::qt_text_input_method_v1 +{ + Q_DECLARE_PUBLIC(QWaylandQtTextInputMethod) +public: + explicit QWaylandQtTextInputMethodPrivate(QWaylandCompositor *compositor); + + QWaylandCompositor *compositor; + QWaylandSurface *focusedSurface = nullptr; + Resource *resource = nullptr; + QHash<Resource * , QWaylandSurface *> enabledSurfaces; + QWaylandDestroyListener focusDestroyListener; + bool inputPanelVisible = false; + bool waitingForSync = false; + + Qt::InputMethodQueries updatingQueries; + Qt::InputMethodHints hints; + QString surroundingText; + QString preferredLanguage; + QRect cursorRectangle; + int cursorPosition = 0; + int anchorPosition = 0; + int absolutePosition = 0; + int surroundingTextOffset = 0; + +private: + void text_input_method_v1_enable(Resource *resource, struct ::wl_resource *surface) override; + void text_input_method_v1_disable(Resource *resource, struct ::wl_resource *surface) override; + void text_input_method_v1_destroy(Resource *resource) override; + void text_input_method_v1_reset(Resource *resource) override; + void text_input_method_v1_commit(Resource *resource) override; + void text_input_method_v1_show_input_panel(Resource *resource) override; + void text_input_method_v1_hide_input_panel(Resource *resource) override; + void text_input_method_v1_update_hints(Resource *resource, int32_t hints) override; + void text_input_method_v1_update_surrounding_text(Resource *resource, const QString &surroundingText, int32_t surroundingTextOffset) override; + void text_input_method_v1_update_anchor_position(Resource *resource, int32_t anchorPosition) override; + void text_input_method_v1_update_cursor_position(Resource *resource, int32_t cursorPosition) override; + void text_input_method_v1_update_absolute_position(Resource *resource, int32_t absolutePosition) override; + void text_input_method_v1_invoke_action(Resource *resource, int32_t type, int32_t cursorPosition) override; + void text_input_method_v1_update_preferred_language(Resource *resource, const QString &preferredLanguage) override; + void text_input_method_v1_update_cursor_rectangle(Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height) override; + void text_input_method_v1_start_update(Resource *resource, int32_t queries) override; + void text_input_method_v1_end_update(Resource *resource) override; + void text_input_method_v1_acknowledge_input_method(Resource *resource) override; +}; + +QT_END_NAMESPACE + +#endif // QWAYLANDQTTEXTINPUTMETHOD_P_H diff --git a/src/compositor/extensions/qwaylandqttextinputmethodmanager.cpp b/src/compositor/extensions/qwaylandqttextinputmethodmanager.cpp new file mode 100644 index 000000000..355e77338 --- /dev/null +++ b/src/compositor/extensions/qwaylandqttextinputmethodmanager.cpp @@ -0,0 +1,102 @@ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#include "qwaylandqttextinputmethodmanager.h" +#include "qwaylandqttextinputmethodmanager_p.h" + +#include <QtWaylandCompositor/QWaylandCompositor> +#include <QtWaylandCompositor/QWaylandSeat> + +#include "qwaylandqttextinputmethod.h" + +QT_BEGIN_NAMESPACE + +QWaylandQtTextInputMethodManagerPrivate::QWaylandQtTextInputMethodManagerPrivate() +{ +} + +void QWaylandQtTextInputMethodManagerPrivate::text_input_method_manager_v1_get_text_input_method(Resource *resource, uint32_t id, struct ::wl_resource *seatResource) +{ + Q_Q(QWaylandQtTextInputMethodManager); + QWaylandCompositor *compositor = static_cast<QWaylandCompositor *>(q->extensionContainer()); + QWaylandSeat *seat = QWaylandSeat::fromSeatResource(seatResource); + QWaylandQtTextInputMethod *textInput = QWaylandQtTextInputMethod::findIn(seat); + if (textInput == nullptr) + textInput = new QWaylandQtTextInputMethod(seat, compositor); + textInput->add(resource->client(), id, wl_resource_get_version(resource->handle)); + QWaylandClient *client = QWaylandClient::fromWlClient(compositor, resource->client()); + QWaylandClient::TextInputProtocols p = client->textInputProtocols(); + client->setTextInputProtocols(p.setFlag(QWaylandClient::TextInputProtocol::QtTextInputMethodV1)); + + if (!textInput->isInitialized()) + textInput->initialize(); +} + +/*! + \qmltype QtTextInputMethodManager + \instantiates QWaylandQtTextInputMethodManager + \inqmlmodule QtWayland.Compositor + \since 6.0 + \brief Provides access to input methods in the compositor. + + The \c QtTextInputMethodManager corresponds to the \c qt-text-input-method-manager interface + in the \c qt-text-input-method-unstable-v1 extension protocol. It is specifically designed + to be used with a Qt-based input method, such as Qt Virtual Keyboard. + + Instantiating this as child of a \l WaylandCompositor adds it to the list of interfaces available + to the client. If a client binds to it, then it will be used to communciate text input to + that client. +*/ + +/*! + \class QWaylandQtTextInputMethodManager + \inmodule QtWaylandCompositor + \since 6.0 + \brief Provides access to input methods in the compositor. + + The \c QWaylandQtTextInputMethodManager class corresponds to the \c qt-text-input-method-manager interface + in the \c qt-text-input-method-unstable-v1 extension protocol. It is specifically designed + to be used with a Qt-based input method, such as Qt Virtual Keyboard. + + Instantiating this as child of a \l WaylandCompositor adds it to the list of interfaces available + to the client. If a client binds to it, then it will be used to communciate text input to + that client. +*/ + +QWaylandQtTextInputMethodManager::QWaylandQtTextInputMethodManager() + : QWaylandCompositorExtensionTemplate<QWaylandQtTextInputMethodManager>(*new QWaylandQtTextInputMethodManagerPrivate) +{ +} + +QWaylandQtTextInputMethodManager::QWaylandQtTextInputMethodManager(QWaylandCompositor *compositor) + : QWaylandCompositorExtensionTemplate<QWaylandQtTextInputMethodManager>(compositor, *new QWaylandQtTextInputMethodManagerPrivate) +{ +} + +void QWaylandQtTextInputMethodManager::initialize() +{ + Q_D(QWaylandQtTextInputMethodManager); + + QWaylandCompositorExtensionTemplate::initialize(); + QWaylandCompositor *compositor = static_cast<QWaylandCompositor *>(extensionContainer()); + if (compositor == nullptr) { + qWarning() << "Failed to find QWaylandCompositor when initializing QWaylandQtTextInputMethodManager"; + return; + } + + d->init(compositor->display(), 1); +} + +const wl_interface *QWaylandQtTextInputMethodManager::interface() +{ + return QWaylandQtTextInputMethodManagerPrivate::interface(); +} + +QByteArray QWaylandQtTextInputMethodManager::interfaceName() +{ + return QWaylandQtTextInputMethodManagerPrivate::interfaceName(); +} + +QT_END_NAMESPACE + +#include "moc_qwaylandqttextinputmethodmanager.cpp" diff --git a/src/compositor/extensions/qwaylandqttextinputmethodmanager.h b/src/compositor/extensions/qwaylandqttextinputmethodmanager.h new file mode 100644 index 000000000..ded6a3aae --- /dev/null +++ b/src/compositor/extensions/qwaylandqttextinputmethodmanager.h @@ -0,0 +1,31 @@ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#ifndef QWAYLANDQTTEXTINPUTMETHODMANAGER_H +#define QWAYLANDQTTEXTINPUTMETHODMANAGER_H + +#include <QtWaylandCompositor/QWaylandCompositorExtension> + +#include <QtCore/QSize> + +QT_BEGIN_NAMESPACE + +class QWaylandQtTextInputMethodManagerPrivate; + +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandQtTextInputMethodManager : public QWaylandCompositorExtensionTemplate<QWaylandQtTextInputMethodManager> +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QWaylandQtTextInputMethodManager) +public: + QWaylandQtTextInputMethodManager(); + QWaylandQtTextInputMethodManager(QWaylandCompositor *compositor); + + void initialize() override; + + static const struct wl_interface *interface(); + static QByteArray interfaceName(); +}; + +QT_END_NAMESPACE + +#endif // QWAYLANDQTTEXTINPUTMETHODMANAGER_H diff --git a/src/compositor/extensions/qwaylandqttextinputmethodmanager_p.h b/src/compositor/extensions/qwaylandqttextinputmethodmanager_p.h new file mode 100644 index 000000000..71be87e85 --- /dev/null +++ b/src/compositor/extensions/qwaylandqttextinputmethodmanager_p.h @@ -0,0 +1,36 @@ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#ifndef QWAYLANDQTTEXTINPUTMETHODMANAGER_P_H +#define QWAYLANDQTTEXTINPUTMETHODMANAGER_P_H + +#include <QtWaylandCompositor/private/qwaylandcompositorextension_p.h> + +#include <QtWaylandCompositor/private/qwayland-server-qt-text-input-method-unstable-v1.h> + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +QT_BEGIN_NAMESPACE + +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandQtTextInputMethodManagerPrivate : public QWaylandCompositorExtensionPrivate, public QtWaylandServer::qt_text_input_method_manager_v1 +{ + Q_DECLARE_PUBLIC(QWaylandQtTextInputMethodManager) +public: + QWaylandQtTextInputMethodManagerPrivate(); + +protected: + void text_input_method_manager_v1_get_text_input_method(Resource *resource, uint32_t id, struct ::wl_resource *seat) override; +}; + +QT_END_NAMESPACE + +#endif // QWAYLANDQTTEXTINPUTMETHODMANAGER_P_H diff --git a/src/compositor/extensions/qwaylandqtwindowmanager.cpp b/src/compositor/extensions/qwaylandqtwindowmanager.cpp index d44dd456b..f33a83ac9 100644 --- a/src/compositor/extensions/qwaylandqtwindowmanager.cpp +++ b/src/compositor/extensions/qwaylandqtwindowmanager.cpp @@ -1,32 +1,6 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Copyright (C) 2017 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// Copyright (C) 2017 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <QtCore/QObject> #include <QtCore/QUrl> @@ -139,3 +113,5 @@ QByteArray QWaylandQtWindowManager::interfaceName() } QT_END_NAMESPACE + +#include "moc_qwaylandqtwindowmanager.cpp" diff --git a/src/compositor/extensions/qwaylandqtwindowmanager.h b/src/compositor/extensions/qwaylandqtwindowmanager.h index d83508219..c1439cf46 100644 --- a/src/compositor/extensions/qwaylandqtwindowmanager.h +++ b/src/compositor/extensions/qwaylandqtwindowmanager.h @@ -1,32 +1,6 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Copyright (C) 2017 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// Copyright (C) 2017 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDQTWINDOWMANAGER_H #define QWAYLANDQTWINDOWMANAGER_H @@ -40,7 +14,7 @@ QT_BEGIN_NAMESPACE class QWaylandQtWindowManagerPrivate; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandQtWindowManager : public QWaylandCompositorExtensionTemplate<QWaylandQtWindowManager> +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandQtWindowManager : public QWaylandCompositorExtensionTemplate<QWaylandQtWindowManager> { Q_OBJECT Q_DECLARE_PRIVATE(QWaylandQtWindowManager) diff --git a/src/compositor/extensions/qwaylandqtwindowmanager_p.h b/src/compositor/extensions/qwaylandqtwindowmanager_p.h index dc353e2c5..8c7e7e827 100644 --- a/src/compositor/extensions/qwaylandqtwindowmanager_p.h +++ b/src/compositor/extensions/qwaylandqtwindowmanager_p.h @@ -1,32 +1,6 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Copyright (C) 2017 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// Copyright (C) 2017 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDQTWINDOWMANAGER_P_H #define QWAYLANDQTWINDOWMANAGER_P_H @@ -50,7 +24,7 @@ QT_BEGIN_NAMESPACE -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandQtWindowManagerPrivate +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandQtWindowManagerPrivate : public QWaylandCompositorExtensionPrivate , public QtWaylandServer::qt_windowmanager { diff --git a/src/compositor/extensions/qwaylandquickshellintegration.cpp b/src/compositor/extensions/qwaylandquickshellintegration.cpp index 5d3d526f1..87762eae6 100644 --- a/src/compositor/extensions/qwaylandquickshellintegration.cpp +++ b/src/compositor/extensions/qwaylandquickshellintegration.cpp @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "qwaylandquickshellintegration.h" @@ -33,7 +7,7 @@ * \class QWaylandQuickShellIntegration * \inmodule QtWaylandCompositor * \since 5.14 - * \brief Provides support for shell surface integration with QtQuick + * \brief Provides support for shell surface integration with QtQuick. * * Shell surface implementations should inherit from this class in order to provide * an integration between the shell surface and QtQuick. @@ -80,6 +54,8 @@ * \sa QObject::eventFilter() */ +QT_BEGIN_NAMESPACE + QWaylandQuickShellIntegration::QWaylandQuickShellIntegration(QObject *parent) : QObject(parent) { @@ -88,3 +64,7 @@ QWaylandQuickShellIntegration::QWaylandQuickShellIntegration(QObject *parent) QWaylandQuickShellIntegration::~QWaylandQuickShellIntegration() { } + +QT_END_NAMESPACE + +#include "moc_qwaylandquickshellintegration.cpp" diff --git a/src/compositor/extensions/qwaylandquickshellintegration.h b/src/compositor/extensions/qwaylandquickshellintegration.h index cae11ee4f..574d3ea47 100644 --- a/src/compositor/extensions/qwaylandquickshellintegration.h +++ b/src/compositor/extensions/qwaylandquickshellintegration.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDQUICKSHELLINTEGRATION_H #define QWAYLANDQUICKSHELLINTEGRATION_H @@ -33,9 +7,11 @@ #include <QtCore/QObject> #include <QtWaylandCompositor/qtwaylandcompositorglobal.h> +QT_REQUIRE_CONFIG(wayland_compositor_quick); + QT_BEGIN_NAMESPACE -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandQuickShellIntegration : public QObject +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandQuickShellIntegration : public QObject { Q_OBJECT public: diff --git a/src/compositor/extensions/qwaylandquickshellsurfaceitem.cpp b/src/compositor/extensions/qwaylandquickshellsurfaceitem.cpp index 4952cef66..7eb1479f5 100644 --- a/src/compositor/extensions/qwaylandquickshellsurfaceitem.cpp +++ b/src/compositor/extensions/qwaylandquickshellsurfaceitem.cpp @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "qwaylandquickshellsurfaceitem.h" #include "qwaylandquickshellsurfaceitem_p.h" @@ -44,14 +18,14 @@ QWaylandQuickShellSurfaceItem *QWaylandQuickShellSurfaceItemPrivate::maybeCreate auto *popupItem = new QWaylandQuickShellSurfaceItem(q); popupItem->setShellSurface(shellSurface); popupItem->setAutoCreatePopupItems(true); - QObject::connect(popupItem, &QWaylandQuickShellSurfaceItem::surfaceDestroyed, [popupItem](){ - popupItem->deleteLater(); - }); + QObject::connect(popupItem, &QWaylandQuickShellSurfaceItem::surfaceDestroyed, + popupItem, &QObject::deleteLater); return popupItem; } /*! * \qmltype ShellSurfaceItem + * \instantiates QWaylandQuickShellSurfaceItem * \inherits WaylandQuickItem * \inqmlmodule QtWayland.Compositor * \since 5.8 @@ -60,7 +34,7 @@ QWaylandQuickShellSurfaceItem *QWaylandQuickShellSurfaceItemPrivate::maybeCreate * This type is used to render \c wl_shell, \c xdg_shell or \c ivi_application surfaces as part of * a Qt Quick scene. It handles moving and resizing triggered by clicking on the window decorations. * - * \sa WaylandQuickItem, WlShellSurface, XdgSurfaceV5, IviSurface + * \sa WaylandQuickItem, WlShellSurface, IviSurface */ /*! @@ -72,7 +46,7 @@ QWaylandQuickShellSurfaceItem *QWaylandQuickShellSurfaceItemPrivate::maybeCreate * This class is used to render \c wl_shell, \c xdg_shell or \c ivi_application surfaces as part of * a Qt Quick scene. It handles moving and resizing triggered by clicking on the window decorations. * - * \sa QWaylandQuickItem, QWaylandWlShellSurface, QWaylandXdgSurfaceV5, QWaylandIviSurface + * \sa QWaylandQuickItem, QWaylandWlShellSurface, QWaylandIviSurface */ /*! @@ -102,7 +76,7 @@ QWaylandQuickShellSurfaceItem::QWaylandQuickShellSurfaceItem(QWaylandQuickShellS } /*! - * \qmlproperty ShellSurface QtWaylandCompositor::ShellSurfaceItem::shellSurface + * \qmlproperty ShellSurface QtWayland.Compositor::ShellSurfaceItem::shellSurface * * This property holds the ShellSurface rendered by this ShellSurfaceItem. * It may either be an XdgSurfaceV5, WlShellSurface or IviSurface depending on which shell protocol @@ -128,6 +102,9 @@ void QWaylandQuickShellSurfaceItem::setShellSurface(QWaylandShellSurface *shellS if (d->m_shellSurface == shellSurface) return; + if (Q_UNLIKELY(d->m_shellSurface)) + disconnect(d->m_shellSurface, &QWaylandShellSurface::modalChanged, this, nullptr); + d->m_shellSurface = shellSurface; if (d->m_shellIntegration) { @@ -141,11 +118,14 @@ void QWaylandQuickShellSurfaceItem::setShellSurface(QWaylandShellSurface *shellS installEventFilter(d->m_shellIntegration); } + connect(shellSurface, &QWaylandShellSurface::modalChanged, this, + [d](){ if (d->m_shellSurface->modal()) d->raise(); }); + emit shellSurfaceChanged(); } /*! - * \qmlproperty Item QtWaylandCompositor::ShellSurfaceItem::moveItem + * \qmlproperty Item QtWayland.Compositor::ShellSurfaceItem::moveItem * * This property holds the move item for this ShellSurfaceItem. This is the item that will be moved * when the clients request the ShellSurface to be moved, maximized, resized etc. This property is @@ -176,7 +156,7 @@ void QWaylandQuickShellSurfaceItem::setMoveItem(QQuickItem *moveItem) } /*! - * \qmlproperty bool QtWaylandCompositor::ShellSurfaceItem::autoCreatePopupItems + * \qmlproperty bool QtWayland.Compositor::ShellSurfaceItem::autoCreatePopupItems * * This property holds whether ShellSurfaceItems for popups parented to the shell * surface managed by this item should automatically be created. @@ -312,4 +292,151 @@ void QWaylandQuickShellEventFilter::timerEvent(QTimerEvent *event) } } +static QWaylandQuickShellSurfaceItem *findSurfaceItemFromMoveItem(QQuickItem *moveItem) +{ + if (Q_UNLIKELY(!moveItem)) + return nullptr; + if (auto *surf = qobject_cast<QWaylandQuickShellSurfaceItem *>(moveItem)) + return surf; + for (auto *item : moveItem->childItems()) { + if (auto *surf = findSurfaceItemFromMoveItem(item)) + return surf; + } + return nullptr; +} + +static inline bool onTop(QWaylandQuickShellSurfaceItem *surf) +{ + return surf->staysOnTop() || surf->shellSurface()->modal(); +} + +static inline bool onBottom(QWaylandQuickShellSurfaceItem *surf) +{ + return surf->staysOnBottom() && !surf->shellSurface()->modal(); +} + +/* + To raise a surface, find the topmost suitable surface and place above that. + We start from the top and: + If we don't have staysOnTop, skip all surfaces with staysOnTop + If we have staysOnBottom, skip all surfaces that don't have staysOnBottom + A modal dialog is handled as if it had staysOnTop + */ +void QWaylandQuickShellSurfaceItemPrivate::raise() +{ + Q_Q(QWaylandQuickShellSurfaceItem); + auto *moveItem = q->moveItem(); + QQuickItem *parent = moveItem->parentItem(); + if (!parent) + return; + const bool putOnTop = staysOnTop || m_shellSurface->modal(); + const bool putOnBottom = staysOnBottom && !m_shellSurface->modal(); + + auto it = parent->childItems().crbegin(); + auto skip = [=](QQuickItem *item) { + if (auto *surf = findSurfaceItemFromMoveItem(item)) + return (!putOnTop && onTop(surf)) || (putOnBottom && !onBottom(surf)); + return true; // ignore any other Quick items that may be there + }; + auto end = parent->childItems().crend(); + while (it != end && skip(*it)) + ++it; + if (it != end) { + QQuickItem *top = *it; + if (moveItem != top) + moveItem->stackAfter(top); + } +} + +/* + To lower a surface, find the lowest suitable surface and place below that. + We start from the bottom and: + If we don't have staysOnBottom, skip all surfaces with staysOnBottom + If we have staysOnTop, skip all surfaces that don't have staysOnTop + A modal dialog is handled as if it had staysOnTop + */ +void QWaylandQuickShellSurfaceItemPrivate::lower() +{ + Q_Q(QWaylandQuickShellSurfaceItem); + auto *moveItem = q->moveItem(); + QQuickItem *parent = moveItem->parentItem(); + if (!parent) + return; + const bool putOnTop = staysOnTop || m_shellSurface->modal(); + const bool putOnBottom = staysOnBottom && !m_shellSurface->modal(); + + auto it = parent->childItems().cbegin(); + auto skip = [=](QQuickItem *item) { + if (auto *surf = findSurfaceItemFromMoveItem(item)) + return (!putOnBottom && onBottom(surf)) || (putOnTop && !onTop(surf)); + return true; // ignore any other Quick items that may be there + }; + while (skip(*it)) + ++it; + + QQuickItem *bottom = *it; + if (moveItem != bottom) + moveItem->stackBefore(bottom); +} + +/*! + * \property QWaylandQuickShellSurfaceItem::staysOnTop + * + * Keep this item above other Wayland surfaces + */ +bool QWaylandQuickShellSurfaceItem::staysOnTop() const +{ + Q_D(const QWaylandQuickShellSurfaceItem); + return d->staysOnTop; +} + +void QWaylandQuickShellSurfaceItem::setStaysOnTop(bool onTop) +{ + Q_D(QWaylandQuickShellSurfaceItem); + if (d->staysOnTop == onTop) + return; + d->staysOnTop = onTop; + if (d->staysOnBottom) { + d->staysOnBottom = false; + emit staysOnBottomChanged(); + } + // We need to call raise() even if onTop is false, since we need to stack under any other + // staysOnTop surfaces in that case + raise(); + emit staysOnTopChanged(); + Q_ASSERT(!(d->staysOnTop && d->staysOnBottom)); +} + +/*! + * \property QWaylandQuickShellSurfaceItem::staysOnBottom + * + * Keep this item above other Wayland surfaces + */ +bool QWaylandQuickShellSurfaceItem::staysOnBottom() const +{ + Q_D(const QWaylandQuickShellSurfaceItem); + return d->staysOnBottom; +} + +void QWaylandQuickShellSurfaceItem::setStaysOnBottom(bool onBottom) +{ + Q_D(QWaylandQuickShellSurfaceItem); + if (d->staysOnBottom == onBottom) + return; + d->staysOnBottom = onBottom; + if (d->staysOnTop) { + d->staysOnTop = false; + emit staysOnTopChanged(); + } + // We need to call lower() even if onBottom is false, since we need to stack over any other + // staysOnBottom surfaces in that case + lower(); + emit staysOnBottomChanged(); + Q_ASSERT(!(d->staysOnTop && d->staysOnBottom)); +} + QT_END_NAMESPACE + +#include "moc_qwaylandquickshellsurfaceitem_p.cpp" + +#include "moc_qwaylandquickshellsurfaceitem.cpp" diff --git a/src/compositor/extensions/qwaylandquickshellsurfaceitem.h b/src/compositor/extensions/qwaylandquickshellsurfaceitem.h index 39949a8fa..9d9610c70 100644 --- a/src/compositor/extensions/qwaylandquickshellsurfaceitem.h +++ b/src/compositor/extensions/qwaylandquickshellsurfaceitem.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDQUICKSHELLSURFACEITEM_H #define QWAYLANDQUICKSHELLSURFACEITEM_H @@ -33,18 +7,25 @@ #include <QtWaylandCompositor/QWaylandCompositorExtension> #include <QtWaylandCompositor/QWaylandQuickItem> +QT_REQUIRE_CONFIG(wayland_compositor_quick); + QT_BEGIN_NAMESPACE class QWaylandQuickShellSurfaceItemPrivate; class QWaylandShellSurface; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandQuickShellSurfaceItem : public QWaylandQuickItem +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandQuickShellSurfaceItem : public QWaylandQuickItem { Q_OBJECT Q_DECLARE_PRIVATE(QWaylandQuickShellSurfaceItem) Q_PROPERTY(QWaylandShellSurface *shellSurface READ shellSurface WRITE setShellSurface NOTIFY shellSurfaceChanged) Q_PROPERTY(QQuickItem *moveItem READ moveItem WRITE setMoveItem NOTIFY moveItemChanged) Q_PROPERTY(bool autoCreatePopupItems READ autoCreatePopupItems WRITE setAutoCreatePopupItems NOTIFY autoCreatePopupItemsChanged) + Q_PROPERTY(bool staysOnTop READ staysOnTop WRITE setStaysOnTop NOTIFY staysOnTopChanged) + Q_PROPERTY(bool staysOnBottom READ staysOnBottom WRITE setStaysOnBottom NOTIFY staysOnBottomChanged) + Q_MOC_INCLUDE("qwaylandshellsurface.h") + QML_NAMED_ELEMENT(ShellSurfaceItem) + QML_ADDED_IN_VERSION(1, 0) public: QWaylandQuickShellSurfaceItem(QQuickItem *parent = nullptr); ~QWaylandQuickShellSurfaceItem() override; @@ -58,10 +39,17 @@ public: bool autoCreatePopupItems(); void setAutoCreatePopupItems(bool enabled); + bool staysOnTop() const; + void setStaysOnTop(bool on); + bool staysOnBottom() const; + void setStaysOnBottom(bool on); + Q_SIGNALS: void shellSurfaceChanged(); void moveItemChanged(); void autoCreatePopupItemsChanged(); + void staysOnTopChanged(); + void staysOnBottomChanged(); protected: QWaylandQuickShellSurfaceItem(QWaylandQuickShellSurfaceItemPrivate &dd, QQuickItem *parent); diff --git a/src/compositor/extensions/qwaylandquickshellsurfaceitem_p.h b/src/compositor/extensions/qwaylandquickshellsurfaceitem_p.h index 27163145e..46e5f65a5 100644 --- a/src/compositor/extensions/qwaylandquickshellsurfaceitem_p.h +++ b/src/compositor/extensions/qwaylandquickshellsurfaceitem_p.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDQUICKSHELLSURFACEITEM_P_H #define QWAYLANDQUICKSHELLSURFACEITEM_P_H @@ -33,7 +7,9 @@ #include <QtWaylandCompositor/QWaylandQuickShellSurfaceItem> #include <QtWaylandCompositor/QWaylandQuickShellIntegration> #include <QtWaylandCompositor/private/qwaylandquickitem_p.h> + #include <QtCore/QBasicTimer> +#include <QtCore/qpointer.h> #include <functional> @@ -53,7 +29,7 @@ QT_BEGIN_NAMESPACE class QWaylandShellSurface; class QWaylandQuickShellSurfaceItem; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandQuickShellSurfaceItemPrivate : public QWaylandQuickItemPrivate +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandQuickShellSurfaceItemPrivate : public QWaylandQuickItemPrivate { Q_DECLARE_PUBLIC(QWaylandQuickShellSurfaceItem) public: @@ -61,19 +37,18 @@ public: QWaylandQuickShellSurfaceItem *maybeCreateAutoPopup(QWaylandShellSurface* shellSurface); static QWaylandQuickShellSurfaceItemPrivate *get(QWaylandQuickShellSurfaceItem *item) { return item->d_func(); } + void raise() override; + void lower() override; + QWaylandQuickShellIntegration *m_shellIntegration = nullptr; QWaylandShellSurface *m_shellSurface = nullptr; QQuickItem *m_moveItem = nullptr; - bool m_autoCreatePopupItems = -#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) - true; -#else - false; -#endif - + bool m_autoCreatePopupItems = true; + bool staysOnTop = false; + bool staysOnBottom = false; }; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandQuickShellEventFilter : public QObject +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandQuickShellEventFilter : public QObject { Q_OBJECT public: diff --git a/src/compositor/extensions/qwaylandquickxdgoutputv1.cpp b/src/compositor/extensions/qwaylandquickxdgoutputv1.cpp index eb6717a78..c637280c1 100644 --- a/src/compositor/extensions/qwaylandquickxdgoutputv1.cpp +++ b/src/compositor/extensions/qwaylandquickxdgoutputv1.cpp @@ -1,38 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2019 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** 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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2019 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <QWaylandCompositor> #include <QWaylandOutput> @@ -40,6 +7,8 @@ #include "qwaylandquickxdgoutputv1.h" #include "qwaylandxdgoutputv1_p.h" +QT_BEGIN_NAMESPACE + QWaylandQuickXdgOutputV1::QWaylandQuickXdgOutputV1() : QWaylandXdgOutputV1() { @@ -71,3 +40,7 @@ void QWaylandQuickXdgOutputV1::componentComplete() } } } + +QT_END_NAMESPACE + +#include "moc_qwaylandquickxdgoutputv1.cpp" diff --git a/src/compositor/extensions/qwaylandquickxdgoutputv1.h b/src/compositor/extensions/qwaylandquickxdgoutputv1.h index c8b16ab8e..c607cf649 100644 --- a/src/compositor/extensions/qwaylandquickxdgoutputv1.h +++ b/src/compositor/extensions/qwaylandquickxdgoutputv1.h @@ -1,38 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2019 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** 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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2019 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDQUICKXDGOUTPUT_V1 #define QWAYLANDQUICKXDGOUTPUT_V1 @@ -41,9 +8,11 @@ #include <QtQml/QQmlParserStatus> #include <QtWaylandCompositor/QWaylandXdgOutputV1> +QT_REQUIRE_CONFIG(wayland_compositor_quick); + QT_BEGIN_NAMESPACE -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandQuickXdgOutputV1 +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandQuickXdgOutputV1 : public QWaylandXdgOutputV1 , public QQmlParserStatus { diff --git a/src/compositor/extensions/qwaylandshell.cpp b/src/compositor/extensions/qwaylandshell.cpp index 45f80114e..68f9d839b 100644 --- a/src/compositor/extensions/qwaylandshell.cpp +++ b/src/compositor/extensions/qwaylandshell.cpp @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "qwaylandshell.h" #include "qwaylandshell_p.h" @@ -55,7 +29,7 @@ QWaylandShell::QWaylandShell(QWaylandObject *waylandObject) */ /*! - * \qmlproperty enumeration QtWaylandCompositor::Shell::focusPolicy + * \qmlproperty enumeration Shell::focusPolicy * * This property holds the focus policy of the Shell. */ @@ -92,14 +66,6 @@ QWaylandShell::QWaylandShell(QWaylandObject *container, QWaylandShellPrivate &dd { } -QWaylandShell::QWaylandShell(QWaylandCompositorExtensionPrivate &dd) - : QWaylandShell(static_cast<QWaylandShellPrivate &>(dd)) -{ -} - -QWaylandShell::QWaylandShell(QWaylandObject *container, QWaylandCompositorExtensionPrivate &dd) - : QWaylandShell(container, static_cast<QWaylandShellPrivate &>(dd)) -{ -} - QT_END_NAMESPACE + +#include "moc_qwaylandshell.cpp" diff --git a/src/compositor/extensions/qwaylandshell.h b/src/compositor/extensions/qwaylandshell.h index a572b3d6e..765d4f0eb 100644 --- a/src/compositor/extensions/qwaylandshell.h +++ b/src/compositor/extensions/qwaylandshell.h @@ -1,46 +1,25 @@ -/**************************************************************************** -** -** Copyright (C) 2017 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDSHELL_H #define QWAYLANDSHELL_H -#include <QtWaylandCompositor/QWaylandCompositorExtension> +#include <QtWaylandCompositor/qtwaylandqmlinclude.h> +#include <QtWaylandCompositor/qwaylandcompositorextension.h> QT_BEGIN_NAMESPACE class QWaylandShellPrivate; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandShell : public QWaylandCompositorExtension +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandShell : public QWaylandCompositorExtension { Q_OBJECT Q_DECLARE_PRIVATE(QWaylandShell) Q_PROPERTY(FocusPolicy focusPolicy READ focusPolicy WRITE setFocusPolicy NOTIFY focusPolicyChanged) + + QML_NAMED_ELEMENT(Shell) + QML_UNCREATABLE("") + QML_ADDED_IN_VERSION(1, 0) public: enum FocusPolicy { AutomaticFocus, @@ -60,14 +39,10 @@ Q_SIGNALS: protected: explicit QWaylandShell(QWaylandShellPrivate &dd); explicit QWaylandShell(QWaylandObject *container, QWaylandShellPrivate &dd); - - //Qt 6: remove - Q_DECL_DEPRECATED QWaylandShell(QWaylandCompositorExtensionPrivate &dd); - Q_DECL_DEPRECATED QWaylandShell(QWaylandObject *container, QWaylandCompositorExtensionPrivate &dd); }; template <typename T> -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandShellTemplate : public QWaylandShell +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandShellTemplate : public QWaylandShell { public: QWaylandShellTemplate() diff --git a/src/compositor/extensions/qwaylandshell_p.h b/src/compositor/extensions/qwaylandshell_p.h index c3ca79338..ab7dc9a34 100644 --- a/src/compositor/extensions/qwaylandshell_p.h +++ b/src/compositor/extensions/qwaylandshell_p.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDSHELL_P_H #define QWAYLANDSHELL_P_H @@ -46,7 +20,7 @@ QT_BEGIN_NAMESPACE -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandShellPrivate : public QWaylandCompositorExtensionPrivate +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandShellPrivate : public QWaylandCompositorExtensionPrivate { Q_DECLARE_PUBLIC(QWaylandShell) public: diff --git a/src/compositor/extensions/qwaylandshellsurface.cpp b/src/compositor/extensions/qwaylandshellsurface.cpp index 6fda778f6..7e2fcee60 100644 --- a/src/compositor/extensions/qwaylandshellsurface.cpp +++ b/src/compositor/extensions/qwaylandshellsurface.cpp @@ -1,36 +1,46 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the config.tests of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QtWaylandCompositor/QWaylandShellSurface> +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#include "qwaylandshellsurface_p.h" + +/*! + * \class QWaylandShellSurfaceTemplate + * \inmodule QtWaylandCompositor + * \since 5.8 + * \brief QWaylandShellSurfaceTemplate is a convenience class for creating custom shell surface + * classes. + * + * QWaylandShellSurfaceTemplate is a template class which inherits from QWaylandShellSurface and + * is convenience for building custom shell extensions. + * + * It provides the connection between Qt Wayland Compositor and the class generated by + * \c qtwaylandscanner, based on the XML description of the extension protocol. + * + * It provides two specific pieces of convenience: + * \list + * \li A reimplementation of \l{QWaylandCompositorExtension::extensionInterface()} which returns + * the \c wl_interface pointer for the qtwaylandscanner-generated base class. + * \li A static \l{findIn()} function which searches for an instance of the extension in a + * provided container, and returns this if it is found. + * \endlist + * + * The same usage pattern applies as for QWaylandCompositorExtensionTemplate. + * + * \sa { Custom Shell} + */ + +/*! + * \fn template <typename T> T *QWaylandShellSurfaceTemplate<T>::findIn(QWaylandObject *container) + * + * If any instance of the interface has been registered with \a container, this is returned. + * Otherwise null is returned. The look-up is based on the generated \c interfaceName() which + * matches the interface name in the protocol description. + */ + /*! * \qmltype ShellSurface + * \instantiates QWaylandShellSurface * \inqmlmodule QtWayland.Compositor * \since 5.8 * \brief Provides a common interface for surface roles specified by shell extensions. @@ -38,13 +48,13 @@ * This interface represents a Wayland surface role given by a Wayland protocol extension that * defines how the WaylandSurface should map onto the screen. * - * Note: Even though this type contains a very limited API, the properties and signals of the + * \note Even though this type contains a very limited API, the properties and signals of the * implementations are named consistently. For example, if you're only using desktop shell * extensions in your compositor, it's safe to access properties such as title, maximized, etc. * directly on the ShellSurface. See the various implementations for additional properties and * signals. * - * \sa WaylandSurface, ShellSurfaceItem, WlShellSurface, XdgSurfaceV5, IviSurface + * \sa WaylandSurface, ShellSurfaceItem, WlShellSurface, IviSurface */ /*! @@ -56,7 +66,7 @@ * This interface represents a Wayland surface role given by a Wayland protocol extension that * defines how the QWaylandSurface should map onto the screen. * - * \sa QWaylandSurface, QWaylandWlShellSurface, QWaylandXdgSurfaceV5, QWaylandIviSurface + * \sa QWaylandSurface, QWaylandWlShellSurface, QWaylandIviSurface, QWaylandShellSurfaceTemplate */ #if QT_CONFIG(wayland_compositor_quick) @@ -64,14 +74,14 @@ * \fn QWaylandQuickShellIntegration *QWaylandShellSurface::createIntegration(QWaylandQuickShellSurfaceItem *item) * * Creates a QWaylandQuickShellIntegration for this QWaylandQuickShellSurface. It's called - * automatically when QWaylandQuickShellSurfaceItem::shellSurface is assigned. + * automatically when \a {item}'s \l {QWaylandQuickShellSurfaceItem::}{shellSurface} is assigned. * * \sa QWaylandQuickShellSurfaceItem */ #endif /*! - * \qmlproperty enum QtWaylandCompositor::ShellSurface::windowType + * \qmlproperty enum QtWayland.Compositor::ShellSurface::windowType * * This property holds the window type of the ShellSurface. */ @@ -81,3 +91,53 @@ * * This property holds the window type of the QWaylandShellSurface. */ + +/*! + * \qmlproperty bool QtWayland.Compositor::ShellSurface::modal + * + * This property is true if the ShellSurface represents a modal dialog. + * \since 6.8 + */ + +/*! + * \property QWaylandShellSurface::modal + * + * This property is true if the ShellSurface represents a modal dialog. + * \since 6.8 + */ + +QT_BEGIN_NAMESPACE + +QWaylandShellSurface::QWaylandShellSurface(QWaylandShellSurfacePrivate &dd) + : QWaylandCompositorExtension(dd) +{ +} + +QWaylandShellSurface::QWaylandShellSurface(QWaylandObject *container, QWaylandShellSurfacePrivate &dd) + : QWaylandCompositorExtension(container, dd) +{ +} + +QWaylandShellSurface::QWaylandShellSurface(QWaylandObject *waylandObject) + : QWaylandCompositorExtension(waylandObject, *new QWaylandShellSurfacePrivate) +{ +} + +bool QWaylandShellSurface::modal() const +{ + Q_D(const QWaylandShellSurface); + return d->modal; +} + +void QWaylandShellSurface::setModal(bool newModal) +{ + Q_D(QWaylandShellSurface); + if (d->modal == newModal) + return; + d->modal = newModal; + emit modalChanged(); +} + +QT_END_NAMESPACE + +#include "moc_qwaylandshellsurface.cpp" diff --git a/src/compositor/extensions/qwaylandshellsurface.h b/src/compositor/extensions/qwaylandshellsurface.h index bcc931228..96ef772ca 100644 --- a/src/compositor/extensions/qwaylandshellsurface.h +++ b/src/compositor/extensions/qwaylandshellsurface.h @@ -1,68 +1,52 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDSHELLSURFACE_H #define QWAYLANDSHELLSURFACE_H -#include <QtWaylandCompositor/QWaylandCompositorExtension> +#include <QtWaylandCompositor/qtwaylandqmlinclude.h> +#include <QtWaylandCompositor/qwaylandcompositorextension.h> QT_BEGIN_NAMESPACE class QWaylandQuickShellIntegration; class QWaylandQuickShellSurfaceItem; class QWaylandShellSurfacePrivate; -class QWaylandShellSurfaceTemplatePrivate; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandShellSurface : public QWaylandCompositorExtension +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandShellSurface : public QWaylandCompositorExtension { Q_OBJECT + Q_DECLARE_PRIVATE(QWaylandShellSurface) + Q_PROPERTY(Qt::WindowType windowType READ windowType NOTIFY windowTypeChanged) + Q_PROPERTY(bool modal READ modal NOTIFY modalChanged FINAL REVISION(6, 8)) + QML_NAMED_ELEMENT(ShellSurface) + QML_UNCREATABLE("") + QML_ADDED_IN_VERSION(1, 0) public: #if QT_CONFIG(wayland_compositor_quick) virtual QWaylandQuickShellIntegration *createIntegration(QWaylandQuickShellSurfaceItem *item) = 0; #endif - QWaylandShellSurface(QWaylandObject *waylandObject) : QWaylandCompositorExtension(waylandObject) {} + QWaylandShellSurface(QWaylandObject *waylandObject); virtual Qt::WindowType windowType() const { return Qt::WindowType::Window; } + bool modal() const; + protected: - QWaylandShellSurface(QWaylandCompositorExtensionPrivate &dd) : QWaylandCompositorExtension(dd){} - QWaylandShellSurface(QWaylandObject *container, QWaylandCompositorExtensionPrivate &dd) : QWaylandCompositorExtension(container, dd) {} + QWaylandShellSurface(QWaylandShellSurfacePrivate &dd); + QWaylandShellSurface(QWaylandObject *container, QWaylandShellSurfacePrivate &dd); + void setModal(bool newModal); Q_SIGNALS: void windowTypeChanged(); + Q_REVISION(6, 8) void modalChanged(); }; template <typename T> -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandShellSurfaceTemplate : public QWaylandShellSurface +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandShellSurfaceTemplate : public QWaylandShellSurface { public: - QWaylandShellSurfaceTemplate(QWaylandObject *container) + QWaylandShellSurfaceTemplate(QWaylandObject *container = nullptr) : QWaylandShellSurface(container) { } @@ -78,11 +62,11 @@ public: } protected: - QWaylandShellSurfaceTemplate(QWaylandCompositorExtensionPrivate &dd) + QWaylandShellSurfaceTemplate(QWaylandShellSurfacePrivate &dd) : QWaylandShellSurface(dd) { } - QWaylandShellSurfaceTemplate(QWaylandObject *container, QWaylandCompositorExtensionPrivate &dd) + QWaylandShellSurfaceTemplate(QWaylandObject *container, QWaylandShellSurfacePrivate &dd) : QWaylandShellSurface(container,dd) { } }; diff --git a/src/compositor/extensions/qwaylandshellsurface_p.h b/src/compositor/extensions/qwaylandshellsurface_p.h new file mode 100644 index 000000000..438571824 --- /dev/null +++ b/src/compositor/extensions/qwaylandshellsurface_p.h @@ -0,0 +1,32 @@ +// Copyright (C) 2024 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#ifndef QWAYLANDSHELLSURFACE_P_H +#define QWAYLANDSHELLSURFACE_P_H + +#include <QtWaylandCompositor/private/qwaylandcompositorextension_p.h> +#include "qwaylandshellsurface.h" + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +QT_BEGIN_NAMESPACE + +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandShellSurfacePrivate : public QWaylandCompositorExtensionPrivate +{ + Q_DECLARE_PUBLIC(QWaylandShellSurface) +public: + bool modal = false; +}; + +QT_END_NAMESPACE + +#endif // QWAYLANDSHELLSURFACE_P_H diff --git a/src/compositor/extensions/qwaylandtextinput.cpp b/src/compositor/extensions/qwaylandtextinput.cpp index 5f6adac9d..933f31208 100644 --- a/src/compositor/extensions/qwaylandtextinput.cpp +++ b/src/compositor/extensions/qwaylandtextinput.cpp @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "qwaylandtextinput.h" #include "qwaylandtextinput_p.h" @@ -36,12 +10,13 @@ #include "qwaylandsurface.h" #include "qwaylandview.h" #include "qwaylandinputmethodeventbuilder_p.h" +#include "qwaylandinputmethodcontrol.h" #include <QGuiApplication> #include <QInputMethodEvent> #if QT_CONFIG(xkbcommon) -#include <QtXkbCommonSupport/private/qxkbcommon_p.h> +#include <QtGui/private/qxkbcommon_p.h> #endif QT_BEGIN_NAMESPACE @@ -130,10 +105,10 @@ void QWaylandTextInputPrivate::sendInputMethodEvent(QInputMethodEvent *event) if (event->replacementLength() > 0 || event->replacementStart() != 0) { // Remove replacement - afterCommit.cursorPosition = qBound(0, afterCommit.cursorPosition + event->replacementStart(), afterCommit.surroundingText.length()); + afterCommit.cursorPosition = qBound(0, afterCommit.cursorPosition + event->replacementStart(), afterCommit.surroundingText.size()); afterCommit.surroundingText.remove(afterCommit.cursorPosition, qMin(event->replacementLength(), - afterCommit.surroundingText.length() - afterCommit.cursorPosition)); + afterCommit.surroundingText.size() - afterCommit.cursorPosition)); if (event->replacementStart() <= 0 && (event->replacementLength() >= -event->replacementStart())) { const int selectionStart = qMin(currentState->cursorPosition, currentState->anchorPosition); @@ -149,7 +124,7 @@ void QWaylandTextInputPrivate::sendInputMethodEvent(QInputMethodEvent *event) // Insert commit string afterCommit.surroundingText.insert(afterCommit.cursorPosition, event->commitString()); - afterCommit.cursorPosition += event->commitString().length(); + afterCommit.cursorPosition += event->commitString().size(); afterCommit.anchorPosition = afterCommit.cursorPosition; for (const QInputMethodEvent::Attribute &attribute : event->attributes()) { @@ -194,13 +169,22 @@ void QWaylandTextInputPrivate::sendKeyEvent(QKeyEvent *event) if (!focusResource || !focusResource->handle) return; - // TODO add support for modifiers + uint mods = 0; + const auto &qtMods = event->modifiers(); + if (qtMods & Qt::ShiftModifier) + mods |= shiftModifierMask; + if (qtMods & Qt::ControlModifier) + mods |= controlModifierMask; + if (qtMods & Qt::AltModifier) + mods |= altModifierMask; + if (qtMods & Qt::MetaModifier) + mods |= metaModifierMask; #if QT_CONFIG(xkbcommon) for (xkb_keysym_t keysym : QXkbCommon::toKeysym(event)) { send_keysym(focusResource->handle, event->timestamp(), keysym, event->type() == QEvent::KeyPress ? WL_KEYBOARD_KEY_STATE_PRESSED : WL_KEYBOARD_KEY_STATE_RELEASED, - 0); + mods); } #else Q_UNUSED(event); @@ -313,9 +297,24 @@ void QWaylandTextInputPrivate::setFocus(QWaylandSurface *surface) focus = surface; } +void QWaylandTextInputPrivate::sendModifiersMap(const QByteArray &modifiersMap) +{ + send_modifiers_map(focusResource->handle, modifiersMap); +} + +#if !QT_CONFIG(xkbcommon) +#define XKB_MOD_NAME_SHIFT "Shift" +#define XKB_MOD_NAME_CTRL "Control" +#define XKB_MOD_NAME_ALT "Mod1" +#define XKB_MOD_NAME_LOGO "Mod4" +#endif void QWaylandTextInputPrivate::zwp_text_input_v2_bind_resource(Resource *resource) { - send_modifiers_map(resource->handle, QByteArray("")); + QByteArray modifiers = XKB_MOD_NAME_SHIFT + QByteArray(1, '\0'); + modifiers += XKB_MOD_NAME_CTRL + QByteArray(1, '\0'); + modifiers += XKB_MOD_NAME_ALT + QByteArray(1, '\0'); + modifiers += XKB_MOD_NAME_LOGO + QByteArray(1, '\0'); + send_modifiers_map(resource->handle, modifiers); } void QWaylandTextInputPrivate::zwp_text_input_v2_destroy_resource(Resource *resource) @@ -335,6 +334,11 @@ void QWaylandTextInputPrivate::zwp_text_input_v2_enable(Resource *resource, wl_r QWaylandSurface *s = QWaylandSurface::fromResource(surface); enabledSurfaces.insert(resource, s); + + QWaylandInputMethodControl *control = s->inputMethodControl(); + if (control) + control->updateTextInput(); + emit q->surfaceEnabled(s); } @@ -388,9 +392,9 @@ void QWaylandTextInputPrivate::zwp_text_input_v2_update_state(Resource *resource Qt::InputMethodQueries queries; if (flags == update_state_change) { - queries = currentState->mergeChanged(*pendingState.data()); + queries = currentState->mergeChanged(*pendingState); } else { - queries = pendingState->updatedQueries(*currentState.data()); + queries = pendingState->updatedQueries(*currentState); currentState.swap(pendingState); } @@ -601,4 +605,33 @@ QByteArray QWaylandTextInput::interfaceName() return QWaylandTextInputPrivate::interfaceName(); } + +void QWaylandTextInput::sendModifiersMap(const QByteArray &modifiersMap) +{ + Q_D(QWaylandTextInput); + + const QList<QByteArray> modifiers = modifiersMap.split('\0'); + + int numModifiers = modifiers.size(); + if (modifiers.last().isEmpty()) + numModifiers--; + + for (int i = 0; i < numModifiers; ++i) { + const auto modString = modifiers.at(i); + if (modString == XKB_MOD_NAME_SHIFT) + d->shiftModifierMask = 1 << i; + else if (modString == XKB_MOD_NAME_CTRL) + d->controlModifierMask = 1 << i; + else if (modString == XKB_MOD_NAME_ALT) + d->altModifierMask = 1 << i; + else if (modString == XKB_MOD_NAME_LOGO) + d->metaModifierMask = 1 << i; + else + qCDebug(qLcWaylandCompositorInputMethods) << "unsupported modifier name " << modString; + } + d->sendModifiersMap(modifiersMap); +} + QT_END_NAMESPACE + +#include "moc_qwaylandtextinput.cpp" diff --git a/src/compositor/extensions/qwaylandtextinput.h b/src/compositor/extensions/qwaylandtextinput.h index fc2918e29..0d7dcd2c7 100644 --- a/src/compositor/extensions/qwaylandtextinput.h +++ b/src/compositor/extensions/qwaylandtextinput.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDTEXTINPUT_H #define QWAYLANDTEXTINPUT_H @@ -64,6 +38,8 @@ public: static const struct wl_interface *interface(); static QByteArray interfaceName(); + void sendModifiersMap(const QByteArray &modifiersMap); + Q_SIGNALS: void updateInputMethod(Qt::InputMethodQueries queries); void surfaceEnabled(QWaylandSurface *surface); diff --git a/src/compositor/extensions/qwaylandtextinput_p.h b/src/compositor/extensions/qwaylandtextinput_p.h index dba0c2bf5..239bc9d5c 100644 --- a/src/compositor/extensions/qwaylandtextinput_p.h +++ b/src/compositor/extensions/qwaylandtextinput_p.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDTEXTINPUT_P_H #define QWAYLANDTEXTINPUT_P_H @@ -36,8 +10,8 @@ #include <QtCore/QObject> #include <QtCore/QMap> +#include <QtCore/QHash> #include <QtCore/QRect> -#include <QtCore/QVector> #include <QtGui/QInputMethod> #include <QtWaylandCompositor/QWaylandSurface> @@ -76,7 +50,7 @@ public: Qt::InputMethodQueries changedState; }; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandTextInputPrivate : public QWaylandCompositorExtensionPrivate, public QtWaylandServer::zwp_text_input_v2 +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandTextInputPrivate : public QWaylandCompositorExtensionPrivate, public QtWaylandServer::zwp_text_input_v2 { Q_DECLARE_PUBLIC(QWaylandTextInput) public: @@ -87,6 +61,7 @@ public: void sendInputPanelState(); void sendTextDirection(); void sendLocale(); + void sendModifiersMap(const QByteArray &modifiersMap); QVariant inputMethodQuery(Qt::InputMethodQuery property, QVariant argument) const; @@ -100,8 +75,8 @@ public: bool inputPanelVisible = false; - QScopedPointer<QWaylandTextInputClientState> currentState; - QScopedPointer<QWaylandTextInputClientState> pendingState; + std::unique_ptr<QWaylandTextInputClientState> currentState; + std::unique_ptr<QWaylandTextInputClientState> pendingState; uint32_t serial = 0; @@ -121,6 +96,12 @@ protected: void zwp_text_input_v2_set_cursor_rectangle(Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height) override; void zwp_text_input_v2_set_preferred_language(Resource *resource, const QString &language) override; void zwp_text_input_v2_update_state(Resource *resource, uint32_t serial, uint32_t flags) override; + +private: + quint32 shiftModifierMask = 1; + quint32 controlModifierMask = 2; + quint32 altModifierMask = 4; + quint32 metaModifierMask = 8; }; QT_END_NAMESPACE diff --git a/src/compositor/extensions/qwaylandtextinputmanager.cpp b/src/compositor/extensions/qwaylandtextinputmanager.cpp index 495ebae84..64f6ffdd7 100644 --- a/src/compositor/extensions/qwaylandtextinputmanager.cpp +++ b/src/compositor/extensions/qwaylandtextinputmanager.cpp @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "qwaylandtextinputmanager.h" #include "qwaylandtextinputmanager_p.h" @@ -47,12 +21,43 @@ void QWaylandTextInputManagerPrivate::zwp_text_input_manager_v2_get_text_input(R QWaylandCompositor *compositor = static_cast<QWaylandCompositor *>(q->extensionContainer()); QWaylandSeat *seat = QWaylandSeat::fromSeatResource(seatResource); QWaylandTextInput *textInput = QWaylandTextInput::findIn(seat); - if (!textInput) { + if (!textInput) textInput = new QWaylandTextInput(seat, compositor); - } textInput->add(resource->client(), id, wl_resource_get_version(resource->handle)); + QWaylandClient *client = QWaylandClient::fromWlClient(compositor, resource->client()); + QWaylandClient::TextInputProtocols p = client->textInputProtocols(); + client->setTextInputProtocols(p.setFlag(QWaylandClient::TextInputProtocol::TextInputV2)); + if (!textInput->isInitialized()) + textInput->initialize(); } +/*! + \qmltype TextInputManager + \instantiates QWaylandTextInputManager + \inqmlmodule QtWayland.Compositor + \brief Provides access to input methods in the compositor. + + The \c TextInputManager corresponds to the \c zwp_text_input_manager_v2 interface + in the \c text_input_unstable_v2 extension protocol. + + Instantiating this as child of a \l WaylandCompositor adds it to the list of interfaces available + to the client. If a client binds to it, then it will be used to communciate text input to + that client. +*/ + +/*! + \class QWaylandTextInputManager + \inmodule QtWaylandCompositor + \brief Provides access to input methods in the compositor. + + The \c QWaylandTextInputManager corresponds to the \c zwp_text_input_manager_v2 interface + in the \c text_input_unstable_v2 extension protocol. + + Instantiating this as child of a \l WaylandCompositor adds it to the list of interfaces available + to the client. If a client binds to it, then it will be used to communciate text input to + that client. +*/ + QWaylandTextInputManager::QWaylandTextInputManager() : QWaylandCompositorExtensionTemplate<QWaylandTextInputManager>(*new QWaylandTextInputManagerPrivate) { @@ -87,3 +92,5 @@ QByteArray QWaylandTextInputManager::interfaceName() } QT_END_NAMESPACE + +#include "moc_qwaylandtextinputmanager.cpp" diff --git a/src/compositor/extensions/qwaylandtextinputmanager.h b/src/compositor/extensions/qwaylandtextinputmanager.h index 90a8b3b14..cab75d8fa 100644 --- a/src/compositor/extensions/qwaylandtextinputmanager.h +++ b/src/compositor/extensions/qwaylandtextinputmanager.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDTEXTINPUTMANAGER_H #define QWAYLANDTEXTINPUTMANAGER_H @@ -38,7 +12,7 @@ QT_BEGIN_NAMESPACE class QWaylandTextInputManagerPrivate; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandTextInputManager : public QWaylandCompositorExtensionTemplate<QWaylandTextInputManager> +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandTextInputManager : public QWaylandCompositorExtensionTemplate<QWaylandTextInputManager> { Q_OBJECT Q_DECLARE_PRIVATE(QWaylandTextInputManager) diff --git a/src/compositor/extensions/qwaylandtextinputmanager_p.h b/src/compositor/extensions/qwaylandtextinputmanager_p.h index 804930bcc..1e998fda4 100644 --- a/src/compositor/extensions/qwaylandtextinputmanager_p.h +++ b/src/compositor/extensions/qwaylandtextinputmanager_p.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDTEXTINPUTMANAGER_P_H #define QWAYLANDTEXTINPUTMANAGER_P_H @@ -47,7 +21,7 @@ QT_BEGIN_NAMESPACE -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandTextInputManagerPrivate : public QWaylandCompositorExtensionPrivate, public QtWaylandServer::zwp_text_input_manager_v2 +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandTextInputManagerPrivate : public QWaylandCompositorExtensionPrivate, public QtWaylandServer::zwp_text_input_manager_v2 { Q_DECLARE_PUBLIC(QWaylandTextInputManager) public: diff --git a/src/compositor/extensions/qwaylandtextinputmanagerv3.cpp b/src/compositor/extensions/qwaylandtextinputmanagerv3.cpp new file mode 100644 index 000000000..e9ad25bff --- /dev/null +++ b/src/compositor/extensions/qwaylandtextinputmanagerv3.cpp @@ -0,0 +1,111 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#include "qwaylandtextinputmanagerv3.h" +#include "qwaylandtextinputmanagerv3_p.h" + +#include <QtWaylandCompositor/QWaylandCompositor> +#include <QtWaylandCompositor/QWaylandSeat> + +#include "qwaylandtextinputv3.h" + +QT_BEGIN_NAMESPACE + +QWaylandTextInputManagerV3Private::QWaylandTextInputManagerV3Private() +{ +} + +void QWaylandTextInputManagerV3Private::zwp_text_input_manager_v3_get_text_input(Resource *resource, uint32_t id, struct ::wl_resource *seatResource) +{ + qCDebug(qLcWaylandCompositorTextInput) << Q_FUNC_INFO; + + Q_Q(QWaylandTextInputManagerV3); + QWaylandCompositor *compositor = static_cast<QWaylandCompositor *>(q->extensionContainer()); + QWaylandSeat *seat = QWaylandSeat::fromSeatResource(seatResource); + QWaylandTextInputV3 *textInput = QWaylandTextInputV3::findIn(seat); + if (!textInput) { + textInput = new QWaylandTextInputV3(seat, compositor); + } + textInput->add(resource->client(), id, wl_resource_get_version(resource->handle)); + QWaylandClient *client = QWaylandClient::fromWlClient(compositor, resource->client()); + QWaylandClient::TextInputProtocols p = client->textInputProtocols(); + client->setTextInputProtocols(p.setFlag(QWaylandClient::TextInputProtocol::TextInputV3)); + if (!textInput->isInitialized()) + textInput->initialize(); +} + +/*! + \internal + \preliminary + + \qmltype TextInputManagerV3 + \instantiates QWaylandTextInputManagerV3 + \inqmlmodule QtWayland.Compositor + \brief Provides access to input methods in the compositor. + + The \c TextInputManagerV3 corresponds to the \c zwp_text_input_manager_v3 interface + in the \c text_input_unstable_v3 extension protocol. + + Instantiating this as child of a \l WaylandCompositor adds it to the list of interfaces available + to the client. If a client binds to it, then it will be used to communciate text input to + that client. + + \note This protocol is currently a work-in-progress and only exists in Qt for validation purposes. It may change at any time. +*/ + +/*! + \internal + \preliminary + \class QWaylandTextInputManagerV3 + \inmodule QtWaylandCompositor + \brief Provides access to input methods in the compositor. + + The \c QWaylandTextInputManagerV3 corresponds to the \c zwp_text_input_manager_v3 interface + in the \c text_input_unstable_v3 extension protocol. + + Instantiating this as child of a \l WaylandCompositor adds it to the list of interfaces available + to the client. If a client binds to it, then it will be used to communciate text input to + that client. + \note This protocol is currently a work-in-progress and only exists in Qt for validation purposes. It may change at any time. +*/ + +QWaylandTextInputManagerV3::QWaylandTextInputManagerV3() + : QWaylandCompositorExtensionTemplate<QWaylandTextInputManagerV3>(*new QWaylandTextInputManagerV3Private) +{ +} + +QWaylandTextInputManagerV3::QWaylandTextInputManagerV3(QWaylandCompositor *compositor) + : QWaylandCompositorExtensionTemplate<QWaylandTextInputManagerV3>(compositor, *new QWaylandTextInputManagerV3Private) +{ +} + +QWaylandTextInputManagerV3::~QWaylandTextInputManagerV3() +{ +} + +void QWaylandTextInputManagerV3::initialize() +{ + qCDebug(qLcWaylandCompositorTextInput) << Q_FUNC_INFO; + + Q_D(QWaylandTextInputManagerV3); + + QWaylandCompositorExtensionTemplate::initialize(); + QWaylandCompositor *compositor = static_cast<QWaylandCompositor *>(extensionContainer()); + if (!compositor) { + qWarning() << "Failed to find QWaylandCompositor when initializing QWaylandTextInputManagerV3"; + return; + } + d->init(compositor->display(), 1); +} + +const wl_interface *QWaylandTextInputManagerV3::interface() +{ + return QWaylandTextInputManagerV3Private::interface(); +} + +QByteArray QWaylandTextInputManagerV3::interfaceName() +{ + return QWaylandTextInputManagerV3Private::interfaceName(); +} + +QT_END_NAMESPACE diff --git a/src/compositor/extensions/qwaylandtextinputmanagerv3.h b/src/compositor/extensions/qwaylandtextinputmanagerv3.h new file mode 100644 index 000000000..a71fdcbaa --- /dev/null +++ b/src/compositor/extensions/qwaylandtextinputmanagerv3.h @@ -0,0 +1,32 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#ifndef QWAYLANDTEXTINPUTMANAGERV3_H +#define QWAYLANDTEXTINPUTMANAGERV3_H + +#include <QtWaylandCompositor/QWaylandCompositorExtension> + +#include <QtCore/QSize> + +QT_BEGIN_NAMESPACE + +class QWaylandTextInputManagerV3Private; + +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandTextInputManagerV3 : public QWaylandCompositorExtensionTemplate<QWaylandTextInputManagerV3> +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QWaylandTextInputManagerV3) +public: + QWaylandTextInputManagerV3(); + explicit QWaylandTextInputManagerV3(QWaylandCompositor *compositor); + ~QWaylandTextInputManagerV3() override; + + void initialize() override; + + static const struct wl_interface *interface(); + static QByteArray interfaceName(); +}; + +QT_END_NAMESPACE + +#endif // QWAYLANDTEXTINPUTMANAGERV3_H diff --git a/src/compositor/extensions/qwaylandtextinputmanagerv3_p.h b/src/compositor/extensions/qwaylandtextinputmanagerv3_p.h new file mode 100644 index 000000000..5559a4418 --- /dev/null +++ b/src/compositor/extensions/qwaylandtextinputmanagerv3_p.h @@ -0,0 +1,36 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#ifndef QWAYLANDTEXTINPUTMANAGERV3_P_H +#define QWAYLANDTEXTINPUTMANAGERV3_P_H + +#include <QtWaylandCompositor/private/qwaylandcompositorextension_p.h> + +#include <QtWaylandCompositor/private/qwayland-server-text-input-unstable-v3.h> + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +QT_BEGIN_NAMESPACE + +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandTextInputManagerV3Private : public QWaylandCompositorExtensionPrivate, public QtWaylandServer::zwp_text_input_manager_v3 +{ + Q_DECLARE_PUBLIC(QWaylandTextInputManagerV3) +public: + QWaylandTextInputManagerV3Private(); + +protected: + void zwp_text_input_manager_v3_get_text_input(Resource *resource, uint32_t id, struct ::wl_resource *seatResource) override; +}; + +QT_END_NAMESPACE + +#endif // QWAYLANDTEXTINPUTMANAGERV3_P_H diff --git a/src/compositor/extensions/qwaylandtextinputv3.cpp b/src/compositor/extensions/qwaylandtextinputv3.cpp new file mode 100644 index 000000000..7a0abd5dd --- /dev/null +++ b/src/compositor/extensions/qwaylandtextinputv3.cpp @@ -0,0 +1,523 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#include "qwaylandtextinputv3.h" +#include "qwaylandtextinputv3_p.h" + +#include <QtWaylandCompositor/QWaylandCompositor> +#include <QtWaylandCompositor/private/qwaylandseat_p.h> + +#include "qwaylandsurface.h" +#include "qwaylandview.h" +#include "qwaylandinputmethodeventbuilder_p.h" + +#include <QGuiApplication> +#include <QInputMethodEvent> +#include <qpa/qwindowsysteminterface.h> + +#if QT_CONFIG(xkbcommon) +#include <QtGui/private/qxkbcommon_p.h> +#endif + +QT_BEGIN_NAMESPACE + +Q_DECLARE_LOGGING_CATEGORY(qLcWaylandCompositorTextInput) + +QWaylandTextInputV3ClientState::QWaylandTextInputV3ClientState() +{ +} + +Qt::InputMethodQueries QWaylandTextInputV3ClientState::updatedQueries(const QWaylandTextInputV3ClientState &other) const +{ + qCDebug(qLcWaylandCompositorTextInput) << Q_FUNC_INFO; + + Qt::InputMethodQueries queries; + + if (hints != other.hints) + queries |= Qt::ImHints; + if (cursorRectangle != other.cursorRectangle) + queries |= Qt::ImCursorRectangle; + if (surroundingText != other.surroundingText) + queries |= Qt::ImSurroundingText | Qt::ImCurrentSelection; + if (cursorPosition != other.cursorPosition) + queries |= Qt::ImCursorPosition | Qt::ImCurrentSelection; + if (anchorPosition != other.anchorPosition) + queries |= Qt::ImAnchorPosition | Qt::ImCurrentSelection; + + return queries; +} + +Qt::InputMethodQueries QWaylandTextInputV3ClientState::mergeChanged(const QWaylandTextInputV3ClientState &other) { + + Qt::InputMethodQueries queries; + + if ((other.changedState & Qt::ImHints) && hints != other.hints) { + hints = other.hints; + queries |= Qt::ImHints; + } + + if ((other.changedState & Qt::ImCursorRectangle) && cursorRectangle != other.cursorRectangle) { + cursorRectangle = other.cursorRectangle; + queries |= Qt::ImCursorRectangle; + } + + if ((other.changedState & Qt::ImSurroundingText) && surroundingText != other.surroundingText) { + surroundingText = other.surroundingText; + queries |= Qt::ImSurroundingText | Qt::ImCurrentSelection; + } + + if ((other.changedState & Qt::ImCursorPosition) && cursorPosition != other.cursorPosition) { + cursorPosition = other.cursorPosition; + queries |= Qt::ImCursorPosition | Qt::ImCurrentSelection; + } + + if ((other.changedState & Qt::ImAnchorPosition) && anchorPosition != other.anchorPosition) { + anchorPosition = other.anchorPosition; + queries |= Qt::ImAnchorPosition | Qt::ImCurrentSelection; + } + + return queries; +} + +QWaylandTextInputV3Private::QWaylandTextInputV3Private(QWaylandCompositor *compositor) + : compositor(compositor) + , currentState(new QWaylandTextInputV3ClientState) + , pendingState(new QWaylandTextInputV3ClientState) +{ +} + +void QWaylandTextInputV3Private::sendInputMethodEvent(QInputMethodEvent *event) +{ + qCDebug(qLcWaylandCompositorTextInput) << Q_FUNC_INFO; + + if (!focusResource || !focusResource->handle) + return; + + bool needsDone = false; + + const QString &newPreeditString = event->preeditString(); + + // Current cursor shape is only line. It means both cursorBegin + // and cursorEnd will be the same values. + int32_t preeditCursorPos = newPreeditString.toUtf8().size(); + + if (event->replacementLength() > 0) { + int replacementStart = event->replacementStart(); + int replacementLength = event->replacementLength(); + const int cursorPos = currentState->cursorPosition; + if (currentState->cursorPosition < -event->replacementStart()) { + qCWarning(qLcWaylandCompositorTextInput) + << Q_FUNC_INFO + << "Invalid replacementStart :" << replacementStart + << "on the cursorPosition :" << cursorPos; + replacementStart = -cursorPos; + } + auto targetText = QStringView{currentState->surroundingText}.sliced(cursorPos + replacementStart); + if (targetText.length() < replacementLength) { + qCWarning(qLcWaylandCompositorTextInput) + << Q_FUNC_INFO + << "Invalid replacementLength :" << replacementLength + << "for the surrounding text :" << targetText; + replacementLength = targetText.length(); + } + const int before = targetText.first(-replacementStart).toUtf8().size(); + const int after = targetText.first(replacementLength).toUtf8().size() - before; + + send_delete_surrounding_text(focusResource->handle, before, after); + needsDone = true; + + // The commit will also be applied here + currentState->surroundingText.replace(cursorPos + replacementStart, + replacementLength, + event->commitString()); + currentState->cursorPosition = cursorPos + replacementStart + event->commitString().length(); + currentState->anchorPosition = cursorPos + replacementStart + event->commitString().length(); + qApp->inputMethod()->update(Qt::ImSurroundingText | Qt::ImCursorPosition | Qt::ImAnchorPosition); + } + + if (currentPreeditString != newPreeditString) { + currentPreeditString = newPreeditString; + send_preedit_string(focusResource->handle, currentPreeditString, preeditCursorPos, preeditCursorPos); + needsDone = true; + } + if (!event->commitString().isEmpty()) { + send_commit_string(focusResource->handle, event->commitString()); + needsDone = true; + } + + if (needsDone) + send_done(focusResource->handle, serials[focusResource]); +} + + +void QWaylandTextInputV3Private::sendKeyEvent(QKeyEvent *event) +{ + qCDebug(qLcWaylandCompositorTextInput) << Q_FUNC_INFO; + + if (!focusResource || !focusResource->handle) + return; + + send_commit_string(focusResource->handle, event->text()); + + send_done(focusResource->handle, serials[focusResource]); +} + +QVariant QWaylandTextInputV3Private::inputMethodQuery(Qt::InputMethodQuery property, QVariant argument) const +{ + qCDebug(qLcWaylandCompositorTextInput) << Q_FUNC_INFO << property; + + switch (property) { + case Qt::ImHints: + return QVariant(static_cast<int>(currentState->hints)); + case Qt::ImCursorRectangle: + return currentState->cursorRectangle; + case Qt::ImFont: + // Not supported + return QVariant(); + case Qt::ImCursorPosition: + qCDebug(qLcWaylandCompositorTextInput) << currentState->cursorPosition; + return currentState->cursorPosition; + case Qt::ImSurroundingText: + qCDebug(qLcWaylandCompositorTextInput) << currentState->surroundingText; + return currentState->surroundingText; + case Qt::ImCurrentSelection: + return currentState->surroundingText.mid(qMin(currentState->cursorPosition, currentState->anchorPosition), + qAbs(currentState->anchorPosition - currentState->cursorPosition)); + case Qt::ImMaximumTextLength: + // Not supported + return QVariant(); + case Qt::ImAnchorPosition: + qCDebug(qLcWaylandCompositorTextInput) << currentState->anchorPosition; + return currentState->anchorPosition; + case Qt::ImAbsolutePosition: + // We assume the surrounding text is our whole document for now + return currentState->cursorPosition; + case Qt::ImTextAfterCursor: + if (argument.isValid()) + return currentState->surroundingText.mid(currentState->cursorPosition, argument.toInt()); + return currentState->surroundingText.mid(currentState->cursorPosition); + case Qt::ImTextBeforeCursor: + if (argument.isValid()) + return currentState->surroundingText.left(currentState->cursorPosition).right(argument.toInt()); + return currentState->surroundingText.left(currentState->cursorPosition); + + default: + return QVariant(); + } +} + +void QWaylandTextInputV3Private::setFocus(QWaylandSurface *surface) +{ + qCDebug(qLcWaylandCompositorTextInput) << Q_FUNC_INFO << surface; + + if (focusResource && focus) { + // sync before leave + // IBUS commits by itself but qtvirtualkeyboard doesn't + // And when handling chinese input, it is required to commit + // before leaving the focus. + if (qgetenv("QT_IM_MODULE") != QByteArrayLiteral("ibus") + || qApp->inputMethod()->locale().language() == QLocale::Chinese) { + qApp->inputMethod()->commit(); + } + + qApp->inputMethod()->hide(); + inputPanelVisible = false; + send_leave(focusResource->handle, focus->resource()); + currentPreeditString.clear(); + } + + if (focus != surface) + focusDestroyListener.reset(); + + Resource *resource = surface ? resourceMap().value(surface->waylandClient()) : 0; + if (resource && surface) { + send_enter(resource->handle, surface->resource()); + + if (focus != surface) + focusDestroyListener.listenForDestruction(surface->resource()); + } + + focus = surface; + focusResource = resource; +} + +void QWaylandTextInputV3Private::zwp_text_input_v3_bind_resource(Resource *resource) +{ + qCDebug(qLcWaylandCompositorTextInput) << Q_FUNC_INFO; + + serials.insert(resource, 0); +} + +void QWaylandTextInputV3Private::zwp_text_input_v3_destroy_resource(Resource *resource) +{ + qCDebug(qLcWaylandCompositorTextInput) << Q_FUNC_INFO; + + serials.remove(resource); + if (focusResource == resource) + focusResource = nullptr; +} + +void QWaylandTextInputV3Private::zwp_text_input_v3_destroy(Resource *resource) +{ + qCDebug(qLcWaylandCompositorTextInput) << Q_FUNC_INFO; + + wl_resource_destroy(resource->handle); +} + +void QWaylandTextInputV3Private::zwp_text_input_v3_enable(Resource *resource) +{ + qCDebug(qLcWaylandCompositorTextInput) << Q_FUNC_INFO; + + Q_Q(QWaylandTextInputV3); + + pendingState.reset(new QWaylandTextInputV3ClientState); + + enabledSurfaces.insert(resource, focus); + emit q->surfaceEnabled(focus); + + inputPanelVisible = true; + qApp->inputMethod()->show(); +} + +void QWaylandTextInputV3Private::zwp_text_input_v3_disable(QtWaylandServer::zwp_text_input_v3::Resource *resource) +{ + qCDebug(qLcWaylandCompositorTextInput) << Q_FUNC_INFO; + + Q_Q(QWaylandTextInputV3); + + QWaylandSurface *s = enabledSurfaces.take(resource); + emit q->surfaceDisabled(s); + + // When reselecting a word by setFocus + if (qgetenv("QT_IM_MODULE") != QByteArrayLiteral("ibus") + || qApp->inputMethod()->locale().language() == QLocale::Chinese) { + qApp->inputMethod()->commit(); + } + qApp->inputMethod()->reset(); + pendingState.reset(new QWaylandTextInputV3ClientState); +} + +void QWaylandTextInputV3Private::zwp_text_input_v3_set_cursor_rectangle(Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height) +{ + qCDebug(qLcWaylandCompositorTextInput) << Q_FUNC_INFO << x << y << width << height; + + if (resource != focusResource) + return; + + pendingState->cursorRectangle = QRect(x, y, width, height); + + pendingState->changedState |= Qt::ImCursorRectangle; +} + +void QWaylandTextInputV3Private::zwp_text_input_v3_commit(Resource *resource) +{ + qCDebug(qLcWaylandCompositorTextInput) << Q_FUNC_INFO; + + serials[resource] = serials[resource] < UINT_MAX ? serials[resource] + 1U : 0U; + + // Just increase serials and ignore empty commits + if (!pendingState->changedState) { + qCDebug(qLcWaylandCompositorTextInput) << Q_FUNC_INFO << "pendingState is not changed"; + return; + } + + // Selection starts. + // But since qtvirtualkeyboard with hunspell does not reset its preedit string, + // compositor forces to reset inputMethod. + if ((currentState->cursorPosition == currentState->anchorPosition) + && (pendingState->cursorPosition != pendingState->anchorPosition)) + qApp->inputMethod()->reset(); + + // Enable reselection + // This is a workaround to make qtvirtualkeyboad's state empty by clearing State::InputMethodClick. + if (currentState->surroundingText == pendingState->surroundingText && currentState->cursorPosition != pendingState->cursorPosition) + qApp->inputMethod()->invokeAction(QInputMethod::Click, pendingState->cursorPosition); + + Qt::InputMethodQueries queries = currentState->mergeChanged(*pendingState.data()); + pendingState.reset(new QWaylandTextInputV3ClientState); + + if (queries) { + qCDebug(qLcWaylandCompositorTextInput) << "QInputMethod::update() after commit with" << queries; + + qApp->inputMethod()->update(queries); + } +} + +void QWaylandTextInputV3Private::zwp_text_input_v3_set_content_type(Resource *resource, uint32_t hint, uint32_t purpose) +{ + qCDebug(qLcWaylandCompositorTextInput) << Q_FUNC_INFO << hint << purpose; + + if (resource != focusResource) + return; + + pendingState->hints = Qt::ImhNone; + + if ((hint & content_hint_completion) == 0) + pendingState->hints |= Qt::ImhNoPredictiveText; + if ((hint & content_hint_auto_capitalization) == 0) + pendingState->hints |= Qt::ImhNoAutoUppercase; + if ((hint & content_hint_lowercase) != 0) + pendingState->hints |= Qt::ImhPreferLowercase; + if ((hint & content_hint_uppercase) != 0) + pendingState->hints |= Qt::ImhPreferUppercase; + if ((hint & content_hint_hidden_text) != 0) + pendingState->hints |= Qt::ImhHiddenText; + if ((hint & content_hint_sensitive_data) != 0) + pendingState->hints |= Qt::ImhSensitiveData; + if ((hint & content_hint_latin) != 0) + pendingState->hints |= Qt::ImhLatinOnly; + if ((hint & content_hint_multiline) != 0) + pendingState->hints |= Qt::ImhMultiLine; + + switch (purpose) { + case content_purpose_normal: + break; + case content_purpose_alpha: + pendingState->hints |= Qt::ImhUppercaseOnly | Qt::ImhLowercaseOnly; + break; + case content_purpose_digits: + pendingState->hints |= Qt::ImhDigitsOnly; + break; + case content_purpose_number: + pendingState->hints |= Qt::ImhFormattedNumbersOnly; + break; + case content_purpose_phone: + pendingState->hints |= Qt::ImhDialableCharactersOnly; + break; + case content_purpose_url: + pendingState->hints |= Qt::ImhUrlCharactersOnly; + break; + case content_purpose_email: + pendingState->hints |= Qt::ImhEmailCharactersOnly; + break; + case content_purpose_name: + case content_purpose_password: + break; + case content_purpose_date: + pendingState->hints |= Qt::ImhDate; + break; + case content_purpose_time: + pendingState->hints |= Qt::ImhTime; + break; + case content_purpose_datetime: + pendingState->hints |= Qt::ImhDate | Qt::ImhTime; + break; + case content_purpose_terminal: + default: + break; + } + + qCDebug(qLcWaylandCompositorTextInput) << Q_FUNC_INFO << pendingState->hints; + + pendingState->changedState |= Qt::ImHints; +} + +void QWaylandTextInputV3Private::zwp_text_input_v3_set_surrounding_text(Resource *resource, const QString &text, int32_t cursor, int32_t anchor) +{ + qCDebug(qLcWaylandCompositorTextInput) << Q_FUNC_INFO << text << cursor << anchor; + + if (resource != focusResource) + return; + + pendingState->surroundingText = text; + pendingState->cursorPosition = QWaylandInputMethodEventBuilder::indexFromWayland(text, cursor); + pendingState->anchorPosition = QWaylandInputMethodEventBuilder::indexFromWayland(text, anchor); + + pendingState->changedState |= Qt::ImSurroundingText | Qt::ImCursorPosition | Qt::ImAnchorPosition; +} + +void QWaylandTextInputV3Private::zwp_text_input_v3_set_text_change_cause(Resource *resource, uint32_t cause) +{ + qCDebug(qLcWaylandCompositorTextInput) << Q_FUNC_INFO; + + Q_UNUSED(resource); + Q_UNUSED(cause); +} + +QWaylandTextInputV3::QWaylandTextInputV3(QWaylandObject *container, QWaylandCompositor *compositor) + : QWaylandCompositorExtensionTemplate(container, *new QWaylandTextInputV3Private(compositor)) +{ + connect(&d_func()->focusDestroyListener, &QWaylandDestroyListener::fired, + this, &QWaylandTextInputV3::focusSurfaceDestroyed); +} + +QWaylandTextInputV3::~QWaylandTextInputV3() +{ +} + +void QWaylandTextInputV3::sendInputMethodEvent(QInputMethodEvent *event) +{ + Q_D(QWaylandTextInputV3); + + d->sendInputMethodEvent(event); +} + +void QWaylandTextInputV3::sendKeyEvent(QKeyEvent *event) +{ + Q_D(QWaylandTextInputV3); + + d->sendKeyEvent(event); +} + +QVariant QWaylandTextInputV3::inputMethodQuery(Qt::InputMethodQuery property, QVariant argument) const +{ + const Q_D(QWaylandTextInputV3); + + return d->inputMethodQuery(property, argument); +} + +QWaylandSurface *QWaylandTextInputV3::focus() const +{ + const Q_D(QWaylandTextInputV3); + + return d->focus; +} + +void QWaylandTextInputV3::setFocus(QWaylandSurface *surface) +{ + Q_D(QWaylandTextInputV3); + + d->setFocus(surface); +} + +void QWaylandTextInputV3::focusSurfaceDestroyed(void *) +{ + qCDebug(qLcWaylandCompositorTextInput) << Q_FUNC_INFO; + + Q_D(QWaylandTextInputV3); + + d->focusDestroyListener.reset(); + + d->focus = nullptr; + d->focusResource = nullptr; +} + +bool QWaylandTextInputV3::isSurfaceEnabled(QWaylandSurface *surface) const +{ + qCDebug(qLcWaylandCompositorTextInput) << Q_FUNC_INFO; + + const Q_D(QWaylandTextInputV3); + + return d->enabledSurfaces.values().contains(surface); +} + +void QWaylandTextInputV3::add(::wl_client *client, uint32_t id, int version) +{ + qCDebug(qLcWaylandCompositorTextInput) << Q_FUNC_INFO << client << id << version; + + Q_D(QWaylandTextInputV3); + + d->add(client, id, version); +} + +const wl_interface *QWaylandTextInputV3::interface() +{ + return QWaylandTextInputV3Private::interface(); +} + +QByteArray QWaylandTextInputV3::interfaceName() +{ + return QWaylandTextInputV3Private::interfaceName(); +} + +QT_END_NAMESPACE diff --git a/src/compositor/extensions/qwaylandtextinputv3.h b/src/compositor/extensions/qwaylandtextinputv3.h new file mode 100644 index 000000000..869238631 --- /dev/null +++ b/src/compositor/extensions/qwaylandtextinputv3.h @@ -0,0 +1,52 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#ifndef QWAYLANDTEXTINPUTV3_H +#define QWAYLANDTEXTINPUTV3_H + +#include <QtWaylandCompositor/QWaylandCompositorExtension> + +struct wl_client; + +QT_BEGIN_NAMESPACE + +class QWaylandTextInputV3Private; + +class QInputMethodEvent; +class QKeyEvent; +class QWaylandSurface; + +class QWaylandTextInputV3 : public QWaylandCompositorExtensionTemplate<QWaylandTextInputV3> +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QWaylandTextInputV3) +public: + explicit QWaylandTextInputV3(QWaylandObject *container, QWaylandCompositor *compositor); + ~QWaylandTextInputV3() override; + + void sendInputMethodEvent(QInputMethodEvent *event); + void sendKeyEvent(QKeyEvent *event); + + QVariant inputMethodQuery(Qt::InputMethodQuery property, QVariant argument) const; + + QWaylandSurface *focus() const; + void setFocus(QWaylandSurface *surface); + + bool isSurfaceEnabled(QWaylandSurface *surface) const; + + void add(::wl_client *client, uint32_t id, int version); + static const struct wl_interface *interface(); + static QByteArray interfaceName(); + +Q_SIGNALS: + void updateInputMethod(Qt::InputMethodQueries queries); + void surfaceEnabled(QWaylandSurface *surface); + void surfaceDisabled(QWaylandSurface *surface); + +private: + void focusSurfaceDestroyed(void *); +}; + +QT_END_NAMESPACE + +#endif // QWAYLANDTEXTINPUTV3_H diff --git a/src/compositor/extensions/qwaylandtextinputv3_p.h b/src/compositor/extensions/qwaylandtextinputv3_p.h new file mode 100644 index 000000000..267d14125 --- /dev/null +++ b/src/compositor/extensions/qwaylandtextinputv3_p.h @@ -0,0 +1,95 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#ifndef QWAYLANDTEXTINPUTV3_P_H +#define QWAYLANDTEXTINPUTV3_P_H + +#include <QtWaylandCompositor/private/qwaylandcompositorextension_p.h> +#include <QtWaylandCompositor/private/qwayland-server-text-input-unstable-v3.h> +#include <QtWaylandCompositor/QWaylandDestroyListener> + +#include <QtCore/QObject> +#include <QtCore/QRect> +#include <QtGui/QInputMethod> +#include <QtWaylandCompositor/QWaylandSurface> + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +QT_BEGIN_NAMESPACE + +class QInputMethodEvent; +class QKeyEvent; +class QWaylandCompositor; +class QWaylandView; + +class QWaylandTextInputV3ClientState { +public: + QWaylandTextInputV3ClientState(); + + Qt::InputMethodQueries updatedQueries(const QWaylandTextInputV3ClientState &other) const; + Qt::InputMethodQueries mergeChanged(const QWaylandTextInputV3ClientState &other); + + Qt::InputMethodHints hints = Qt::ImhNone; + QRect cursorRectangle; + QString surroundingText; + int cursorPosition = 0; + int anchorPosition = 0; + + Qt::InputMethodQueries changedState; +}; + +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandTextInputV3Private : public QWaylandCompositorExtensionPrivate, public QtWaylandServer::zwp_text_input_v3 +{ + Q_DECLARE_PUBLIC(QWaylandTextInputV3) +public: + explicit QWaylandTextInputV3Private(QWaylandCompositor *compositor); + + void sendInputMethodEvent(QInputMethodEvent *event); + void sendKeyEvent(QKeyEvent *event); + + QVariant inputMethodQuery(Qt::InputMethodQuery property, QVariant argument) const; + + void setFocus(QWaylandSurface *surface); + + QWaylandCompositor *compositor = nullptr; + + QWaylandSurface *focus = nullptr; + Resource *focusResource = nullptr; + QWaylandDestroyListener focusDestroyListener; + + bool inputPanelVisible = false; + + QString currentPreeditString; + + QScopedPointer<QWaylandTextInputV3ClientState> currentState; + QScopedPointer<QWaylandTextInputV3ClientState> pendingState; + + QHash<Resource *, uint32_t> serials; + QHash<Resource *, QWaylandSurface *> enabledSurfaces; + +protected: + void zwp_text_input_v3_bind_resource(Resource *resource) override; + void zwp_text_input_v3_destroy_resource(Resource *resource) override; + + void zwp_text_input_v3_destroy(Resource *resource) override; + void zwp_text_input_v3_enable(Resource *resource) override; + void zwp_text_input_v3_disable(Resource *resource) override; + void zwp_text_input_v3_set_surrounding_text(Resource *resource, const QString &text, int32_t cursor, int32_t anchor) override; + void zwp_text_input_v3_set_text_change_cause(Resource *resource, uint32_t cause) override; + void zwp_text_input_v3_set_content_type(Resource *resource, uint32_t hint, uint32_t purpose) override; + void zwp_text_input_v3_set_cursor_rectangle(Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height) override; + void zwp_text_input_v3_commit(Resource *resource) override; +}; + +QT_END_NAMESPACE + +#endif // QWAYLANDTEXTINPUTV3_P_H diff --git a/src/compositor/extensions/qwaylandviewporter.cpp b/src/compositor/extensions/qwaylandviewporter.cpp index 3856c135d..c44bcca15 100644 --- a/src/compositor/extensions/qwaylandviewporter.cpp +++ b/src/compositor/extensions/qwaylandviewporter.cpp @@ -1,38 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** 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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "qwaylandviewporter_p.h" @@ -156,14 +123,16 @@ void QWaylandViewporterPrivate::Viewport::checkCommittedState() return; } - QRectF max = QRectF(QPointF(), m_surface->bufferSize() / m_surface->bufferScale()); - // We can't use QRectF.contains, because that would return false for values on the border - if (max.united(source) != max) { - wl_resource_post_error(resource()->handle, error_out_of_buffer, - "source %f,%f, %fx%f extends outside attached buffer %fx%f", - source.x(), source.y(), source.width(), source.height(), - max.width(), max.height()); - return; + if (m_surface->bufferSize().isValid()) { + QRectF max = QRectF(QPointF(), m_surface->bufferSize() / m_surface->bufferScale()); + // We can't use QRectF.contains, because that would return false for values on the border + if (max.united(source) != max) { + wl_resource_post_error(resource()->handle, error_out_of_buffer, + "source %f,%f, %fx%f extends outside attached buffer %fx%f", + source.x(), source.y(), source.width(), source.height(), + max.width(), max.height()); + return; + } } } @@ -241,3 +210,5 @@ void QWaylandViewporterPrivate::Viewport::wp_viewport_set_destination(QtWaylandS } QT_END_NAMESPACE + +#include "moc_qwaylandviewporter.cpp" diff --git a/src/compositor/extensions/qwaylandviewporter.h b/src/compositor/extensions/qwaylandviewporter.h index 811c74145..0c87a936d 100644 --- a/src/compositor/extensions/qwaylandviewporter.h +++ b/src/compositor/extensions/qwaylandviewporter.h @@ -1,38 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** 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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDVIEWPORTER_H #define QWAYLANDVIEWPORTER_H @@ -43,7 +10,7 @@ QT_BEGIN_NAMESPACE class QWaylandViewporterPrivate; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandViewporter +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandViewporter : public QWaylandCompositorExtensionTemplate<QWaylandViewporter> { Q_OBJECT diff --git a/src/compositor/extensions/qwaylandviewporter_p.h b/src/compositor/extensions/qwaylandviewporter_p.h index d22da6990..84e0c90fc 100644 --- a/src/compositor/extensions/qwaylandviewporter_p.h +++ b/src/compositor/extensions/qwaylandviewporter_p.h @@ -1,38 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** 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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDVIEWPORTER_P_H #define QWAYLANDVIEWPORTER_P_H @@ -42,6 +9,8 @@ #include <QtWaylandCompositor/private/qwaylandcompositorextension_p.h> #include <QtWaylandCompositor/private/qwayland-server-viewporter.h> +#include <QtCore/qpointer.h> + // // W A R N I N G // ------------- @@ -57,7 +26,7 @@ QT_BEGIN_NAMESPACE class QWaylandSurface; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandViewporterPrivate +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandViewporterPrivate : public QWaylandCompositorExtensionPrivate , public QtWaylandServer::wp_viewporter { @@ -65,7 +34,7 @@ class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandViewporterPrivate public: explicit QWaylandViewporterPrivate() = default; - class Q_WAYLAND_COMPOSITOR_EXPORT Viewport + class Q_WAYLANDCOMPOSITOR_EXPORT Viewport : public QtWaylandServer::wp_viewport { public: diff --git a/src/compositor/extensions/qwaylandwlscaler.cpp b/src/compositor/extensions/qwaylandwlscaler.cpp deleted file mode 100644 index 5c8e4b270..000000000 --- a/src/compositor/extensions/qwaylandwlscaler.cpp +++ /dev/null @@ -1,274 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** 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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qwaylandwlscaler_p.h" - -#include <QtWaylandCompositor/QWaylandSurface> -#include <QtWaylandCompositor/QWaylandCompositor> - -#include <QtWaylandCompositor/private/qwaylandsurface_p.h> - -QT_BEGIN_NAMESPACE - -#if QT_DEPRECATED_SINCE(5, 13) -/*! - \qmltype WlScaler - \inqmlmodule QtWayland.Compositor - \since 5.13 - \brief Provides an extension for surface resizing and cropping. - - The WlScaler extension provides a way for clients to resize and crop surface contents. - - WlScaler corresponds to the Wayland interface, \c wl_scaler. - - \c wl_scaler is a non-standard and deprecated protocol that has largely been replaced by - \c wp_viewporter. I.e. This extensions is only useful for supporting legacy clients. - \c wp_viewporter support is enabled automatically for all Qml compositors. - - To provide the functionality of the extension in a compositor, create an instance of the - WlScaler component and add it to the list of extensions supported by the compositor: - - \qml \QtMinorVersion - import QtWayland.Compositor 1.\1 - - WaylandCompositor { - // ... - WlScaler {} - } - \endqml - - \deprecated -*/ - -/*! - \class QWaylandWlScaler - \inmodule QtWaylandCompositor - \since 5.13 - \brief Provides an extension for surface resizing and croping. - - The QWaylandWlScaler extension provides a way for clients to resize and crop surface - contents. - - QWaylandWlScaler corresponds to the Wayland interface, \c wl_scaler. - - \c wl_scaler is a non-standard and deprecated protocol that has largely been replaced by - \c wp_viewporter. I.e. This extensions is only useful for supporting legacy clients. - - \sa QWaylandViewporter - - \deprecated -*/ - -/*! - Constructs a QWaylandWlScaler object. -*/ -QWaylandWlScaler::QWaylandWlScaler() - : QWaylandCompositorExtensionTemplate<QWaylandWlScaler>(*new QWaylandWlScalerPrivate) -{ -} - -/*! - * Constructs a QWaylandWlScaler object for the provided \a compositor. - */ -QWaylandWlScaler::QWaylandWlScaler(QWaylandCompositor *compositor) - : QWaylandCompositorExtensionTemplate<QWaylandWlScaler>(compositor, *new QWaylandWlScalerPrivate()) -{ -} - -/*! - Initializes the extension. -*/ -void QWaylandWlScaler::initialize() -{ - Q_D(QWaylandWlScaler); - - QWaylandCompositorExtensionTemplate::initialize(); - auto *compositor = static_cast<QWaylandCompositor *>(extensionContainer()); - if (!compositor) { - qWarning() << "Failed to find QWaylandCompositor when initializing QWaylandWlScaler"; - return; - } - d->init(compositor->display(), 2); -} - -/*! - Returns the Wayland interface for the QWaylandWlScaler. -*/ -const wl_interface *QWaylandWlScaler::interface() -{ - return QWaylandWlScalerPrivate::interface(); -} - -void QWaylandWlScalerPrivate::scaler_destroy(Resource *resource) -{ - // Viewport objects are allowed ot outlive the scaler - wl_resource_destroy(resource->handle); -} - -void QWaylandWlScalerPrivate::scaler_get_viewport(Resource *resource, uint id, wl_resource *surfaceResource) -{ - auto *surface = QWaylandSurface::fromResource(surfaceResource); - if (!surface) { - qWarning() << "Couldn't find surface for viewporter"; - return; - } - - // Note: This will only protect us not creating scalers for surfaces with wp_viewport objects - auto *surfacePrivate = QWaylandSurfacePrivate::get(surface); - if (surfacePrivate->viewport) { - wl_resource_post_error(resource->handle, WL_SCALER_ERROR_VIEWPORT_EXISTS, - "viewport already exists for surface"); - return; - } - - // We can't set viewport here, since it's of the new type for wp_viewporter -// surfacePrivate->viewport = new Viewport(surface, resource->client(), id, resource->version()); - new Viewport(surface, resource->client(), id, resource->version()); -} - -QWaylandWlScalerPrivate::Viewport::Viewport(QWaylandSurface *surface, wl_client *client, int id, int version) - : QtWaylandServer::wl_viewport(client, id, version) - , m_surface(surface) -{ - Q_ASSERT(surface); -} - -//TODO: This isn't currently called -// This function has to be called immediately after a surface is committed, before no -// other client events have been dispatched, or we may incorrectly error out on an -// incomplete pending state. See comment below. -void QWaylandWlScalerPrivate::Viewport::checkCommittedState() -{ - auto *surfacePrivate = QWaylandSurfacePrivate::get(m_surface); - - // We can't use the current state for destination/source when checking, - // as that has fallbacks to the buffer size so we can't distinguish - // between the set/unset case. We use the pending state because no other - // requests has modified it yet. - QSize destination = surfacePrivate->pending.destinationSize; - QRectF source = surfacePrivate->pending.sourceGeometry; - - if (!destination.isValid() && source.size() != source.size().toSize()) { - //TODO: Do rounding to nearest integer - } - - QRectF max = QRectF(QPointF(), m_surface->bufferSize() / m_surface->bufferScale()); - // We can't use QRectF.contains, because that would return false for values on the border - if (max.united(source) != max) { - //TODO: surface contents are no undefined, surface size is still valid though - qCDebug(qLcWaylandCompositor) << "Source set outside buffer bounds (client error)"; - } -} - - -void QWaylandWlScalerPrivate::Viewport::viewport_destroy_resource(Resource *resource) -{ - Q_UNUSED(resource); - delete this; -} - -void QWaylandWlScalerPrivate::Viewport::viewport_destroy(Resource *resource) -{ - if (m_surface) { - auto *surfacePrivate = QWaylandSurfacePrivate::get(m_surface); - surfacePrivate->pending.destinationSize = QSize(); - surfacePrivate->pending.sourceGeometry = QRectF(); - } - wl_resource_destroy(resource->handle); -} - -void QWaylandWlScalerPrivate::Viewport::viewport_set(QtWaylandServer::wl_viewport::Resource *resource, wl_fixed_t src_x, wl_fixed_t src_y, wl_fixed_t src_width, wl_fixed_t src_height, int32_t dst_width, int32_t dst_height) -{ - viewport_set_source(resource, src_x, src_y, src_width, src_height); - viewport_set_destination(resource, dst_width, dst_height); -} - -void QWaylandWlScalerPrivate::Viewport::viewport_set_source(QtWaylandServer::wl_viewport::Resource *resource, wl_fixed_t x, wl_fixed_t y, wl_fixed_t width, wl_fixed_t height) -{ - Q_UNUSED(resource); - - if (!m_surface) { - qCDebug(qLcWaylandCompositor) << "set_source requested for destroyed surface"; - return; - } - - QPointF position(wl_fixed_to_double(x), wl_fixed_to_double(y)); - QSizeF size(wl_fixed_to_double(width), wl_fixed_to_double(height)); - QRectF sourceGeometry(position, size); - - if (sourceGeometry == QRectF(-1, -1, -1, -1)) { - auto *surfacePrivate = QWaylandSurfacePrivate::get(m_surface); - surfacePrivate->pending.sourceGeometry = QRectF(); - return; - } - - if (position.x() < 0 || position.y() < 0) { - wl_resource_post_error(resource->handle, error_bad_value, - "negative position in set_source"); - return; - } - - if (!size.isValid()) { - wl_resource_post_error(resource->handle, error_bad_value, - "negative size in set_source"); - return; - } - - auto *surfacePrivate = QWaylandSurfacePrivate::get(m_surface); - surfacePrivate->pending.sourceGeometry = sourceGeometry; -} - -void QWaylandWlScalerPrivate::Viewport::viewport_set_destination(QtWaylandServer::wl_viewport::Resource *resource, int32_t width, int32_t height) -{ - Q_UNUSED(resource); - - if (!m_surface) { - qCDebug(qLcWaylandCompositor) << "set_destination requested for destroyed surface"; - return; - } - - QSize destinationSize(width, height); - if (!destinationSize.isValid() && destinationSize != QSize(-1, -1)) { - wl_resource_post_error(resource->handle, error_bad_value, - "negative size in set_destination"); - return; - } - auto *surfacePrivate = QWaylandSurfacePrivate::get(m_surface); - surfacePrivate->pending.destinationSize = destinationSize; -} -#endif // QT_DEPRECATED_SINCE - -QT_END_NAMESPACE diff --git a/src/compositor/extensions/qwaylandwlscaler.h b/src/compositor/extensions/qwaylandwlscaler.h deleted file mode 100644 index 4ecdf3968..000000000 --- a/src/compositor/extensions/qwaylandwlscaler.h +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** 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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QWAYLANDWLSCALER_H -#define QWAYLANDWLSCALER_H - -#include <QtWaylandCompositor/QWaylandCompositorExtension> - -QT_BEGIN_NAMESPACE - -#if QT_DEPRECATED_SINCE(5, 13) -class QWaylandWlScalerPrivate; - -// TODO: We should have used the QT_DEPRECATED macro here, but for some reason -// header file generation stops working when that's added. -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandWlScaler - : public QWaylandCompositorExtensionTemplate<QWaylandWlScaler> -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QWaylandWlScaler) - -public: - explicit QWaylandWlScaler(); - explicit QWaylandWlScaler(QWaylandCompositor *compositor); - - void initialize() override; - - static const struct wl_interface *interface(); -}; -#endif - -QT_END_NAMESPACE - -#endif // QWAYLANDWLSCALER_H diff --git a/src/compositor/extensions/qwaylandwlscaler_p.h b/src/compositor/extensions/qwaylandwlscaler_p.h deleted file mode 100644 index 10a66f884..000000000 --- a/src/compositor/extensions/qwaylandwlscaler_p.h +++ /dev/null @@ -1,95 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** 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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QWAYLANDWLSCALER_P_H -#define QWAYLANDWLSCALER_P_H - -#include "qwaylandwlscaler.h" - -#include <QtWaylandCompositor/private/qwaylandcompositorextension_p.h> -#include <QtWaylandCompositor/private/qwayland-server-scaler.h> - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -QT_BEGIN_NAMESPACE - -#if QT_DEPRECATED_SINCE(5, 13) -class QWaylandSurface; - -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandWlScalerPrivate - : public QWaylandCompositorExtensionPrivate - , public QtWaylandServer::wl_scaler -{ - Q_DECLARE_PUBLIC(QWaylandWlScaler) -public: - explicit QWaylandWlScalerPrivate() = default; - -protected: - void scaler_destroy(Resource *resource) override; - void scaler_get_viewport(Resource *resource, uint32_t id, wl_resource *surface) override; - -private: - class Viewport : public QtWaylandServer::wl_viewport - { - public: - explicit Viewport(QWaylandSurface *surface, wl_client *client, int id, int version); - void checkCommittedState(); - - protected: - void viewport_destroy_resource(Resource *resource) override; - void viewport_destroy(Resource *resource) override; - void viewport_set(Resource *resource, wl_fixed_t src_x, wl_fixed_t src_y, wl_fixed_t src_width, wl_fixed_t src_height, int32_t dst_width, int32_t dst_height) override; - void viewport_set_source(Resource *resource, wl_fixed_t x, wl_fixed_t y, wl_fixed_t width, wl_fixed_t height) override; - void viewport_set_destination(Resource *resource, int32_t width, int32_t height) override; - - private: - QPointer<QWaylandSurface> m_surface = nullptr; - }; -}; -#endif - -QT_END_NAMESPACE - -#endif // QWAYLANDWLSCALER_P_H diff --git a/src/compositor/extensions/qwaylandwlshell.cpp b/src/compositor/extensions/qwaylandwlshell.cpp index 6eb1c06e4..c0e6119e1 100644 --- a/src/compositor/extensions/qwaylandwlshell.cpp +++ b/src/compositor/extensions/qwaylandwlshell.cpp @@ -1,32 +1,6 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Copyright (C) 2017 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// Copyright (C) 2017 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "qwaylandwlshell.h" #include "qwaylandwlshell_p.h" @@ -244,7 +218,8 @@ void QWaylandWlShellSurfacePrivate::shell_surface_set_class(Resource *resource, /*! * \qmltype WlShell - * \inqmlmodule QtWayland.Compositor + * \instantiates QWaylandWlShell + * \inqmlmodule QtWayland.Compositor.WlShell * \since 5.8 * \brief Provides an extension for desktop-style user interfaces. * @@ -258,8 +233,8 @@ void QWaylandWlShellSurfacePrivate::shell_surface_set_class(Resource *resource, * an instance of the WlShell component and add it to the list of extensions * supported by the compositor: * - * \qml \QtMinorVersion - * import QtWayland.Compositor 1.\1 + * \qml + * import QtWayland.Compositor.WlShell * * WaylandCompositor { * WlShell { @@ -370,7 +345,7 @@ const struct wl_interface *QWaylandWlShell::interface() } /*! - * \qmlsignal void QtWaylandCompositor::WlShell::wlShellSurfaceRequested(WaylandSurface surface, WaylandResource resource) + * \qmlsignal void WlShell::wlShellSurfaceRequested(WaylandSurface surface, WaylandResource resource) * * This signal is emitted when the client has requested a \c wl_shell_surface to be associated with * \a surface. The handler for this signal may create a shell surface for \a resource and initialize @@ -388,7 +363,7 @@ const struct wl_interface *QWaylandWlShell::interface() */ /*! - * \qmlsignal void QtWaylandCompositor::WlShell::wlShellSurfaceCreated(WlShellSurface shellSurface) + * \qmlsignal void WlShell::wlShellSurfaceCreated(WlShellSurface shellSurface) * * This signal is emitted when the client has created a \c wl_shell_surface. * A common use case is to let the handler of this signal instantiate a ShellSurfaceItem or @@ -413,7 +388,8 @@ QByteArray QWaylandWlShell::interfaceName() /*! * \qmltype WlShellSurface - * \inqmlmodule QtWayland.Compositor + * \instantiates QWaylandWlShellSurface + * \inqmlmodule QtWayland.Compositor.WlShell * \since 5.8 * \brief Provides a \c wl_shell_surface that offers desktop-style compositor-specific features to a surface. * @@ -462,7 +438,7 @@ QWaylandWlShellSurface::~QWaylandWlShellSurface() } /*! - * \qmlmethod void QtWaylandCompositor::WlShellSurface::initialize(WlShell shell, WaylandSurface surface, WaylandResource resource) + * \qmlmethod void WlShellSurface::initialize(WlShell shell, WaylandSurface surface, WaylandResource resource) * * Initializes the WlShellSurface and associates it with the given \a shell, \a surface, and \a resource. */ @@ -562,7 +538,7 @@ void QWaylandWlShellSurface::sendConfigure(const QSize &size, ResizeEdge edges) } /*! - * \qmlmethod void QtWaylandCompositor::WlShellSurface::sendPopupDone() + * \qmlmethod void WlShellSurface::sendPopupDone() * * Sends a popup_done event to the client to indicate that the user has clicked * somewhere outside the client's surfaces. @@ -586,7 +562,7 @@ QWaylandQuickShellIntegration *QWaylandWlShellSurface::createIntegration(QWaylan #endif /*! - * \qmlproperty WaylandSurface QtWaylandCompositor::WlShellSurface::surface + * \qmlproperty WaylandSurface WlShellSurface::surface * * This property holds the \c wl_surface associated with this WlShellSurface. */ @@ -603,7 +579,7 @@ QWaylandSurface *QWaylandWlShellSurface::surface() const } /*! - * \qmlproperty WlShell QtWaylandCompositor::WlShellSurface::shell + * \qmlproperty WlShell WlShellSurface::shell * * This property holds the shell associated with this WlShellSurface. */ @@ -620,7 +596,7 @@ QWaylandWlShell *QWaylandWlShellSurface::shell() const } /*! - * \qmlproperty enum QtWaylandCompositor::WlShellSurface::windowType + * \qmlproperty enum WlShellSurface::windowType * * This property holds the window type of the WlShellSurface. */ @@ -632,7 +608,7 @@ Qt::WindowType QWaylandWlShellSurface::windowType() const } /*! - * \qmlproperty string QtWaylandCompositor::WlShellSurface::title + * \qmlproperty string WlShellSurface::title * * This property holds the title of the WlShellSurface. */ @@ -649,7 +625,7 @@ QString QWaylandWlShellSurface::title() const } /*! - * \qmlproperty string QtWaylandCompositor::WlShellSurface::className + * \qmlproperty string WlShellSurface::className * * This property holds the class name of the WlShellSurface. */ @@ -671,7 +647,7 @@ QWaylandSurfaceRole *QWaylandWlShellSurface::role() } /*! - * \qmlmethod void QtWaylandCompositor::WlShellSurface::ping() + * \qmlmethod void WlShellSurface::ping() * * Sends a ping event to the client. If the client replies to the event the pong * signal will be emitted. @@ -699,3 +675,5 @@ QWaylandWlShellSurface *QWaylandWlShellSurface::fromResource(wl_resource *resour } QT_END_NAMESPACE + +#include "moc_qwaylandwlshell.cpp" diff --git a/src/compositor/extensions/qwaylandwlshell.h b/src/compositor/extensions/qwaylandwlshell.h index 117d24a23..250c78447 100644 --- a/src/compositor/extensions/qwaylandwlshell.h +++ b/src/compositor/extensions/qwaylandwlshell.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDWLSHELL_H #define QWAYLANDWLSHELL_H @@ -34,7 +8,9 @@ #include <QtWaylandCompositor/QWaylandResource> #include <QtWaylandCompositor/QWaylandShell> #include <QtWaylandCompositor/QWaylandShellSurface> +#if QT_CONFIG(wayland_compositor_quick) #include <QtWaylandCompositor/qwaylandquickchildren.h> +#endif #include <QtCore/QSize> @@ -49,7 +25,7 @@ class QWaylandOutput; class QWaylandSurfaceRole; class QWaylandWlShellSurface; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandWlShell : public QWaylandShellTemplate<QWaylandWlShell> +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandWlShell : public QWaylandShellTemplate<QWaylandWlShell> { Q_OBJECT Q_DECLARE_PRIVATE(QWaylandWlShell) @@ -74,15 +50,18 @@ Q_SIGNALS: void wlShellSurfaceCreated(QWaylandWlShellSurface *shellSurface); }; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandWlShellSurface : public QWaylandShellSurfaceTemplate<QWaylandWlShellSurface> +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandWlShellSurface : public QWaylandShellSurfaceTemplate<QWaylandWlShellSurface> { Q_OBJECT Q_DECLARE_PRIVATE(QWaylandWlShellSurface) +#if QT_CONFIG(wayland_compositor_quick) Q_WAYLAND_COMPOSITOR_DECLARE_QUICK_CHILDREN(QWaylandWlShellSurface) +#endif Q_PROPERTY(QWaylandSurface *surface READ surface NOTIFY surfaceChanged) Q_PROPERTY(QWaylandWlShell *shell READ shell NOTIFY shellChanged) Q_PROPERTY(QString title READ title NOTIFY titleChanged) Q_PROPERTY(QString className READ className NOTIFY classNameChanged) + Q_MOC_INCLUDE("qwaylandsurface.h") public: enum FullScreenMethod { diff --git a/src/compositor/extensions/qwaylandwlshell_p.h b/src/compositor/extensions/qwaylandwlshell_p.h index 3782f5164..4202a8aed 100644 --- a/src/compositor/extensions/qwaylandwlshell_p.h +++ b/src/compositor/extensions/qwaylandwlshell_p.h @@ -1,38 +1,12 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDWLSHELL_P_H #define QWAYLANDWLSHELL_P_H #include <QtWaylandCompositor/qtwaylandcompositorglobal.h> #include <QtWaylandCompositor/qwaylandsurface.h> -#include <QtWaylandCompositor/private/qwaylandcompositorextension_p.h> +#include <QtWaylandCompositor/private/qwaylandshellsurface_p.h> #include <QtWaylandCompositor/private/qwaylandshell_p.h> #include <QtWaylandCompositor/QWaylandWlShellSurface> #include <QtWaylandCompositor/QWaylandSeat> @@ -44,6 +18,8 @@ #include <QtWaylandCompositor/private/qwayland-server-wayland.h> +#include <QtCore/qpointer.h> + // // W A R N I N G // ------------- @@ -57,7 +33,7 @@ QT_BEGIN_NAMESPACE -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandWlShellPrivate +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandWlShellPrivate : public QWaylandShellPrivate , public QtWaylandServer::wl_shell { @@ -75,8 +51,8 @@ protected: QList<QWaylandWlShellSurface *> m_shellSurfaces; }; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandWlShellSurfacePrivate - : public QWaylandCompositorExtensionPrivate +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandWlShellSurfacePrivate + : public QWaylandShellSurfacePrivate , public QtWaylandServer::wl_shell_surface { Q_DECLARE_PUBLIC(QWaylandWlShellSurface) diff --git a/src/compositor/extensions/qwaylandwlshellintegration.cpp b/src/compositor/extensions/qwaylandwlshellintegration.cpp index 3853d7eec..b625d164f 100644 --- a/src/compositor/extensions/qwaylandwlshellintegration.cpp +++ b/src/compositor/extensions/qwaylandwlshellintegration.cpp @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "qwaylandwlshellintegration_p.h" @@ -98,8 +72,8 @@ void WlShellIntegration::handleSetDefaultTopLevel() void WlShellIntegration::handleSetTransient(QWaylandSurface *parentSurface, const QPoint &relativeToParent, bool inactive) { - Q_UNUSED(parentSurface) - Q_UNUSED(relativeToParent) + Q_UNUSED(parentSurface); + Q_UNUSED(relativeToParent); // Take focus if the policy allows and it's not inactive if (m_shellSurface->shell()->focusPolicy() == QWaylandShell::AutomaticFocus && !inactive) @@ -296,25 +270,25 @@ bool WlShellIntegration::filterMouseMoveEvent(QMouseEvent *event) if (grabberState == GrabberState::Resize) { Q_ASSERT(resizeState.seat == m_item->compositor()->seatFor(event)); if (!resizeState.initialized) { - resizeState.initialMousePos = event->windowPos(); + resizeState.initialMousePos = event->scenePosition(); resizeState.initialized = true; return true; } float scaleFactor = m_item->view()->output()->scaleFactor(); - QPointF delta = (event->windowPos() - resizeState.initialMousePos) / scaleFactor * devicePixelRatio(); + QPointF delta = (event->scenePosition() - resizeState.initialMousePos) / scaleFactor * devicePixelRatio(); QSize newSize = m_shellSurface->sizeForResize(resizeState.initialSize, delta, resizeState.resizeEdges); m_shellSurface->sendConfigure(newSize, resizeState.resizeEdges); } else if (grabberState == GrabberState::Move) { Q_ASSERT(moveState.seat == m_item->compositor()->seatFor(event)); QQuickItem *moveItem = m_item->moveItem(); if (!moveState.initialized) { - moveState.initialOffset = moveItem->mapFromItem(nullptr, event->windowPos()); + moveState.initialOffset = moveItem->mapFromItem(nullptr, event->scenePosition()); moveState.initialized = true; return true; } if (!moveItem->parentItem()) return true; - QPointF parentPos = moveItem->parentItem()->mapFromItem(nullptr, event->windowPos()); + QPointF parentPos = moveItem->parentItem()->mapFromItem(nullptr, event->scenePosition()); moveItem->setPosition(parentPos - moveState.initialOffset); } return false; @@ -333,3 +307,5 @@ bool WlShellIntegration::filterMouseReleaseEvent(QMouseEvent *event) } QT_END_NAMESPACE + +#include "moc_qwaylandwlshellintegration_p.cpp" diff --git a/src/compositor/extensions/qwaylandwlshellintegration_p.h b/src/compositor/extensions/qwaylandwlshellintegration_p.h index 8fd4a2b89..1818e7b8f 100644 --- a/src/compositor/extensions/qwaylandwlshellintegration_p.h +++ b/src/compositor/extensions/qwaylandwlshellintegration_p.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDWLSHELLINTEGRATION_H #define QWAYLANDWLSHELLINTEGRATION_H @@ -34,6 +8,8 @@ #include <QtWaylandCompositor/QWaylandWlShellSurface> +#include <QtCore/qpointer.h> + QT_BEGIN_NAMESPACE // diff --git a/src/compositor/extensions/qwaylandxdgdecorationv1.cpp b/src/compositor/extensions/qwaylandxdgdecorationv1.cpp index a58601cd4..c7af0bca5 100644 --- a/src/compositor/extensions/qwaylandxdgdecorationv1.cpp +++ b/src/compositor/extensions/qwaylandxdgdecorationv1.cpp @@ -1,38 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** 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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "qwaylandxdgdecorationv1_p.h" @@ -46,7 +13,8 @@ QT_BEGIN_NAMESPACE /*! \qmltype XdgDecorationManagerV1 - \inqmlmodule QtWayland.Compositor + \instantiates QWaylandXdgDecorationManagerV1 + \inqmlmodule QtWayland.Compositor.XdgShell \since 5.12 \brief Provides an extension for negotiation of server-side and client-side window decorations. @@ -59,8 +27,8 @@ QT_BEGIN_NAMESPACE To provide the functionality of the extension in a compositor, create an instance of the XdgDecorationManagerV1 component and add it to the list of extensions supported by the compositor: - \qml \QtMinorVersion - import QtWayland.Compositor 1.\1 + \qml + import QtWayland.Compositor WaylandCompositor { // Xdg decoration manager assumes xdg-shell is being used @@ -75,7 +43,7 @@ QT_BEGIN_NAMESPACE } \endqml - \sa QWaylandXdgToplevel::decorationMode + \sa QWaylandXdgToplevel::decorationMode, {Server Side Decoration Compositor} */ /*! @@ -118,7 +86,7 @@ void QWaylandXdgDecorationManagerV1::initialize() } /*! - \qmlproperty string QtWaylandCompositor::XdgDecorationManagerV1::preferredMode + \qmlproperty string XdgDecorationManagerV1::preferredMode This property holds the decoration mode the compositor prefers. @@ -258,3 +226,5 @@ void QWaylandXdgToplevelDecorationV1::handleClientPreferredModeChanged() } QT_END_NAMESPACE + +#include "moc_qwaylandxdgdecorationv1.cpp" diff --git a/src/compositor/extensions/qwaylandxdgdecorationv1.h b/src/compositor/extensions/qwaylandxdgdecorationv1.h index 4390716e8..263504cf1 100644 --- a/src/compositor/extensions/qwaylandxdgdecorationv1.h +++ b/src/compositor/extensions/qwaylandxdgdecorationv1.h @@ -1,38 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** 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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDXDGDECORATIONV1_H #define QWAYLANDXDGDECORATIONV1_H @@ -44,7 +11,7 @@ QT_BEGIN_NAMESPACE class QWaylandXdgDecorationManagerV1Private; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgDecorationManagerV1 : public QWaylandCompositorExtensionTemplate<QWaylandXdgDecorationManagerV1> +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandXdgDecorationManagerV1 : public QWaylandCompositorExtensionTemplate<QWaylandXdgDecorationManagerV1> { Q_OBJECT Q_DECLARE_PRIVATE(QWaylandXdgDecorationManagerV1) diff --git a/src/compositor/extensions/qwaylandxdgdecorationv1_p.h b/src/compositor/extensions/qwaylandxdgdecorationv1_p.h index fdd555abb..8d06f6a57 100644 --- a/src/compositor/extensions/qwaylandxdgdecorationv1_p.h +++ b/src/compositor/extensions/qwaylandxdgdecorationv1_p.h @@ -1,38 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** 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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDXDGDECORATIONV1_P_H #define QWAYLANDXDGDECORATIONV1_P_H @@ -59,7 +26,7 @@ QT_BEGIN_NAMESPACE class QWaylandXdgToplevel; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgDecorationManagerV1Private +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandXdgDecorationManagerV1Private : public QWaylandCompositorExtensionPrivate , public QtWaylandServer::zxdg_decoration_manager_v1 { @@ -75,7 +42,7 @@ private: DecorationMode m_preferredMode = DecorationMode::ClientSideDecoration; }; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgToplevelDecorationV1 +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandXdgToplevelDecorationV1 : public QtWaylandServer::zxdg_toplevel_decoration_v1 { public: diff --git a/src/compositor/extensions/qwaylandxdgdialogv1.cpp b/src/compositor/extensions/qwaylandxdgdialogv1.cpp new file mode 100644 index 000000000..102bfb1dd --- /dev/null +++ b/src/compositor/extensions/qwaylandxdgdialogv1.cpp @@ -0,0 +1,64 @@ +// Copyright (C) 2024 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#include "qwaylandcompositor.h" +#include "qwaylandxdgdialogv1_p.h" + +#include <QWaylandXdgToplevel> +#include <wayland-server.h> + +QT_BEGIN_NAMESPACE + +QWaylandXdgDialogV1Global::QWaylandXdgDialogV1Global(QWaylandCompositor *parent) + : QWaylandCompositorExtensionTemplate<QWaylandXdgDialogV1Global>(parent) +{ +} + +void QWaylandXdgDialogV1Global::initialize() +{ + QWaylandCompositorExtensionTemplate::initialize(); + QWaylandCompositor *compositor = static_cast<QWaylandCompositor *>(extensionContainer()); + if (compositor) + init(compositor->display(), 1); +} + +void QWaylandXdgDialogV1Global::xdg_wm_dialog_v1_get_xdg_dialog(Resource *resource, uint32_t id, wl_resource *toplevelResource) +{ + auto *toplevel = QWaylandXdgToplevel::fromResource(toplevelResource); + (void)new QWaylandXdgDialogV1(toplevel, resource->client(), id); +} + +QWaylandXdgDialogV1::QWaylandXdgDialogV1(QWaylandXdgToplevel *toplevel, wl_client *client, int id) + : QtWaylandServer::xdg_dialog_v1(client, id, 1), m_topLevel(toplevel) +{ +} + +void QWaylandXdgDialogV1::xdg_dialog_v1_set_modal(Resource *resource) +{ + Q_UNUSED(resource); + if (m_topLevel) + m_topLevel->setModal(true); + +} + +void QWaylandXdgDialogV1::xdg_dialog_v1_unset_modal(Resource *resource) +{ + Q_UNUSED(resource); + if (m_topLevel) + m_topLevel->setModal(false); +} + +void QWaylandXdgDialogV1::xdg_dialog_v1_destroy_resource(Resource *resource) +{ + Q_UNUSED(resource); + delete this; +} + +void QWaylandXdgDialogV1::xdg_dialog_v1_destroy(Resource *resource) +{ + if (m_topLevel) + m_topLevel->setModal(false); + wl_resource_destroy(resource->handle); +} + +QT_END_NAMESPACE diff --git a/src/compositor/extensions/qwaylandxdgdialogv1_p.h b/src/compositor/extensions/qwaylandxdgdialogv1_p.h new file mode 100644 index 000000000..b6353c72f --- /dev/null +++ b/src/compositor/extensions/qwaylandxdgdialogv1_p.h @@ -0,0 +1,57 @@ +// Copyright (C) 2024 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#ifndef QWAYLANDXDGDIALOGV1_P_H +#define QWAYLANDXDGDIALOGV1_P_H +#include "qwaylandxdgshell.h" +#include <QtWaylandCompositor/QWaylandCompositorExtensionTemplate> +#include <QtWaylandCompositor/private/qwaylandcompositorextension_p.h> +#include <QtWaylandCompositor/private/qwayland-server-xdg-dialog-v1.h> + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +QT_BEGIN_NAMESPACE + +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandXdgDialogV1Global + : public QWaylandCompositorExtensionTemplate<QWaylandXdgDialogV1Global> + , public QtWaylandServer::xdg_wm_dialog_v1 +{ + Q_OBJECT +public: + QWaylandXdgDialogV1Global(QWaylandCompositor *parent = nullptr); + + void initialize() override; + +protected: + void xdg_wm_dialog_v1_get_xdg_dialog(Resource *resource, uint32_t id, wl_resource *toplevelResource) override; +}; + +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandXdgDialogV1 + : public QtWaylandServer::xdg_dialog_v1 +{ +public: + QWaylandXdgDialogV1(QWaylandXdgToplevel *toplevel, wl_client *client, int id); + +protected: + void xdg_dialog_v1_destroy_resource(Resource *resource) override; + void xdg_dialog_v1_destroy(Resource *resource) override; + + void xdg_dialog_v1_set_modal(Resource *resource) override; + void xdg_dialog_v1_unset_modal(Resource *resource) override; + +private: + QPointer<QWaylandXdgToplevel> m_topLevel; +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/compositor/extensions/qwaylandxdgoutputv1.cpp b/src/compositor/extensions/qwaylandxdgoutputv1.cpp index 2ab26c162..035d8dd3d 100644 --- a/src/compositor/extensions/qwaylandxdgoutputv1.cpp +++ b/src/compositor/extensions/qwaylandxdgoutputv1.cpp @@ -1,38 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2019 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** 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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2019 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <QWaylandCompositor> @@ -45,9 +12,10 @@ QT_BEGIN_NAMESPACE /*! * \qmltype XdgOutputManagerV1 - * \inqmlmodule QtWayland.Compositor + * \instantiates QWaylandXdgOutputManagerV1 + * \inqmlmodule QtWayland.Compositor.XdgShell * \since 5.14 - * \brief Provides an extension for describing outputs in a desktop oriented fashion + * \brief Provides an extension for describing outputs in a desktop oriented fashion. * * The XdgOutputManagerV1 extension provides a way for a compositor to describe outputs in a way * that is more in line with the concept of an output on desktop oriented systems. @@ -63,8 +31,8 @@ QT_BEGIN_NAMESPACE * XdgOutputManagerV1 component and add it to the list of extensions supported by the compositor, * and associated each XdgOutputV1 with its WaylandOutput: * - * \qml \QtMinorVersion - * import QtWayland.Compositor 1.\1 + * \qml + * import QtWayland.Compositor * * WaylandCompositor { * XdgOutputManagerV1 { @@ -104,7 +72,7 @@ QT_BEGIN_NAMESPACE * \class QWaylandXdgOutputManagerV1 * \inmodule QtWaylandCompositor * \since 5.14 - * \brief Provides an extension for describing outputs in a desktop oriented fashion + * \brief Provides an extension for describing outputs in a desktop oriented fashion. * * The QWaylandXdgOutputManagerV1 extension provides a way for a compositor to describe outputs in a way * that is more in line with the concept of an output on desktop oriented systems. @@ -238,7 +206,7 @@ QWaylandXdgOutputV1::~QWaylandXdgOutputV1() } /*! - * \qmlproperty XdgOutputManagerV1 QtWaylandCompositor::XdgOutputV1::manager + * \qmlproperty XdgOutputManagerV1 XdgOutputV1::manager * \readonly * * This property holds the object that manages this XdgOutputV1. @@ -256,7 +224,7 @@ QWaylandXdgOutputManagerV1 *QWaylandXdgOutputV1::manager() const } /*! - * \qmlproperty WaylandOutput QtWaylandCompositor::XdgOutputV1::output + * \qmlproperty WaylandOutput XdgOutputV1::output * \readonly * * This property holds the WaylandOutput associated with this XdgOutputV1. @@ -274,7 +242,7 @@ QWaylandOutput *QWaylandXdgOutputV1::output() const } /*! - * \qmlproperty string QtWaylandCompositor::XdgOutputV1::name + * \qmlproperty string XdgOutputV1::name * * This property holds the name of this output. * @@ -325,7 +293,7 @@ void QWaylandXdgOutputV1::setName(const QString &name) } /*! - * \qmlproperty string QtWaylandCompositor::XdgOutputV1::description + * \qmlproperty string XdgOutputV1::description * * This property holds the description of this output. * @@ -366,7 +334,7 @@ void QWaylandXdgOutputV1::setDescription(const QString &description) } /*! - * \qmlproperty point QtWaylandCompositor::XdgOutputV1::logicalPosition + * \qmlproperty point XdgOutputV1::logicalPosition * * This property holds the coordinates of the output within the global compositor space. * @@ -402,7 +370,7 @@ void QWaylandXdgOutputV1::setLogicalPosition(const QPoint &position) } /*! - * \qmlproperty size QtWaylandCompositor::XdgOutputV1::logicalSize + * \qmlproperty size XdgOutputV1::logicalSize * * This property holds the size of the output in the global compositor space. * @@ -454,7 +422,7 @@ void QWaylandXdgOutputV1::setLogicalSize(const QSize &size) } /*! - * \qmlproperty rect QtWaylandCompositor::XdgOutputV1::logicalGeometry + * \qmlproperty rect XdgOutputV1::logicalGeometry * \readonly * * This property holds the position and size of the output in the global compositor space. @@ -593,3 +561,5 @@ void QWaylandXdgOutputV1Private::zxdg_output_v1_destroy(Resource *resource) } QT_END_NAMESPACE + +#include "moc_qwaylandxdgoutputv1.cpp" diff --git a/src/compositor/extensions/qwaylandxdgoutputv1.h b/src/compositor/extensions/qwaylandxdgoutputv1.h index 957ac3bed..79a6235c7 100644 --- a/src/compositor/extensions/qwaylandxdgoutputv1.h +++ b/src/compositor/extensions/qwaylandxdgoutputv1.h @@ -1,45 +1,14 @@ -/**************************************************************************** -** -** Copyright (C) 2019 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** 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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2019 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDXDGOUTPUTV1_H #define QWAYLANDXDGOUTPUTV1_H -#include <QRect> +#include <QtCore/QRect> #include <QtWaylandCompositor/QWaylandCompositorExtension> +#if QT_CONFIG(wayland_compositor_quick) #include <QtWaylandCompositor/qwaylandquickchildren.h> +#endif QT_BEGIN_NAMESPACE @@ -48,7 +17,7 @@ class QWaylandOutput; class QWaylandXdgOutputManagerV1Private; class QWaylandXdgOutputV1Private; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgOutputManagerV1 +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandXdgOutputManagerV1 : public QWaylandCompositorExtensionTemplate<QWaylandXdgOutputManagerV1> { Q_OBJECT @@ -62,11 +31,14 @@ public: static const wl_interface *interface(); }; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgOutputV1 : public QObject +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandXdgOutputV1 : public QObject { Q_OBJECT Q_DECLARE_PRIVATE(QWaylandXdgOutputV1) +#if QT_CONFIG(wayland_compositor_quick) Q_WAYLAND_COMPOSITOR_DECLARE_QUICK_CHILDREN(QWaylandXdgOutputV1) +#endif + Q_PROPERTY(QWaylandXdgOutputManagerV1 *manager READ manager NOTIFY managerChanged) Q_PROPERTY(QWaylandOutput *output READ output NOTIFY outputChanged) Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) @@ -74,6 +46,7 @@ class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgOutputV1 : public QObject Q_PROPERTY(QPoint logicalPosition READ logicalPosition WRITE setLogicalPosition NOTIFY logicalPositionChanged) Q_PROPERTY(QSize logicalSize READ logicalSize WRITE setLogicalSize NOTIFY logicalSizeChanged) Q_PROPERTY(QRect logicalGeometry READ logicalGeometry NOTIFY logicalGeometryChanged) + Q_MOC_INCLUDE("qwaylandoutput.h") public: QWaylandXdgOutputV1(); QWaylandXdgOutputV1(QWaylandOutput *output, QWaylandXdgOutputManagerV1 *manager); diff --git a/src/compositor/extensions/qwaylandxdgoutputv1_p.h b/src/compositor/extensions/qwaylandxdgoutputv1_p.h index 2e8a6fff9..9db3703fc 100644 --- a/src/compositor/extensions/qwaylandxdgoutputv1_p.h +++ b/src/compositor/extensions/qwaylandxdgoutputv1_p.h @@ -1,42 +1,11 @@ -/**************************************************************************** -** -** Copyright (C) 2019 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** 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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2019 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDXDGOUTPUTV1_P_H #define QWAYLANDXDGOUTPUTV1_P_H +#include <QtCore/QHash> + #include <QWaylandOutput> #include <QWaylandXdgOutputV1> #include <QtWaylandCompositor/private/qwaylandcompositorextension_p.h> @@ -55,7 +24,7 @@ QT_BEGIN_NAMESPACE -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgOutputManagerV1Private +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandXdgOutputManagerV1Private : public QWaylandCompositorExtensionPrivate , public QtWaylandServer::zxdg_output_manager_v1 { @@ -76,7 +45,7 @@ private: QHash<QWaylandOutput *, QWaylandXdgOutputV1 *> xdgOutputs; }; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgOutputV1Private +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandXdgOutputV1Private : public QObjectPrivate , public QtWaylandServer::zxdg_output_v1 { diff --git a/src/compositor/extensions/qwaylandxdgshell.cpp b/src/compositor/extensions/qwaylandxdgshell.cpp index 1b8a3c2e2..7185d749e 100644 --- a/src/compositor/extensions/qwaylandxdgshell.cpp +++ b/src/compositor/extensions/qwaylandxdgshell.cpp @@ -1,38 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** 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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "qwaylandxdgshell.h" #include "qwaylandxdgshell_p.h" @@ -42,6 +9,8 @@ #endif #include <QtWaylandCompositor/private/qwaylandutils_p.h> +#include "qwaylandxdgdialogv1_p.h" + #include <QtWaylandCompositor/QWaylandCompositor> #include <QtWaylandCompositor/QWaylandSeat> #include <QtWaylandCompositor/QWaylandSurface> @@ -78,7 +47,7 @@ void QWaylandXdgShellPrivate::unregisterXdgSurface(QWaylandXdgSurface *xdgSurfac QWaylandXdgSurface *QWaylandXdgShellPrivate::xdgSurfaceFromSurface(QWaylandSurface *surface) { - for (QWaylandXdgSurface *xdgSurface : qAsConst(m_xdgSurfaces)) { + for (QWaylandXdgSurface *xdgSurface : std::as_const(m_xdgSurfaces)) { if (surface == xdgSurface->surface()) return xdgSurface; } @@ -141,7 +110,8 @@ void QWaylandXdgShellPrivate::xdg_wm_base_pong(Resource *resource, uint32_t seri /*! * \qmltype XdgShell - * \inqmlmodule QtWayland.Compositor + * \instantiates QWaylandXdgShell + * \inqmlmodule QtWayland.Compositor.XdgShell * \since 5.12 * \brief Provides an extension for desktop-style user interfaces. * @@ -155,8 +125,8 @@ void QWaylandXdgShellPrivate::xdg_wm_base_pong(Resource *resource, uint32_t seri * an instance of the XdgShell component and add it to the list of extensions * supported by the compositor: * - * \qml \QtMinorVersion - * import QtWayland.Compositor 1.\1 + * \qml + * import QtWayland.Compositor.XdgShell * * WaylandCompositor { * XdgShell { @@ -213,6 +183,10 @@ void QWaylandXdgShell::initialize() connect(compositor, &QWaylandCompositor::defaultSeatChanged, this, &QWaylandXdgShell::handleSeatChanged); + + // Support the dialog extension unconditionally. + QObject *dialogExtension = new QWaylandXdgDialogV1Global(compositor); + dialogExtension->setParent(this); } /*! @@ -229,7 +203,7 @@ QByteArray QWaylandXdgShell::interfaceName() } /*! - * \qmlmethod void QtWaylandCompositor::XdgShell::ping(WaylandClient client) + * \qmlmethod void XdgShell::ping(WaylandClient client) * * Sends a ping event to \a client. If the client replies to the event the * \l pong signal will be emitted. @@ -362,6 +336,9 @@ void QWaylandXdgSurfacePrivate::xdg_surface_get_toplevel(QtWaylandServer::xdg_su m_toplevel = new QWaylandXdgToplevel(q, topLevelResource); emit q->toplevelCreated(); emit m_xdgShell->toplevelCreated(m_toplevel, q); + q->connect(m_toplevel, &QWaylandXdgToplevel::modalChanged, q, [q, this](){ + q->setModal(m_toplevel->modal()); + }); } void QWaylandXdgSurfacePrivate::xdg_surface_get_popup(QtWaylandServer::xdg_surface::Resource *resource, uint32_t id, wl_resource *parentResource, wl_resource *positionerResource) @@ -461,7 +438,8 @@ void QWaylandXdgSurfacePrivate::xdg_surface_set_window_geometry(QtWaylandServer: /*! * \qmltype XdgSurface - * \inqmlmodule QtWayland.Compositor + * \instantiates QWaylandXdgSurface + * \inqmlmodule QtWayland.Compositor.XdgShell * \since 5.12 * \brief XdgSurface provides desktop-style compositor-specific features to an xdg surface. * @@ -506,7 +484,7 @@ QWaylandXdgSurface::QWaylandXdgSurface(QWaylandXdgShell *xdgShell, QWaylandSurfa } /*! - * \qmlmethod void QtWaylandCompositor::XdgSurface::initialize(object xdgShell, object surface, object client, int id) + * \qmlmethod void XdgSurface::initialize(object xdgShell, object surface, object client, int id) * * Initializes the XdgSurface, associating it with the given \a xdgShell, \a surface, * \a client, and \a id. @@ -532,7 +510,7 @@ void QWaylandXdgSurface::initialize(QWaylandXdgShell *xdgShell, QWaylandSurface } /*! - * \qmlproperty enum QtWaylandCompositor::XdgSurface::windowType + * \qmlproperty enum XdgSurface::windowType * * This property holds the window type of the XdgSurface. */ @@ -543,7 +521,7 @@ Qt::WindowType QWaylandXdgSurface::windowType() const } /*! - * \qmlproperty rect QtWaylandCompositor::XdgSurface::windowGeometry + * \qmlproperty rect XdgSurface::windowGeometry * * This property holds the window geometry of the QWaylandXdgSurface. The window * geometry describes the window's visible bounds from the user's perspective. @@ -588,7 +566,7 @@ void QWaylandXdgSurface::handleBufferScaleChanged() } /*! - * \qmlproperty XdgShell QtWaylandCompositor::XdgSurface::shell + * \qmlproperty XdgShell XdgSurface::shell * * This property holds the shell associated with this XdgSurface. */ @@ -605,7 +583,7 @@ QWaylandXdgShell *QWaylandXdgSurface::shell() const } /*! - * \qmlproperty WaylandSurface QtWaylandCompositor::XdgSurface::surface + * \qmlproperty WaylandSurface XdgSurface::surface * * This property holds the surface associated with this XdgSurface. */ @@ -622,7 +600,7 @@ QWaylandSurface *QWaylandXdgSurface::surface() const } /*! - * \qmlproperty XdgToplevel QtWaylandCompositor::XdgSurface::toplevel + * \qmlproperty XdgToplevel XdgSurface::toplevel * * This property holds the properties and methods that are specific to the * toplevel XdgSurface. @@ -645,7 +623,7 @@ QWaylandXdgToplevel *QWaylandXdgSurface::toplevel() const } /*! - * \qmlproperty XdgPopup QtWaylandCompositor::XdgSurface::popup + * \qmlproperty XdgPopup XdgSurface::popup * * This property holds the properties and methods that are specific to the * popup XdgSurface. @@ -710,7 +688,8 @@ QWaylandQuickShellIntegration *QWaylandXdgSurface::createIntegration(QWaylandQui /*! * \qmltype XdgToplevel - * \inqmlmodule QtWayland.Compositor + * \instantiates QWaylandXdgToplevel + * \inqmlmodule QtWayland.Compositor.XdgShell * \since 5.12 * \brief XdgToplevel represents the toplevel window specific parts of an xdg surface. * @@ -740,7 +719,7 @@ QWaylandQuickShellIntegration *QWaylandXdgSurface::createIntegration(QWaylandQui QWaylandXdgToplevel::QWaylandXdgToplevel(QWaylandXdgSurface *xdgSurface, QWaylandResource &resource) : QObject(*new QWaylandXdgToplevelPrivate(xdgSurface, resource)) { - QVector<QWaylandXdgToplevel::State> states; + QList<QWaylandXdgToplevel::State> states; sendConfigure({0, 0}, states); } @@ -755,7 +734,7 @@ QWaylandXdgToplevel::~QWaylandXdgToplevel() } /*! - * \qmlproperty XdgSurface QtWaylandCompositor::XdgToplevel::xdgSurface + * \qmlproperty XdgSurface XdgToplevel::xdgSurface * * This property holds the XdgSurface for this XdgToplevel. */ @@ -772,7 +751,7 @@ QWaylandXdgSurface *QWaylandXdgToplevel::xdgSurface() const } /*! - * \qmlproperty XdgToplevel QtWaylandCompositor::XdgToplevel::parentToplevel + * \qmlproperty XdgToplevel XdgToplevel::parentToplevel * * This property holds the XdgToplevel parent of this XdgToplevel. */ @@ -790,7 +769,7 @@ QWaylandXdgToplevel *QWaylandXdgToplevel::parentToplevel() const } /*! - * \qmlproperty string QtWaylandCompositor::XdgToplevel::title + * \qmlproperty string XdgToplevel::title * * This property holds the title of the XdgToplevel. */ @@ -807,7 +786,7 @@ QString QWaylandXdgToplevel::title() const } /*! - * \qmlproperty string QtWaylandCompositor::XdgToplevel::appId + * \qmlproperty string XdgToplevel::appId * * This property holds the app id of the XdgToplevel. */ @@ -824,7 +803,7 @@ QString QWaylandXdgToplevel::appId() const } /*! - * \qmlproperty size QtWaylandCompositor::XdgToplevel::maxSize + * \qmlproperty size XdgToplevel::maxSize * * This property holds the maximum size of the XdgToplevel as requested by the client. * @@ -845,7 +824,7 @@ QSize QWaylandXdgToplevel::maxSize() const } /*! - * \qmlproperty size QtWaylandCompositor::XdgToplevel::minSize + * \qmlproperty size XdgToplevel::minSize * * This property holds the minimum size of the XdgToplevel as requested by the client. * @@ -870,14 +849,14 @@ QSize QWaylandXdgToplevel::minSize() const * * This property holds the last states the client acknowledged for this QWaylandToplevel. */ -QVector<QWaylandXdgToplevel::State> QWaylandXdgToplevel::states() const +QList<QWaylandXdgToplevel::State> QWaylandXdgToplevel::states() const { Q_D(const QWaylandXdgToplevel); return d->m_lastAckedConfigure.states; } /*! - * \qmlproperty bool QtWaylandCompositor::XdgToplevel::maximized + * \qmlproperty bool XdgToplevel::maximized * * This property holds whether the client has acknowledged that it should be maximized. */ @@ -894,7 +873,7 @@ bool QWaylandXdgToplevel::maximized() const } /*! - * \qmlproperty bool QtWaylandCompositor::XdgToplevel::fullscreen + * \qmlproperty bool XdgToplevel::fullscreen * * This property holds whether the client has acknowledged that it should be fullscreen. */ @@ -911,7 +890,7 @@ bool QWaylandXdgToplevel::fullscreen() const } /*! - * \qmlproperty bool QtWaylandCompositor::XdgToplevel::resizing + * \qmlproperty bool XdgToplevel::resizing * * This property holds whether the client has acknowledged that it is being resized. */ @@ -928,7 +907,7 @@ bool QWaylandXdgToplevel::resizing() const } /*! - * \qmlproperty bool QtWaylandCompositor::XdgToplevel::activated + * \qmlproperty bool XdgToplevel::activated * * This property holds whether toplevel is drawing itself as having input focus. */ @@ -945,6 +924,34 @@ bool QWaylandXdgToplevel::activated() const } /*! + * \qmlproperty bool XdgToplevel::modal + * + * This property holds whether toplevel blocks other windows from receiving input. + * \since 6.8 + */ + +/*! + * \property QWaylandXdgToplevel::modal + * + * This property holds whether toplevel blocks other windows from receiving input. + * \since 6.8 + */ +bool QWaylandXdgToplevel::modal() const +{ + Q_D(const QWaylandXdgToplevel); + return d->m_modal; +} + +void QWaylandXdgToplevel::setModal(bool newModal) +{ + Q_D(QWaylandXdgToplevel); + if (d->m_modal == newModal) + return; + d->m_modal = newModal; + emit modalChanged(); +} + +/*! * \enum QWaylandXdgToplevel::DecorationMode * * This enum type is used to specify the window decoration mode for toplevel windows. @@ -954,7 +961,7 @@ bool QWaylandXdgToplevel::activated() const */ /*! - * \qmlproperty enumeration QtWaylandCompositor::XdgToplevel::decorationMode + * \qmlproperty enumeration XdgToplevel::decorationMode * * This property holds the current window decoration mode for this toplevel. * @@ -979,7 +986,7 @@ QWaylandXdgToplevel::DecorationMode QWaylandXdgToplevel::decorationMode() const } /*! - * \qmlmethod size QtWaylandCompositor::XdgToplevel::sizeForResize(size size, point delta, uint edges) + * \qmlmethod size XdgToplevel::sizeForResize(size size, point delta, uint edges) * * Convenience for computing the new size given the current \a size, a \a delta, and * the \a edges active in the drag. @@ -1018,7 +1025,7 @@ QSize QWaylandXdgToplevel::sizeForResize(const QSizeF &size, const QPointF &delt * of the surface. A size of zero means the client is free to decide the size. * Known \a states are enumerated in QWaylandXdgToplevel::State. */ -uint QWaylandXdgToplevel::sendConfigure(const QSize &size, const QVector<QWaylandXdgToplevel::State> &states) +uint QWaylandXdgToplevel::sendConfigure(const QSize &size, const QList<QWaylandXdgToplevel::State> &states) { if (!size.isValid()) { qWarning() << "Can't configure xdg_toplevel with an invalid size" << size; @@ -1035,22 +1042,22 @@ uint QWaylandXdgToplevel::sendConfigure(const QSize &size, const QVector<QWaylan } /*! - * \qmlmethod int QtWaylandCompositor::XdgToplevel::sendConfigure(size size, list<int> states) + * \qmlmethod int XdgToplevel::sendConfigure(size size, list<int> states) * * Sends a configure event to the client. \a size contains the pixel size of the surface. * A size of zero means the client is free to decide the size. * Known \a states are enumerated in XdgToplevel::State. */ -uint QWaylandXdgToplevel::sendConfigure(const QSize &size, const QVector<int> &states) +uint QWaylandXdgToplevel::sendConfigure(const QSize &size, const QList<int> &states) { - QVector<State> s; + QList<State> s; for (auto state : states) s << State(state); return sendConfigure(size, s); } /*! - * \qmlmethod void QtWaylandCompositor::XdgToplevel::sendClose() + * \qmlmethod void XdgToplevel::sendClose() * * Sends a close event to the client. The client may choose to ignore the event. */ @@ -1065,7 +1072,7 @@ void QWaylandXdgToplevel::sendClose() } /*! - * \qmlmethod void QtWaylandCompositor::XdgToplevel::sendMaximized(size size) + * \qmlmethod void XdgToplevel::sendMaximized(size size) * * Convenience for sending a configure event with the maximized state set, and * fullscreen and resizing removed. The activated state is left in its current state. @@ -1093,7 +1100,7 @@ uint QWaylandXdgToplevel::sendMaximized(const QSize &size) } /*! - * \qmlmethod void QtWaylandCompositor::XdgToplevel::sendUnmaximized(size size) + * \qmlmethod void XdgToplevel::sendUnmaximized(size size) * * Convenience for sending a configure event with the maximized, fullscreen and * resizing states removed, and fullscreen and resizing removed. The activated @@ -1123,7 +1130,7 @@ uint QWaylandXdgToplevel::sendUnmaximized(const QSize &size) } /*! - * \qmlmethod void QtWaylandCompositor::XdgToplevel::sendFullscreen(size size) + * \qmlmethod void XdgToplevel::sendFullscreen(size size) * * Convenience for sending a configure event with the fullscreen state set, and * maximized and resizing removed. The activated state is left in its current state. @@ -1155,7 +1162,7 @@ uint QWaylandXdgToplevel::sendFullscreen(const QSize &size) } /*! - * \qmlmethod void QtWaylandCompositor::XdgToplevel::sendResizing(size maxSize) + * \qmlmethod void XdgToplevel::sendResizing(size maxSize) * * Convenience for sending a configure event with the resizing state set, and * maximized and fullscreen removed. The activated state is left in its current state. @@ -1201,7 +1208,7 @@ QWaylandXdgToplevel *QWaylandXdgToplevel::fromResource(wl_resource *resource) } /*! - * \qmlsignal QtWaylandCompositor::XdgShell::xdgSurfaceCreated(XdgSurface xdgSurface) + * \qmlsignal XdgShell::xdgSurfaceCreated(XdgSurface xdgSurface) * * This signal is emitted when the client has created a \c xdg_surface. * Note that \a xdgSurface is not mapped, i.e. according to the \c xdg-shell @@ -1221,7 +1228,7 @@ QWaylandXdgToplevel *QWaylandXdgToplevel::fromResource(wl_resource *resource) */ /*! - * \qmlsignal QtWaylandCompositor::XdgShell::toplevelCreated(XdgToplevel toplevel, XdgSurface xdgSurface) + * \qmlsignal XdgShell::toplevelCreated(XdgToplevel toplevel, XdgSurface xdgSurface) * * This signal is emitted when the client has created a \c xdg_toplevel. * A common use case is to let the handler of this signal instantiate a ShellSurfaceItem or @@ -1241,7 +1248,7 @@ QWaylandXdgToplevel *QWaylandXdgToplevel::fromResource(wl_resource *resource) */ /*! - * \qmlsignal QtWaylandCompositor::XdgShell::popupCreated(XdgPopup popup, XdgSurface xdgSurface) + * \qmlsignal XdgShell::popupCreated(XdgPopup popup, XdgSurface xdgSurface) * * This signal is emitted when the client has created a \c xdg_popup. * A common use case is to let the handler of this signal instantiate a ShellSurfaceItem or @@ -1261,7 +1268,7 @@ QWaylandXdgToplevel *QWaylandXdgToplevel::fromResource(wl_resource *resource) */ /*! - * \qmlsignal QtWaylandCompositor::XdgShell::pong(int serial) + * \qmlsignal XdgShell::pong(int serial) * * This signal is emitted when the client has responded to a ping event with serial, \a serial. * @@ -1312,7 +1319,7 @@ void QWaylandXdgToplevelPrivate::handleAckConfigure(uint serial) break; } - QVector<uint> changedStates; + QList<uint> changedStates; std::set_symmetric_difference( m_lastAckedConfigure.states.begin(), m_lastAckedConfigure.states.end(), config.states.begin(), config.states.end(), @@ -1547,7 +1554,8 @@ void QWaylandXdgToplevelPrivate::xdg_toplevel_set_minimized(QtWaylandServer::xdg /*! * \qmltype XdgPopup - * \inqmlmodule QtWayland.Compositor + * \instantiates QWaylandXdgPopup + * \inqmlmodule QtWayland.Compositor.XdgShell * \since 5.12 * \brief XdgPopup represents the popup specific parts of and xdg surface. * @@ -1581,7 +1589,7 @@ QWaylandXdgPopup::QWaylandXdgPopup(QWaylandXdgSurface *xdgSurface, QWaylandXdgSu } /*! - * \qmlproperty XdgSurface QtWaylandCompositor::XdgPopup::xdgSurface + * \qmlproperty XdgSurface XdgPopup::xdgSurface * * This property holds the XdgSurface associated with this XdgPopup. */ @@ -1598,7 +1606,7 @@ QWaylandXdgSurface *QWaylandXdgPopup::xdgSurface() const } /*! - * \qmlproperty XdgSurface QtWaylandCompositor::XdgPopup::parentXdgSurface + * \qmlproperty XdgSurface XdgPopup::parentXdgSurface * * This property holds the XdgSurface associated with the parent of this XdgPopup. */ @@ -1616,7 +1624,7 @@ QWaylandXdgSurface *QWaylandXdgPopup::parentXdgSurface() const } /*! - * \qmlproperty rect QtWaylandCompositor::XdgPopup::configuredGeometry + * \qmlproperty rect XdgPopup::configuredGeometry * * The window geometry the popup received in the configure event. Relative to the * upper left corner of the parent surface. @@ -1635,7 +1643,7 @@ QRect QWaylandXdgPopup::configuredGeometry() const } /*! - * \qmlproperty rect QtWaylandCompositor::XdgPopup::anchorRect + * \qmlproperty rect XdgPopup::anchorRect * * The anchor rectangle relative to the parent window geometry that the child * surface should be placed relative to. @@ -1654,7 +1662,7 @@ QRect QWaylandXdgPopup::anchorRect() const } /*! - * \qmlproperty enumeration QtWaylandCompositor::XdgPopup::anchorEdges + * \qmlproperty enumeration XdgPopup::anchorEdges * * This property holds the set of edges on the anchor rect that the child surface should be placed * relative to. If no edges are specified in a direction, the anchor point should be @@ -1681,7 +1689,7 @@ Qt::Edges QWaylandXdgPopup::anchorEdges() const } /*! - * \qmlproperty rect QtWaylandCompositor::XdgPopup::gravityEdges + * \qmlproperty rect XdgPopup::gravityEdges * * Specifies in what direction the surface should be positioned, relative to the anchor * point. @@ -1706,7 +1714,7 @@ Qt::Edges QWaylandXdgPopup::gravityEdges() const } /*! - * \qmlproperty enumeration QtWaylandCompositor::XdgPopup::slideConstraints + * \qmlproperty enumeration XdgPopup::slideConstraints * * This property holds the orientations in which the child should slide to fit within the screen. * @@ -1725,7 +1733,7 @@ Qt::Orientations QWaylandXdgPopup::slideConstraints() const Q_D(const QWaylandXdgPopup); const uint flags = d->m_positionerData.constraintAdjustments; - Qt::Orientations constraints = 0; + Qt::Orientations constraints = {}; if (flags & XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_SLIDE_X) constraints |= Qt::Horizontal; @@ -1736,7 +1744,7 @@ Qt::Orientations QWaylandXdgPopup::slideConstraints() const } /*! - * \qmlproperty enumeration QtWaylandCompositor::XdgPopup::flipConstraints + * \qmlproperty enumeration XdgPopup::flipConstraints * * This property holds the orientations in which the child should flip to fit within the screen. * @@ -1755,7 +1763,7 @@ Qt::Orientations QWaylandXdgPopup::flipConstraints() const Q_D(const QWaylandXdgPopup); const uint flags = d->m_positionerData.constraintAdjustments; - Qt::Orientations constraints = 0; + Qt::Orientations constraints = {}; if (flags & XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_FLIP_X) constraints |= Qt::Horizontal; @@ -1766,7 +1774,7 @@ Qt::Orientations QWaylandXdgPopup::flipConstraints() const } /*! - * \qmlproperty enumeration QtWaylandCompositor::XdgPopup::resizeConstraints + * \qmlproperty enumeration XdgPopup::resizeConstraints * * This property holds the orientations in which the child should resize to fit within the screen. * @@ -1785,7 +1793,7 @@ Qt::Orientations QWaylandXdgPopup::resizeConstraints() const Q_D(const QWaylandXdgPopup); const uint flags = d->m_positionerData.constraintAdjustments; - Qt::Orientations constraints = 0; + Qt::Orientations constraints = {}; if (flags & XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_RESIZE_X) constraints |= Qt::Horizontal; @@ -1796,7 +1804,7 @@ Qt::Orientations QWaylandXdgPopup::resizeConstraints() const } /*! - * \qmlproperty point QtWaylandCompositor::XdgPopup::offset + * \qmlproperty point XdgPopup::offset * * The position relative to the position of the anchor on the anchor rectangle and * the anchor on the surface. @@ -1815,7 +1823,7 @@ QPoint QWaylandXdgPopup::offset() const } /*! - * \qmlproperty size QtWaylandCompositor::XdgPopup::positionerSize + * \qmlproperty size XdgPopup::positionerSize * * The size requested for the window geometry by the positioner object. */ @@ -1832,7 +1840,7 @@ QSize QWaylandXdgPopup::positionerSize() const } /*! - * \qmlproperty point QtWaylandCompositor::XdgPopup::unconstrainedPosition + * \qmlproperty point XdgPopup::unconstrainedPosition * * The position of the surface relative to the parent window geometry if the surface * is not constrained. I.e. when not moved to fit inside the screen or similar. @@ -1851,7 +1859,7 @@ QPoint QWaylandXdgPopup::unconstrainedPosition() const } /*! - * \qmlmethod int QtWaylandCompositor::XdgPopup::sendConfigure(rect geometry) + * \qmlmethod int XdgPopup::sendConfigure(rect geometry) * * Sends a configure event to the client. \a geometry contains the window geometry * relative to the upper left corner of the window geometry of the parent surface. @@ -1873,7 +1881,7 @@ uint QWaylandXdgPopup::sendConfigure(const QRect &geometry) } /*! - * \qmlmethod void QtWaylandCompositor::XdgPopup::sendPopupDone() + * \qmlmethod void XdgPopup::sendPopupDone() * \since 5.14 * * Dismiss the popup. According to the \c xdg-shell protocol this should make the @@ -2133,3 +2141,5 @@ Qt::Edges QWaylandXdgPositioner::convertToEdges(QWaylandXdgPositioner::gravity g QT_END_NAMESPACE + +#include "moc_qwaylandxdgshell.cpp" diff --git a/src/compositor/extensions/qwaylandxdgshell.h b/src/compositor/extensions/qwaylandxdgshell.h index 2e3e28180..4c5a2fef7 100644 --- a/src/compositor/extensions/qwaylandxdgshell.h +++ b/src/compositor/extensions/qwaylandxdgshell.h @@ -1,38 +1,6 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** 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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ + +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDXDGSHELL_H #define QWAYLANDXDGSHELL_H @@ -41,7 +9,9 @@ #include <QtWaylandCompositor/QWaylandResource> #include <QtWaylandCompositor/QWaylandShell> #include <QtWaylandCompositor/QWaylandShellSurface> +#if QT_CONFIG(wayland_compositor_quick) #include <QtWaylandCompositor/qwaylandquickchildren.h> +#endif #include <QtCore/QRect> @@ -63,7 +33,7 @@ class QWaylandXdgPopup; class QWaylandXdgPopupPrivate; class QWaylandXdgPositioner; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgShell : public QWaylandShellTemplate<QWaylandXdgShell> +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandXdgShell : public QWaylandShellTemplate<QWaylandXdgShell> { Q_OBJECT Q_DECLARE_PRIVATE(QWaylandXdgShell) @@ -90,16 +60,19 @@ private Q_SLOTS: void handleFocusChanged(QWaylandSurface *newSurface, QWaylandSurface *oldSurface); }; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgSurface : public QWaylandShellSurfaceTemplate<QWaylandXdgSurface> +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandXdgSurface : public QWaylandShellSurfaceTemplate<QWaylandXdgSurface> { Q_OBJECT Q_DECLARE_PRIVATE(QWaylandXdgSurface) +#if QT_CONFIG(wayland_compositor_quick) Q_WAYLAND_COMPOSITOR_DECLARE_QUICK_CHILDREN(QWaylandXdgSurface) +#endif Q_PROPERTY(QWaylandXdgShell *shell READ shell NOTIFY shellChanged) Q_PROPERTY(QWaylandSurface *surface READ surface NOTIFY surfaceChanged) Q_PROPERTY(QWaylandXdgToplevel *toplevel READ toplevel NOTIFY toplevelCreated) Q_PROPERTY(QWaylandXdgPopup *popup READ popup NOTIFY popupCreated) Q_PROPERTY(QRect windowGeometry READ windowGeometry NOTIFY windowGeometryChanged) + Q_MOC_INCLUDE("qwaylandsurface.h") public: explicit QWaylandXdgSurface(); @@ -138,7 +111,7 @@ private Q_SLOTS: void handleBufferScaleChanged(); }; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgToplevel : public QObject +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandXdgToplevel : public QObject { Q_OBJECT Q_DECLARE_PRIVATE(QWaylandXdgToplevel) @@ -153,7 +126,9 @@ class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgToplevel : public QObject Q_PROPERTY(bool fullscreen READ fullscreen NOTIFY fullscreenChanged) Q_PROPERTY(bool resizing READ resizing NOTIFY resizingChanged) Q_PROPERTY(bool activated READ activated NOTIFY activatedChanged) + Q_PROPERTY(bool modal READ modal NOTIFY modalChanged FINAL REVISION(6,8)) Q_PROPERTY(enum DecorationMode decorationMode READ decorationMode NOTIFY decorationModeChanged) + public: enum State : uint { MaximizedState = 1, @@ -179,7 +154,7 @@ public: QString appId() const; QSize maxSize() const; QSize minSize() const; - QVector<QWaylandXdgToplevel::State> states() const; + QList<QWaylandXdgToplevel::State> states() const; bool maximized() const; bool fullscreen() const; bool resizing() const; @@ -187,8 +162,8 @@ public: DecorationMode decorationMode() const; Q_INVOKABLE QSize sizeForResize(const QSizeF &size, const QPointF &delta, Qt::Edges edges) const; - uint sendConfigure(const QSize &size, const QVector<State> &states); - Q_INVOKABLE uint sendConfigure(const QSize &size, const QVector<int> &states); + uint sendConfigure(const QSize &size, const QList<State> &states); + Q_INVOKABLE uint sendConfigure(const QSize &size, const QList<int> &states); Q_INVOKABLE void sendClose(); Q_INVOKABLE uint sendMaximized(const QSize &size); Q_INVOKABLE uint sendUnmaximized(const QSize &size = QSize(0, 0)); @@ -198,6 +173,8 @@ public: static QWaylandSurfaceRole *role(); static QWaylandXdgToplevel *fromResource(::wl_resource *resource); + bool modal() const; + Q_SIGNALS: void parentToplevelChanged(); void titleChanged(); @@ -221,16 +198,20 @@ Q_SIGNALS: void decorationModeChanged(); + Q_REVISION(6, 8) void modalChanged(); + private: QList<int> statesAsInts() const; + void setModal(bool newModal); + friend class QWaylandXdgDialogV1; }; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgPopup : public QObject +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandXdgPopup : public QObject { Q_OBJECT Q_DECLARE_PRIVATE(QWaylandXdgPopup) - Q_PROPERTY(QWaylandXdgSurface *xdgSurface READ xdgSurface) - Q_PROPERTY(QWaylandXdgSurface *parentXdgSurface READ parentXdgSurface) + Q_PROPERTY(QWaylandXdgSurface *xdgSurface READ xdgSurface CONSTANT) + Q_PROPERTY(QWaylandXdgSurface *parentXdgSurface READ parentXdgSurface CONSTANT) Q_PROPERTY(QRect configuredGeometry READ configuredGeometry NOTIFY configuredGeometryChanged) // Positioner properties @@ -260,7 +241,7 @@ public: QPoint unconstrainedPosition() const; Q_INVOKABLE uint sendConfigure(const QRect &geometry); - Q_REVISION(14) Q_INVOKABLE void sendPopupDone(); + Q_REVISION(1, 14) Q_INVOKABLE void sendPopupDone(); static QWaylandSurfaceRole *role(); diff --git a/src/compositor/extensions/qwaylandxdgshell_p.h b/src/compositor/extensions/qwaylandxdgshell_p.h index 3223abf3a..9ab188a44 100644 --- a/src/compositor/extensions/qwaylandxdgshell_p.h +++ b/src/compositor/extensions/qwaylandxdgshell_p.h @@ -1,43 +1,10 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** 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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDXDGSHELL_P_H #define QWAYLANDXDGSHELL_P_H -#include <QtWaylandCompositor/private/qwaylandcompositorextension_p.h> +#include <QtWaylandCompositor/private/qwaylandshellsurface_p.h> #include <QtWaylandCompositor/private/qwaylandshell_p.h> #include <QtWaylandCompositor/private/qwayland-server-xdg-shell.h> @@ -60,11 +27,11 @@ QT_BEGIN_NAMESPACE -struct Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgPositionerData { +struct Q_WAYLANDCOMPOSITOR_EXPORT QWaylandXdgPositionerData { QSize size; QRect anchorRect; - Qt::Edges anchorEdges = 0; - Qt::Edges gravityEdges = 0; + Qt::Edges anchorEdges = {}; + Qt::Edges gravityEdges = {}; uint constraintAdjustments = XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_NONE; QPoint offset; QWaylandXdgPositionerData(); @@ -73,7 +40,7 @@ struct Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgPositionerData { QPoint unconstrainedPosition() const; }; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgShellPrivate +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandXdgShellPrivate : public QWaylandShellPrivate , public QtWaylandServer::xdg_wm_base { @@ -98,8 +65,8 @@ protected: void xdg_wm_base_pong(Resource *resource, uint32_t serial) override; }; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgSurfacePrivate - : public QWaylandCompositorExtensionPrivate +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandXdgSurfacePrivate + : public QWaylandShellSurfacePrivate , public QtWaylandServer::xdg_surface { Q_DECLARE_PUBLIC(QWaylandXdgSurface) @@ -132,18 +99,18 @@ private: void xdg_surface_set_window_geometry(Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height) override; }; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgToplevelPrivate : public QObjectPrivate, public QtWaylandServer::xdg_toplevel +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandXdgToplevelPrivate : public QObjectPrivate, public QtWaylandServer::xdg_toplevel { Q_DECLARE_PUBLIC(QWaylandXdgToplevel) public: struct ConfigureEvent { ConfigureEvent() = default; - ConfigureEvent(const QVector<QWaylandXdgToplevel::State> + ConfigureEvent(const QList<QWaylandXdgToplevel::State> &incomingStates, const QSize &incomingSize, uint incomingSerial) : states(incomingStates), size(incomingSize), serial(incomingSerial) { } - QVector<QWaylandXdgToplevel::State> states; + QList<QWaylandXdgToplevel::State> states; QSize size = {0, 0}; uint serial = 0; }; @@ -186,11 +153,12 @@ public: QSize m_maxSize; QSize m_minSize = {0, 0}; QWaylandXdgToplevelDecorationV1 *m_decoration = nullptr; + bool m_modal = false; static QWaylandSurfaceRole s_role; }; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgPopupPrivate : public QObjectPrivate, public QtWaylandServer::xdg_popup +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandXdgPopupPrivate : public QObjectPrivate, public QtWaylandServer::xdg_popup { Q_DECLARE_PUBLIC(QWaylandXdgPopup) public: @@ -223,7 +191,7 @@ private: QList<ConfigureEvent> m_pendingConfigures; }; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgPositioner : public QtWaylandServer::xdg_positioner +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandXdgPositioner : public QtWaylandServer::xdg_positioner { public: QWaylandXdgPositioner(const QWaylandResource& resource); diff --git a/src/compositor/extensions/qwaylandxdgshellintegration.cpp b/src/compositor/extensions/qwaylandxdgshellintegration.cpp index 0aa160544..643ad65ba 100644 --- a/src/compositor/extensions/qwaylandxdgshellintegration.cpp +++ b/src/compositor/extensions/qwaylandxdgshellintegration.cpp @@ -1,38 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** 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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "qwaylandxdgshellintegration_p.h" @@ -82,45 +49,63 @@ bool XdgToplevelIntegration::eventFilter(QObject *object, QEvent *event) if (event->type() == QEvent::MouseMove) { QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event); return filterMouseMoveEvent(mouseEvent); - } else if (event->type() == QEvent::MouseButtonRelease) { - QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event); - return filterMouseReleaseEvent(mouseEvent); + } else if (event->type() == QEvent::MouseButtonRelease || event->type() == QEvent::TouchEnd || event->type() == QEvent::TouchCancel) { + return filterPointerReleaseEvent(); + } else if (event->type() == QEvent::TouchUpdate) { + QTouchEvent *touchEvent = static_cast<QTouchEvent *>(event); + return filterTouchUpdateEvent(touchEvent); } return QWaylandQuickShellIntegration::eventFilter(object, event); } -bool XdgToplevelIntegration::filterMouseMoveEvent(QMouseEvent *event) +bool XdgToplevelIntegration::filterPointerMoveEvent(const QPointF &scenePosition) { if (grabberState == GrabberState::Resize) { - Q_ASSERT(resizeState.seat == m_item->compositor()->seatFor(event)); if (!resizeState.initialized) { - resizeState.initialMousePos = event->windowPos(); + resizeState.initialMousePos = scenePosition; resizeState.initialized = true; return true; } - QPointF delta = m_item->mapToSurface(event->windowPos() - resizeState.initialMousePos); + QPointF delta = m_item->mapToSurface(scenePosition - resizeState.initialMousePos); QSize newSize = m_toplevel->sizeForResize(resizeState.initialWindowSize, delta, resizeState.resizeEdges); m_toplevel->sendResizing(newSize); } else if (grabberState == GrabberState::Move) { - Q_ASSERT(moveState.seat == m_item->compositor()->seatFor(event)); QQuickItem *moveItem = m_item->moveItem(); if (!moveState.initialized) { - moveState.initialOffset = moveItem->mapFromItem(nullptr, event->windowPos()); + moveState.initialOffset = moveItem->mapFromItem(nullptr, scenePosition); moveState.initialized = true; return true; } if (!moveItem->parentItem()) return true; - QPointF parentPos = moveItem->parentItem()->mapFromItem(nullptr, event->windowPos()); + QPointF parentPos = moveItem->parentItem()->mapFromItem(nullptr, scenePosition); moveItem->setPosition(parentPos - moveState.initialOffset); } return false; } -bool XdgToplevelIntegration::filterMouseReleaseEvent(QMouseEvent *event) +bool XdgToplevelIntegration::filterTouchUpdateEvent(QTouchEvent *event) { - Q_UNUSED(event); + if (event->pointCount() == 0) + return false; + + Q_ASSERT(grabberState != GrabberState::Move || moveState.seat == m_item->compositor()->seatFor(event)); + Q_ASSERT(grabberState != GrabberState::Resize || resizeState.seat == m_item->compositor()->seatFor(event)); + QEventPoint point = event->points().first(); + return filterPointerMoveEvent(point.scenePosition()); + } + +bool XdgToplevelIntegration::filterMouseMoveEvent(QMouseEvent *event) +{ + Q_ASSERT(grabberState != GrabberState::Move || moveState.seat == m_item->compositor()->seatFor(event)); + Q_ASSERT(grabberState != GrabberState::Resize || resizeState.seat == m_item->compositor()->seatFor(event)); + + return filterPointerMoveEvent(event->scenePosition()); +} + +bool XdgToplevelIntegration::filterPointerReleaseEvent() +{ if (grabberState != GrabberState::Default) { grabberState = GrabberState::Default; return true; @@ -151,7 +136,7 @@ void XdgToplevelIntegration::handleSetMaximized() if (!m_item->view()->isPrimary()) return; - QVector<QWaylandXdgToplevel::State> states = m_toplevel->states(); + QList<QWaylandXdgToplevel::State> states = m_toplevel->states(); if (!states.contains(QWaylandXdgToplevel::State::FullscreenState) && !states.contains(QWaylandXdgToplevel::State::MaximizedState)) { windowedGeometry.initialWindowSize = m_xdgSurface->windowGeometry().size(); @@ -207,7 +192,7 @@ void XdgToplevelIntegration::handleSetFullscreen() if (!m_item->view()->isPrimary()) return; - QVector<QWaylandXdgToplevel::State> states = m_toplevel->states(); + QList<QWaylandXdgToplevel::State> states = m_toplevel->states(); if (!states.contains(QWaylandXdgToplevel::State::FullscreenState) && !states.contains(QWaylandXdgToplevel::State::MaximizedState)) { windowedGeometry.initialWindowSize = m_xdgSurface->windowGeometry().size(); @@ -318,3 +303,5 @@ void XdgPopupIntegration::handleGeometryChanged() } QT_END_NAMESPACE + +#include "moc_qwaylandxdgshellintegration_p.cpp" diff --git a/src/compositor/extensions/qwaylandxdgshellintegration_p.h b/src/compositor/extensions/qwaylandxdgshellintegration_p.h index cd6bad572..eba397678 100644 --- a/src/compositor/extensions/qwaylandxdgshellintegration_p.h +++ b/src/compositor/extensions/qwaylandxdgshellintegration_p.h @@ -1,38 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** 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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDXDGSHELLINTEGRATION_H #define QWAYLANDXDGSHELLINTEGRATION_H @@ -122,8 +89,10 @@ private: // geometry-changed. } nonwindowedState; + bool filterPointerMoveEvent(const QPointF &scenePosition); bool filterMouseMoveEvent(QMouseEvent *event); - bool filterMouseReleaseEvent(QMouseEvent *event); + bool filterPointerReleaseEvent(); + bool filterTouchUpdateEvent(QTouchEvent *event); }; class XdgPopupIntegration : public QWaylandQuickShellIntegration diff --git a/src/compositor/extensions/qwaylandxdgshellv5.cpp b/src/compositor/extensions/qwaylandxdgshellv5.cpp deleted file mode 100644 index fab3c841a..000000000 --- a/src/compositor/extensions/qwaylandxdgshellv5.cpp +++ /dev/null @@ -1,1517 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qwaylandxdgshellv5.h" -#include "qwaylandxdgshellv5_p.h" - -#if QT_CONFIG(wayland_compositor_quick) -#include "qwaylandxdgshellv5integration_p.h" -#endif -#include <QtWaylandCompositor/private/qwaylandutils_p.h> - -#include <QtWaylandCompositor/QWaylandCompositor> -#include <QtWaylandCompositor/QWaylandSurface> -#include <QtWaylandCompositor/QWaylandSurfaceRole> -#include <QtWaylandCompositor/QWaylandResource> -#include <QtWaylandCompositor/QWaylandSeat> - -#include <QtCore/QObject> - -#include <algorithm> - -QT_BEGIN_NAMESPACE - -QWaylandSurfaceRole QWaylandXdgSurfaceV5Private::s_role("xdg_surface"); -QWaylandSurfaceRole QWaylandXdgPopupV5Private::s_role("xdg_popup"); - -QWaylandXdgShellV5Private::QWaylandXdgShellV5Private() -{ -} - -void QWaylandXdgShellV5Private::ping(Resource *resource, uint32_t serial) -{ - m_pings.insert(serial); - send_ping(resource->handle, serial); -} - -void QWaylandXdgShellV5Private::registerSurface(QWaylandXdgSurfaceV5 *xdgSurface) -{ - m_xdgSurfaces.insert(xdgSurface->surface()->client()->client(), xdgSurface); -} - -void QWaylandXdgShellV5Private::unregisterXdgSurface(QWaylandXdgSurfaceV5 *xdgSurface) -{ - auto xdgSurfacePrivate = QWaylandXdgSurfaceV5Private::get(xdgSurface); - if (!m_xdgSurfaces.remove(xdgSurfacePrivate->resource()->client(), xdgSurface)) - qWarning("%s Unexpected state. Can't find registered xdg surface\n", Q_FUNC_INFO); -} - -void QWaylandXdgShellV5Private::registerXdgPopup(QWaylandXdgPopupV5 *xdgPopup) -{ - m_xdgPopups.insert(xdgPopup->surface()->client()->client(), xdgPopup); -} - -void QWaylandXdgShellV5Private::unregisterXdgPopup(QWaylandXdgPopupV5 *xdgPopup) -{ - auto xdgPopupPrivate = QWaylandXdgPopupV5Private::get(xdgPopup); - if (!m_xdgPopups.remove(xdgPopupPrivate->resource()->client(), xdgPopup)) - qWarning("%s Unexpected state. Can't find registered xdg popup\n", Q_FUNC_INFO); -} - -bool QWaylandXdgShellV5Private::isValidPopupParent(QWaylandSurface *parentSurface) const -{ - QWaylandXdgPopupV5 *topmostPopup = topmostPopupForClient(parentSurface->client()->client()); - if (topmostPopup && topmostPopup->surface() != parentSurface) { - return false; - } - - QWaylandSurfaceRole *parentRole = parentSurface->role(); - if (parentRole != QWaylandXdgSurfaceV5::role() && parentRole != QWaylandXdgPopupV5::role()) { - return false; - } - - return true; -} - -QWaylandXdgPopupV5 *QWaylandXdgShellV5Private::topmostPopupForClient(wl_client *client) const -{ - QList<QWaylandXdgPopupV5 *> clientPopups = m_xdgPopups.values(client); - return clientPopups.empty() ? nullptr : clientPopups.last(); -} - -QWaylandXdgSurfaceV5 *QWaylandXdgShellV5Private::xdgSurfaceFromSurface(QWaylandSurface *surface) const -{ - for (QWaylandXdgSurfaceV5 *xdgSurface : m_xdgSurfaces) { - if (surface == xdgSurface->surface()) - return xdgSurface; - } - return nullptr; -} - -void QWaylandXdgShellV5Private::xdg_shell_destroy(Resource *resource) -{ - if (!m_xdgSurfaces.values(resource->client()).empty()) - wl_resource_post_error(resource->handle, XDG_SHELL_ERROR_DEFUNCT_SURFACES, - "xdg_shell was destroyed before children"); - - wl_resource_destroy(resource->handle); -} - -void QWaylandXdgShellV5Private::xdg_shell_get_xdg_surface(Resource *resource, uint32_t id, - wl_resource *surface_res) -{ - Q_Q(QWaylandXdgShellV5); - QWaylandSurface *surface = QWaylandSurface::fromResource(surface_res); - - if (xdgSurfaceFromSurface(surface)) { - wl_resource_post_error(resource->handle, XDG_SHELL_ERROR_ROLE, - "An active xdg_surface already exists for wl_surface@%d", - wl_resource_get_id(surface->resource())); - return; - } - - if (!surface->setRole(QWaylandXdgSurfaceV5::role(), resource->handle, XDG_SHELL_ERROR_ROLE)) - return; - - QWaylandResource xdgSurfaceResource(wl_resource_create(resource->client(), &xdg_surface_v5_interface, - wl_resource_get_version(resource->handle), id)); - - emit q->xdgSurfaceRequested(surface, xdgSurfaceResource); - - QWaylandXdgSurfaceV5 *xdgSurface = QWaylandXdgSurfaceV5::fromResource(xdgSurfaceResource.resource()); - if (!xdgSurface) { - // A QWaylandXdgSurfaceV5 was not created in response to the xdgSurfaceRequested signal, so we - // create one as fallback here instead. - xdgSurface = new QWaylandXdgSurfaceV5(q, surface, xdgSurfaceResource); - } - - registerSurface(xdgSurface); - emit q->xdgSurfaceCreated(xdgSurface); -} - -void QWaylandXdgShellV5Private::xdg_shell_use_unstable_version(Resource *resource, int32_t version) -{ - if (xdg_shell_v5::version_current != version) { - wl_resource_post_error(resource->handle, WL_DISPLAY_ERROR_INVALID_OBJECT, - "incompatible version, server is %d, but client wants %d", - xdg_shell_v5::version_current, version); - } -} - -void QWaylandXdgShellV5Private::xdg_shell_get_xdg_popup(Resource *resource, uint32_t id, - wl_resource *surface_res, wl_resource *parent, - wl_resource *seatResource, uint32_t serial, - int32_t x, int32_t y) -{ - Q_UNUSED(serial); - Q_Q(QWaylandXdgShellV5); - QWaylandSurface *surface = QWaylandSurface::fromResource(surface_res); - QWaylandSurface *parentSurface = QWaylandSurface::fromResource(parent); - - if (!isValidPopupParent(parentSurface)) { - wl_resource_post_error(resource->handle, XDG_SHELL_ERROR_INVALID_POPUP_PARENT, - "the client specified an invalid popup parent surface"); - return; - } - - if (!surface->setRole(QWaylandXdgPopupV5::role(), resource->handle, XDG_SHELL_ERROR_ROLE)) { - return; - } - - QWaylandResource xdgPopupResource (wl_resource_create(resource->client(), &xdg_popup_v5_interface, - wl_resource_get_version(resource->handle), id)); - QWaylandSeat *seat = QWaylandSeat::fromSeatResource(seatResource); - QPoint position(x, y); - emit q->xdgPopupRequested(surface, parentSurface, seat, position, xdgPopupResource); - - QWaylandXdgPopupV5 *xdgPopup = QWaylandXdgPopupV5::fromResource(xdgPopupResource.resource()); - if (!xdgPopup) { - // A QWaylandXdgPopupV5 was not created in response to the xdgPopupRequested signal, so we - // create one as fallback here instead. - xdgPopup = new QWaylandXdgPopupV5(q, surface, parentSurface, position, xdgPopupResource); - } - - registerXdgPopup(xdgPopup); - emit q->xdgPopupCreated(xdgPopup); -} - -void QWaylandXdgShellV5Private::xdg_shell_pong(Resource *resource, uint32_t serial) -{ - Q_UNUSED(resource); - Q_Q(QWaylandXdgShellV5); - if (m_pings.remove(serial)) - emit q->pong(serial); - else - qWarning("Received an unexpected pong!"); -} - -QWaylandXdgSurfaceV5Private::QWaylandXdgSurfaceV5Private() - : m_lastAckedConfigure({{}, QSize(0, 0), 0}) -{ -} - -void QWaylandXdgSurfaceV5Private::handleFocusLost() -{ - Q_Q(QWaylandXdgSurfaceV5); - QWaylandXdgSurfaceV5Private::ConfigureEvent current = lastSentConfigure(); - current.states.removeOne(QWaylandXdgSurfaceV5::State::ActivatedState); - q->sendConfigure(current.size, current.states); -} - -void QWaylandXdgSurfaceV5Private::handleFocusReceived() -{ - Q_Q(QWaylandXdgSurfaceV5); - - QWaylandXdgSurfaceV5Private::ConfigureEvent current = lastSentConfigure(); - if (!current.states.contains(QWaylandXdgSurfaceV5::State::ActivatedState)) { - current.states.push_back(QWaylandXdgSurfaceV5::State::ActivatedState); - } - - q->sendConfigure(current.size, current.states); -} - -QRect QWaylandXdgSurfaceV5Private::calculateFallbackWindowGeometry() const -{ - // TODO: The unset window geometry should include subsurfaces as well, so this solution - // won't work too well on those kinds of clients. - return QRect(QPoint(), m_surface->destinationSize()); -} - -void QWaylandXdgSurfaceV5Private::updateFallbackWindowGeometry() -{ - Q_Q(QWaylandXdgSurfaceV5); - if (!m_unsetWindowGeometry) - return; - - const QRect unsetGeometry = calculateFallbackWindowGeometry(); - if (unsetGeometry == m_windowGeometry) - return; - - m_windowGeometry = unsetGeometry; - emit q->windowGeometryChanged(); -} - -void QWaylandXdgSurfaceV5Private::setWindowType(Qt::WindowType windowType) -{ - if (m_windowType == windowType) - return; - - m_windowType = windowType; - - Q_Q(QWaylandXdgSurfaceV5); - emit q->windowTypeChanged(); -} - -void QWaylandXdgSurfaceV5Private::xdg_surface_destroy_resource(Resource *resource) -{ - Q_UNUSED(resource); - Q_Q(QWaylandXdgSurfaceV5); - QWaylandXdgShellV5Private::get(m_xdgShell)->unregisterXdgSurface(q); - delete q; -} - -void QWaylandXdgSurfaceV5Private::xdg_surface_destroy(Resource *resource) -{ - wl_resource_destroy(resource->handle); -} - -void QWaylandXdgSurfaceV5Private::xdg_surface_move(Resource *resource, wl_resource *seat, uint32_t serial) -{ - Q_UNUSED(resource); - Q_UNUSED(serial); - - Q_Q(QWaylandXdgSurfaceV5); - QWaylandSeat *input_device = QWaylandSeat::fromSeatResource(seat); - emit q->startMove(input_device); -} - -void QWaylandXdgSurfaceV5Private::xdg_surface_resize(Resource *resource, wl_resource *seat, - uint32_t serial, uint32_t edges) -{ - Q_UNUSED(resource); - Q_UNUSED(serial); - - Q_Q(QWaylandXdgSurfaceV5); - QWaylandSeat *input_device = QWaylandSeat::fromSeatResource(seat); - emit q->startResize(input_device, QWaylandXdgSurfaceV5::ResizeEdge(edges)); -} - -void QWaylandXdgSurfaceV5Private::xdg_surface_set_maximized(Resource *resource) -{ - Q_UNUSED(resource); - Q_Q(QWaylandXdgSurfaceV5); - emit q->setMaximized(); -} - -void QWaylandXdgSurfaceV5Private::xdg_surface_unset_maximized(Resource *resource) -{ - Q_UNUSED(resource); - Q_Q(QWaylandXdgSurfaceV5); - emit q->unsetMaximized(); -} - -void QWaylandXdgSurfaceV5Private::xdg_surface_set_fullscreen(Resource *resource, wl_resource *output_res) -{ - Q_UNUSED(resource); - Q_Q(QWaylandXdgSurfaceV5); - QWaylandOutput *output = output_res ? QWaylandOutput::fromResource(output_res) : nullptr; - emit q->setFullscreen(output); -} - -void QWaylandXdgSurfaceV5Private::xdg_surface_unset_fullscreen(Resource *resource) -{ - Q_UNUSED(resource); - Q_Q(QWaylandXdgSurfaceV5); - emit q->unsetFullscreen(); -} - -void QWaylandXdgSurfaceV5Private::xdg_surface_set_minimized(Resource *resource) -{ - Q_UNUSED(resource); - Q_Q(QWaylandXdgSurfaceV5); - emit q->setMinimized(); -} - -void QWaylandXdgSurfaceV5Private::xdg_surface_set_parent(Resource *resource, wl_resource *parent) -{ - Q_UNUSED(resource); - QWaylandXdgSurfaceV5 *parentSurface = nullptr; - if (parent) { - parentSurface = static_cast<QWaylandXdgSurfaceV5Private *>( - QWaylandXdgSurfaceV5Private::Resource::fromResource(parent)->xdg_surface_object)->q_func(); - } - - Q_Q(QWaylandXdgSurfaceV5); - - if (m_parentSurface != parentSurface) { - m_parentSurface = parentSurface; - emit q->parentSurfaceChanged(); - } - - if (m_parentSurface && m_windowType != Qt::WindowType::SubWindow) { - // There's a parent now, which means the surface is transient - setWindowType(Qt::WindowType::SubWindow); - emit q->setTransient(); - } else if (!m_parentSurface && m_windowType != Qt::WindowType::Window) { - // When the surface has no parent it is toplevel - setWindowType(Qt::WindowType::Window); - emit q->setTopLevel(); - } -} - -void QWaylandXdgSurfaceV5Private::xdg_surface_set_app_id(Resource *resource, const QString &app_id) -{ - Q_UNUSED(resource); - if (app_id == m_appId) - return; - Q_Q(QWaylandXdgSurfaceV5); - m_appId = app_id; - emit q->appIdChanged(); -} - -void QWaylandXdgSurfaceV5Private::xdg_surface_show_window_menu(Resource *resource, wl_resource *seatResource, - uint32_t serial, int32_t x, int32_t y) -{ - Q_UNUSED(resource); - Q_UNUSED(serial); - QPoint position(x, y); - auto seat = QWaylandSeat::fromSeatResource(seatResource); - Q_Q(QWaylandXdgSurfaceV5); - emit q->showWindowMenu(seat, position); -} - -void QWaylandXdgSurfaceV5Private::xdg_surface_ack_configure(Resource *resource, uint32_t serial) -{ - Q_UNUSED(resource); - Q_Q(QWaylandXdgSurfaceV5); - - ConfigureEvent config; - Q_FOREVER { - if (m_pendingConfigures.empty()) { - qWarning("Received an unexpected ack_configure!"); - return; - } - - config = m_pendingConfigures.takeFirst(); - - if (config.serial == serial) - break; - } - - std::vector<uint> changedStates; - std::set_symmetric_difference( - m_lastAckedConfigure.states.begin(), m_lastAckedConfigure.states.end(), - config.states.begin(), config.states.end(), - std::back_inserter(changedStates)); - - m_lastAckedConfigure = config; - - if (!changedStates.empty()) { - for (uint state : changedStates) { - switch (state) { - case QWaylandXdgSurfaceV5::State::MaximizedState: - emit q->maximizedChanged(); - break; - case QWaylandXdgSurfaceV5::State::FullscreenState: - emit q->fullscreenChanged(); - break; - case QWaylandXdgSurfaceV5::State::ResizingState: - emit q->resizingChanged(); - break; - case QWaylandXdgSurfaceV5::State::ActivatedState: - emit q->activatedChanged(); - break; - } - } - emit q->statesChanged(); - } - - emit q->ackConfigure(serial); -} - -void QWaylandXdgSurfaceV5Private::xdg_surface_set_title(Resource *resource, const QString &title) -{ - Q_UNUSED(resource); - if (title == m_title) - return; - Q_Q(QWaylandXdgSurfaceV5); - m_title = title; - emit q->titleChanged(); -} - -void QWaylandXdgSurfaceV5Private::xdg_surface_set_window_geometry(Resource *resource, - int32_t x, int32_t y, - int32_t width, int32_t height) -{ - Q_UNUSED(resource); - - if (width <= 0 || height <= 0) { - qWarning() << "Invalid (non-positive) dimensions received in set_window_geometry"; - return; - } - - m_unsetWindowGeometry = false; - - QRect geometry(x, y, width, height); - - Q_Q(QWaylandXdgSurfaceV5); - if ((q->maximized() || q->fullscreen()) && m_lastAckedConfigure.size != geometry.size()) - qWarning() << "Client window geometry did not obey last acked configure"; - - if (geometry == m_windowGeometry) - return; - - m_windowGeometry = geometry; - emit q->windowGeometryChanged(); -} - -QWaylandXdgPopupV5Private::QWaylandXdgPopupV5Private() -{ -} - -void QWaylandXdgPopupV5Private::xdg_popup_destroy_resource(Resource *resource) -{ - Q_UNUSED(resource); - Q_Q(QWaylandXdgPopupV5); - QWaylandXdgShellV5Private::get(m_xdgShell)->unregisterXdgPopup(q); - delete q; -} - -void QWaylandXdgPopupV5Private::xdg_popup_destroy(Resource *resource) -{ - //TODO: post error if not topmost popup - wl_resource_destroy(resource->handle); -} - -/*! - * \qmltype XdgShellV5 - * \inqmlmodule QtWayland.Compositor - * \since 5.8 - * \brief Provides an extension for desktop-style user interfaces. - * - * The XdgShellV5 extension provides a way to associate an XdgSurfaceV5 - * with a regular Wayland surface. Using the xdg_surface interface, the client - * can request that the surface is resized, moved, and so on. - * - * XdgShellV5 corresponds to the Wayland interface \c xdg_shell. - * - * To provide the functionality of the shell extension in a compositor, create - * an instance of the XdgShellV5 component and add it as a child of the - * compositor: - * - * \qml \QtMinorVersion - * import QtWayland.Compositor 1.\1 - * - * WaylandCompositor { - * XdgShellV5 { - * // ... - * } - * } - * \endqml - * - * \deprecated - */ - -/*! - * \class QWaylandXdgShellV5 - * \inmodule QtWaylandCompositor - * \since 5.8 - * \brief The QWaylandXdgShellV5 class is an extension for desktop-style user interfaces. - * - * The QWaylandXdgShellV5 extension provides a way to associate a QWaylandXdgSurfaceV5 with - * a regular Wayland surface. Using the xdg_surface interface, the client - * can request that the surface is resized, moved, and so on. - * - * QWaylandXdgShellV5 corresponds to the Wayland interface \c xdg_shell. - * - * \deprecated - */ - -/*! - * Constructs a QWaylandXdgShellV5 object. - */ -QWaylandXdgShellV5::QWaylandXdgShellV5() - : QWaylandShellTemplate<QWaylandXdgShellV5>(*new QWaylandXdgShellV5Private()) -{ } - -/*! - * Constructs a QWaylandXdgShellV5 object for the provided \a compositor. - */ -QWaylandXdgShellV5::QWaylandXdgShellV5(QWaylandCompositor *compositor) - : QWaylandShellTemplate<QWaylandXdgShellV5>(compositor, *new QWaylandXdgShellV5Private()) -{ } - -/*! - * Initializes the shell extension. - */ -void QWaylandXdgShellV5::initialize() -{ - Q_D(QWaylandXdgShellV5); - QWaylandShellTemplate::initialize(); - QWaylandCompositor *compositor = static_cast<QWaylandCompositor *>(extensionContainer()); - if (!compositor) { - qWarning() << "Failed to find QWaylandCompositor when initializing QWaylandXdgShellV5"; - return; - } - d->init(compositor->display(), 1); - - handleSeatChanged(compositor->defaultSeat(), nullptr); - - connect(compositor, &QWaylandCompositor::defaultSeatChanged, - this, &QWaylandXdgShellV5::handleSeatChanged); -} - -QWaylandClient *QWaylandXdgShellV5::popupClient() const -{ - Q_D(const QWaylandXdgShellV5); - for (QWaylandXdgPopupV5 *popup : d->m_xdgPopups) { - if (popup->surface()->hasContent()) - return popup->surface()->client(); - } - return nullptr; -} - -/*! - * Returns the Wayland interface for the QWaylandXdgShellV5. - */ -const struct wl_interface *QWaylandXdgShellV5::interface() -{ - return QWaylandXdgShellV5Private::interface(); -} - -QByteArray QWaylandXdgShellV5::interfaceName() -{ - return QWaylandXdgShellV5Private::interfaceName(); -} - -/*! - * \qmlmethod void QtWaylandCompositor::XdgShellV5::ping() - * - * Sends a ping event to the \a client. If the client replies to the event, the - * pong signal will be emitted. - */ - -/*! - * Sends a ping event to the \a client. If the client replies to the event, the - * pong signal will be emitted. - */ -uint QWaylandXdgShellV5::ping(QWaylandClient *client) -{ - Q_D(QWaylandXdgShellV5); - - QWaylandCompositor *compositor = static_cast<QWaylandCompositor *>(extensionContainer()); - Q_ASSERT(compositor); - - uint32_t serial = compositor->nextSerial(); - - QWaylandXdgShellV5Private::Resource *clientResource = d->resourceMap().value(client->client(), nullptr); - Q_ASSERT(clientResource); - - d->ping(clientResource, serial); - return serial; -} - -// ### remove once QMap has rbegin()/rend() -template <typename Iterator> -std::reverse_iterator<Iterator> make_reverse(Iterator it) -{ - return std::reverse_iterator<Iterator>(std::move(it)); -} - -void QWaylandXdgShellV5::closeAllPopups() -{ - Q_D(QWaylandXdgShellV5); - // Close pop-ups from top-most to bottom-most, lest we get protocol errors: - for (auto rit = make_reverse(d->m_xdgPopups.end()), rend = make_reverse(d->m_xdgPopups.begin()); rit != rend; ++rit) { - (*rit)->sendPopupDone(); - } -} - -/*! - * \qmlsignal void QtWaylandCompositor::XdgShellV5::xdgSurfaceRequested(WaylandSurface surface, WaylandResource resource) - * - * This signal is emitted when the client has requested an \c xdg_surface to be associated - * with \a surface. The handler for this signal may create the shell surface for \a resource - * and initialize it within the scope of the signal emission. Otherwise an XdgSurfaceV5 will - * be created automatically. - */ - -/*! - * \fn void QWaylandXdgShellV5::xdgSurfaceRequested(QWaylandSurface *surface, const QWaylandResource &resource) - * - * This signal is emitted when the client has requested an \c xdg_surface to be associated - * with \a surface. The handler for this signal may create the shell surface for \a resource - * and initialize it within the scope of the signal emission. Otherwise a QWaylandXdgSurfaceV5 - * will be created automatically. - */ - -/*! - * \qmlsignal void QtWaylandCompositor::XdgShellV5::xdgSurfaceCreated(XdgSurfaceV5 xdgSurface) - * - * This signal is emitted when the client has created an \c xdg_surface. - * A common use case is to let the handler of this signal instantiate a ShellSurfaceItem or - * WaylandQuickItem for displaying \a xdgSurface in a QtQuick scene. - */ - -/*! - * \fn void QWaylandXdgShellV5::xdgSurfaceCreated(QWaylandXdgSurfaceV5 *xdgSurface) - * - * This signal is emitted when the client has created an \c xdg_surface. - * A common use case is to let the handler of this signal instantiate a QWaylandShellSurfaceItem or - * QWaylandQuickItem for displaying \a xdgSurface in a QtQuick scene. - */ - -/*! - * \qmlsignal void QtWaylandCompositor::XdgShellV5::xdgPopupRequested(WaylandSurface surface, WaylandSurface parent, WaylandSeat seat, point position, WaylandResource resource) - * - * This signal is emitted when the client has requested an \c xdg_popup to be associated - * with \a surface. The handler for this signal may create the xdg popup for \a resource and - * initialize it within the scope of the signal emission. Otherwise an XdgPopupV5 will be - * created automatically. - * - * The \a seat is the \c wl_seat that caused the popup to be opened. - * - * \a position is the desired position of the popup, relative to the \a parent. - */ - -/*! - * \fn void QWaylandXdgShellV5::xdgPopupRequested(QWaylandSurface *surface, QWaylandSurface *parent, QWaylandSeat *seat, const QPoint &position, const QWaylandResource &resource) - * - * This signal is emitted when the client has requested an \c xdg_surface to be associated - * with \a surface. The handler for this signal may create the xdg poup for \a resource and - * initialize it within the scope of the signal emission. Otherwise a QWaylandXdgPopupV5 will be - * created automatically. - * - * The \a seat is the \c wl_seat that caused the popup to be opened. - * - * \a position is the desired position of the popup, relative to the \a parent. - */ - -/*! - * \qmlsignal void QtWaylandCompositor::XdgShellV5::xdgPopupCreated(XdgPopupV5 xdgPopup) - * - * This signal is emitted when the client has created an \c xdg_popup. - * A common use case is to let the handler of this signal instantiate a ShellSurfaceItem or - * WaylandQuickItem for displaying \a xdgPopup in a QtQuick scene. - */ - -/*! - * \fn void QWaylandXdgShellV5::xdgPopupCreated(QWaylandXdgPopupV5 *xdgPopup) - * - * This signal is emitted when the client has created an \c xdg_popup. - * A common use case is to let the handler of this signal instantiate a QWaylandShellSurfaceItem or - * QWaylandQuickItem for displaying \a xdgPopup in a QtQuick scene. - */ - -/*! - * \qmlsignal void QtWaylandCompositor::XdgShellV5::pong(int serial) - * - * This signal is emitted when the client has responded to a ping event with serial \a serial. - * - * \sa QtWaylandCompositor::XdgShellV5::ping() - */ - -/*! - * \fn void QWaylandXdgShellV5::pong(uint serial) - * - * This signal is emitted when the client has responded to a ping event with serial \a serial. - * - * \sa QWaylandXdgShellV5::ping() - */ - -void QWaylandXdgShellV5::handleSeatChanged(QWaylandSeat *newSeat, QWaylandSeat *oldSeat) -{ - if (oldSeat != nullptr) { - disconnect(oldSeat, &QWaylandSeat::keyboardFocusChanged, - this, &QWaylandXdgShellV5::handleFocusChanged); - } - - if (newSeat != nullptr) { - connect(newSeat, &QWaylandSeat::keyboardFocusChanged, - this, &QWaylandXdgShellV5::handleFocusChanged); - } -} - -void QWaylandXdgShellV5::handleFocusChanged(QWaylandSurface *newSurface, QWaylandSurface *oldSurface) -{ - Q_D(QWaylandXdgShellV5); - - QWaylandXdgSurfaceV5 *newXdgSurface = d->xdgSurfaceFromSurface(newSurface); - QWaylandXdgSurfaceV5 *oldXdgSurface = d->xdgSurfaceFromSurface(oldSurface); - - if (newXdgSurface) - QWaylandXdgSurfaceV5Private::get(newXdgSurface)->handleFocusReceived(); - - if (oldXdgSurface) - QWaylandXdgSurfaceV5Private::get(oldXdgSurface)->handleFocusLost(); -} - -/*! - * \qmltype XdgSurfaceV5 - * \inqmlmodule QtWayland.Compositor - * \since 5.8 - * \brief Provides a \c xdg_surface that offers desktop-style compositor-specific features to a surface. - * - * This type is part of the \l{XdgShellV5} extension and provides a way to extend - * the functionality of an existing WaylandSurface with features specific to desktop-style - * compositors, such as resizing and moving the surface. - * - * It corresponds to the Wayland interface \c xdg_surface for the unstable xdg-shell protocol v5. - * - * \deprecated - */ - -/*! - * \class QWaylandXdgSurfaceV5 - * \inmodule QtWaylandCompositor - * \since 5.8 - * \brief The QWaylandXdgSurfaceV5 class provides desktop-style compositor-specific features to an xdg surface. - * - * This class is part of the QWaylandXdgShellV5 extension and provides a way to - * extend the functionality of an existing QWaylandSurface with features - * specific to desktop-style compositors, such as resizing and moving the - * surface. - * - * It corresponds to the Wayland interface xdg_surface. - * - * \deprecated - */ - -/*! - * \qmlsignal QtWaylandCompositor::XdgSurfaceV5::setTopLevel() - * - * This signal is emitted when the parent surface is unset, effectively - * making the window top level. - */ - -/*! - * \qmlsignal QtWaylandCompositor::XdgSurfaceV5::setTransient() - * - * This signal is emitted when the parent surface is set, effectively - * making the window transient. - */ - -/*! - * Constructs a QWaylandXdgSurfaceV5. - */ -QWaylandXdgSurfaceV5::QWaylandXdgSurfaceV5() - : QWaylandShellSurfaceTemplate<QWaylandXdgSurfaceV5>(*new QWaylandXdgSurfaceV5Private) -{ -} - -/*! - * Constructs a QWaylandXdgSurfaceV5 for \a surface and initializes it with the - * given \a xdgShell, \a surface, and resource \a res. - */ -QWaylandXdgSurfaceV5::QWaylandXdgSurfaceV5(QWaylandXdgShellV5 *xdgShell, QWaylandSurface *surface, const QWaylandResource &res) - : QWaylandShellSurfaceTemplate<QWaylandXdgSurfaceV5>(*new QWaylandXdgSurfaceV5Private) -{ - initialize(xdgShell, surface, res); -} - -/*! - * \qmlmethod void QtWaylandCompositor::XdgSurfaceV5::initialize(XdgShellV5 xdgShell, WaylandSurface surface, WaylandResource resource) - * - * Initializes the XdgSurfaceV5, associating it with the given \a xdgShell, \a surface, - * and \a resource. - */ - -/*! - * Initializes the QWaylandXdgSurfaceV5, associating it with the given \a xdgShell, \a surface - * and \a resource. - */ -void QWaylandXdgSurfaceV5::initialize(QWaylandXdgShellV5 *xdgShell, QWaylandSurface *surface, const QWaylandResource &resource) -{ - Q_D(QWaylandXdgSurfaceV5); - d->m_xdgShell = xdgShell; - d->m_surface = surface; - d->init(resource.resource()); - setExtensionContainer(surface); - d->m_windowGeometry = d->calculateFallbackWindowGeometry(); - connect(surface, &QWaylandSurface::destinationSizeChanged, this, &QWaylandXdgSurfaceV5::handleSurfaceSizeChanged); - connect(surface, &QWaylandSurface::bufferScaleChanged, this, &QWaylandXdgSurfaceV5::handleBufferScaleChanged); - emit shellChanged(); - emit surfaceChanged(); - emit windowGeometryChanged(); - QWaylandCompositorExtension::initialize(); -} - -/*! - * \qmlsignal void QtWaylandCompositor::XdgSurfaceV5::showWindowMenu(WaylandSeat seat, point localSurfacePosition) - * - * This signal is emitted when the client wants to show a context menu at \a localSurfacePosition, - * using the Wayland seat \a seat. It's typically emitted in response to the user right-clicking - * the window decorations. - */ - -/*! - * \fn void QWaylandXdgSurfaceV5::showWindowMenu(QWaylandSeat *seat, const QPoint &localSurfacePosition) - * - * This signal is emitted when the client wants to show a context menu at \a localSurfacePosition, - * using the Wayland seat \a seat. It's typically emitted in response to the user right-clicking - * the window decorations. - */ - -/*! - * \qmlsignal void QtWaylandCompositor::XdgSurfaceV5::startMove(WaylandSeat seat) - * - * This signal is emitted when the client wants to start an interactive move of the XdgSurfaceV5, - * typically in response to the window decorations being dragged by \a seat. - */ - -/*! - * \fn void QWaylandXdgSurfaceV5::startMove(QWaylandSeat *seat) - * - * This signal is emitted when the client wants to start an interactive move of the - * QWaylandXdgSurfaceV5, typically in response to the window decorations being dragged by \a seat. - */ - -/*! - * \qmlsignal void QtWaylandCompositor::XdgSurfaceV5::startResize(WaylandSeat seat, enumeration edges) - * - * This signal is emitted when the client wants to start an interactive resize of the XdgSurfaceV5, - * typically in response to the window decorations being dragged by \a seat on the window borders - * given by \a edges. - * - * \sa QWaylandXdgSurfaceV5::ResizeEdge - */ - -/*! - * \fn void QWaylandXdgSurfaceV5::startResize(QWaylandSeat *seat, ResizeEdge edges) - * - * This signal is emitted when the client wants to start an interactive resize of the - * QWaylandXdgSurfaceV5, typically in response to the window decorations being dragged by - * \a seat on the window borders given by \a edges. - */ - -/*! - * \qmlsignal void QtWaylandCompositor::XdgSurfaceV5::setMaximized() - * - * This signal is emitted when the client wants the \c xdg_surface to be maximized. - */ - -/*! - * \fn void QWaylandXdgSurfaceV5::setMaximized() - * - * This signal is emitted when the client wants the \c xdg_surface to be maximized. - */ - -/*! - * \qmlsignal void QtWaylandCompositor::XdgSurfaceV5::unsetMaximized() - * - * This signal is emitted when the client doesn't want the \c xdg_surface to be maximized anymore. - */ - -/*! - * \fn void QWaylandXdgSurfaceV5::unsetMaximized() - * - * This signal is emitted when the client doesn't want the \c xdg_surface to be maximized anymore. - */ - -/*! - * \qmlsignal void QtWaylandCompositor::XdgSurfaceV5::setFullscreen(WaylandOutput output) - * - * This signal is emitted when the client wants the \c xdg_surface to be in full screen mode. - * The client may specify an \a output it wishes the \c xdg_surface to be shown on. - */ - -/*! - * \fn void QWaylandXdgSurfaceV5::setFullscreen(QWaylandOutput *output) - * - * This signal is emitted when the client wants the \c xdg_surface to be in full screen mode. - * The client may specify an \a output it wishes the \c xdg_surface to be shown on. - */ - -/*! - * \qmlsignal void QtWaylandCompositor::XdgSurfaceV5::unsetFullscreen() - * - * This signal is emitted when the client doesn't want the \c xdg_surface to be in full screen mode - * anymore. - */ - -/*! - * \fn void QWaylandXdgSurfaceV5::unsetFullscreen() - * - * This signal is emitted when the client doesn't want the \c xdg_surface to be in full screen mode - * anymore. - */ - -/*! - * \qmlsignal void QtWaylandCompositor::XdgSurfaceV5::setMinimized() - * - * This signal is emitted when the client wants the \c xdg_surface to be minimized. - */ - -/*! - * \fn void QWaylandXdgSurfaceV5::setMinimized() - * - * This signal is emitted when the client wants the \c xdg_surface to be minimized. - */ - -/*! - * \qmlsignal void QtWaylandCompositor::XdgSurfaceV5::ackConfigure(int serial) - * - * This signal is emitted when the client has received configure events up to and including the - * configure event with serial \a serial and will draw its surface accordingly in the next committed - * buffer. - */ - -/*! - * \fn void QWaylandXdgSurfaceV5::ackConfigure(uint serial) - * - * This signal is emitted when the client has received configure events up to and including the - * configure event with serial \a serial and will draw its surface accordingly in the next committed - * buffer. - */ - -/*! - * \internal - */ -void QWaylandXdgSurfaceV5::initialize() -{ - QWaylandCompositorExtension::initialize(); -} - -QList<int> QWaylandXdgSurfaceV5::statesAsInts() const -{ - QList<int> list; - const auto s = states(); - list.reserve(s.size()); - for (auto state : s) { - list << static_cast<int>(state); - } - return list; -} - -void QWaylandXdgSurfaceV5::handleSurfaceSizeChanged() -{ - Q_D(QWaylandXdgSurfaceV5); - d->updateFallbackWindowGeometry(); -} - -void QWaylandXdgSurfaceV5::handleBufferScaleChanged() -{ - Q_D(QWaylandXdgSurfaceV5); - d->updateFallbackWindowGeometry(); -} - -/*! - * \qmlproperty XdgShellV5 QtWaylandCompositor::XdgSurfaceV5::shell - * - * This property holds the shell associated with this XdgSurfaceV5. - */ - -/*! - * \property QWaylandXdgSurfaceV5::shell - * - * This property holds the shell associated with this QWaylandXdgSurfaceV5. - */ -QWaylandXdgShellV5 *QWaylandXdgSurfaceV5::shell() const -{ - Q_D(const QWaylandXdgSurfaceV5); - return d->m_xdgShell; -} - -/*! - * \qmlproperty WaylandSurface QtWaylandCompositor::XdgSurfaceV5::surface - * - * This property holds the surface associated with this XdgSurfaceV5. - */ - -/*! - * \property QWaylandXdgSurfaceV5::surface - * - * This property holds the surface associated with this QWaylandXdgSurfaceV5. - */ -QWaylandSurface *QWaylandXdgSurfaceV5::surface() const -{ - Q_D(const QWaylandXdgSurfaceV5); - return d->m_surface; -} - -/*! - * \qmlproperty enumeration QtWaylandCompositor::XdgSurfaceV5::windowType - * - * This property holds the window type of the XdgSurfaceV5. - */ - -Qt::WindowType QWaylandXdgSurfaceV5::windowType() const -{ - Q_D(const QWaylandXdgSurfaceV5); - return d->m_windowType; -} - -/*! - * \qmlproperty XdgSurfaceV5 QtWaylandCompositor::XdgSurfaceV5::parentSurface - * - * This property holds the XdgSurfaceV5 parent of this XdgSurfaceV5. - * When a parent surface is set, the parentSurfaceChanged() signal - * is guaranteed to be emitted before setTopLevel() and setTransient(). - * - * \sa QtWaylandCompositor::XdgSurfaceV5::setTopLevel() - * \sa QtWaylandCompositor::XdgSurfaceV5::setTransient() - */ - -/*! - * \property QWaylandXdgSurfaceV5::parentSurface - * - * This property holds the XdgSurfaceV5 parent of this XdgSurfaceV5. - * When a parent surface is set, the parentSurfaceChanged() signal - * is guaranteed to be emitted before setTopLevel() and setTransient(). - * - * \sa QWaylandXdgSurfaceV5::setTopLevel() - * \sa QWaylandXdgSurfaceV5::setTransient() - */ -QWaylandXdgSurfaceV5 *QWaylandXdgSurfaceV5::parentSurface() const -{ - Q_D(const QWaylandXdgSurfaceV5); - return d->m_parentSurface; -} - -/*! - * \qmlproperty string QtWaylandCompositor::XdgSurfaceV5::title - * - * This property holds the title of the XdgSurfaceV5. - */ - -/*! - * \property QWaylandXdgSurfaceV5::title - * - * This property holds the title of the QWaylandXdgSurfaceV5. - */ -QString QWaylandXdgSurfaceV5::title() const -{ - Q_D(const QWaylandXdgSurfaceV5); - return d->m_title; -} - -/*! - * \property QWaylandXdgSurfaceV5::appId - * - * This property holds the app id of the QWaylandXdgSurfaceV5. - */ -QString QWaylandXdgSurfaceV5::appId() const -{ - Q_D(const QWaylandXdgSurfaceV5); - return d->m_appId; -} - -/*! - * \property QWaylandXdgSurfaceV5::windowGeometry - * - * This property holds the window geometry of the QWaylandXdgSurfaceV5. The window - * geometry describes the window's visible bounds from the user's perspective. - * The geometry includes title bars and borders if drawn by the client, but - * excludes drop shadows. It is meant to be used for aligning and tiling - * windows. - */ -QRect QWaylandXdgSurfaceV5::windowGeometry() const -{ - Q_D(const QWaylandXdgSurfaceV5); - return d->m_windowGeometry; -} - -/*! - * \property QWaylandXdgSurfaceV5::states - * - * This property holds the last states the client acknowledged for this QWaylandXdgSurfaceV5. - */ -QVector<uint> QWaylandXdgSurfaceV5::states() const -{ - Q_D(const QWaylandXdgSurfaceV5); - return d->m_lastAckedConfigure.states; -} - -bool QWaylandXdgSurfaceV5::maximized() const -{ - Q_D(const QWaylandXdgSurfaceV5); - return d->m_lastAckedConfigure.states.contains(QWaylandXdgSurfaceV5::State::MaximizedState); -} - -bool QWaylandXdgSurfaceV5::fullscreen() const -{ - Q_D(const QWaylandXdgSurfaceV5); - return d->m_lastAckedConfigure.states.contains(QWaylandXdgSurfaceV5::State::FullscreenState); -} - -bool QWaylandXdgSurfaceV5::resizing() const -{ - Q_D(const QWaylandXdgSurfaceV5); - return d->m_lastAckedConfigure.states.contains(QWaylandXdgSurfaceV5::State::ResizingState); -} - -bool QWaylandXdgSurfaceV5::activated() const -{ - Q_D(const QWaylandXdgSurfaceV5); - return d->m_lastAckedConfigure.states.contains(QWaylandXdgSurfaceV5::State::ActivatedState); -} - -/*! - * Returns the Wayland interface for the QWaylandXdgSurfaceV5. - */ -const wl_interface *QWaylandXdgSurfaceV5::interface() -{ - return QWaylandXdgSurfaceV5Private::interface(); -} - -QByteArray QWaylandXdgSurfaceV5::interfaceName() -{ - return QWaylandXdgSurfaceV5Private::interfaceName(); -} - -/*! - * Returns the surface role for the QWaylandXdgSurfaceV5. - */ -QWaylandSurfaceRole *QWaylandXdgSurfaceV5::role() -{ - return &QWaylandXdgSurfaceV5Private::s_role; -} - -/*! - * Returns the QWaylandXdgSurfaceV5 corresponding to the \a resource. - */ -QWaylandXdgSurfaceV5 *QWaylandXdgSurfaceV5::fromResource(wl_resource *resource) -{ - if (auto p = QtWayland::fromResource<QWaylandXdgSurfaceV5Private *>(resource)) - return p->q_func(); - return nullptr; -} - -QSize QWaylandXdgSurfaceV5::sizeForResize(const QSizeF &size, const QPointF &delta, - QWaylandXdgSurfaceV5::ResizeEdge edge) -{ - qreal width = size.width(); - qreal height = size.height(); - if (edge & LeftEdge) - width -= delta.x(); - else if (edge & RightEdge) - width += delta.x(); - - if (edge & TopEdge) - height -= delta.y(); - else if (edge & BottomEdge) - height += delta.y(); - - QSizeF newSize(qMax(width, 1.0), qMax(height, 1.0)); - return newSize.toSize(); -} - -/*! - * \qmlmethod int QtWaylandCompositor::XdgSurfaceV5::sendConfigure(size size, list<uint> states) - * - * Sends a configure event to the client. \a size contains the pixel size of the surface. - * Known \a states are enumerated in XdgSurfaceV5::State. - */ - -/*! - * Sends a configure event to the client. Parameter \a size contains the pixel size - * of the surface. Known \a states are enumerated in QWaylandXdgSurfaceV5::State. - */ -uint QWaylandXdgSurfaceV5::sendConfigure(const QSize &size, const QVector<uint> &states) -{ - if (!size.isValid()) { - qWarning() << "Can't configure xdg surface (v5) with an invalid size" << size; - return 0; - } - Q_D(QWaylandXdgSurfaceV5); - auto statesBytes = QByteArray::fromRawData((char *)states.data(), states.size() * sizeof(State)); - QWaylandSurface *surface = qobject_cast<QWaylandSurface *>(extensionContainer()); - Q_ASSERT(surface); - QWaylandCompositor *compositor = surface->compositor(); - Q_ASSERT(compositor); - uint32_t serial = compositor->nextSerial(); - d->m_pendingConfigures.append(QWaylandXdgSurfaceV5Private::ConfigureEvent{states, size, serial}); - d->send_configure(size.width(), size.height(), statesBytes, serial); - return serial; -} - -uint QWaylandXdgSurfaceV5::sendConfigure(const QSize &size, const QVector<QWaylandXdgSurfaceV5::State> &states) -{ - QVector<uint> asUints; - asUints.reserve(states.size()); - for (QWaylandXdgSurfaceV5::State state : states) { - asUints << state; - } - return sendConfigure(size, asUints); -} - -/*! - * \qmlmethod void QtWaylandCompositor::XdgSurfaceV5::sendClose() - * - * Sends a close event to the client. - */ - -/*! - * Sends a close event to the client. - */ -void QWaylandXdgSurfaceV5::sendClose() -{ - Q_D(QWaylandXdgSurfaceV5); - d->send_close(); -} - -uint QWaylandXdgSurfaceV5::sendMaximized(const QSize &size) -{ - Q_D(QWaylandXdgSurfaceV5); - QWaylandXdgSurfaceV5Private::ConfigureEvent conf = d->lastSentConfigure(); - - if (!conf.states.contains(QWaylandXdgSurfaceV5::State::MaximizedState)) - conf.states.append(QWaylandXdgSurfaceV5::State::MaximizedState); - conf.states.removeOne(QWaylandXdgSurfaceV5::State::FullscreenState); - conf.states.removeOne(QWaylandXdgSurfaceV5::State::ResizingState); - - return sendConfigure(size, conf.states); -} - -uint QWaylandXdgSurfaceV5::sendUnmaximized(const QSize &size) -{ - Q_D(QWaylandXdgSurfaceV5); - QWaylandXdgSurfaceV5Private::ConfigureEvent conf = d->lastSentConfigure(); - - conf.states.removeOne(QWaylandXdgSurfaceV5::State::MaximizedState); - conf.states.removeOne(QWaylandXdgSurfaceV5::State::FullscreenState); - conf.states.removeOne(QWaylandXdgSurfaceV5::State::ResizingState); - - return sendConfigure(size, conf.states); -} - -uint QWaylandXdgSurfaceV5::sendFullscreen(const QSize &size) -{ - Q_D(QWaylandXdgSurfaceV5); - QWaylandXdgSurfaceV5Private::ConfigureEvent conf = d->lastSentConfigure(); - - if (!conf.states.contains(QWaylandXdgSurfaceV5::State::FullscreenState)) - conf.states.append(QWaylandXdgSurfaceV5::State::FullscreenState); - conf.states.removeOne(QWaylandXdgSurfaceV5::State::MaximizedState); - conf.states.removeOne(QWaylandXdgSurfaceV5::State::ResizingState); - - return sendConfigure(size, conf.states); -} - -uint QWaylandXdgSurfaceV5::sendResizing(const QSize &maxSize) -{ - Q_D(QWaylandXdgSurfaceV5); - QWaylandXdgSurfaceV5Private::ConfigureEvent conf = d->lastSentConfigure(); - - if (!conf.states.contains(QWaylandXdgSurfaceV5::State::ResizingState)) - conf.states.append(QWaylandXdgSurfaceV5::State::ResizingState); - conf.states.removeOne(QWaylandXdgSurfaceV5::State::MaximizedState); - conf.states.removeOne(QWaylandXdgSurfaceV5::State::FullscreenState); - - return sendConfigure(maxSize, conf.states); -} - -#if QT_CONFIG(wayland_compositor_quick) -QWaylandQuickShellIntegration *QWaylandXdgSurfaceV5::createIntegration(QWaylandQuickShellSurfaceItem *item) -{ - return new QtWayland::XdgShellV5Integration(item); -} -#endif - -/*! - * \qmltype XdgPopupV5 - * \inqmlmodule QtWayland.Compositor - * \since 5.8 - * \brief Provides a \c xdg_popup interface that implements popup features for the xdg-shell protocol. - * - * This type is part of the \l{XdgShellV5} extension and provides a way to extend - * the functionality of an existing WaylandSurface for handling popup surfaces created by clients - * using xdg-shell. - * - * It corresponds to the Wayland interface \c xdg_popup for the unstable xdg-shell protocol v5. - * - * \deprecated - */ - -/*! - * \class QWaylandXdgPopupV5 - * \inmodule QtWaylandCompositor - * \since 5.8 - * \brief The QWaylandXdgPopupV5 class provides menus for an xdg surface. - * - * This class is part of the QWaylandXdgShellV5 extension and provides a way to - * extend the functionality of an existing QWaylandSurface with features - * specific to desktop-style menus for an xdg surface. - * - * It corresponds to the Wayland interface xdg_popup. - * - * \deprecated - */ - -/*! - * Constructs a QWaylandXdgPopupV5. - */ -QWaylandXdgPopupV5::QWaylandXdgPopupV5() - : QWaylandShellSurfaceTemplate<QWaylandXdgPopupV5>(*new QWaylandXdgPopupV5Private) -{ -} - -/*! - * Constructs a QWaylandXdgPopupV5, associating it with \a xdgShell at the specified \a position - * for \a surface, and initializes it with the given \a parentSurface and \a resource. - */ -QWaylandXdgPopupV5::QWaylandXdgPopupV5(QWaylandXdgShellV5 *xdgShell, QWaylandSurface *surface, - QWaylandSurface *parentSurface, const QPoint &position, const QWaylandResource &resource) - : QWaylandShellSurfaceTemplate<QWaylandXdgPopupV5>(*new QWaylandXdgPopupV5Private) -{ - initialize(xdgShell, surface, parentSurface, position, resource); -} - -/*! - * \qmlmethod void QtWaylandCompositor::XdgPopupV5::initialize(XdgShellV5 shell, WaylandSurface surface, WaylandSurface parentSurface, point position, WaylandResource resource) - * - * Initializes the xdg popup, associating it with the given \a shell, \a surface, - * \a parentSurface, \a position and \a resource. - */ - -/*! - * Initializes the QWaylandXdgPopupV5, associating it with the given \a shell, \a surface, - * \a parentSurface, \a position, and \a resource. - */ -void QWaylandXdgPopupV5::initialize(QWaylandXdgShellV5 *shell, QWaylandSurface *surface, QWaylandSurface *parentSurface, - const QPoint& position, const QWaylandResource &resource) -{ - Q_D(QWaylandXdgPopupV5); - d->m_surface = surface; - d->m_parentSurface = parentSurface; - d->m_xdgShell = shell; - d->m_position = position; - d->init(resource.resource()); - setExtensionContainer(surface); - emit shellChanged(); - emit surfaceChanged(); - emit parentSurfaceChanged(); - emit positionChanged(); - QWaylandCompositorExtension::initialize(); -} - -/*! - * \qmlproperty XdgShellV5 QtWaylandCompositor::XdgPopupV5::shell - * - * This property holds the shell associated with this XdgPopupV5. - */ - -/*! - * \property QWaylandXdgPopupV5::shell - * - * This property holds the shell associated with this QWaylandXdgPopupV5. - */ -QWaylandXdgShellV5 *QWaylandXdgPopupV5::shell() const -{ - Q_D(const QWaylandXdgPopupV5); - return d->m_xdgShell; -} - -/*! - * \qmlproperty WaylandSurface QtWaylandCompositor::XdgPopupV5::surface - * - * This property holds the surface associated with this XdgPopupV5. - */ - -/*! - * \property QWaylandXdgPopupV5::surface - * - * This property holds the surface associated with this QWaylandXdgPopupV5. - */ -QWaylandSurface *QWaylandXdgPopupV5::surface() const -{ - Q_D(const QWaylandXdgPopupV5); - return d->m_surface; -} - -/*! - * \qmlproperty WaylandSurface QtWaylandCompositor::XdgPopupV5::parentSurface - * - * This property holds the surface associated with the parent of this XdgPopupV5. - */ - -/*! - * \property QWaylandXdgPopupV5::parentSurface - * - * This property holds the surface associated with the parent of this - * QWaylandXdgPopupV5. - */ -QWaylandSurface *QWaylandXdgPopupV5::parentSurface() const -{ - Q_D(const QWaylandXdgPopupV5); - return d->m_parentSurface; -} - - -/*! - * \qmlproperty point QtWaylandCompositor::XdgPopupV5::position - * - * This property holds the location of the upper left corner of the surface - * relative to the upper left corner of the parent surface, in surface local - * coordinates. - */ - -/*! - * \property QWaylandXdgPopupV5::position - * - * This property holds the location of the upper left corner of the surface - * relative to the upper left corner of the parent surface, in surface local - * coordinates. - */ -QPoint QWaylandXdgPopupV5::position() const -{ - Q_D(const QWaylandXdgPopupV5); - return d->m_position; -} - -/*! - * \internal - */ -void QWaylandXdgPopupV5::initialize() -{ - QWaylandCompositorExtension::initialize(); -} - -/*! - * Returns the Wayland interface for the QWaylandXdgPopupV5. - */ -const wl_interface *QWaylandXdgPopupV5::interface() -{ - return QWaylandXdgPopupV5Private::interface(); -} - -QByteArray QWaylandXdgPopupV5::interfaceName() -{ - return QWaylandXdgPopupV5Private::interfaceName(); -} - -/*! - * Returns the surface role for the QWaylandXdgPopupV5. - */ -QWaylandSurfaceRole *QWaylandXdgPopupV5::role() -{ - return &QWaylandXdgPopupV5Private::s_role; -} - -QWaylandXdgPopupV5 *QWaylandXdgPopupV5::fromResource(wl_resource *resource) -{ - if (auto p = QtWayland::fromResource<QWaylandXdgPopupV5Private *>(resource)) - return p->q_func(); - return nullptr; -} - -void QWaylandXdgPopupV5::sendPopupDone() -{ - Q_D(QWaylandXdgPopupV5); - d->send_popup_done(); -} - -#if QT_CONFIG(wayland_compositor_quick) -QWaylandQuickShellIntegration *QWaylandXdgPopupV5::createIntegration(QWaylandQuickShellSurfaceItem *item) -{ - return new QtWayland::XdgPopupV5Integration(item); -} -#endif - -QT_END_NAMESPACE diff --git a/src/compositor/extensions/qwaylandxdgshellv5.h b/src/compositor/extensions/qwaylandxdgshellv5.h deleted file mode 100644 index d0fba5f69..000000000 --- a/src/compositor/extensions/qwaylandxdgshellv5.h +++ /dev/null @@ -1,252 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QWAYLANDXDGSHELLV5_H -#define QWAYLANDXDGSHELLV5_H - -#include <QtWaylandCompositor/QWaylandCompositorExtension> -#include <QtWaylandCompositor/QWaylandResource> -#include <QtWaylandCompositor/QWaylandShell> -#include <QtWaylandCompositor/QWaylandShellSurface> -#include <QtWaylandCompositor/qwaylandquickchildren.h> - -#include <QtCore/QRect> - -struct wl_resource; - -QT_BEGIN_NAMESPACE - -class QWaylandXdgShellV5Private; -class QWaylandXdgSurfaceV5; -class QWaylandXdgSurfaceV5Private; -class QWaylandXdgPopupV5; -class QWaylandXdgPopupV5Private; - -class QWaylandSurface; -class QWaylandSurfaceRole; -class QWaylandSeat; -class QWaylandOutput; -class QWaylandClient; - -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgShellV5 : public QWaylandShellTemplate<QWaylandXdgShellV5> -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QWaylandXdgShellV5) -public: - QWaylandXdgShellV5(); - QWaylandXdgShellV5(QWaylandCompositor *compositor); - - void initialize() override; - QWaylandClient *popupClient() const; - - static const struct wl_interface *interface(); - static QByteArray interfaceName(); - -public Q_SLOTS: - uint ping(QWaylandClient *client); - void closeAllPopups(); - -Q_SIGNALS: - void xdgSurfaceRequested(QWaylandSurface *surface, const QWaylandResource &resource); - void xdgSurfaceCreated(QWaylandXdgSurfaceV5 *xdgSurface); - void xdgPopupCreated(QWaylandXdgPopupV5 *xdgPopup); - void xdgPopupRequested(QWaylandSurface *surface, QWaylandSurface *parent, QWaylandSeat *seat, const QPoint &position, const QWaylandResource &resource); - void pong(uint serial); - -private Q_SLOTS: - void handleSeatChanged(QWaylandSeat *newSeat, QWaylandSeat *oldSeat); - void handleFocusChanged(QWaylandSurface *newSurface, QWaylandSurface *oldSurface); - -}; - -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgSurfaceV5 : public QWaylandShellSurfaceTemplate<QWaylandXdgSurfaceV5> -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QWaylandXdgSurfaceV5) - Q_WAYLAND_COMPOSITOR_DECLARE_QUICK_CHILDREN(QWaylandXdgSurfaceV5) - Q_PROPERTY(QWaylandXdgShellV5 *shell READ shell NOTIFY shellChanged) - Q_PROPERTY(QWaylandSurface *surface READ surface NOTIFY surfaceChanged) - Q_PROPERTY(QWaylandXdgSurfaceV5 *parentSurface READ parentSurface NOTIFY parentSurfaceChanged) - Q_PROPERTY(QString title READ title NOTIFY titleChanged) - Q_PROPERTY(QString appId READ appId NOTIFY appIdChanged) - Q_PROPERTY(QRect windowGeometry READ windowGeometry NOTIFY windowGeometryChanged) - - Q_PROPERTY(QList<int> states READ statesAsInts NOTIFY statesChanged) - Q_PROPERTY(bool maximized READ maximized NOTIFY maximizedChanged) - Q_PROPERTY(bool fullscreen READ fullscreen NOTIFY fullscreenChanged) - Q_PROPERTY(bool resizing READ resizing NOTIFY resizingChanged) - Q_PROPERTY(bool activated READ activated NOTIFY activatedChanged) - -public: - enum State : uint { - MaximizedState = 1, - FullscreenState = 2, - ResizingState = 3, - ActivatedState = 4 - }; - Q_ENUM(State) - - enum ResizeEdge : uint { - NoneEdge = 0, - TopEdge = 1, - BottomEdge = 2, - LeftEdge = 4, - TopLeftEdge = 5, - BottomLeftEdge = 6, - RightEdge = 8, - TopRightEdge = 9, - BottomRightEdge = 10 - }; - Q_ENUM(ResizeEdge) - - QWaylandXdgSurfaceV5(); - QWaylandXdgSurfaceV5(QWaylandXdgShellV5* xdgShell, QWaylandSurface *surface, const QWaylandResource &resource); - - Q_INVOKABLE void initialize(QWaylandXdgShellV5* xdgShell, QWaylandSurface *surface, const QWaylandResource &resource); - - Qt::WindowType windowType() const override; - - QString title() const; - QString appId() const; - QRect windowGeometry() const; - QVector<uint> states() const; - bool maximized() const; - bool fullscreen() const; - bool resizing() const; - bool activated() const; - - QWaylandXdgShellV5 *shell() const; - - QWaylandSurface *surface() const; - QWaylandXdgSurfaceV5 *parentSurface() const; - - static const struct wl_interface *interface(); - static QByteArray interfaceName(); - static QWaylandSurfaceRole *role(); - static QWaylandXdgSurfaceV5 *fromResource(::wl_resource *resource); - - Q_INVOKABLE QSize sizeForResize(const QSizeF &size, const QPointF &delta, ResizeEdge edge); - Q_INVOKABLE uint sendConfigure(const QSize &size, const QVector<uint> &states); - Q_INVOKABLE uint sendConfigure(const QSize &size, const QVector<State> &states); - Q_INVOKABLE void sendClose(); - - Q_INVOKABLE uint sendMaximized(const QSize &size); - Q_INVOKABLE uint sendUnmaximized(const QSize &size = QSize(0, 0)); - Q_INVOKABLE uint sendFullscreen(const QSize &size); - Q_INVOKABLE uint sendResizing(const QSize &maxSize); - -#if QT_CONFIG(wayland_compositor_quick) - QWaylandQuickShellIntegration *createIntegration(QWaylandQuickShellSurfaceItem *item) override; -#endif - -Q_SIGNALS: - void shellChanged(); - void surfaceChanged(); - void titleChanged(); - void windowGeometryChanged(); - void appIdChanged(); - void parentSurfaceChanged(); - - void statesChanged(); - void maximizedChanged(); - void fullscreenChanged(); - void resizingChanged(); - void activatedChanged(); - - void showWindowMenu(QWaylandSeat *seat, const QPoint &localSurfacePosition); - void startMove(QWaylandSeat *seat); - void startResize(QWaylandSeat *seat, ResizeEdge edges); - void setTopLevel(); - void setTransient(); - void setMaximized(); - void unsetMaximized(); - void setFullscreen(QWaylandOutput *output); - void unsetFullscreen(); - void setMinimized(); - void ackConfigure(uint serial); - -private: - void initialize() override; - QList<int> statesAsInts() const; - -private Q_SLOTS: - void handleSurfaceSizeChanged(); - void handleBufferScaleChanged(); -}; - -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgPopupV5 : public QWaylandShellSurfaceTemplate<QWaylandXdgPopupV5> -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QWaylandXdgPopupV5) - Q_WAYLAND_COMPOSITOR_DECLARE_QUICK_CHILDREN(QWaylandXdgPopupV5) - Q_PROPERTY(QWaylandXdgShellV5 *shell READ shell NOTIFY shellChanged) - Q_PROPERTY(QWaylandSurface *surface READ surface NOTIFY surfaceChanged) - Q_PROPERTY(QWaylandSurface *parentSurface READ parentSurface NOTIFY parentSurfaceChanged) - Q_PROPERTY(QPoint position READ position NOTIFY positionChanged) - -public: - QWaylandXdgPopupV5(); - QWaylandXdgPopupV5(QWaylandXdgShellV5 *xdgShell, QWaylandSurface *surface, QWaylandSurface *parentSurface, - const QPoint &position, const QWaylandResource &resource); - - Qt::WindowType windowType() const override { return Qt::WindowType::Popup; } - - Q_INVOKABLE void initialize(QWaylandXdgShellV5 *shell, QWaylandSurface *surface, - QWaylandSurface *parentSurface, const QPoint &position, const QWaylandResource &resource); - - QWaylandXdgShellV5 *shell() const; - - QWaylandSurface *surface() const; - QWaylandSurface *parentSurface() const; - QPoint position() const; - - static const struct wl_interface *interface(); - static QByteArray interfaceName(); - static QWaylandSurfaceRole *role(); - static QWaylandXdgPopupV5 *fromResource(::wl_resource *resource); - - Q_INVOKABLE void sendPopupDone(); - -#if QT_CONFIG(wayland_compositor_quick) - QWaylandQuickShellIntegration *createIntegration(QWaylandQuickShellSurfaceItem *item) override; -#endif - -Q_SIGNALS: - void shellChanged(); - void surfaceChanged(); - void parentSurfaceChanged(); - void positionChanged(); - -private: - void initialize() override; -}; - -QT_END_NAMESPACE - -#endif /*QWAYLANDXDGSHELLV5_H*/ diff --git a/src/compositor/extensions/qwaylandxdgshellv5_p.h b/src/compositor/extensions/qwaylandxdgshellv5_p.h deleted file mode 100644 index 9aaad65b5..000000000 --- a/src/compositor/extensions/qwaylandxdgshellv5_p.h +++ /dev/null @@ -1,173 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QWAYLANDXDGSHELLV5_P_H -#define QWAYLANDXDGSHELLV5_P_H - -#include <QtWaylandCompositor/private/qwaylandcompositorextension_p.h> -#include <QtWaylandCompositor/private/qwaylandshell_p.h> -#include <QtWaylandCompositor/private/qwayland-server-xdg-shell-unstable-v5_p.h> - -#include <QtWaylandCompositor/QWaylandXdgShellV5> - -#include <QtCore/QSet> - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -QT_BEGIN_NAMESPACE - -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgShellV5Private - : public QWaylandShellPrivate - , public QtWaylandServer::xdg_shell_v5 -{ - Q_DECLARE_PUBLIC(QWaylandXdgShellV5) -public: - QWaylandXdgShellV5Private(); - void ping(Resource *resource, uint32_t serial); - void registerSurface(QWaylandXdgSurfaceV5 *xdgSurface); - void unregisterXdgSurface(QWaylandXdgSurfaceV5 *xdgSurface); - void registerXdgPopup(QWaylandXdgPopupV5 *xdgPopup); - void unregisterXdgPopup(QWaylandXdgPopupV5 *xdgPopup); - static QWaylandXdgShellV5Private *get(QWaylandXdgShellV5 *xdgShell) { return xdgShell->d_func(); } - bool isValidPopupParent(QWaylandSurface *parentSurface) const; - QWaylandXdgPopupV5 *topmostPopupForClient(struct wl_client* client) const; - - QSet<uint32_t> m_pings; - QMultiMap<struct wl_client *, QWaylandXdgSurfaceV5 *> m_xdgSurfaces; - QMultiMap<struct wl_client *, QWaylandXdgPopupV5 *> m_xdgPopups; - - QWaylandXdgSurfaceV5 *xdgSurfaceFromSurface(QWaylandSurface *surface) const; - -protected: - void xdg_shell_destroy(Resource *resource) override; - void xdg_shell_get_xdg_surface(Resource *resource, uint32_t id, - struct ::wl_resource *surface) override; - void xdg_shell_use_unstable_version(Resource *resource, int32_t version) override; - void xdg_shell_get_xdg_popup(Resource *resource, uint32_t id, struct ::wl_resource *surface, - struct ::wl_resource *parent, struct ::wl_resource *seatResource, - uint32_t serial, int32_t x, int32_t y) override; - void xdg_shell_pong(Resource *resource, uint32_t serial) override; -}; - -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgSurfaceV5Private - : public QWaylandCompositorExtensionPrivate - , public QtWaylandServer::xdg_surface_v5 -{ - Q_DECLARE_PUBLIC(QWaylandXdgSurfaceV5) -public: - QWaylandXdgSurfaceV5Private(); - static QWaylandXdgSurfaceV5Private *get(QWaylandXdgSurfaceV5 *xdgSurface) { return xdgSurface->d_func(); } - - struct ConfigureEvent { - QVector<uint> states; - QSize size; - uint serial; - }; - - void handleFocusLost(); - void handleFocusReceived(); - QRect calculateFallbackWindowGeometry() const; - void updateFallbackWindowGeometry(); - - void setWindowType(Qt::WindowType windowType); - -private: - QWaylandXdgShellV5 *m_xdgShell = nullptr; - QWaylandSurface *m_surface = nullptr; - QWaylandXdgSurfaceV5 *m_parentSurface = nullptr; - - Qt::WindowType m_windowType = Qt::WindowType::Window; - - QString m_title; - QString m_appId; - QRect m_windowGeometry; - bool m_unsetWindowGeometry = true; - - QList<ConfigureEvent> m_pendingConfigures; - ConfigureEvent m_lastAckedConfigure; - ConfigureEvent lastSentConfigure() const { return m_pendingConfigures.empty() ? m_lastAckedConfigure : m_pendingConfigures.first(); } - - void xdg_surface_destroy_resource(Resource *resource) override; - - void xdg_surface_destroy(Resource *resource) override; - void xdg_surface_move(Resource *resource, struct ::wl_resource *seat, - uint32_t serial) override; - void xdg_surface_resize(Resource *resource, struct ::wl_resource *seat, uint32_t serial, - uint32_t edges) override; - void xdg_surface_set_maximized(Resource *resource) override; - void xdg_surface_unset_maximized(Resource *resource) override; - void xdg_surface_set_fullscreen(Resource *resource, - struct ::wl_resource *output) override; - void xdg_surface_unset_fullscreen(Resource *resource) override; - void xdg_surface_set_minimized(Resource *resource) override; - void xdg_surface_set_parent(Resource *resource, struct ::wl_resource *parent) override; - void xdg_surface_set_app_id(Resource *resource, const QString &app_id) override; - void xdg_surface_show_window_menu(Resource *resource, struct ::wl_resource *seatResource, - uint32_t serial, int32_t x, int32_t y) override; - void xdg_surface_ack_configure(Resource *resource, uint32_t serial) override; - void xdg_surface_set_title(Resource *resource, const QString &title) override; - void xdg_surface_set_window_geometry(Resource *resource, int32_t x, int32_t y, - int32_t width, int32_t height) override; - - static QWaylandSurfaceRole s_role; -}; - -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgPopupV5Private - : public QWaylandCompositorExtensionPrivate - , public QtWaylandServer::xdg_popup_v5 -{ - Q_DECLARE_PUBLIC(QWaylandXdgPopupV5) - -public: - QWaylandXdgPopupV5Private(); - static QWaylandXdgPopupV5Private *get(QWaylandXdgPopupV5 *xdgPopup) { return xdgPopup->d_func(); } - - QWaylandSurface *m_surface = nullptr; - QWaylandSurface *m_parentSurface = nullptr; - QWaylandXdgShellV5 *m_xdgShell = nullptr; - QPoint m_position; - - void xdg_popup_destroy_resource(Resource *resource) override; - void xdg_popup_destroy(xdg_popup_v5::Resource *resource) override; - - static QWaylandSurfaceRole s_role; -}; - -QT_END_NAMESPACE - -#endif // QWAYLANDXDGSHELLV5_P_H diff --git a/src/compositor/extensions/qwaylandxdgshellv5integration.cpp b/src/compositor/extensions/qwaylandxdgshellv5integration.cpp deleted file mode 100644 index cbb61d3bd..000000000 --- a/src/compositor/extensions/qwaylandxdgshellv5integration.cpp +++ /dev/null @@ -1,249 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qwaylandxdgshellv5integration_p.h" - -#include <QtWaylandCompositor/QWaylandQuickShellSurfaceItem> -#include <QtWaylandCompositor/QWaylandCompositor> -#include <QtWaylandCompositor/QWaylandSeat> -#include <QtWaylandCompositor/private/qwaylandxdgshellv5_p.h> -#include <QMouseEvent> -#include <QGuiApplication> - -QT_BEGIN_NAMESPACE - -namespace QtWayland { - -static void handlePopupCreated(QWaylandQuickShellSurfaceItem *parentItem, QWaylandXdgPopupV5 *popup) -{ - if (parentItem->surface() == popup->parentSurface()) - QWaylandQuickShellSurfaceItemPrivate::get(parentItem)->maybeCreateAutoPopup(popup); -} - -XdgShellV5Integration::XdgShellV5Integration(QWaylandQuickShellSurfaceItem *item) - : QWaylandQuickShellIntegration(item) - , m_item(item) - , m_xdgSurface(qobject_cast<QWaylandXdgSurfaceV5 *>(item->shellSurface())) - , grabberState(GrabberState::Default) -{ - m_item->setSurface(m_xdgSurface->surface()); - connect(m_xdgSurface, &QWaylandXdgSurfaceV5::startMove, this, &XdgShellV5Integration::handleStartMove); - connect(m_xdgSurface, &QWaylandXdgSurfaceV5::startResize, this, &XdgShellV5Integration::handleStartResize); - connect(m_xdgSurface, &QWaylandXdgSurfaceV5::setTopLevel, this, &XdgShellV5Integration::handleSetTopLevel); - connect(m_xdgSurface, &QWaylandXdgSurfaceV5::setTransient, this, &XdgShellV5Integration::handleSetTransient); - connect(m_xdgSurface, &QWaylandXdgSurfaceV5::setMaximized, this, &XdgShellV5Integration::handleSetMaximized); - connect(m_xdgSurface, &QWaylandXdgSurfaceV5::unsetMaximized, this, &XdgShellV5Integration::handleUnsetMaximized); - connect(m_xdgSurface, &QWaylandXdgSurfaceV5::maximizedChanged, this, &XdgShellV5Integration::handleMaximizedChanged); - connect(m_xdgSurface, &QWaylandXdgSurfaceV5::activatedChanged, this, &XdgShellV5Integration::handleActivatedChanged); - connect(m_xdgSurface->surface(), &QWaylandSurface::destinationSizeChanged, this, &XdgShellV5Integration::handleSurfaceSizeChanged); - connect(m_xdgSurface->shell(), &QWaylandXdgShellV5::xdgPopupCreated, this, [item](QWaylandXdgPopupV5 *popup){ - handlePopupCreated(item, popup); - }); -} - -XdgShellV5Integration::~XdgShellV5Integration() -{ - m_item->setSurface(nullptr); -} - -bool XdgShellV5Integration::eventFilter(QObject *object, QEvent *event) -{ - if (event->type() == QEvent::MouseMove) { - QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event); - return filterMouseMoveEvent(mouseEvent); - } else if (event->type() == QEvent::MouseButtonRelease) { - QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event); - return filterMouseReleaseEvent(mouseEvent); - } - return QWaylandQuickShellIntegration::eventFilter(object, event); -} - -bool XdgShellV5Integration::filterMouseMoveEvent(QMouseEvent *event) -{ - if (grabberState == GrabberState::Resize) { - Q_ASSERT(resizeState.seat == m_item->compositor()->seatFor(event)); - if (!resizeState.initialized) { - resizeState.initialMousePos = event->windowPos(); - resizeState.initialized = true; - return true; - } - QPointF delta = m_item->mapToSurface(event->windowPos() - resizeState.initialMousePos); - QSize newSize = m_xdgSurface->sizeForResize(resizeState.initialWindowSize, delta, resizeState.resizeEdges); - m_xdgSurface->sendResizing(newSize); - } else if (grabberState == GrabberState::Move) { - Q_ASSERT(moveState.seat == m_item->compositor()->seatFor(event)); - QQuickItem *moveItem = m_item->moveItem(); - if (!moveState.initialized) { - moveState.initialOffset = moveItem->mapFromItem(nullptr, event->windowPos()); - moveState.initialized = true; - return true; - } - if (!moveItem->parentItem()) - return true; - QPointF parentPos = moveItem->parentItem()->mapFromItem(nullptr, event->windowPos()); - moveItem->setPosition(parentPos - moveState.initialOffset); - } - return false; -} - -bool XdgShellV5Integration::filterMouseReleaseEvent(QMouseEvent *event) -{ - Q_UNUSED(event); - - if (grabberState == GrabberState::Resize) { - m_xdgSurface->sendUnmaximized(); - grabberState = GrabberState::Default; - return true; - } else if (grabberState == GrabberState::Move) { - grabberState = GrabberState::Default; - return true; - } - return false; -} - -void XdgShellV5Integration::handleStartMove(QWaylandSeat *seat) -{ - grabberState = GrabberState::Move; - moveState.seat = seat; - moveState.initialized = false; -} - -void XdgShellV5Integration::handleStartResize(QWaylandSeat *seat, QWaylandXdgSurfaceV5::ResizeEdge edges) -{ - grabberState = GrabberState::Resize; - resizeState.seat = seat; - resizeState.resizeEdges = edges; - resizeState.initialWindowSize = m_xdgSurface->windowGeometry().size(); - resizeState.initialPosition = m_item->moveItem()->position(); - resizeState.initialSurfaceSize = m_item->surface()->destinationSize(); - resizeState.initialized = false; -} - -void XdgShellV5Integration::handleSetTopLevel() -{ - if (m_xdgSurface->shell()->focusPolicy() == QWaylandShell::AutomaticFocus) - m_item->takeFocus(); -} - -void XdgShellV5Integration::handleSetTransient() -{ - if (m_xdgSurface->shell()->focusPolicy() == QWaylandShell::AutomaticFocus) - m_item->takeFocus(); -} - -void XdgShellV5Integration::handleSetMaximized() -{ - if (!m_item->view()->isPrimary()) - return; - - maximizeState.initialWindowSize = m_xdgSurface->windowGeometry().size(); - maximizeState.initialPosition = m_item->moveItem()->position(); - - QWaylandOutput *output = m_item->view()->output(); - m_xdgSurface->sendMaximized(output->availableGeometry().size() / output->scaleFactor()); -} - -void XdgShellV5Integration::handleUnsetMaximized() -{ - if (!m_item->view()->isPrimary()) - return; - - m_xdgSurface->sendUnmaximized(maximizeState.initialWindowSize); -} - -void XdgShellV5Integration::handleMaximizedChanged() -{ - if (m_xdgSurface->maximized()) { - QWaylandOutput *output = m_item->view()->output(); - m_item->moveItem()->setPosition(output->position() + output->availableGeometry().topLeft()); - } else { - m_item->moveItem()->setPosition(maximizeState.initialPosition); - } -} - -void XdgShellV5Integration::handleActivatedChanged() -{ - if (m_xdgSurface->activated()) - m_item->raise(); -} - -void XdgShellV5Integration::handleSurfaceSizeChanged() -{ - if (grabberState == GrabberState::Resize) { - qreal dx = 0; - qreal dy = 0; - if (resizeState.resizeEdges & QWaylandXdgSurfaceV5::ResizeEdge::TopEdge) - dy = resizeState.initialSurfaceSize.height() - m_item->surface()->destinationSize().height(); - if (resizeState.resizeEdges & QWaylandXdgSurfaceV5::ResizeEdge::LeftEdge) - dx = resizeState.initialSurfaceSize.width() - m_item->surface()->destinationSize().width(); - QPointF offset = m_item->mapFromSurface({dx, dy}); - m_item->moveItem()->setPosition(resizeState.initialPosition + offset); - } -} - -XdgPopupV5Integration::XdgPopupV5Integration(QWaylandQuickShellSurfaceItem *item) - : QWaylandQuickShellIntegration (item) - , m_item(item) - , m_xdgPopup(qobject_cast<QWaylandXdgPopupV5 *>(item->shellSurface())) - , m_xdgShell(QWaylandXdgPopupV5Private::get(m_xdgPopup)->m_xdgShell) -{ - item->setSurface(m_xdgPopup->surface()); - if (item->view()->output()) { - QPoint position = item->mapFromSurface(m_xdgPopup->position()).toPoint(); - item->moveItem()->setPosition(position); - } else { - qWarning() << "XdgPopupV5Integration popup item without output" << item; - } - - QWaylandClient *client = m_xdgPopup->surface()->client(); - auto shell = m_xdgShell; - QWaylandQuickShellEventFilter::startFilter(client, [shell]() { shell->closeAllPopups(); }); - - connect(m_xdgPopup, &QWaylandXdgPopupV5::destroyed, this, &XdgPopupV5Integration::handlePopupDestroyed); - connect(m_xdgPopup->shell(), &QWaylandXdgShellV5::xdgPopupCreated, this, [item](QWaylandXdgPopupV5 *popup) { - handlePopupCreated(item, popup); - }); -} - -XdgPopupV5Integration::~XdgPopupV5Integration() -{ - m_item->setSurface(nullptr); -} - -void XdgPopupV5Integration::handlePopupDestroyed() -{ - QWaylandXdgShellV5Private *shellPrivate = QWaylandXdgShellV5Private::get(m_xdgShell); - auto popups = shellPrivate->m_xdgPopups; - if (popups.isEmpty()) - QWaylandQuickShellEventFilter::cancelFilter(); -} - -} - -QT_END_NAMESPACE diff --git a/src/compositor/extensions/qwaylandxdgshellv5integration_p.h b/src/compositor/extensions/qwaylandxdgshellv5integration_p.h deleted file mode 100644 index ea4477ba0..000000000 --- a/src/compositor/extensions/qwaylandxdgshellv5integration_p.h +++ /dev/null @@ -1,127 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QWAYLANDXDGSHELLV5INTEGRATION_H -#define QWAYLANDXDGSHELLV5INTEGRATION_H - -#include <QtWaylandCompositor/private/qwaylandquickshellsurfaceitem_p.h> -#include <QtWaylandCompositor/QWaylandXdgSurfaceV5> - -QT_BEGIN_NAMESPACE - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -namespace QtWayland { - -class XdgShellV5Integration : public QWaylandQuickShellIntegration -{ - Q_OBJECT -public: - XdgShellV5Integration(QWaylandQuickShellSurfaceItem *item); - ~XdgShellV5Integration() override; - -protected: - bool eventFilter(QObject *object, QEvent *event) override; - -private Q_SLOTS: - void handleStartMove(QWaylandSeat *seat); - void handleStartResize(QWaylandSeat *seat, QWaylandXdgSurfaceV5::ResizeEdge edges); - void handleSetTopLevel(); - void handleSetTransient(); - void handleSetMaximized(); - void handleUnsetMaximized(); - void handleMaximizedChanged(); - void handleActivatedChanged(); - void handleSurfaceSizeChanged(); - -private: - enum class GrabberState { - Default, - Resize, - Move - }; - QWaylandQuickShellSurfaceItem *m_item = nullptr; - QWaylandXdgSurfaceV5 *m_xdgSurface = nullptr; - - GrabberState grabberState; - struct { - QWaylandSeat *seat = nullptr; - QPointF initialOffset; - bool initialized = false; - } moveState; - - struct { - QWaylandSeat *seat = nullptr; - QWaylandXdgSurfaceV5::ResizeEdge resizeEdges; - QSizeF initialWindowSize; - QPointF initialMousePos; - QPointF initialPosition; - QSize initialSurfaceSize; - bool initialized = false; - } resizeState; - - struct { - QSize initialWindowSize; - QPointF initialPosition; - } maximizeState; - - bool filterMouseMoveEvent(QMouseEvent *event); - bool filterMouseReleaseEvent(QMouseEvent *event); -}; - -class XdgPopupV5Integration : public QWaylandQuickShellIntegration -{ - Q_OBJECT -public: - XdgPopupV5Integration(QWaylandQuickShellSurfaceItem *item); - ~XdgPopupV5Integration() override; - -private Q_SLOTS: - void handlePopupDestroyed(); - -private: - QWaylandQuickShellSurfaceItem *m_item = nullptr; - QWaylandXdgPopupV5 *m_xdgPopup = nullptr; - QWaylandXdgShellV5 *m_xdgShell = nullptr; -}; - -} - -QT_END_NAMESPACE - -#endif // QWAYLANDXDGSHELLV5INTEGRATION_H diff --git a/src/compositor/extensions/qwaylandxdgshellv6.cpp b/src/compositor/extensions/qwaylandxdgshellv6.cpp deleted file mode 100644 index 934dccb06..000000000 --- a/src/compositor/extensions/qwaylandxdgshellv6.cpp +++ /dev/null @@ -1,2033 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** 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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qwaylandxdgshellv6.h" -#include "qwaylandxdgshellv6_p.h" - -#if QT_CONFIG(wayland_compositor_quick) -#include "qwaylandxdgshellv6integration_p.h" -#endif -#include <QtWaylandCompositor/private/qwaylandutils_p.h> - -#include <QtWaylandCompositor/QWaylandCompositor> -#include <QtWaylandCompositor/QWaylandSeat> -#include <QtWaylandCompositor/QWaylandSurface> -#include <QtWaylandCompositor/QWaylandSurfaceRole> -#include <QtWaylandCompositor/QWaylandResource> - -#include <QtCore/QObject> - -#include <algorithm> - -QT_BEGIN_NAMESPACE - -QWaylandXdgShellV6Private::QWaylandXdgShellV6Private() -{ -} - -void QWaylandXdgShellV6Private::ping(QtWaylandServer::zxdg_shell_v6::Resource *resource, uint32_t serial) -{ - m_pings.insert(serial); - send_ping(resource->handle, serial); -} - -void QWaylandXdgShellV6Private::registerXdgSurface(QWaylandXdgSurfaceV6 *xdgSurface) -{ - m_xdgSurfaces.insert(xdgSurface->surface()->client()->client(), xdgSurface); -} - -void QWaylandXdgShellV6Private::unregisterXdgSurface(QWaylandXdgSurfaceV6 *xdgSurface) -{ - auto xdgSurfacePrivate = QWaylandXdgSurfaceV6Private::get(xdgSurface); - if (!m_xdgSurfaces.remove(xdgSurfacePrivate->resource()->client(), xdgSurface)) - qWarning("%s Unexpected state. Can't find registered xdg surface\n", Q_FUNC_INFO); -} - -Qt::Edges QWaylandXdgShellV6Private::convertToEdges(uint xdgEdges) -{ - return Qt::Edges(((xdgEdges & 0b1100) >> 1) | ((xdgEdges & 0b0010) << 2) | (xdgEdges & 0b0001)); -} - -QWaylandXdgSurfaceV6 *QWaylandXdgShellV6Private::xdgSurfaceFromSurface(QWaylandSurface *surface) -{ - for (QWaylandXdgSurfaceV6 *xdgSurface : qAsConst(m_xdgSurfaces)) { - if (surface == xdgSurface->surface()) - return xdgSurface; - } - return nullptr; -} - -void QWaylandXdgShellV6Private::zxdg_shell_v6_destroy(Resource *resource) -{ - if (!m_xdgSurfaces.values(resource->client()).empty()) - wl_resource_post_error(resource->handle, ZXDG_SHELL_V6_ERROR_DEFUNCT_SURFACES, - "xdg_shell was destroyed before children"); - - wl_resource_destroy(resource->handle); -} - -void QWaylandXdgShellV6Private::zxdg_shell_v6_create_positioner(QtWaylandServer::zxdg_shell_v6::Resource *resource, uint32_t id) -{ - QWaylandResource positionerResource(wl_resource_create(resource->client(), &zxdg_positioner_v6_interface, - wl_resource_get_version(resource->handle), id)); - - new QWaylandXdgPositionerV6(positionerResource); -} - -void QWaylandXdgShellV6Private::zxdg_shell_v6_get_xdg_surface(Resource *resource, uint32_t id, wl_resource *surfaceResource) -{ - Q_Q(QWaylandXdgShellV6); - QWaylandSurface *surface = QWaylandSurface::fromResource(surfaceResource); - - if (surface->role() != nullptr) { - wl_resource_post_error(resource->handle, ZXDG_SHELL_V6_ERROR_ROLE, - "wl_surface@%d, already has role %s\n", - wl_resource_get_id(surface->resource()), - surface->role()->name().constData()); - return; - } - - if (surface->hasContent()) { - //TODO: According to the spec, this is a client error, but there's no appropriate error code - qWarning() << "get_xdg_surface requested on a zxdg_surface_v6 with content"; - } - - QWaylandResource xdgSurfaceResource(wl_resource_create(resource->client(), &zxdg_surface_v6_interface, - wl_resource_get_version(resource->handle), id)); - - QWaylandXdgSurfaceV6 *xdgSurface = new QWaylandXdgSurfaceV6(q, surface, xdgSurfaceResource); - - registerXdgSurface(xdgSurface); - emit q->xdgSurfaceCreated(xdgSurface); -} - -void QWaylandXdgShellV6Private::zxdg_shell_v6_pong(Resource *resource, uint32_t serial) -{ - Q_UNUSED(resource); - Q_Q(QWaylandXdgShellV6); - if (m_pings.remove(serial)) - emit q->pong(serial); - else - qWarning("Received an unexpected pong!"); -} - -/*! - * \qmltype XdgShellV6 - * \inqmlmodule QtWayland.Compositor - * \since 5.10 - * \brief Provides an extension for desktop-style user interfaces. - * - * The XdgShellV6 extension provides a way to associate a XdgToplevelV6 or XdgPopupV6 - * with a regular Wayland surface. Using the XdgToplevelV6 interface, the client - * can request that the surface is resized, moved, and so on. - * - * XdgShellV6 corresponds to the Wayland interface, \c zxdg_shell_v6. - * - * To provide the functionality of the shell extension in a compositor, create - * an instance of the XdgShellV6 component and add it to the list of extensions - * supported by the compositor: - * - * \qml \QtMinorVersion - * import QtWayland.Compositor 1.\1 - * - * WaylandCompositor { - * XdgShellV6 { - * // ... - * } - * } - * \endqml - */ - -/*! - * \class QWaylandXdgShellV6 - * \inmodule QtWaylandCompositor - * \since 5.10 - * \brief The QWaylandXdgShellV6 class is an extension for desktop-style user interfaces. - * - * The QWaylandXdgShellV6 extension provides a way to associate a QWaylandXdgToplevelV6 or - * QWaylandXdgPopupV6 with a regular Wayland surface. Using the QWaylandXdgToplevelV6 interface, - * the client can request that the surface is resized, moved, and so on. - * - * QWaylandXdgShellV6 corresponds to the Wayland interface, \c zxdg_shell_v6. - */ - -/*! - * Constructs a QWaylandXdgShellV6 object. - */ -QWaylandXdgShellV6::QWaylandXdgShellV6() - : QWaylandShellTemplate<QWaylandXdgShellV6>(*new QWaylandXdgShellV6Private()) -{ -} - -/*! - * Constructs a QWaylandXdgShellV6 object for the provided \a compositor. - */ -QWaylandXdgShellV6::QWaylandXdgShellV6(QWaylandCompositor *compositor) - : QWaylandShellTemplate<QWaylandXdgShellV6>(compositor, *new QWaylandXdgShellV6Private()) -{ -} - -/*! - * Initializes the shell extension. - */ -void QWaylandXdgShellV6::initialize() -{ - Q_D(QWaylandXdgShellV6); - QWaylandShellTemplate::initialize(); - QWaylandCompositor *compositor = static_cast<QWaylandCompositor *>(extensionContainer()); - if (!compositor) { - qWarning() << "Failed to find QWaylandCompositor when initializing QWaylandXdgShellV6"; - return; - } - d->init(compositor->display(), 1); - - handleSeatChanged(compositor->defaultSeat(), nullptr); - - connect(compositor, &QWaylandCompositor::defaultSeatChanged, - this, &QWaylandXdgShellV6::handleSeatChanged); -} - -/*! - * Returns the Wayland interface for the QWaylandXdgShellV6. - */ -const struct wl_interface *QWaylandXdgShellV6::interface() -{ - return QWaylandXdgShellV6Private::interface(); -} - -QByteArray QWaylandXdgShellV6::interfaceName() -{ - return QWaylandXdgShellV6Private::interfaceName(); -} - -/*! - * \qmlmethod void QtWaylandCompositor::XdgShellV6::ping(WaylandClient client) - * - * Sends a ping event to \a client. If the client replies to the event the - * \l pong signal will be emitted. - */ - -/*! - * Sends a ping event to \a client. If the client replies to the event the - * \l pong signal will be emitted. - */ -uint QWaylandXdgShellV6::ping(QWaylandClient *client) -{ - Q_D(QWaylandXdgShellV6); - - QWaylandCompositor *compositor = static_cast<QWaylandCompositor *>(extensionContainer()); - Q_ASSERT(compositor); - - uint32_t serial = compositor->nextSerial(); - - QWaylandXdgShellV6Private::Resource *clientResource = d->resourceMap().value(client->client(), nullptr); - Q_ASSERT(clientResource); - - d->ping(clientResource, serial); - return serial; -} - -void QWaylandXdgShellV6::handleSeatChanged(QWaylandSeat *newSeat, QWaylandSeat *oldSeat) -{ - if (oldSeat != nullptr) { - disconnect(oldSeat, &QWaylandSeat::keyboardFocusChanged, - this, &QWaylandXdgShellV6::handleFocusChanged); - } - - if (newSeat != nullptr) { - connect(newSeat, &QWaylandSeat::keyboardFocusChanged, - this, &QWaylandXdgShellV6::handleFocusChanged); - } -} - -void QWaylandXdgShellV6::handleFocusChanged(QWaylandSurface *newSurface, QWaylandSurface *oldSurface) -{ - Q_D(QWaylandXdgShellV6); - - QWaylandXdgSurfaceV6 *newXdgSurface = d->xdgSurfaceFromSurface(newSurface); - QWaylandXdgSurfaceV6 *oldXdgSurface = d->xdgSurfaceFromSurface(oldSurface); - - if (newXdgSurface) - QWaylandXdgSurfaceV6Private::get(newXdgSurface)->handleFocusReceived(); - - if (oldXdgSurface) - QWaylandXdgSurfaceV6Private::get(oldXdgSurface)->handleFocusLost(); -} - -QWaylandXdgSurfaceV6Private::QWaylandXdgSurfaceV6Private() -{ -} - -void QWaylandXdgSurfaceV6Private::setWindowType(Qt::WindowType windowType) -{ - if (m_windowType == windowType) - return; - - m_windowType = windowType; - - Q_Q(QWaylandXdgSurfaceV6); - emit q->windowTypeChanged(); -} - -void QWaylandXdgSurfaceV6Private::handleFocusLost() -{ - if (m_toplevel) - QWaylandXdgToplevelV6Private::get(m_toplevel)->handleFocusLost(); -} - -void QWaylandXdgSurfaceV6Private::handleFocusReceived() -{ - if (m_toplevel) - QWaylandXdgToplevelV6Private::get(m_toplevel)->handleFocusReceived(); -} - -QRect QWaylandXdgSurfaceV6Private::calculateFallbackWindowGeometry() const -{ - // TODO: The unset window geometry should include subsurfaces as well, so this solution - // won't work too well on those kinds of clients. - return QRect(QPoint(), m_surface->destinationSize()); -} - -void QWaylandXdgSurfaceV6Private::updateFallbackWindowGeometry() -{ - Q_Q(QWaylandXdgSurfaceV6); - if (!m_unsetWindowGeometry) - return; - - const QRect unsetGeometry = calculateFallbackWindowGeometry(); - if (unsetGeometry == m_windowGeometry) - return; - - m_windowGeometry = unsetGeometry; - emit q->windowGeometryChanged(); -} - -void QWaylandXdgSurfaceV6Private::zxdg_surface_v6_destroy_resource(QtWaylandServer::zxdg_surface_v6::Resource *resource) -{ - Q_UNUSED(resource); - Q_Q(QWaylandXdgSurfaceV6); - QWaylandXdgShellV6Private::get(m_xdgShell)->unregisterXdgSurface(q); - delete q; -} - -void QWaylandXdgSurfaceV6Private::zxdg_surface_v6_destroy(QtWaylandServer::zxdg_surface_v6::Resource *resource) -{ - wl_resource_destroy(resource->handle); -} - -void QWaylandXdgSurfaceV6Private::zxdg_surface_v6_get_toplevel(QtWaylandServer::zxdg_surface_v6::Resource *resource, uint32_t id) -{ - Q_Q(QWaylandXdgSurfaceV6); - - if (m_toplevel || m_popup) { - wl_resource_post_error(resource->handle, ZXDG_SURFACE_V6_ERROR_ALREADY_CONSTRUCTED, - "zxdg_surface_v6 already has a role object"); - return; - } - - if (!m_surface->setRole(QWaylandXdgToplevelV6::role(), resource->handle, ZXDG_SHELL_V6_ERROR_ROLE)) - return; - - QWaylandResource topLevelResource(wl_resource_create(resource->client(), &zxdg_toplevel_v6_interface, - wl_resource_get_version(resource->handle), id)); - - m_toplevel = new QWaylandXdgToplevelV6(q, topLevelResource); - emit q->toplevelCreated(); - emit m_xdgShell->toplevelCreated(m_toplevel, q); -} - -void QWaylandXdgSurfaceV6Private::zxdg_surface_v6_get_popup(QtWaylandServer::zxdg_surface_v6::Resource *resource, uint32_t id, wl_resource *parentResource, wl_resource *positionerResource) -{ - Q_Q(QWaylandXdgSurfaceV6); - - if (m_toplevel || m_popup) { - wl_resource_post_error(resource->handle, ZXDG_SURFACE_V6_ERROR_ALREADY_CONSTRUCTED, - "zxdg_surface_v6 already has a role object"); - return; - } - - QWaylandXdgSurfaceV6 *parent = QWaylandXdgSurfaceV6::fromResource(parentResource); - if (!parent) { - wl_resource_post_error(resource->handle, ZXDG_SHELL_V6_ERROR_INVALID_POPUP_PARENT, - "zxdg_surface_v6.get_popup with invalid popup parent"); - return; - } - - QWaylandXdgPositionerV6 *positioner = QWaylandXdgPositionerV6::fromResource(positionerResource); - if (!positioner) { - wl_resource_post_error(resource->handle, ZXDG_SHELL_V6_ERROR_INVALID_POSITIONER, - "zxdg_surface_v6.get_popup without positioner"); - return; - } - - if (!positioner->m_data.isComplete()) { - QWaylandXdgPositionerV6Data p = positioner->m_data; - wl_resource_post_error(resource->handle, ZXDG_SHELL_V6_ERROR_INVALID_POSITIONER, - "zxdg_surface_v6.get_popup with invalid positioner (size: %dx%d, anchorRect: %dx%d)", - p.size.width(), p.size.height(), p.anchorRect.width(), p.anchorRect.height()); - return; - } - - QRect anchorBounds(QPoint(0, 0), parent->windowGeometry().size()); - if (!anchorBounds.contains(positioner->m_data.anchorRect)) { - // TODO: this is a protocol error and should ideally be handled like this: - //wl_resource_post_error(resource->handle, ZXDG_SHELL_V6_ERROR_INVALID_POSITIONER, - // "zxdg_positioner_v6 anchor rect extends beyound its parent's window geometry"); - //return; - // However, our own clients currently do this, so we'll settle for a gentle warning instead. - qCWarning(qLcWaylandCompositor) << "Ignoring client protocol error: zxdg_positioner_v6 anchor" - << "rect extends beyond its parent's window geometry"; - } - - if (!m_surface->setRole(QWaylandXdgPopupV6::role(), resource->handle, ZXDG_SHELL_V6_ERROR_ROLE)) - return; - - QWaylandResource popupResource(wl_resource_create(resource->client(), &zxdg_popup_v6_interface, - wl_resource_get_version(resource->handle), id)); - - m_popup = new QWaylandXdgPopupV6(q, parent, positioner, popupResource); - emit q->popupCreated(); - emit m_xdgShell->popupCreated(m_popup, q); -} - -void QWaylandXdgSurfaceV6Private::zxdg_surface_v6_ack_configure(QtWaylandServer::zxdg_surface_v6::Resource *resource, uint32_t serial) -{ - if (m_toplevel) { - QWaylandXdgToplevelV6Private::get(m_toplevel)->handleAckConfigure(serial); - } else if (m_popup) { - QWaylandXdgPopupV6Private::get(m_popup)->handleAckConfigure(serial); - } else { - wl_resource_post_error(resource->handle, ZXDG_SURFACE_V6_ERROR_NOT_CONSTRUCTED, - "ack_configure requested on an unconstructed zxdg_surface_v6"); - } -} - -void QWaylandXdgSurfaceV6Private::zxdg_surface_v6_set_window_geometry(QtWaylandServer::zxdg_surface_v6::Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height) -{ - Q_Q(QWaylandXdgSurfaceV6); - - if (!q->surface()->role()) { - wl_resource_post_error(resource->handle, ZXDG_SURFACE_V6_ERROR_NOT_CONSTRUCTED, - "set_window_geometry requested on an unconstructed zxdg_surface_v6"); - return; - } - - if (width <= 0 || height <= 0) { - // The protocol spec says "setting an invalid size will raise an error". But doesn't tell - // which error to raise, and there's no fitting error in the zxdg_surface_v6_error enum. - // So until this is fixed, just output a warning and return. - qWarning() << "Invalid (non-positive) dimensions received in set_window_geometry"; - return; - } - - m_unsetWindowGeometry = false; - - QRect geometry(x, y, width, height); - - if (m_windowGeometry == geometry) - return; - - m_windowGeometry = geometry; - emit q->windowGeometryChanged(); -} - -/*! - * \qmltype XdgSurfaceV6 - * \inqmlmodule QtWayland.Compositor - * \since 5.10 - * \brief XdgSurfaceV6 provides desktop-style compositor-specific features to an xdg surface. - * - * This type is part of the \l{XdgShellV6} extension and provides a way to - * extend the functionality of an existing \l{WaylandSurface} with features - * specific to desktop-style compositors, such as resizing and moving the - * surface. - * - * It corresponds to the Wayland interface \c zxdg_surface_v6. - */ - -/*! - * \class QWaylandXdgSurfaceV6 - * \inmodule QtWaylandCompositor - * \since 5.10 - * \brief The QWaylandXdgSurfaceV6 class provides desktop-style compositor-specific features to an xdg surface. - * - * This class is part of the QWaylandXdgShellV6 extension and provides a way to - * extend the functionality of an existing QWaylandSurface with features - * specific to desktop-style compositors, such as resizing and moving the - * surface. - * - * It corresponds to the Wayland interface \c zxdg_surface_v6. - */ - -/*! - * Constructs a QWaylandXdgSurfaceV6. - */ -QWaylandXdgSurfaceV6::QWaylandXdgSurfaceV6() - : QWaylandShellSurfaceTemplate<QWaylandXdgSurfaceV6>(*new QWaylandXdgSurfaceV6Private) -{ -} - -/*! - * Constructs a QWaylandXdgSurfaceV6 for \a surface and initializes it with the - * given \a xdgShell, \a surface, and resource \a res. - */ -QWaylandXdgSurfaceV6::QWaylandXdgSurfaceV6(QWaylandXdgShellV6 *xdgShell, QWaylandSurface *surface, const QWaylandResource &res) - : QWaylandShellSurfaceTemplate<QWaylandXdgSurfaceV6>(*new QWaylandXdgSurfaceV6Private) -{ - initialize(xdgShell, surface, res); -} - -/*! - * \qmlmethod void QtWaylandCompositor::XdgSurfaceV6::initialize(object xdgShell, object surface, object client, int id) - * - * Initializes the XdgSurface, associating it with the given \a xdgShell, \a surface, - * \a client, and \a id. - */ - -/*! - * Initializes the QWaylandXdgSurfaceV6, associating it with the given \a xdgShell, \a surface - * and \a resource. - */ -void QWaylandXdgSurfaceV6::initialize(QWaylandXdgShellV6 *xdgShell, QWaylandSurface *surface, const QWaylandResource &resource) -{ - Q_D(QWaylandXdgSurfaceV6); - d->m_xdgShell = xdgShell; - d->m_surface = surface; - d->init(resource.resource()); - setExtensionContainer(surface); - d->m_windowGeometry = d->calculateFallbackWindowGeometry(); - connect(surface, &QWaylandSurface::destinationSizeChanged, this, &QWaylandXdgSurfaceV6::handleSurfaceSizeChanged); - connect(surface, &QWaylandSurface::bufferScaleChanged, this, &QWaylandXdgSurfaceV6::handleBufferScaleChanged); - emit shellChanged(); - emit surfaceChanged(); - QWaylandCompositorExtension::initialize(); -} - -/*! - * \qmlproperty enum QtWaylandCompositor::XdgSurfaceV6::windowType - * - * This property holds the window type of the XdgSurfaceV6. - */ -Qt::WindowType QWaylandXdgSurfaceV6::windowType() const -{ - Q_D(const QWaylandXdgSurfaceV6); - return d->m_windowType; -} - -/*! - * \qmlproperty rect QtWaylandCompositor::XdgSurfaceV6::windowGeometry - * - * This property holds the window geometry of the QWaylandXdgSurfaceV6. The window - * geometry describes the window's visible bounds from the user's perspective. - * The geometry includes title bars and borders if drawn by the client, but - * excludes drop shadows. It is meant to be used for aligning and tiling - * windows. - */ - -/*! - * \property QWaylandXdgSurfaceV6::windowGeometry - * - * This property holds the window geometry of the QWaylandXdgSurfaceV6. The window - * geometry describes the window's visible bounds from the user's perspective. - * The geometry includes title bars and borders if drawn by the client, but - * excludes drop shadows. It is meant to be used for aligning and tiling - * windows. - */ -QRect QWaylandXdgSurfaceV6::windowGeometry() const -{ - Q_D(const QWaylandXdgSurfaceV6); - return d->m_windowGeometry; -} - -/*! - * \internal - */ -void QWaylandXdgSurfaceV6::initialize() -{ - QWaylandCompositorExtension::initialize(); -} - -void QWaylandXdgSurfaceV6::handleSurfaceSizeChanged() -{ - Q_D(QWaylandXdgSurfaceV6); - d->updateFallbackWindowGeometry(); -} - -void QWaylandXdgSurfaceV6::handleBufferScaleChanged() -{ - Q_D(QWaylandXdgSurfaceV6); - d->updateFallbackWindowGeometry(); -} - -/*! - * \qmlproperty XdgShellV6 QtWaylandCompositor::XdgSurfaceV6::shell - * - * This property holds the shell associated with this XdgSurface. - */ - -/*! - * \property QWaylandXdgSurfaceV6::shell - * - * This property holds the shell associated with this QWaylandXdgSurfaceV6. - */ -QWaylandXdgShellV6 *QWaylandXdgSurfaceV6::shell() const -{ - Q_D(const QWaylandXdgSurfaceV6); - return d->m_xdgShell; -} - -/*! - * \qmlproperty WaylandSurface QtWaylandCompositor::XdgSurfaceV6::surface - * - * This property holds the surface associated with this XdgSurfaceV6. - */ - -/*! - * \property QWaylandXdgSurfaceV6::surface - * - * This property holds the surface associated with this QWaylandXdgSurfaceV6. - */ -QWaylandSurface *QWaylandXdgSurfaceV6::surface() const -{ - Q_D(const QWaylandXdgSurfaceV6); - return d->m_surface; -} - -/*! - * \qmlproperty XdgToplevelV6 QtWaylandCompositor::XdgSurfaceV6::toplevel - * - * This property holds the properties and methods that are specific to the - * toplevel XdgSurfaceV6. - * - * \sa popup, XdgShellV6::toplevelCreated - */ - -/*! - * \property QWaylandXdgSurfaceV6::toplevel - * - * This property holds the properties and methods that are specific to the - * toplevel QWaylandXdgSurfaceV6. - * - * \sa QWaylandXdgSurfaceV6::popup, QWaylandXdgShellV6::toplevelCreated - */ -QWaylandXdgToplevelV6 *QWaylandXdgSurfaceV6::toplevel() const -{ - Q_D(const QWaylandXdgSurfaceV6); - return d->m_toplevel; -} - -/*! - * \qmlproperty XdgPopupV6 QtWaylandCompositor::XdgSurfaceV6::popup - * - * This property holds the properties and methods that are specific to the - * popup XdgSurfaceV6. - * - * \sa toplevel, XdgShellV6::popupCreated - */ - -/*! - * \property QWaylandXdgSurfaceV6::popup - * - * This property holds the properties and methods that are specific to the - * popup QWaylandXdgSurfaceV6. - * - * \sa QWaylandXdgSurfaceV6::toplevel, QWaylandXdgShellV6::popupCreated - */ -QWaylandXdgPopupV6 *QWaylandXdgSurfaceV6::popup() const -{ - Q_D(const QWaylandXdgSurfaceV6); - return d->m_popup; -} - -/*! - * Returns the Wayland interface for the QWaylandXdgSurfaceV6. - */ -const wl_interface *QWaylandXdgSurfaceV6::interface() -{ - return QWaylandXdgSurfaceV6Private::interface(); -} - -/*! - * \internal - */ -QByteArray QWaylandXdgSurfaceV6::interfaceName() -{ - return QWaylandXdgSurfaceV6Private::interfaceName(); -} - -/*! - * Returns the QWaylandXdgSurfaceV6 corresponding to the \a resource. - */ -QWaylandXdgSurfaceV6 *QWaylandXdgSurfaceV6::fromResource(wl_resource *resource) -{ - if (auto p = QtWayland::fromResource<QWaylandXdgSurfaceV6Private *>(resource)) - return p->q_func(); - return nullptr; -} - -#if QT_CONFIG(wayland_compositor_quick) -QWaylandQuickShellIntegration *QWaylandXdgSurfaceV6::createIntegration(QWaylandQuickShellSurfaceItem *item) -{ - Q_D(const QWaylandXdgSurfaceV6); - - if (d->m_toplevel) - return new QtWayland::XdgToplevelV6Integration(item); - - if (d->m_popup) - return new QtWayland::XdgPopupV6Integration(item); - - return nullptr; -} -#endif - -/*! - * \qmltype XdgToplevelV6 - * \inqmlmodule QtWayland.Compositor - * \since 5.10 - * \brief XdgToplevelV6 represents the toplevel window specific parts of an xdg surface. - * - * This type is part of the \l{XdgShellV6} extension and provides a way to - * extend the functionality of an XdgSurfaceV6 with features - * specific to desktop-style windows. - * - * It corresponds to the Wayland interface \c zxdg_toplevel_v6. - */ - -/*! - * \class QWaylandXdgToplevelV6 - * \inmodule QtWaylandCompositor - * \since 5.10 - * \brief The QWaylandXdgToplevelV6 class represents the toplevel window specific parts of an xdg surface. - * - * This class is part of the QWaylandXdgShellV6 extension and provides a way to - * extend the functionality of an QWaylandXdgSurfaceV6 with features - * specific to desktop-style windows. - * - * It corresponds to the Wayland interface \c zxdg_toplevel_v6. - */ - -/*! - * Constructs a QWaylandXdgToplevelV6 for the given \a xdgSurface and \a resource. - */ -QWaylandXdgToplevelV6::QWaylandXdgToplevelV6(QWaylandXdgSurfaceV6 *xdgSurface, QWaylandResource &resource) - : QObject(*new QWaylandXdgToplevelV6Private(xdgSurface, resource)) -{ - QVector<QWaylandXdgToplevelV6::State> states; - sendConfigure({0, 0}, states); -} - -/*! - * \qmlproperty XdgToplevelV6 QtWaylandCompositor::XdgToplevelV6::parentToplevel - * - * This property holds the XdgToplevelV6 parent of this XdgToplevelV6. - */ - -/*! - * \property QWaylandXdgToplevelV6::parentToplevel - * - * This property holds the XdgToplevelV6 parent of this XdgToplevelV6. - * - */ -QWaylandXdgToplevelV6 *QWaylandXdgToplevelV6::parentToplevel() const -{ - Q_D(const QWaylandXdgToplevelV6); - return d->m_parentToplevel; -} - -/*! - * \qmlproperty string QtWaylandCompositor::XdgToplevelV6::title - * - * This property holds the title of the XdgToplevelV6. - */ - -/*! - * \property QWaylandXdgToplevelV6::title - * - * This property holds the title of the QWaylandXdgToplevelV6. - */ -QString QWaylandXdgToplevelV6::title() const -{ - Q_D(const QWaylandXdgToplevelV6); - return d->m_title; -} - -/*! - * \qmlproperty string QtWaylandCompositor::XdgToplevelV6::appId - * - * This property holds the app id of the XdgToplevelV6. - */ - -/*! - * \property QWaylandXdgToplevelV6::appId - * - * This property holds the app id of the QWaylandXdgToplevelV6. - */ -QString QWaylandXdgToplevelV6::appId() const -{ - Q_D(const QWaylandXdgToplevelV6); - return d->m_appId; -} - -/*! - * \qmlproperty size QtWaylandCompositor::XdgToplevelV6::maxSize - * - * This property holds the maximum size of the XdgToplevelV6 as requested by the client. - * - * The compositor is free to ignore this value and request a larger size. - */ - -/*! - * \property QWaylandXdgToplevelV6::maxSize - * - * This property holds the maximum size of the QWaylandXdgToplevelV6. - * - * The compositor is free to ignore this value and request a larger size. - */ -QSize QWaylandXdgToplevelV6::maxSize() const -{ - Q_D(const QWaylandXdgToplevelV6); - return d->m_maxSize; -} - -/*! - * \qmlproperty size QtWaylandCompositor::XdgToplevelV6::minSize - * - * This property holds the minimum size of the XdgToplevelV6 as requested by the client. - * - * The compositor is free to ignore this value and request a smaller size. - */ - -/*! - * \property QWaylandXdgToplevelV6::minSize - * - * This property holds the minimum size of the QWaylandXdgToplevelV6. - * - * The compositor is free to ignore this value and request a smaller size. - */ -QSize QWaylandXdgToplevelV6::minSize() const -{ - Q_D(const QWaylandXdgToplevelV6); - return d->m_minSize; -} - -/*! - * \property QWaylandXdgToplevelV6::states - * - * This property holds the last states the client acknowledged for this QWaylandToplevelV6. - */ -QVector<QWaylandXdgToplevelV6::State> QWaylandXdgToplevelV6::states() const -{ - Q_D(const QWaylandXdgToplevelV6); - return d->m_lastAckedConfigure.states; -} - -/*! - * \qmlproperty bool QtWaylandCompositor::XdgToplevelV6::maximized - * - * This property holds whether the client has acknowledged that it should be maximized. - */ - -/*! - * \property QWaylandXdgToplevelV6::maximized - * - * This property holds whether the client has acknowledged that it should be maximized. - */ -bool QWaylandXdgToplevelV6::maximized() const -{ - Q_D(const QWaylandXdgToplevelV6); - return d->m_lastAckedConfigure.states.contains(QWaylandXdgToplevelV6::State::MaximizedState); -} - -/*! - * \qmlproperty bool QtWaylandCompositor::XdgToplevelV6::fullscreen - * - * This property holds whether the client has acknowledged that it should be fullscreen. - */ - -/*! - * \property QWaylandXdgToplevelV6::fullscreen - * - * This property holds whether the client has acknowledged that it should be fullscreen. - */ -bool QWaylandXdgToplevelV6::fullscreen() const -{ - Q_D(const QWaylandXdgToplevelV6); - return d->m_lastAckedConfigure.states.contains(QWaylandXdgToplevelV6::State::FullscreenState); -} - -/*! - * \qmlproperty bool QtWaylandCompositor::XdgToplevelV6::resizing - * - * This property holds whether the client has acknowledged that it is being resized. - */ - -/*! - * \property QWaylandXdgToplevelV6::resizing - * - * This property holds whether the client has acknowledged that it is being resized. - */ -bool QWaylandXdgToplevelV6::resizing() const -{ - Q_D(const QWaylandXdgToplevelV6); - return d->m_lastAckedConfigure.states.contains(QWaylandXdgToplevelV6::State::ResizingState); -} - -/*! - * \qmlproperty bool QtWaylandCompositor::XdgToplevelV6::activated - * - * This property holds whether toplevel is drawing itself as having input focus. - */ - -/*! - * \property QWaylandXdgToplevelV6::activated - * - * This property holds whether toplevel is drawing itself as having input focus. - */ -bool QWaylandXdgToplevelV6::activated() const -{ - Q_D(const QWaylandXdgToplevelV6); - return d->m_lastAckedConfigure.states.contains(QWaylandXdgToplevelV6::State::ActivatedState); -} - -/*! - * \qmlmethod size QtWaylandCompositor::XdgToplevelV6::sizeForResize(size size, point delta, uint edges) - * - * Convenience for computing the new size given the current \a size, a \a delta, and - * the \a edges active in the drag. - */ - -/*! - * Convenience for computing the new size given the current \a size, a \a delta, and - * the \a edges active in the drag. - */ -QSize QWaylandXdgToplevelV6::sizeForResize(const QSizeF &size, const QPointF &delta, Qt::Edges edges) const -{ - qreal width = size.width(); - qreal height = size.height(); - if (edges & Qt::LeftEdge) - width -= delta.x(); - else if (edges & Qt::RightEdge) - width += delta.x(); - - if (edges & Qt::TopEdge) - height -= delta.y(); - else if (edges & Qt::BottomEdge) - height += delta.y(); - - QSize newSize = QSize(width, height) - .expandedTo(minSize()) - .expandedTo({1, 1}); // We don't want to send a size of (0,0) as that means that the client decides - - if (maxSize().isValid()) - newSize = newSize.boundedTo(maxSize()); - - return newSize; -} - -/*! - * Sends a configure event to the client. Parameter \a size contains the pixel size - * of the surface. A size of zero means the client is free to decide the size. - * Known \a states are enumerated in QWaylandXdgToplevelV6::State. - */ -uint QWaylandXdgToplevelV6::sendConfigure(const QSize &size, const QVector<QWaylandXdgToplevelV6::State> &states) -{ - if (!size.isValid()) { - qWarning() << "Can't configure zxdg_toplevel_v6 with an invalid size" << size; - return 0; - } - Q_D(QWaylandXdgToplevelV6); - auto statesBytes = QByteArray::fromRawData(reinterpret_cast<const char *>(states.data()), - states.size() * static_cast<int>(sizeof(State))); - uint32_t serial = d->m_xdgSurface->surface()->compositor()->nextSerial(); - d->m_pendingConfigures.append(QWaylandXdgToplevelV6Private::ConfigureEvent{states, size, serial}); - d->send_configure(size.width(), size.height(), statesBytes); - QWaylandXdgSurfaceV6Private::get(d->m_xdgSurface)->send_configure(serial); - return serial; -} - -/*! - * \qmlmethod int QtWaylandCompositor::XdgToplevelV6::sendConfigure(size size, list<int> states) - * - * Sends a configure event to the client. \a size contains the pixel size of the surface. - * A size of zero means the client is free to decide the size. - * Known \a states are enumerated in XdgToplevelV6::State. - */ -uint QWaylandXdgToplevelV6::sendConfigure(const QSize &size, const QVector<int> &states) -{ - QVector<State> s; - for (auto state : states) - s << State(state); - return sendConfigure(size, s); -} - -/*! - * \qmlmethod void QtWaylandCompositor::XdgToplevelV6::sendClose() - * - * Sends a close event to the client. The client may choose to ignore the event. - */ - -/*! - * Sends a close event to the client. The client may choose to ignore the event. - */ -void QWaylandXdgToplevelV6::sendClose() -{ - Q_D(QWaylandXdgToplevelV6); - d->send_close(); -} - -/*! - * \qmlmethod void QtWaylandCompositor::XdgToplevelV6::sendMaximized(size size) - * - * Convenience for sending a configure event with the maximized state set, and - * fullscreen and resizing removed. The activated state is left in its current state. - * - * \a size is the new size of the window. - */ - -/*! - * Convenience for sending a configure event with the maximized state set, and - * fullscreen and resizing removed. The activated state is left in its current state. - * - * \a size is the new size of the window. - */ -uint QWaylandXdgToplevelV6::sendMaximized(const QSize &size) -{ - Q_D(QWaylandXdgToplevelV6); - QWaylandXdgToplevelV6Private::ConfigureEvent conf = d->lastSentConfigure(); - - if (!conf.states.contains(QWaylandXdgToplevelV6::State::MaximizedState)) - conf.states.append(QWaylandXdgToplevelV6::State::MaximizedState); - conf.states.removeOne(QWaylandXdgToplevelV6::State::FullscreenState); - conf.states.removeOne(QWaylandXdgToplevelV6::State::ResizingState); - - return sendConfigure(size, conf.states); -} - -/*! - * \qmlmethod void QtWaylandCompositor::XdgToplevelV6::sendUnmaximized(size size) - * - * Convenience for sending a configure event with the maximized, fullscreen and - * resizing states removed, and fullscreen and resizing removed. The activated - * state is left in its current state. - * - * \a size is the new size of the window. If \a size is zero, the client decides the size. - */ - -/*! - * Convenience for sending a configure event with the maximized, fullscreen and - * resizing states removed, and fullscreen and resizing removed. The activated - * state is left in its current state. - * - * \a size is the new size of the window. If \a size is zero, the client decides the size. - */ -uint QWaylandXdgToplevelV6::sendUnmaximized(const QSize &size) -{ - Q_D(QWaylandXdgToplevelV6); - QWaylandXdgToplevelV6Private::ConfigureEvent conf = d->lastSentConfigure(); - - conf.states.removeOne(QWaylandXdgToplevelV6::State::MaximizedState); - conf.states.removeOne(QWaylandXdgToplevelV6::State::FullscreenState); - conf.states.removeOne(QWaylandXdgToplevelV6::State::ResizingState); - - return sendConfigure(size, conf.states); - -} - -/*! - * \qmlmethod void QtWaylandCompositor::XdgToplevelV6::sendFullscreen(size size) - * - * Convenience for sending a configure event with the fullscreen state set, and - * maximized and resizing removed. The activated state is left in its current state. - * - * \sa sendUnmaximized - * - * \a size is the new size of the window. - */ - -/*! - * Convenience for sending a configure event with the fullscreen state set, and - * maximized and resizing removed. The activated state is left in its current state. - * - * \sa sendUnmaximized - * - * \a size is the new size of the window. - */ -uint QWaylandXdgToplevelV6::sendFullscreen(const QSize &size) -{ - Q_D(QWaylandXdgToplevelV6); - QWaylandXdgToplevelV6Private::ConfigureEvent conf = d->lastSentConfigure(); - - if (!conf.states.contains(QWaylandXdgToplevelV6::State::FullscreenState)) - conf.states.append(QWaylandXdgToplevelV6::State::FullscreenState); - conf.states.removeOne(QWaylandXdgToplevelV6::State::MaximizedState); - conf.states.removeOne(QWaylandXdgToplevelV6::State::ResizingState); - - return sendConfigure(size, conf.states); -} - -/*! - * \qmlmethod void QtWaylandCompositor::XdgToplevelV6::sendResizing(size maxSize) - * - * Convenience for sending a configure event with the resizing state set, and - * maximized and fullscreen removed. The activated state is left in its current state. - * - * \a maxSize is the new size of the window. - */ - -/*! - * Convenience for sending a configure event with the resizing state set, and - * maximized and fullscreen removed. The activated state is left in its current state. - * - * \a maxSize is the new size of the window. - */ -uint QWaylandXdgToplevelV6::sendResizing(const QSize &maxSize) -{ - Q_D(QWaylandXdgToplevelV6); - QWaylandXdgToplevelV6Private::ConfigureEvent conf = d->lastSentConfigure(); - - if (!conf.states.contains(QWaylandXdgToplevelV6::State::ResizingState)) - conf.states.append(QWaylandXdgToplevelV6::State::ResizingState); - conf.states.removeOne(QWaylandXdgToplevelV6::State::MaximizedState); - conf.states.removeOne(QWaylandXdgToplevelV6::State::FullscreenState); - - return sendConfigure(maxSize, conf.states); -} - -/*! - * Returns the surface role for the QWaylandToplevelV6. - */ -QWaylandSurfaceRole *QWaylandXdgToplevelV6::role() -{ - return &QWaylandXdgToplevelV6Private::s_role; -} - - -/*! - * \qmlsignal QtWaylandCompositor::XdgShellV6::xdgSurfaceCreated(XdgSurfaceV6 xdgSurface) - * - * This signal is emitted when the client has created a \c zxdg_surface_v6. - * Note that \a xdgSurface is not mapped, i.e. according to the \c xdg-shell - * protocol it should not be displayed, until it has received a role object. - * - * \sa toplevelCreated(), popupCreated() - */ - -/*! - * \fn void QWaylandXdgShellV6::xdgSurfaceCreated(QWaylandXdgSurfaceV6 *xdgSurface) - * - * This signal is emitted when the client has created a \c zxdg_surface_v6. - * Note that \a xdgSurface is not mapped, i.e. according to the \c xdg-shell - * protocol it should not be displayed, until it has received a role object. - * - * \sa toplevelCreated(), popupCreated() - */ - -/*! - * \qmlsignal QtWaylandCompositor::XdgShellV6::toplevelCreated(XdgToplevelV6 toplevel, XdgSurfaceV6 xdgSurface) - * - * This signal is emitted when the client has created a \c zxdg_toplevel_v6. - * A common use case is to let the handler of this signal instantiate a ShellSurfaceItem or - * WaylandQuickItem for displaying \a toplevel in a QtQuick scene. - * - * \a xdgSurface is the XdgSurfaceV6 \a toplevel is the role object for. - */ - -/*! - * \fn void QWaylandXdgShellV6::toplevelCreated(QWaylandXdgToplevelV6 *toplevel, QWaylandXdgSurfaceV6 *xdgSurface) - * - * This signal is emitted when the client has created a \c zxdg_toplevel_v6. - * A common use case is to let the handler of this signal instantiate a QWaylandShellSurfaceItem or - * QWaylandQuickItem for displaying \a toplevel in a QtQuick scene. - * - * \a xdgSurface is the XdgSurfaceV6 \a toplevel is the role object for. - */ - -/*! - * \qmlsignal QtWaylandCompositor::XdgShellV6::popupCreated(XdgPopupV6 popup, XdgSurfaceV6 xdgSurface) - * - * This signal is emitted when the client has created a \c zxdg_popup_v6. - * A common use case is to let the handler of this signal instantiate a ShellSurfaceItem or - * WaylandQuickItem for displaying \a popup in a QtQuick scene. - * - * \a xdgSurface is the XdgSurfaceV6 \a popup is the role object for. - */ - -/*! - * \fn void QWaylandXdgShellV6::popupCreated(QWaylandXdgPopupV6 *popup, QWaylandXdgSurfaceV6 *xdgSurface) - * - * This signal is emitted when the client has created a \c zxdg_popup_v6. - * A common use case is to let the handler of this signal instantiate a QWaylandShellSurfaceItem or - * QWaylandQuickItem for displaying \a popup in a QtQuick scene. - * - * \a xdgSurface is the XdgSurfaceV6 \a popup is the role object for. - */ - -/*! - * \qmlsignal QtWaylandCompositor::XdgShellV6::pong(int serial) - * - * This signal is emitted when the client has responded to a ping event with serial, \a serial. - * - * \sa ping() - */ - -/*! - * \fn void QWaylandXdgShellV6::pong(uint serial) - * - * This signal is emitted when the client has responded to a ping event with serial, \a serial. - * - * \sa QWaylandXdgShellV6::ping() - */ - -QList<int> QWaylandXdgToplevelV6::statesAsInts() const -{ - QList<int> list; - const auto s = states(); - list.reserve(s.size()); - for (auto state : s) { - list << static_cast<int>(state); - } - return list; -} - -QWaylandSurfaceRole QWaylandXdgToplevelV6Private::s_role("zxdg_toplevel_v6"); - -QWaylandXdgToplevelV6Private::QWaylandXdgToplevelV6Private(QWaylandXdgSurfaceV6 *xdgSurface, const QWaylandResource &resource) - : m_xdgSurface(xdgSurface) -{ - init(resource.resource()); -} - -void QWaylandXdgToplevelV6Private::handleAckConfigure(uint serial) -{ - Q_Q(QWaylandXdgToplevelV6); - ConfigureEvent config; - Q_FOREVER { - if (m_pendingConfigures.empty()) { - qWarning("Toplevel received an unexpected ack_configure!"); - return; - } - - // This won't work unless there always is a toplevel.configure for each xdgsurface.configure - config = m_pendingConfigures.takeFirst(); - - if (config.serial == serial) - break; - } - - QVector<uint> changedStates; - std::set_symmetric_difference( - m_lastAckedConfigure.states.begin(), m_lastAckedConfigure.states.end(), - config.states.begin(), config.states.end(), - std::back_inserter(changedStates)); - - m_lastAckedConfigure = config; - - for (uint state : changedStates) { - switch (state) { - case state_maximized: - emit q->maximizedChanged(); - break; - case state_fullscreen: - emit q->fullscreenChanged(); - break; - case state_resizing: - emit q->resizingChanged(); - break; - case state_activated: - emit q->activatedChanged(); - break; - } - } - - if (!changedStates.empty()) - emit q->statesChanged(); -} - -void QWaylandXdgToplevelV6Private::handleFocusLost() -{ - Q_Q(QWaylandXdgToplevelV6); - QWaylandXdgToplevelV6Private::ConfigureEvent current = lastSentConfigure(); - current.states.removeOne(QWaylandXdgToplevelV6::State::ActivatedState); - q->sendConfigure(current.size, current.states); -} - -void QWaylandXdgToplevelV6Private::handleFocusReceived() -{ - Q_Q(QWaylandXdgToplevelV6); - QWaylandXdgToplevelV6Private::ConfigureEvent current = lastSentConfigure(); - if (!current.states.contains(QWaylandXdgToplevelV6::State::ActivatedState)) { - current.states.push_back(QWaylandXdgToplevelV6::State::ActivatedState); - q->sendConfigure(current.size, current.states); - } -} - -void QWaylandXdgToplevelV6Private::zxdg_toplevel_v6_destroy_resource(QtWaylandServer::zxdg_toplevel_v6::Resource *resource) -{ - Q_UNUSED(resource); - Q_Q(QWaylandXdgToplevelV6); - delete q; -} - -void QWaylandXdgToplevelV6Private::zxdg_toplevel_v6_destroy(QtWaylandServer::zxdg_toplevel_v6::Resource *resource) -{ - wl_resource_destroy(resource->handle); - //TODO: Should the xdg surface be desroyed as well? Or is it allowed to recreate a new toplevel for it? -} - -void QWaylandXdgToplevelV6Private::zxdg_toplevel_v6_set_parent(QtWaylandServer::zxdg_toplevel_v6::Resource *resource, wl_resource *parent) -{ - Q_UNUSED(resource); - QWaylandXdgToplevelV6 *parentToplevel = nullptr; - if (parent) { - parentToplevel = static_cast<QWaylandXdgToplevelV6Private *>( - QWaylandXdgToplevelV6Private::Resource::fromResource(parent)->zxdg_toplevel_v6_object)->q_func(); - } - - Q_Q(QWaylandXdgToplevelV6); - - if (m_parentToplevel != parentToplevel) { - m_parentToplevel = parentToplevel; - emit q->parentToplevelChanged(); - } - - if (m_parentToplevel && m_xdgSurface->windowType() != Qt::WindowType::SubWindow) { - // There's a parent now, which means the surface is transient - QWaylandXdgSurfaceV6Private::get(m_xdgSurface)->setWindowType(Qt::WindowType::SubWindow); - } else if (!m_parentToplevel && m_xdgSurface->windowType() != Qt::WindowType::Window) { - // When the surface has no parent it is toplevel - QWaylandXdgSurfaceV6Private::get(m_xdgSurface)->setWindowType(Qt::WindowType::Window); - } -} - -void QWaylandXdgToplevelV6Private::zxdg_toplevel_v6_set_title(QtWaylandServer::zxdg_toplevel_v6::Resource *resource, const QString &title) -{ - Q_UNUSED(resource); - if (title == m_title) - return; - Q_Q(QWaylandXdgToplevelV6); - m_title = title; - emit q->titleChanged(); -} - -void QWaylandXdgToplevelV6Private::zxdg_toplevel_v6_set_app_id(QtWaylandServer::zxdg_toplevel_v6::Resource *resource, const QString &app_id) -{ - Q_UNUSED(resource); - if (app_id == m_appId) - return; - Q_Q(QWaylandXdgToplevelV6); - m_appId = app_id; - emit q->appIdChanged(); -} - -void QWaylandXdgToplevelV6Private::zxdg_toplevel_v6_show_window_menu(QtWaylandServer::zxdg_toplevel_v6::Resource *resource, wl_resource *seatResource, uint32_t serial, int32_t x, int32_t y) -{ - Q_UNUSED(resource); - Q_UNUSED(serial); - QPoint position(x, y); - auto seat = QWaylandSeat::fromSeatResource(seatResource); - Q_Q(QWaylandXdgToplevelV6); - emit q->showWindowMenu(seat, position); -} - -void QWaylandXdgToplevelV6Private::zxdg_toplevel_v6_move(Resource *resource, wl_resource *seatResource, uint32_t serial) -{ - Q_UNUSED(resource); - Q_UNUSED(serial); - Q_Q(QWaylandXdgToplevelV6); - QWaylandSeat *seat = QWaylandSeat::fromSeatResource(seatResource); - emit q->startMove(seat); -} - -void QWaylandXdgToplevelV6Private::zxdg_toplevel_v6_resize(QtWaylandServer::zxdg_toplevel_v6::Resource *resource, wl_resource *seatResource, uint32_t serial, uint32_t edges) -{ - Q_UNUSED(resource); - Q_UNUSED(serial); - Q_Q(QWaylandXdgToplevelV6); - QWaylandSeat *seat = QWaylandSeat::fromSeatResource(seatResource); - emit q->startResize(seat, QWaylandXdgShellV6Private::convertToEdges(edges)); -} - -void QWaylandXdgToplevelV6Private::zxdg_toplevel_v6_set_max_size(QtWaylandServer::zxdg_toplevel_v6::Resource *resource, int32_t width, int32_t height) -{ - Q_UNUSED(resource); - - QSize maxSize(width, height); - if (width == 0 && height == 0) - maxSize = QSize(); // Wayland size of zero means unspecified which best translates to invalid - - if (m_maxSize == maxSize) - return; - - if (width < 0 || height < 0) { - // The spec says raise a protocol error, but there's no matching error defined - qWarning() << "Received a zxdg_toplevel_v6.set_max_size request with a negative size"; - return; - } - - if (m_minSize.isValid() && maxSize.isValid() && - (maxSize.width() < m_minSize.width() || maxSize.height() < m_minSize.height())) { - // The spec says raise a protocol error, but there's no matching error defined - qWarning() << "Received a zxdg_toplevel_v6.set_max_size request with a size smaller than the minimium size"; - return; - } - - m_maxSize = maxSize; - - Q_Q(QWaylandXdgToplevelV6); - emit q->maxSizeChanged(); -} - -void QWaylandXdgToplevelV6Private::zxdg_toplevel_v6_set_min_size(QtWaylandServer::zxdg_toplevel_v6::Resource *resource, int32_t width, int32_t height) -{ - Q_UNUSED(resource); - - QSize minSize(width, height); - if (width == 0 && height == 0) - minSize = QSize(); // Wayland size of zero means unspecified - - if (m_minSize == minSize) - return; - - if (width < 0 || height < 0) { - // The spec says raise a protocol error, but there's no matching error defined - qWarning() << "Received a zxdg_toplevel_v6.set_min_size request with a negative size"; - return; - } - - if (m_maxSize.isValid() && minSize.isValid() && - (minSize.width() > m_maxSize.width() || minSize.height() > m_maxSize.height())) { - // The spec says raise a protocol error, but there's no matching error defined - qWarning() << "Received a zxdg_toplevel_v6.set_min_size request with a size larger than the maximum size"; - return; - } - - m_minSize = minSize; - - Q_Q(QWaylandXdgToplevelV6); - emit q->minSizeChanged(); -} - -void QWaylandXdgToplevelV6Private::zxdg_toplevel_v6_set_maximized(QtWaylandServer::zxdg_toplevel_v6::Resource *resource) -{ - Q_UNUSED(resource); - Q_Q(QWaylandXdgToplevelV6); - emit q->setMaximized(); -} - -void QWaylandXdgToplevelV6Private::zxdg_toplevel_v6_unset_maximized(QtWaylandServer::zxdg_toplevel_v6::Resource *resource) -{ - Q_UNUSED(resource); - Q_Q(QWaylandXdgToplevelV6); - emit q->unsetMaximized(); -} - -void QWaylandXdgToplevelV6Private::zxdg_toplevel_v6_set_fullscreen(QtWaylandServer::zxdg_toplevel_v6::Resource *resource, wl_resource *output_res) -{ - Q_UNUSED(resource); - Q_Q(QWaylandXdgToplevelV6); - QWaylandOutput *output = output_res ? QWaylandOutput::fromResource(output_res) : nullptr; - emit q->setFullscreen(output); -} - -void QWaylandXdgToplevelV6Private::zxdg_toplevel_v6_unset_fullscreen(QtWaylandServer::zxdg_toplevel_v6::Resource *resource) -{ - Q_UNUSED(resource); - Q_Q(QWaylandXdgToplevelV6); - emit q->unsetFullscreen(); -} - -void QWaylandXdgToplevelV6Private::zxdg_toplevel_v6_set_minimized(QtWaylandServer::zxdg_toplevel_v6::Resource *resource) -{ - Q_UNUSED(resource); - Q_Q(QWaylandXdgToplevelV6); - emit q->setMinimized(); -} - -/*! - * \qmltype XdgPopupV6 - * \inqmlmodule QtWayland.Compositor - * \since 5.10 - * \brief XdgPopupV6 represents the popup specific parts of and xdg surface. - * - * This type is part of the \l{XdgShellV6} extension and provides a way to extend - * extend the functionality of an \l{XdgSurfaceV6} with features - * specific to desktop-style menus for an xdg surface. - * - * It corresponds to the Wayland interface \c zxdg_popup_v6. - */ - -/*! - * \class QWaylandXdgPopupV6 - * \inmodule QtWaylandCompositor - * \since 5.10 - * \brief The QWaylandXdgPopupV6 class represents the popup specific parts of an xdg surface. - * - * This class is part of the QWaylandXdgShellV6 extension and provides a way to - * extend the functionality of a QWaylandXdgSurfaceV6 with features - * specific to desktop-style menus for an xdg surface. - * - * It corresponds to the Wayland interface \c zxdg_popup_v6. - */ - -/*! - * Constructs a QWaylandXdgPopupV6. - */ -QWaylandXdgPopupV6::QWaylandXdgPopupV6(QWaylandXdgSurfaceV6 *xdgSurface, QWaylandXdgSurfaceV6 *parentXdgSurface, - QWaylandXdgPositionerV6 *positioner, QWaylandResource &resource) - : QObject(*new QWaylandXdgPopupV6Private(xdgSurface, parentXdgSurface, positioner, resource)) -{ -} - -/*! - * \qmlproperty XdgSurfaceV6 QtWaylandCompositor::XdgPopupV6::xdgSurface - * - * This property holds the XdgSurfaceV6 associated with this XdgPopupV6. - */ - -/*! - * \property QWaylandXdgPopupV6::xdgSurface - * - * This property holds the QWaylandXdgSurfaceV6 associated with this QWaylandXdgPopupV6. - */ -QWaylandXdgSurfaceV6 *QWaylandXdgPopupV6::xdgSurface() const -{ - Q_D(const QWaylandXdgPopupV6); - return d->m_xdgSurface; -} - -/*! - * \qmlproperty XdgSurfaceV6 QtWaylandCompositor::XdgPopupV6::parentXdgSurface - * - * This property holds the XdgSurfaceV6 associated with the parent of this XdgPopupV6. - */ - -/*! - * \property QWaylandXdgPopupV6::parentXdgSurface - * - * This property holds the QWaylandXdgSurfaceV6 associated with the parent of this - * QWaylandXdgPopupV6. - */ -QWaylandXdgSurfaceV6 *QWaylandXdgPopupV6::parentXdgSurface() const -{ - Q_D(const QWaylandXdgPopupV6); - return d->m_parentXdgSurface; -} - -/*! - * \qmlproperty rect QtWaylandCompositor::XdgPopupV6::configuredGeometry - * - * The window geometry the popup received in the configure event. Relative to the - * upper left corner of the parent surface. - */ - -/*! - * \property QWaylandXdgPopupV6::configuredGeometry - * - * The window geometry the popup received in the configure event. Relative to the - * upper left corner of the parent surface. - */ -QRect QWaylandXdgPopupV6::configuredGeometry() const -{ - Q_D(const QWaylandXdgPopupV6); - return d->m_geometry; -} - -/*! - * \qmlproperty rect QtWaylandCompositor::XdgPopupV6::anchorRect - * - * The anchor rectangle relative to the parent window geometry that the child - * surface should be placed relative to. - */ - -/*! - * \property QWaylandXdgPopupV6::anchorRect - * - * Returns the anchor rectangle relative to the parent window geometry that the child - * surface should be placed relative to. - */ -QRect QWaylandXdgPopupV6::anchorRect() const -{ - Q_D(const QWaylandXdgPopupV6); - return d->m_positionerData.anchorRect; -} - -/*! - * \qmlproperty enumeration QtWaylandCompositor::XdgPopupV6::anchorEdges - * - * This property holds the set of edges on the anchor rect that the child surface should be placed - * relative to. If no edges are specified in a direction, the anchor point should be - * centered between the edges. - * - * The possible values are: - * \value Qt.TopEdge The top edge of the rectangle. - * \value Qt.LeftEdge The left edge of the rectangle. - * \value Qt.RightEdge The right edge of the rectangle. - * \value Qt.BottomEdge The bottom edge of the rectangle. - */ - -/*! - * \property QWaylandXdgPopupV6::anchorEdges - * - * Returns the set of edges on the anchor rect that the child surface should be placed - * relative to. If no edges are specified in a direction, the anchor point should be - * centered between the edges. - */ -Qt::Edges QWaylandXdgPopupV6::anchorEdges() const -{ - Q_D(const QWaylandXdgPopupV6); - return d->m_positionerData.anchorEdges; -} - -/*! - * \qmlproperty rect QtWaylandCompositor::XdgPopupV6::gravityEdges - * - * Specifies in what direction the surface should be positioned, relative to the anchor - * point. - * - * The possible values are: - * \value Qt.TopEdge The surface should slide towards the top of the screen. - * \value Qt.LeftEdge The surface should slide towards the left of the screen. - * \value Qt.RightEdge The surface should slide towards the right of the screen. - * \value Qt.BottomEdge The surface should slide towards the bottom of the screen. - */ - -/*! - * \property QWaylandXdgPopupV6::gravityEdges - * - * Specifies in what direction the surface should be positioned, relative to the anchor - * point. - */ -Qt::Edges QWaylandXdgPopupV6::gravityEdges() const -{ - Q_D(const QWaylandXdgPopupV6); - return d->m_positionerData.gravityEdges; -} - -/*! - * \qmlproperty enumeration QtWaylandCompositor::XdgPopupV6::slideConstraints - * - * This property holds the orientations in which the child should slide to fit within the screen. - * - * Possible values: - * \value Qt.Horizontal Horizontal - * \value Qt.Vertical Vertical - */ - -/*! - * \property QWaylandXdgPopupV6::slideConstraints - * - * This property holds the orientations in which the child should slide to fit within the screen. - */ -Qt::Orientations QWaylandXdgPopupV6::slideConstraints() const -{ - Q_D(const QWaylandXdgPopupV6); - const uint flags = d->m_positionerData.constraintAdjustments; - - Qt::Orientations constraints = 0; - - if (flags & ZXDG_POSITIONER_V6_CONSTRAINT_ADJUSTMENT_SLIDE_X) - constraints |= Qt::Horizontal; - if (flags & ZXDG_POSITIONER_V6_CONSTRAINT_ADJUSTMENT_SLIDE_Y) - constraints |= Qt::Vertical; - - return constraints; -} - -/*! - * \qmlproperty enumeration QtWaylandCompositor::XdgPopupV6::flipConstraints - * - * This property holds the orientations in which the child should flip to fit within the screen. - * - * Possible values: - * \value Qt.Horizontal Horizontal - * \value Qt.Vertical Vertical - */ - -/*! - * \property QWaylandXdgPopupV6::flipConstraints - * - * This property holds the orientations in which the child should flip to fit within the screen. - */ -Qt::Orientations QWaylandXdgPopupV6::flipConstraints() const -{ - Q_D(const QWaylandXdgPopupV6); - const uint flags = d->m_positionerData.constraintAdjustments; - - Qt::Orientations constraints = 0; - - if (flags & ZXDG_POSITIONER_V6_CONSTRAINT_ADJUSTMENT_FLIP_X) - constraints |= Qt::Horizontal; - if (flags & ZXDG_POSITIONER_V6_CONSTRAINT_ADJUSTMENT_FLIP_Y) - constraints |= Qt::Vertical; - - return constraints; -} - -/*! - * \qmlproperty enumeration QtWaylandCompositor::XdgPopupV6::resizeConstraints - * - * This property holds the orientations in which the child should resize to fit within the screen. - * - * Possible values: - * \value Qt.Horizontal Horizontal - * \value Qt.Vertical Vertical - */ - -/*! - * \property QWaylandXdgPopupV6::resizeConstraints - * - * This property holds the orientations in which the child should resize to fit within the screen. - */ -Qt::Orientations QWaylandXdgPopupV6::resizeConstraints() const -{ - Q_D(const QWaylandXdgPopupV6); - const uint flags = d->m_positionerData.constraintAdjustments; - - Qt::Orientations constraints = 0; - - if (flags & ZXDG_POSITIONER_V6_CONSTRAINT_ADJUSTMENT_RESIZE_X) - constraints |= Qt::Horizontal; - if (flags & ZXDG_POSITIONER_V6_CONSTRAINT_ADJUSTMENT_RESIZE_Y) - constraints |= Qt::Vertical; - - return constraints; -} - -/*! - * \qmlproperty point QtWaylandCompositor::XdgPopupV6::offset - * - * The position relative to the position of the anchor on the anchor rectangle and - * the anchor on the surface. - */ - -/*! - * \property QWaylandXdgPopupV6::offset - * - * Returns the surface position relative to the position of the anchor on the anchor - * rectangle and the anchor on the surface. - */ -QPoint QWaylandXdgPopupV6::offset() const -{ - Q_D(const QWaylandXdgPopupV6); - return d->m_positionerData.offset; -} - -/*! - * \qmlproperty size QtWaylandCompositor::XdgPopupV6::positionerSize - * - * The size requested for the window geometry by the positioner object. - */ - -/*! - * \property QWaylandXdgPopupV6::positionerSize - * - * Returns the size requested for the window geometry by the positioner object. - */ -QSize QWaylandXdgPopupV6::positionerSize() const -{ - Q_D(const QWaylandXdgPopupV6); - return d->m_positionerData.size; -} - -/*! - * \qmlproperty point QtWaylandCompositor::XdgPopupV6::unconstrainedPosition - * - * The position of the surface relative to the parent window geometry if the surface - * is not constrained. I.e. when not moved to fit inside the screen or similar. - */ - -/*! - * \property QWaylandXdgPopupV6::unconstrainedPosition - * - * The position of the surface relative to the parent window geometry if the surface - * is not constrained. I.e. when not moved to fit inside the screen or similar. - */ -QPoint QWaylandXdgPopupV6::unconstrainedPosition() const -{ - Q_D(const QWaylandXdgPopupV6); - return d->m_positionerData.unconstrainedPosition(); -} - -/*! - * \qmlmethod int QtWaylandCompositor::XdgPopupV6::sendConfigure(rect geometry) - * - * Sends a configure event to the client. \a geometry contains the window geometry - * relative to the upper left corner of the window geometry of the parent surface. - * - * This implicitly sends a configure event to the corresponding XdgSurfaceV6 as well. - */ - -/*! - * Sends a configure event to the client. \a geometry contains the window geometry - * relative to the upper left corner of the window geometry of the parent surface. - * - * This implicitly sends a configure event to the corresponding QWaylandXdgSurfaceV6 - * as well. - */ -uint QWaylandXdgPopupV6::sendConfigure(const QRect &geometry) -{ - Q_D(QWaylandXdgPopupV6); - return d->sendConfigure(geometry); -} - -/*! - * \qmlmethod void QtWaylandCompositor::XdgPopupV6::sendPopupDone() - * \since 5.14 - * - * Dismiss the popup. According to the \c xdg-shell-unstable-v6 protocol this should make the - * client destroy the popup. - */ - -/*! - * \since 5.14 - * - * Dismiss the popup. According to the \c xdg-shell-unstable-v6 protocol this should make the - * client destroy the popup. - */ -void QWaylandXdgPopupV6::sendPopupDone() -{ - Q_D(QWaylandXdgPopupV6); - d->send_popup_done(); -} - -/*! - * Returns the surface role for the QWaylandPopupV6. - */ -QWaylandSurfaceRole *QWaylandXdgPopupV6::role() -{ - return &QWaylandXdgPopupV6Private::s_role; -} - -QWaylandXdgPopupV6Private::QWaylandXdgPopupV6Private(QWaylandXdgSurfaceV6 *xdgSurface, QWaylandXdgSurfaceV6 *parentXdgSurface, - QWaylandXdgPositionerV6 *positioner, const QWaylandResource &resource) - : m_xdgSurface(xdgSurface) - , m_parentXdgSurface(parentXdgSurface) - , m_positionerData(positioner->m_data) -{ - Q_ASSERT(m_positionerData.isComplete()); - init(resource.resource()); - - QWaylandXdgSurfaceV6Private::get(m_xdgSurface)->setWindowType(Qt::WindowType::Popup); - - //TODO: Need an API for sending a different initial configure - sendConfigure(QRect(m_positionerData.unconstrainedPosition(), m_positionerData.size)); -} - -void QWaylandXdgPopupV6Private::handleAckConfigure(uint serial) -{ - Q_Q(QWaylandXdgPopupV6); - ConfigureEvent config; - Q_FOREVER { - if (m_pendingConfigures.empty()) { - qWarning("Popup received an unexpected ack_configure!"); - return; - } - - // This won't work unless there always is a popup.configure for each xdgsurface.configure - config = m_pendingConfigures.takeFirst(); - - if (config.serial == serial) - break; - } - - if (m_geometry == config.geometry) - return; - - m_geometry = config.geometry; - emit q->configuredGeometryChanged(); -} - -uint QWaylandXdgPopupV6Private::sendConfigure(const QRect &geometry) -{ - uint32_t serial = m_xdgSurface->surface()->compositor()->nextSerial(); - m_pendingConfigures.append(QWaylandXdgPopupV6Private::ConfigureEvent{geometry, serial}); - send_configure(geometry.x(), geometry.y(), geometry.width(), geometry.height()); - QWaylandXdgSurfaceV6Private::get(m_xdgSurface)->send_configure(serial); - return serial; -} - -void QWaylandXdgPopupV6Private::zxdg_popup_v6_destroy(QtWaylandServer::zxdg_popup_v6::Resource *resource) -{ - Q_UNUSED(resource); - qWarning() << Q_FUNC_INFO << "Not implemented"; //TODO -} - -void QWaylandXdgPopupV6Private::zxdg_popup_v6_grab(QtWaylandServer::zxdg_popup_v6::Resource *resource, wl_resource *seat, uint32_t serial) -{ - Q_UNUSED(resource); - Q_UNUSED(serial); - Q_UNUSED(seat); - qWarning() << Q_FUNC_INFO << "Not implemented"; //TODO - //switch keyboard focus - //eventually send configure with activated. -} - -QWaylandSurfaceRole QWaylandXdgPopupV6Private::s_role("zxdg_popup_v6"); - -QWaylandXdgPositionerV6Data::QWaylandXdgPositionerV6Data() - : offset(0, 0) -{} - -bool QWaylandXdgPositionerV6Data::isComplete() const -{ - return size.width() > 0 && size.height() > 0 && anchorRect.size().width() > 0 && anchorRect.size().height() > 0; -} - -QPoint QWaylandXdgPositionerV6Data::anchorPoint() const -{ - int yPosition = 0; - if (anchorEdges & Qt::TopEdge) - yPosition = anchorRect.top(); - else if (anchorEdges & Qt::BottomEdge) - yPosition = anchorRect.bottom() + 1; - else - yPosition = anchorRect.top() + anchorRect.height() / 2; - - int xPosition = 0; - if (anchorEdges & Qt::LeftEdge) - xPosition = anchorRect.left(); - else if (anchorEdges & Qt::RightEdge) - xPosition = anchorRect.right() + 1; - else - xPosition = anchorRect.left() + anchorRect.width() / 2; - - return QPoint(xPosition, yPosition); -} - -QPoint QWaylandXdgPositionerV6Data::unconstrainedPosition() const -{ - int gravityOffsetY = 0; - if (gravityEdges & Qt::TopEdge) - gravityOffsetY = -size.height(); - else if (!(gravityEdges & Qt::BottomEdge)) - gravityOffsetY = -size.height() / 2; - - int gravityOffsetX = 0; - if (gravityEdges & Qt::LeftEdge) - gravityOffsetX = -size.width(); - else if (!(gravityEdges & Qt::RightEdge)) - gravityOffsetX = -size.width() / 2; - - QPoint gravityOffset(gravityOffsetX, gravityOffsetY); - return anchorPoint() + gravityOffset + offset; -} - -QWaylandXdgPositionerV6::QWaylandXdgPositionerV6(const QWaylandResource &resource) -{ - init(resource.resource()); -} - -void QWaylandXdgPositionerV6::zxdg_positioner_v6_destroy_resource(QtWaylandServer::zxdg_positioner_v6::Resource *resource) -{ - Q_UNUSED(resource); - delete this; -} - -void QWaylandXdgPositionerV6::zxdg_positioner_v6_destroy(QtWaylandServer::zxdg_positioner_v6::Resource *resource) -{ - wl_resource_destroy(resource->handle); -} - -void QWaylandXdgPositionerV6::zxdg_positioner_v6_set_size(QtWaylandServer::zxdg_positioner_v6::Resource *resource, int32_t width, int32_t height) -{ - if (width <= 0 || height <= 0) { - wl_resource_post_error(resource->handle, ZXDG_POSITIONER_V6_ERROR_INVALID_INPUT, - "zxdg_positioner_v6.set_size requested with non-positive dimensions"); - return; - } - - QSize size(width, height); - m_data.size = size; -} - -void QWaylandXdgPositionerV6::zxdg_positioner_v6_set_anchor_rect(QtWaylandServer::zxdg_positioner_v6::Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height) -{ - if (width <= 0 || height <= 0) { - wl_resource_post_error(resource->handle, ZXDG_POSITIONER_V6_ERROR_INVALID_INPUT, - "zxdg_positioner_v6.set_anchor_rect requested with non-positive dimensions"); - return; - } - - QRect anchorRect(x, y, width, height); - m_data.anchorRect = anchorRect; -} - -void QWaylandXdgPositionerV6::zxdg_positioner_v6_set_anchor(QtWaylandServer::zxdg_positioner_v6::Resource *resource, uint32_t anchor) -{ - Qt::Edges anchorEdges = QWaylandXdgShellV6Private::convertToEdges(anchor); - - if ((anchorEdges & Qt::BottomEdge && anchorEdges & Qt::TopEdge) || - (anchorEdges & Qt::LeftEdge && anchorEdges & Qt::RightEdge)) { - wl_resource_post_error(resource->handle, ZXDG_POSITIONER_V6_ERROR_INVALID_INPUT, - "zxdg_positioner_v6.set_anchor requested with parallel edges"); - return; - } - - m_data.anchorEdges = anchorEdges; -} - -void QWaylandXdgPositionerV6::zxdg_positioner_v6_set_gravity(QtWaylandServer::zxdg_positioner_v6::Resource *resource, uint32_t gravity) -{ - Qt::Edges gravityEdges = QWaylandXdgShellV6Private::convertToEdges(gravity); - - if ((gravityEdges & Qt::BottomEdge && gravityEdges & Qt::TopEdge) || - (gravityEdges & Qt::LeftEdge && gravityEdges & Qt::RightEdge)) { - wl_resource_post_error(resource->handle, ZXDG_POSITIONER_V6_ERROR_INVALID_INPUT, - "zxdg_positioner_v6.set_gravity requested with parallel edges"); - return; - } - - m_data.gravityEdges = gravityEdges; -} - -void QWaylandXdgPositionerV6::zxdg_positioner_v6_set_constraint_adjustment(QtWaylandServer::zxdg_positioner_v6::Resource *resource, uint32_t constraint_adjustment) -{ - Q_UNUSED(resource); - m_data.constraintAdjustments = constraint_adjustment; -} - -void QWaylandXdgPositionerV6::zxdg_positioner_v6_set_offset(QtWaylandServer::zxdg_positioner_v6::Resource *resource, int32_t x, int32_t y) -{ - Q_UNUSED(resource); - m_data.offset = QPoint(x, y); -} - -QWaylandXdgPositionerV6 *QWaylandXdgPositionerV6::fromResource(wl_resource *resource) -{ - return QtWayland::fromResource<QWaylandXdgPositionerV6 *>(resource); -} - -QT_END_NAMESPACE diff --git a/src/compositor/extensions/qwaylandxdgshellv6.h b/src/compositor/extensions/qwaylandxdgshellv6.h deleted file mode 100644 index 71f82521a..000000000 --- a/src/compositor/extensions/qwaylandxdgshellv6.h +++ /dev/null @@ -1,264 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** 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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QWAYLANDXDGSHELLV6_H -#define QWAYLANDXDGSHELLV6_H - -#include <QtWaylandCompositor/QWaylandCompositorExtension> -#include <QtWaylandCompositor/QWaylandResource> -#include <QtWaylandCompositor/QWaylandShell> -#include <QtWaylandCompositor/QWaylandShellSurface> -#include <QtWaylandCompositor/qwaylandquickchildren.h> - -#include <QtCore/QRect> - -struct wl_resource; - -QT_BEGIN_NAMESPACE - -class QWaylandClient; -class QWaylandOutput; -class QWaylandSeat; -class QWaylandSurface; -class QWaylandSurfaceRole; -class QWaylandXdgShellV6Private; -class QWaylandXdgSurfaceV6; -class QWaylandXdgSurfaceV6Private; -class QWaylandXdgToplevelV6; -class QWaylandXdgToplevelV6Private; -class QWaylandXdgPopupV6; -class QWaylandXdgPopupV6Private; -class QWaylandXdgPositionerV6; - -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgShellV6 : public QWaylandShellTemplate<QWaylandXdgShellV6> -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QWaylandXdgShellV6) -public: - QWaylandXdgShellV6(); - QWaylandXdgShellV6(QWaylandCompositor *compositor); - - void initialize() override; - - static const struct wl_interface *interface(); - static QByteArray interfaceName(); - -public Q_SLOTS: - uint ping(QWaylandClient *client); - -Q_SIGNALS: - void xdgSurfaceCreated(QWaylandXdgSurfaceV6 *xdgSurface); - void toplevelCreated(QWaylandXdgToplevelV6 *toplevel, QWaylandXdgSurfaceV6 *xdgSurface); - void popupCreated(QWaylandXdgPopupV6 *popup, QWaylandXdgSurfaceV6 *xdgSurface); - void pong(uint serial); - -private Q_SLOTS: - void handleSeatChanged(QWaylandSeat *newSeat, QWaylandSeat *oldSeat); - void handleFocusChanged(QWaylandSurface *newSurface, QWaylandSurface *oldSurface); -}; - -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgSurfaceV6 : public QWaylandShellSurfaceTemplate<QWaylandXdgSurfaceV6> -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QWaylandXdgSurfaceV6) - Q_WAYLAND_COMPOSITOR_DECLARE_QUICK_CHILDREN(QWaylandXdgSurfaceV6) - Q_PROPERTY(QWaylandXdgShellV6 *shell READ shell NOTIFY shellChanged) - Q_PROPERTY(QWaylandSurface *surface READ surface NOTIFY surfaceChanged) - Q_PROPERTY(QWaylandXdgToplevelV6 *toplevel READ toplevel NOTIFY toplevelCreated) - Q_PROPERTY(QWaylandXdgPopupV6 *popup READ popup NOTIFY popupCreated) - Q_PROPERTY(QRect windowGeometry READ windowGeometry NOTIFY windowGeometryChanged) - -public: - QWaylandXdgSurfaceV6(); - QWaylandXdgSurfaceV6(QWaylandXdgShellV6* xdgShell, QWaylandSurface *surface, const QWaylandResource &resource); - - Q_INVOKABLE void initialize(QWaylandXdgShellV6* xdgShell, QWaylandSurface *surface, const QWaylandResource &resource); - - Qt::WindowType windowType() const override; - - QWaylandXdgShellV6 *shell() const; - QWaylandSurface *surface() const; - QWaylandXdgToplevelV6 *toplevel() const; - QWaylandXdgPopupV6 *popup() const; - QRect windowGeometry() const; - - static const struct wl_interface *interface(); - static QByteArray interfaceName(); - static QWaylandXdgSurfaceV6 *fromResource(::wl_resource *resource); - -#if QT_CONFIG(wayland_compositor_quick) - QWaylandQuickShellIntegration *createIntegration(QWaylandQuickShellSurfaceItem *item) override; -#endif - -Q_SIGNALS: - void shellChanged(); - void surfaceChanged(); - void toplevelCreated(); - void popupCreated(); - void windowGeometryChanged(); - -private: - void initialize() override; - -private Q_SLOTS: - void handleSurfaceSizeChanged(); - void handleBufferScaleChanged(); -}; - -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgToplevelV6 : public QObject -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QWaylandXdgToplevelV6) - Q_PROPERTY(QWaylandXdgToplevelV6 *parentToplevel READ parentToplevel NOTIFY parentToplevelChanged) - Q_PROPERTY(QString title READ title NOTIFY titleChanged) - Q_PROPERTY(QString appId READ appId NOTIFY appIdChanged) - Q_PROPERTY(QSize maxSize READ maxSize NOTIFY maxSizeChanged) - Q_PROPERTY(QSize minSize READ minSize NOTIFY minSizeChanged) - Q_PROPERTY(QList<int> states READ statesAsInts NOTIFY statesChanged) - Q_PROPERTY(bool maximized READ maximized NOTIFY maximizedChanged) - Q_PROPERTY(bool fullscreen READ fullscreen NOTIFY fullscreenChanged) - Q_PROPERTY(bool resizing READ resizing NOTIFY resizingChanged) - Q_PROPERTY(bool activated READ activated NOTIFY activatedChanged) -public: - enum State : uint { - MaximizedState = 1, - FullscreenState = 2, - ResizingState = 3, - ActivatedState = 4 - }; - Q_ENUM(State) - - QWaylandXdgToplevelV6(QWaylandXdgSurfaceV6 *xdgSurface, QWaylandResource &resource); - - QWaylandXdgToplevelV6 *parentToplevel() const; - - QString title() const; - QString appId() const; - QSize maxSize() const; - QSize minSize() const; - QVector<QWaylandXdgToplevelV6::State> states() const; - bool maximized() const; - bool fullscreen() const; - bool resizing() const; - bool activated() const; - - Q_INVOKABLE QSize sizeForResize(const QSizeF &size, const QPointF &delta, Qt::Edges edges) const; - uint sendConfigure(const QSize &size, const QVector<State> &states); - Q_INVOKABLE uint sendConfigure(const QSize &size, const QVector<int> &states); - Q_INVOKABLE void sendClose(); - Q_INVOKABLE uint sendMaximized(const QSize &size); - Q_INVOKABLE uint sendUnmaximized(const QSize &size = QSize(0, 0)); - Q_INVOKABLE uint sendFullscreen(const QSize &size); - Q_INVOKABLE uint sendResizing(const QSize &maxSize); - - static QWaylandSurfaceRole *role(); - -Q_SIGNALS: - void parentToplevelChanged(); - void titleChanged(); - void appIdChanged(); - void maxSizeChanged(); - void minSizeChanged(); - void startMove(QWaylandSeat *seat); - void startResize(QWaylandSeat *seat, Qt::Edges edges); - void statesChanged(); - void maximizedChanged(); - void fullscreenChanged(); - void resizingChanged(); - void activatedChanged(); - - void showWindowMenu(QWaylandSeat *seat, const QPoint &localSurfacePosition); - void setMaximized(); - void unsetMaximized(); - void setFullscreen(QWaylandOutput *output); - void unsetFullscreen(); - void setMinimized(); - -private: - QList<int> statesAsInts() const; -}; - -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgPopupV6 : public QObject -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QWaylandXdgPopupV6) - Q_PROPERTY(QWaylandXdgSurfaceV6 *xdgSurface READ xdgSurface) - Q_PROPERTY(QWaylandXdgSurfaceV6 *parentXdgSurface READ parentXdgSurface) - Q_PROPERTY(QRect configuredGeometry READ configuredGeometry NOTIFY configuredGeometryChanged) - - // Positioner properties - Q_PROPERTY(QRect anchorRect READ anchorRect CONSTANT) - Q_PROPERTY(Qt::Edges anchorEdges READ anchorEdges CONSTANT) - Q_PROPERTY(Qt::Edges gravityEdges READ gravityEdges CONSTANT) - Q_PROPERTY(Qt::Orientations slideConstraints READ slideConstraints CONSTANT) - Q_PROPERTY(Qt::Orientations flipConstraints READ flipConstraints CONSTANT) - Q_PROPERTY(Qt::Orientations resizeConstraints READ resizeConstraints CONSTANT) - Q_PROPERTY(QPoint offset READ offset CONSTANT) - Q_PROPERTY(QSize positionerSize READ positionerSize CONSTANT) - Q_PROPERTY(QPoint unconstrainedPosition READ unconstrainedPosition CONSTANT) -public: - QWaylandXdgSurfaceV6 *xdgSurface() const; - QWaylandXdgSurfaceV6 *parentXdgSurface() const; - QRect configuredGeometry() const; - - // Positioner properties - QRect anchorRect() const; - Qt::Edges anchorEdges() const ; - Qt::Edges gravityEdges() const ; - Qt::Orientations slideConstraints() const; - Qt::Orientations flipConstraints() const; - Qt::Orientations resizeConstraints() const; - QPoint offset() const; - QSize positionerSize() const; - QPoint unconstrainedPosition() const; - - Q_INVOKABLE uint sendConfigure(const QRect &geometry); - Q_REVISION(14) Q_INVOKABLE void sendPopupDone(); - - static QWaylandSurfaceRole *role(); - -Q_SIGNALS: - void configuredGeometryChanged(); - -private: - QWaylandXdgPopupV6(QWaylandXdgSurfaceV6 *xdgSurface, QWaylandXdgSurfaceV6 *parentXdgSurface, - QWaylandXdgPositionerV6 *positioner, QWaylandResource &resource); - friend class QWaylandXdgSurfaceV6Private; -}; - -QT_END_NAMESPACE - -#endif // QWAYLANDXDGSHELLV6_H diff --git a/src/compositor/extensions/qwaylandxdgshellv6_p.h b/src/compositor/extensions/qwaylandxdgshellv6_p.h deleted file mode 100644 index 457bc2201..000000000 --- a/src/compositor/extensions/qwaylandxdgshellv6_p.h +++ /dev/null @@ -1,246 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** 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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QWAYLANDXDGSHELLV6_P_H -#define QWAYLANDXDGSHELLV6_P_H - -#include <QtWaylandCompositor/private/qwaylandcompositorextension_p.h> -#include <QtWaylandCompositor/private/qwaylandshell_p.h> -#include <QtWaylandCompositor/private/qwayland-server-xdg-shell-unstable-v6.h> - -#include <QtWaylandCompositor/QWaylandXdgShellV6> - -#include <QtCore/QSet> - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -QT_BEGIN_NAMESPACE - -struct Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgPositionerV6Data { - QSize size; - QRect anchorRect; - Qt::Edges anchorEdges = 0; - Qt::Edges gravityEdges = 0; - uint constraintAdjustments = ZXDG_POSITIONER_V6_CONSTRAINT_ADJUSTMENT_NONE; - QPoint offset; - QWaylandXdgPositionerV6Data(); - bool isComplete() const; - QPoint anchorPoint() const; - QPoint unconstrainedPosition() const; -}; - -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgShellV6Private - : public QWaylandShellPrivate - , public QtWaylandServer::zxdg_shell_v6 -{ - Q_DECLARE_PUBLIC(QWaylandXdgShellV6) -public: - QWaylandXdgShellV6Private(); - void ping(Resource *resource, uint32_t serial); - void registerXdgSurface(QWaylandXdgSurfaceV6 *xdgSurface); - void unregisterXdgSurface(QWaylandXdgSurfaceV6 *xdgSurface); - static QWaylandXdgShellV6Private *get(QWaylandXdgShellV6 *xdgShell) { return xdgShell->d_func(); } - static Qt::Edges convertToEdges(uint xdgEdges); - - QSet<uint32_t> m_pings; - QMultiMap<struct wl_client *, QWaylandXdgSurfaceV6 *> m_xdgSurfaces; - - QWaylandXdgSurfaceV6 *xdgSurfaceFromSurface(QWaylandSurface *surface); - -protected: - void zxdg_shell_v6_destroy(Resource *resource) override; - void zxdg_shell_v6_create_positioner(Resource *resource, uint32_t id) override; - void zxdg_shell_v6_get_xdg_surface(Resource *resource, uint32_t id, - struct ::wl_resource *surface) override; - void zxdg_shell_v6_pong(Resource *resource, uint32_t serial) override; -}; - -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgSurfaceV6Private - : public QWaylandCompositorExtensionPrivate - , public QtWaylandServer::zxdg_surface_v6 -{ - Q_DECLARE_PUBLIC(QWaylandXdgSurfaceV6) -public: - QWaylandXdgSurfaceV6Private(); - void setWindowType(Qt::WindowType windowType); - void handleFocusLost(); - void handleFocusReceived(); - static QWaylandXdgSurfaceV6Private *get(QWaylandXdgSurfaceV6 *xdgSurface) { return xdgSurface->d_func(); } - - QRect calculateFallbackWindowGeometry() const; - void updateFallbackWindowGeometry(); - -private: - QWaylandXdgShellV6 *m_xdgShell = nullptr; - QWaylandSurface *m_surface = nullptr; - - QWaylandXdgToplevelV6 *m_toplevel = nullptr; - QWaylandXdgPopupV6 *m_popup = nullptr; - QRect m_windowGeometry; - bool m_unsetWindowGeometry = true; - QMargins m_windowMargins; - Qt::WindowType m_windowType = Qt::WindowType::Window; - - void zxdg_surface_v6_destroy_resource(Resource *resource) override; - void zxdg_surface_v6_destroy(Resource *resource) override; - void zxdg_surface_v6_get_toplevel(Resource *resource, uint32_t id) override; - void zxdg_surface_v6_get_popup(Resource *resource, uint32_t id, struct ::wl_resource *parent, struct ::wl_resource *positioner) override; - void zxdg_surface_v6_ack_configure(Resource *resource, uint32_t serial) override; - void zxdg_surface_v6_set_window_geometry(Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height) override; -}; - -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgToplevelV6Private : public QObjectPrivate, public QtWaylandServer::zxdg_toplevel_v6 -{ - Q_DECLARE_PUBLIC(QWaylandXdgToplevelV6) -public: - struct ConfigureEvent { - ConfigureEvent() = default; - ConfigureEvent(const QVector<QWaylandXdgToplevelV6::State> - &incomingStates, - const QSize &incomingSize, uint incomingSerial) - : states(incomingStates), size(incomingSize), serial(incomingSerial) - { } - QVector<QWaylandXdgToplevelV6::State> states; - QSize size = {0, 0}; - uint serial = 0; - }; - - QWaylandXdgToplevelV6Private(QWaylandXdgSurfaceV6 *xdgSurface, const QWaylandResource& resource); - ConfigureEvent lastSentConfigure() const { return m_pendingConfigures.empty() ? m_lastAckedConfigure : m_pendingConfigures.last(); } - void handleAckConfigure(uint serial); //TODO: move? - void handleFocusLost(); - void handleFocusReceived(); - - static QWaylandXdgToplevelV6Private *get(QWaylandXdgToplevelV6 *toplevel) { return toplevel->d_func(); } - -protected: - - void zxdg_toplevel_v6_destroy_resource(Resource *resource) override; - - void zxdg_toplevel_v6_destroy(Resource *resource) override; - void zxdg_toplevel_v6_set_parent(Resource *resource, struct ::wl_resource *parent) override; - void zxdg_toplevel_v6_set_title(Resource *resource, const QString &title) override; - void zxdg_toplevel_v6_set_app_id(Resource *resource, const QString &app_id) override; - void zxdg_toplevel_v6_show_window_menu(Resource *resource, struct ::wl_resource *seat, uint32_t serial, int32_t x, int32_t y) override; - void zxdg_toplevel_v6_move(Resource *resource, struct ::wl_resource *seatResource, uint32_t serial) override; - void zxdg_toplevel_v6_resize(Resource *resource, struct ::wl_resource *seat, uint32_t serial, uint32_t edges) override; - void zxdg_toplevel_v6_set_max_size(Resource *resource, int32_t width, int32_t height) override; - void zxdg_toplevel_v6_set_min_size(Resource *resource, int32_t width, int32_t height) override; - void zxdg_toplevel_v6_set_maximized(Resource *resource) override; - void zxdg_toplevel_v6_unset_maximized(Resource *resource) override; - void zxdg_toplevel_v6_set_fullscreen(Resource *resource, struct ::wl_resource *output) override; - void zxdg_toplevel_v6_unset_fullscreen(Resource *resource) override; - void zxdg_toplevel_v6_set_minimized(Resource *resource) override; - -public: - QWaylandXdgSurfaceV6 *m_xdgSurface = nullptr; - QWaylandXdgToplevelV6 *m_parentToplevel = nullptr; - QList<ConfigureEvent> m_pendingConfigures; - ConfigureEvent m_lastAckedConfigure; - QString m_title; - QString m_appId; - QSize m_maxSize; - QSize m_minSize; - - static QWaylandSurfaceRole s_role; -}; - -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgPopupV6Private : public QObjectPrivate, public QtWaylandServer::zxdg_popup_v6 -{ - Q_DECLARE_PUBLIC(QWaylandXdgPopupV6) -public: - struct ConfigureEvent { - QRect geometry; - uint serial; - }; - - QWaylandXdgPopupV6Private(QWaylandXdgSurfaceV6 *xdgSurface, QWaylandXdgSurfaceV6 *parentXdgSurface, - QWaylandXdgPositionerV6 *positioner, const QWaylandResource& resource); - - void handleAckConfigure(uint serial); - - static QWaylandXdgPopupV6Private *get(QWaylandXdgPopupV6 *popup) { return popup->d_func(); } - - static QWaylandSurfaceRole s_role; - -private: - uint sendConfigure(const QRect &geometry); - -protected: - void zxdg_popup_v6_destroy(Resource *resource) override; - void zxdg_popup_v6_grab(Resource *resource, struct ::wl_resource *seat, uint32_t serial) override; - -private: - QWaylandXdgSurfaceV6 *m_xdgSurface = nullptr; - QWaylandXdgSurfaceV6 *m_parentXdgSurface = nullptr; - QWaylandXdgPositionerV6Data m_positionerData; - QRect m_geometry; - QList<ConfigureEvent> m_pendingConfigures; -}; - -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgPositionerV6 : public QtWaylandServer::zxdg_positioner_v6 -{ -public: - QWaylandXdgPositionerV6(const QWaylandResource& resource); - static QWaylandXdgPositionerV6 *fromResource(wl_resource *resource); - -protected: - void zxdg_positioner_v6_destroy_resource(Resource *resource) override; //TODO: do something special here? - - void zxdg_positioner_v6_destroy(Resource *resource) override; - void zxdg_positioner_v6_set_size(Resource *resource, int32_t width, int32_t height) override; - void zxdg_positioner_v6_set_anchor_rect(Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height) override; - void zxdg_positioner_v6_set_anchor(Resource *resource, uint32_t anchor) override; - void zxdg_positioner_v6_set_gravity(Resource *resource, uint32_t gravity) override; - void zxdg_positioner_v6_set_constraint_adjustment(Resource *resource, uint32_t constraint_adjustment) override; - void zxdg_positioner_v6_set_offset(Resource *resource, int32_t x, int32_t y) override; - -public: - QWaylandXdgPositionerV6Data m_data; -}; - -QT_END_NAMESPACE - -#endif // QWAYLANDXDGSHELLV6_P_H diff --git a/src/compositor/extensions/qwaylandxdgshellv6integration.cpp b/src/compositor/extensions/qwaylandxdgshellv6integration.cpp deleted file mode 100644 index e424af193..000000000 --- a/src/compositor/extensions/qwaylandxdgshellv6integration.cpp +++ /dev/null @@ -1,312 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** 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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qwaylandxdgshellv6integration_p.h" - -#include <QtWaylandCompositor/QWaylandXdgSurfaceV6> -#include <QtWaylandCompositor/QWaylandCompositor> -#include <QtWaylandCompositor/QWaylandSeat> - -QT_BEGIN_NAMESPACE - -namespace QtWayland { - -static void handlePopupCreated(QWaylandQuickShellSurfaceItem *parentItem, QWaylandXdgPopupV6 *popup) -{ - if (parentItem->shellSurface() == popup->parentXdgSurface()) - QWaylandQuickShellSurfaceItemPrivate::get(parentItem)->maybeCreateAutoPopup(popup->xdgSurface()); -} - -XdgToplevelV6Integration::XdgToplevelV6Integration(QWaylandQuickShellSurfaceItem *item) - : QWaylandQuickShellIntegration(item) - , m_item(item) - , m_xdgSurface(qobject_cast<QWaylandXdgSurfaceV6 *>(item->shellSurface())) - , m_toplevel(m_xdgSurface->toplevel()) - , grabberState(GrabberState::Default) -{ - Q_ASSERT(m_toplevel); - - m_item->setSurface(m_xdgSurface->surface()); - - connect(m_toplevel, &QWaylandXdgToplevelV6::startMove, this, &XdgToplevelV6Integration::handleStartMove); - connect(m_toplevel, &QWaylandXdgToplevelV6::startResize, this, &XdgToplevelV6Integration::handleStartResize); - connect(m_toplevel, &QWaylandXdgToplevelV6::setMaximized, this, &XdgToplevelV6Integration::handleSetMaximized); - connect(m_toplevel, &QWaylandXdgToplevelV6::unsetMaximized, this, &XdgToplevelV6Integration::handleUnsetMaximized); - connect(m_toplevel, &QWaylandXdgToplevelV6::maximizedChanged, this, &XdgToplevelV6Integration::handleMaximizedChanged); - connect(m_toplevel, &QWaylandXdgToplevelV6::setFullscreen, this, &XdgToplevelV6Integration::handleSetFullscreen); - connect(m_toplevel, &QWaylandXdgToplevelV6::unsetFullscreen, this, &XdgToplevelV6Integration::handleUnsetFullscreen); - connect(m_toplevel, &QWaylandXdgToplevelV6::fullscreenChanged, this, &XdgToplevelV6Integration::handleFullscreenChanged); - connect(m_toplevel, &QWaylandXdgToplevelV6::activatedChanged, this, &XdgToplevelV6Integration::handleActivatedChanged); - connect(m_xdgSurface->shell(), &QWaylandXdgShellV6::popupCreated, this, [item](QWaylandXdgPopupV6 *popup, QWaylandXdgSurfaceV6 *){ - handlePopupCreated(item, popup); - }); - connect(m_xdgSurface->surface(), &QWaylandSurface::destinationSizeChanged, this, &XdgToplevelV6Integration::handleSurfaceSizeChanged); - connect(m_toplevel, &QObject::destroyed, this, &XdgToplevelV6Integration::handleToplevelDestroyed); -} - -bool XdgToplevelV6Integration::eventFilter(QObject *object, QEvent *event) -{ - if (event->type() == QEvent::MouseMove) { - QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event); - return filterMouseMoveEvent(mouseEvent); - } else if (event->type() == QEvent::MouseButtonRelease) { - QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event); - return filterMouseReleaseEvent(mouseEvent); - } - return QWaylandQuickShellIntegration::eventFilter(object, event); -} - -bool XdgToplevelV6Integration::filterMouseMoveEvent(QMouseEvent *event) -{ - if (grabberState == GrabberState::Resize) { - Q_ASSERT(resizeState.seat == m_item->compositor()->seatFor(event)); - if (!resizeState.initialized) { - resizeState.initialMousePos = event->windowPos(); - resizeState.initialized = true; - return true; - } - QPointF delta = m_item->mapToSurface(event->windowPos() - resizeState.initialMousePos); - QSize newSize = m_toplevel->sizeForResize(resizeState.initialWindowSize, delta, resizeState.resizeEdges); - m_toplevel->sendResizing(newSize); - } else if (grabberState == GrabberState::Move) { - Q_ASSERT(moveState.seat == m_item->compositor()->seatFor(event)); - QQuickItem *moveItem = m_item->moveItem(); - if (!moveState.initialized) { - moveState.initialOffset = moveItem->mapFromItem(nullptr, event->windowPos()); - moveState.initialized = true; - return true; - } - if (!moveItem->parentItem()) - return true; - QPointF parentPos = moveItem->parentItem()->mapFromItem(nullptr, event->windowPos()); - moveItem->setPosition(parentPos - moveState.initialOffset); - } - return false; -} - -bool XdgToplevelV6Integration::filterMouseReleaseEvent(QMouseEvent *event) -{ - Q_UNUSED(event); - - if (grabberState != GrabberState::Default) { - grabberState = GrabberState::Default; - return true; - } - return false; -} - -void XdgToplevelV6Integration::handleStartMove(QWaylandSeat *seat) -{ - grabberState = GrabberState::Move; - moveState.seat = seat; - moveState.initialized = false; -} - -void XdgToplevelV6Integration::handleStartResize(QWaylandSeat *seat, Qt::Edges edges) -{ - grabberState = GrabberState::Resize; - resizeState.seat = seat; - resizeState.resizeEdges = edges; - resizeState.initialWindowSize = m_xdgSurface->windowGeometry().size(); - resizeState.initialPosition = m_item->moveItem()->position(); - resizeState.initialSurfaceSize = m_item->surface()->destinationSize(); - resizeState.initialized = false; -} - -void XdgToplevelV6Integration::handleSetMaximized() -{ - if (!m_item->view()->isPrimary()) - return; - - QVector<QWaylandXdgToplevelV6::State> states = m_toplevel->states(); - - if (!states.contains(QWaylandXdgToplevelV6::State::FullscreenState) && !states.contains(QWaylandXdgToplevelV6::State::MaximizedState)) { - windowedGeometry.initialWindowSize = m_xdgSurface->windowGeometry().size(); - windowedGeometry.initialPosition = m_item->moveItem()->position(); - } - - // Any prior output-resize handlers are irrelevant at this point. - disconnect(nonwindowedState.sizeChangedConnection); - nonwindowedState.output = m_item->view()->output(); - nonwindowedState.sizeChangedConnection = connect(nonwindowedState.output, &QWaylandOutput::availableGeometryChanged, this, &XdgToplevelV6Integration::handleMaximizedSizeChanged); - handleMaximizedSizeChanged(); -} - -void XdgToplevelV6Integration::handleMaximizedSizeChanged() -{ - // Insurance against handleToplevelDestroyed() not managing to disconnect this - // handler in time. - if (m_toplevel == nullptr) - return; - - m_toplevel->sendMaximized(nonwindowedState.output->availableGeometry().size() / nonwindowedState.output->scaleFactor()); -} - -void XdgToplevelV6Integration::handleUnsetMaximized() -{ - if (!m_item->view()->isPrimary()) - return; - - // If no prior windowed size was recorded, send a 0x0 configure event - // to allow the client to choose its preferred size. - if (windowedGeometry.initialWindowSize.isValid()) - m_toplevel->sendUnmaximized(windowedGeometry.initialWindowSize); - else - m_toplevel->sendUnmaximized(); -} - -void XdgToplevelV6Integration::handleMaximizedChanged() -{ - if (m_toplevel->maximized()) { - QWaylandOutput *output = m_item->view()->output(); - m_item->moveItem()->setPosition(output->position() + output->availableGeometry().topLeft()); - } else { - m_item->moveItem()->setPosition(windowedGeometry.initialPosition); - } -} - -void XdgToplevelV6Integration::handleSetFullscreen() -{ - if (!m_item->view()->isPrimary()) - return; - - QVector<QWaylandXdgToplevelV6::State> states = m_toplevel->states(); - - if (!states.contains(QWaylandXdgToplevelV6::State::FullscreenState) && !states.contains(QWaylandXdgToplevelV6::State::MaximizedState)) { - windowedGeometry.initialWindowSize = m_xdgSurface->windowGeometry().size(); - windowedGeometry.initialPosition = m_item->moveItem()->position(); - } - - // Any prior output-resize handlers are irrelevant at this point. - disconnect(nonwindowedState.sizeChangedConnection); - nonwindowedState.output = m_item->view()->output(); - nonwindowedState.sizeChangedConnection = connect(nonwindowedState.output, &QWaylandOutput::geometryChanged, this, &XdgToplevelV6Integration::handleFullscreenSizeChanged); - handleFullscreenSizeChanged(); -} - -void XdgToplevelV6Integration::handleFullscreenSizeChanged() -{ - // Insurance against handleToplevelDestroyed() not managing to disconnect this - // handler in time. - if (m_toplevel == nullptr) - return; - - m_toplevel->sendFullscreen(nonwindowedState.output->geometry().size() / nonwindowedState.output->scaleFactor()); -} - -void XdgToplevelV6Integration::handleUnsetFullscreen() -{ - if (!m_item->view()->isPrimary()) - return; - - // If no prior windowed size was recorded, send a 0x0 configure event - // to allow the client to choose its preferred size. - if (windowedGeometry.initialWindowSize.isValid()) - m_toplevel->sendUnmaximized(windowedGeometry.initialWindowSize); - else - m_toplevel->sendUnmaximized(); -} - -void XdgToplevelV6Integration::handleFullscreenChanged() -{ - if (m_toplevel->fullscreen()) { - QWaylandOutput *output = m_item->view()->output(); - m_item->moveItem()->setPosition(output->position() + output->geometry().topLeft()); - } else { - m_item->moveItem()->setPosition(windowedGeometry.initialPosition); - } -} - -void XdgToplevelV6Integration::handleActivatedChanged() -{ - if (m_toplevel->activated()) - m_item->raise(); -} - -void XdgToplevelV6Integration::handleSurfaceSizeChanged() -{ - if (grabberState == GrabberState::Resize) { - qreal dx = 0; - qreal dy = 0; - if (resizeState.resizeEdges & Qt::TopEdge) - dy = resizeState.initialSurfaceSize.height() - m_item->surface()->destinationSize().height(); - if (resizeState.resizeEdges & Qt::LeftEdge) - dx = resizeState.initialSurfaceSize.width() - m_item->surface()->destinationSize().width(); - QPointF offset = m_item->mapFromSurface({dx, dy}); - m_item->moveItem()->setPosition(resizeState.initialPosition + offset); - } -} - -void XdgToplevelV6Integration::handleToplevelDestroyed() -{ - // Disarm any handlers that might fire on the now-stale toplevel pointer - nonwindowedState.output = nullptr; - disconnect(nonwindowedState.sizeChangedConnection); -} - -XdgPopupV6Integration::XdgPopupV6Integration(QWaylandQuickShellSurfaceItem *item) - : m_item(item) - , m_xdgSurface(qobject_cast<QWaylandXdgSurfaceV6 *>(item->shellSurface())) - , m_popup(m_xdgSurface->popup()) -{ - Q_ASSERT(m_popup); - - m_item->setSurface(m_xdgSurface->surface()); - handleGeometryChanged(); - - connect(m_popup, &QWaylandXdgPopupV6::configuredGeometryChanged, this, &XdgPopupV6Integration::handleGeometryChanged); - connect(m_xdgSurface->shell(), &QWaylandXdgShellV6::popupCreated, this, [item](QWaylandXdgPopupV6 *popup, QWaylandXdgSurfaceV6 *){ - handlePopupCreated(item, popup); - }); -} - -void XdgPopupV6Integration::handleGeometryChanged() -{ - if (m_item->view()->output()) { - const QPoint windowOffset = m_popup->parentXdgSurface()->windowGeometry().topLeft(); - const QPoint surfacePosition = m_popup->unconstrainedPosition() + windowOffset; - const QPoint itemPosition = m_item->mapFromSurface(surfacePosition).toPoint(); - //TODO: positioner size or other size...? - //TODO check positioner constraints etc... sliding, flipping - m_item->moveItem()->setPosition(itemPosition); - } else { - qWarning() << "XdgPopupV6Integration popup item without output" << m_item; - } -} - -} - -QT_END_NAMESPACE diff --git a/src/compositor/extensions/qwaylandxdgshellv6integration_p.h b/src/compositor/extensions/qwaylandxdgshellv6integration_p.h deleted file mode 100644 index 9df2885f1..000000000 --- a/src/compositor/extensions/qwaylandxdgshellv6integration_p.h +++ /dev/null @@ -1,148 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** 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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QWAYLANDXDGSHELLV6INTEGRATION_H -#define QWAYLANDXDGSHELLV6INTEGRATION_H - -#include <QtWaylandCompositor/private/qwaylandquickshellsurfaceitem_p.h> -#include <QtWaylandCompositor/QWaylandQuickShellSurfaceItem> -#include <QtWaylandCompositor/QWaylandXdgToplevelV6> - -QT_BEGIN_NAMESPACE - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -class QWaylandXdgSurfaceV6; - -namespace QtWayland { - -class XdgToplevelV6Integration : public QWaylandQuickShellIntegration -{ - Q_OBJECT -public: - XdgToplevelV6Integration(QWaylandQuickShellSurfaceItem *item); - -protected: - bool eventFilter(QObject *object, QEvent *event) override; - -private Q_SLOTS: - void handleStartMove(QWaylandSeat *seat); - void handleStartResize(QWaylandSeat *seat, Qt::Edges edges); - void handleSetMaximized(); - void handleUnsetMaximized(); - void handleMaximizedChanged(); - void handleSetFullscreen(); - void handleUnsetFullscreen(); - void handleFullscreenChanged(); - void handleActivatedChanged(); - void handleSurfaceSizeChanged(); - void handleToplevelDestroyed(); - void handleMaximizedSizeChanged(); - void handleFullscreenSizeChanged(); - -private: - QWaylandQuickShellSurfaceItem *m_item = nullptr; - QWaylandXdgSurfaceV6 *m_xdgSurface = nullptr; - QWaylandXdgToplevelV6 *m_toplevel = nullptr; - - enum class GrabberState { - Default, - Resize, - Move - }; - GrabberState grabberState; - - struct { - QWaylandSeat *seat = nullptr; - QPointF initialOffset; - bool initialized = false; - } moveState; - - struct { - QWaylandSeat *seat = nullptr; - Qt::Edges resizeEdges; - QSizeF initialWindowSize; - QPointF initialMousePos; - QPointF initialPosition; - QSize initialSurfaceSize; - bool initialized = false; - } resizeState; - - struct { - QSize initialWindowSize; - QPointF initialPosition; - } windowedGeometry; - - struct { - QWaylandOutput *output = nullptr; - QMetaObject::Connection sizeChangedConnection; // Depending on whether maximized or fullscreen, - // will be hooked to geometry-changed or available- - // geometry-changed. - } nonwindowedState; - - bool filterMouseMoveEvent(QMouseEvent *event); - bool filterMouseReleaseEvent(QMouseEvent *event); -}; - -class XdgPopupV6Integration : public QWaylandQuickShellIntegration -{ - Q_OBJECT -public: - XdgPopupV6Integration(QWaylandQuickShellSurfaceItem *item); - -private Q_SLOTS: - void handleGeometryChanged(); - -private: - QWaylandQuickShellSurfaceItem *m_item = nullptr; - QWaylandXdgSurfaceV6 *m_xdgSurface = nullptr; - QWaylandXdgPopupV6 *m_popup = nullptr; -}; - -} - -QT_END_NAMESPACE - -#endif // QWAYLANDXDGSHELLV6INTEGRATION_H diff --git a/src/compositor/extensions/qwlqtkey.cpp b/src/compositor/extensions/qwlqtkey.cpp index 03a97c7ee..fb0f760ba 100644 --- a/src/compositor/extensions/qwlqtkey.cpp +++ b/src/compositor/extensions/qwlqtkey.cpp @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "qwlqtkey_p.h" #include <QtWaylandCompositor/QWaylandSurface> @@ -69,3 +43,5 @@ bool QtKeyExtensionGlobal::postQtKeyEvent(QKeyEvent *event, QWaylandSurface *sur } QT_END_NAMESPACE + +#include "moc_qwlqtkey_p.cpp" diff --git a/src/compositor/extensions/qwlqtkey_p.h b/src/compositor/extensions/qwlqtkey_p.h index f0517e50f..e7cff9607 100644 --- a/src/compositor/extensions/qwlqtkey_p.h +++ b/src/compositor/extensions/qwlqtkey_p.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef WLQTKEY_H #define WLQTKEY_H @@ -44,6 +18,7 @@ #include <QtWaylandCompositor/QWaylandCompositorExtensionTemplate> #include <QtWaylandCompositor/QWaylandCompositor> #include <QtWaylandCompositor/private/qwayland-server-qt-key-unstable-v1.h> +#include <QtCore/private/qglobal_p.h> #include <wayland-util.h> diff --git a/src/compositor/extensions/qwlqttouch.cpp b/src/compositor/extensions/qwlqttouch.cpp index 1f92432fb..1435dde1e 100644 --- a/src/compositor/extensions/qwlqttouch.cpp +++ b/src/compositor/extensions/qwlqttouch.cpp @@ -1,34 +1,9 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "qwlqttouch_p.h" #include "qwaylandview.h" +#include <QPointingDevice> #include <QTouchEvent> #include <QWindow> @@ -57,14 +32,14 @@ static inline int toFixed(qreal f) bool TouchExtensionGlobal::postTouchEvent(QTouchEvent *event, QWaylandSurface *surface) { - const QList<QTouchEvent::TouchPoint> points = event->touchPoints(); - const int pointCount = points.count(); + const QList<QTouchEvent::TouchPoint> points = event->points(); + const int pointCount = points.size(); if (!pointCount) return false; wl_client *surfaceClient = surface->client()->client(); uint32_t time = m_compositor->currentTimeMsecs(); - const int rescount = m_resources.count(); + const int rescount = m_resources.size(); for (int res = 0; res < rescount; ++res) { Resource *target = m_resources.at(res); @@ -76,47 +51,31 @@ bool TouchExtensionGlobal::postTouchEvent(QTouchEvent *event, QWaylandSurface *s // included in the touch point events. int sentPointCount = 0; for (int i = 0; i < pointCount; ++i) { - if (points.at(i).state() != Qt::TouchPointStationary) + if (points.at(i).state() != QEventPoint::Stationary) ++sentPointCount; } for (int i = 0; i < pointCount; ++i) { const QTouchEvent::TouchPoint &tp(points.at(i)); // Stationary points are never sent. They are cached on client side. - if (tp.state() == Qt::TouchPointStationary) + if (tp.state() == QEventPoint::Stationary) continue; uint32_t id = tp.id(); uint32_t state = (tp.state() & 0xFFFF) | (sentPointCount << 16); - uint32_t flags = (tp.flags() & 0xFFFF) | (int(event->device()->capabilities()) << 16); - - int x = toFixed(tp.pos().x()); - int y = toFixed(tp.pos().y()); - int nx = toFixed(tp.normalizedPos().x()); - int ny = toFixed(tp.normalizedPos().y()); - int w = toFixed(tp.rect().width()); - int h = toFixed(tp.rect().height()); + uint32_t flags = (int(event->pointingDevice()->capabilities()) << 16); + + int x = toFixed(tp.position().x()); + int y = toFixed(tp.position().y()); + int nx = toFixed(tp.normalizedPosition().x()); + int ny = toFixed(tp.normalizedPosition().y()); + int w = toFixed(tp.ellipseDiameters().width()); + int h = toFixed(tp.ellipseDiameters().height()); int vx = toFixed(tp.velocity().x()); int vy = toFixed(tp.velocity().y()); uint32_t pressure = uint32_t(tp.pressure() * 255); QByteArray rawData; - QVector<QPointF> rawPosList = tp.rawScreenPositions(); - int rawPosCount = rawPosList.count(); - if (rawPosCount) { - rawPosCount = qMin(maxRawPos, rawPosCount); - QVector<float>::iterator iter = m_posData.begin(); - for (int rpi = 0; rpi < rawPosCount; ++rpi) { - const QPointF &rawPos(rawPosList.at(rpi)); - // This will stay in screen coordinates for performance - // reasons, clients using this data will presumably know - // what they are doing. - *iter++ = static_cast<float>(rawPos.x()); - *iter++ = static_cast<float>(rawPos.y()); - } - rawData = QByteArray::fromRawData(reinterpret_cast<const char*>(m_posData.constData()), sizeof(float) * rawPosCount * 2); - } - send_touch(target->handle, time, id, state, x, y, nx, ny, w, h, @@ -153,3 +112,5 @@ void TouchExtensionGlobal::touch_extension_destroy_resource(Resource *resource) } QT_END_NAMESPACE + +#include "moc_qwlqttouch_p.cpp" diff --git a/src/compositor/extensions/qwlqttouch_p.h b/src/compositor/extensions/qwlqttouch_p.h index 76087151c..2d96da7fc 100644 --- a/src/compositor/extensions/qwlqttouch_p.h +++ b/src/compositor/extensions/qwlqttouch_p.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef WLTOUCH_H #define WLTOUCH_H @@ -44,6 +18,7 @@ #include <QtWaylandCompositor/private/qwayland-server-touch-extension.h> #include <QtWaylandCompositor/QWaylandCompositor> #include <QtWaylandCompositor/QWaylandCompositorExtensionTemplate> +#include <QtCore/private/qglobal_p.h> #include <wayland-util.h> @@ -86,7 +61,7 @@ private: QWaylandCompositor *m_compositor = nullptr; BehaviorFlags m_flags = BehaviorFlag::None; QList<Resource *> m_resources; - QVector<float> m_posData; + QList<float> m_posData; }; Q_DECLARE_OPERATORS_FOR_FLAGS(TouchExtensionGlobal::BehaviorFlags) diff --git a/src/compositor/extensions/qwltexturesharingextension.cpp b/src/compositor/extensions/qwltexturesharingextension.cpp index 6f801e956..c474176d2 100644 --- a/src/compositor/extensions/qwltexturesharingextension.cpp +++ b/src/compositor/extensions/qwltexturesharingextension.cpp @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2019 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "qwltexturesharingextension_p.h" @@ -40,7 +14,8 @@ #include <QTimer> #include <QtGui/private/qtexturefilereader_p.h> -#include <QtGui/QOpenGLTexture> + +#include <QtOpenGL/QOpenGLTexture> #include <QtGui/QImageReader> #include <QtQuick/QSGTexture> @@ -49,66 +24,6 @@ QT_BEGIN_NAMESPACE -class SharedTexture : public QSGTexture -{ - Q_OBJECT -public: - SharedTexture(QtWayland::ServerBuffer *buffer); - - int textureId() const override; - QSize textureSize() const override; - bool hasAlphaChannel() const override; - bool hasMipmaps() const override; - - void bind() override; - -private: - void updateGLTexture() const; - QtWayland::ServerBuffer *m_buffer = nullptr; - mutable QOpenGLTexture *m_tex = nullptr; -}; - -SharedTexture::SharedTexture(QtWayland::ServerBuffer *buffer) - : m_buffer(buffer), m_tex(nullptr) -{ -} - -int SharedTexture::textureId() const -{ - updateGLTexture(); - return m_tex ? m_tex->textureId() : 0; -} - -QSize SharedTexture::textureSize() const -{ - updateGLTexture(); - return m_tex ? QSize(m_tex->width(), m_tex->height()) : QSize(); -} - -bool SharedTexture::hasAlphaChannel() const -{ - return true; -} - -bool SharedTexture::hasMipmaps() const -{ - updateGLTexture(); - return m_tex ? (m_tex->mipLevels() > 1) : false; -} - -void SharedTexture::bind() -{ - updateGLTexture(); - if (m_tex) - m_tex->bind(); -} - -inline void SharedTexture::updateGLTexture() const -{ - if (!m_tex && m_buffer) - m_tex = m_buffer->toOpenGlTexture(); -} - class SharedTextureFactory : public QQuickTextureFactory { public: @@ -133,9 +48,17 @@ public: return m_buffer ? (m_buffer->size().width() * m_buffer->size().height() * 4) : 0; } - QSGTexture *createTexture(QQuickWindow *) const override + QSGTexture *createTexture(QQuickWindow *window) const override { - return new SharedTexture(const_cast<QtWayland::ServerBuffer *>(m_buffer)); + if (m_buffer != nullptr) { + QOpenGLTexture *texture = const_cast<QtWayland::ServerBuffer *>(m_buffer)->toOpenGlTexture(); + return QNativeInterface::QSGOpenGLTexture::fromNative(texture->textureId(), + window, + m_buffer->size(), + QQuickWindow::TextureHasAlphaChannel); + } + + return nullptr; } private: @@ -176,7 +99,7 @@ public: return m_errorString; } -public slots: +public Q_SLOTS: void doResponse(const QString &key, QtWayland::ServerBuffer *buffer) { if (key != m_id) @@ -221,7 +144,7 @@ QQuickImageResponse *QWaylandSharedTextureProvider::requestImageResponse(const Q void QWaylandSharedTextureProvider::setExtensionReady(QWaylandTextureSharingExtension *extension) { - for (auto *response : qAsConst(m_pendingResponses)) + for (auto *response : std::as_const(m_pendingResponses)) response->doRequest(extension); m_pendingResponses.clear(); m_pendingResponses.squeeze(); @@ -276,7 +199,7 @@ void QWaylandTextureSharingExtension::initialize() auto suffixes = QTextureFileReader::supportedFileFormats(); suffixes.append(QImageReader::supportedImageFormats()); - for (auto ext : qAsConst(suffixes)) + for (auto ext : std::as_const(suffixes)) m_image_suffixes << QLatin1Char('.') + QString::fromLatin1(ext); //qDebug() << "m_image_suffixes" << m_image_suffixes << "m_image_dirs" << m_image_dirs; @@ -301,13 +224,13 @@ QString QWaylandTextureSharingExtension::getExistingFilePath(const QString &key) if (key.contains(QLatin1String("../"))) return QString(); - for (auto dir : m_image_dirs) { + for (auto dir : std::as_const(m_image_dirs)) { QString path = dir + key; if (QFileInfo::exists(path)) return path; } - for (auto dir : m_image_dirs) { + for (auto dir : std::as_const(m_image_dirs)) { for (auto ext : m_image_suffixes) { QString fp = dir + key + ext; //qDebug() << "trying" << fp; @@ -455,9 +378,8 @@ QtWayland::ServerBuffer *QWaylandTextureSharingExtension::getCompressedBuffer(co return nullptr; } - QByteArray pixelData = QByteArray::fromRawData(td.data().constData() + td.dataOffset(), td.dataLength()); - - return m_server_buffer_integration->createServerBufferFromData(pixelData, td.size(), td.glInternalFormat()); + return m_server_buffer_integration->createServerBufferFromData(td.getDataView(), td.size(), + td.glInternalFormat()); } void QWaylandTextureSharingExtension::cleanupBuffers() @@ -477,11 +399,13 @@ void QWaylandTextureSharingExtension::cleanupBuffers() void QWaylandTextureSharingExtension::dumpBufferInfo() { - qDebug() << "shared buffers:" << m_server_buffers.count(); + qDebug() << "shared buffers:" << m_server_buffers.size(); for (auto it = m_server_buffers.cbegin(); it != m_server_buffers.cend(); ++it) qDebug() << " " << it.key() << ":" << it.value().buffer << "in use" << it.value().buffer->bufferInUse() << "usedLocally" << it.value().usedLocally ; } QT_END_NAMESPACE +#include "moc_qwltexturesharingextension_p.cpp" + #include "qwltexturesharingextension.moc" diff --git a/src/compositor/extensions/qwltexturesharingextension_p.h b/src/compositor/extensions/qwltexturesharingextension_p.h index bd0cd66ba..92f9ee187 100644 --- a/src/compositor/extensions/qwltexturesharingextension_p.h +++ b/src/compositor/extensions/qwltexturesharingextension_p.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2019 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWLTEXTURESHARINGEXTENSION_P_H #define QWLTEXTURESHARINGEXTENSION_P_H @@ -67,7 +41,7 @@ namespace QtWayland class QWaylandTextureSharingExtension; class SharedTextureImageResponse; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandSharedTextureProvider : public QQuickAsyncImageProvider +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandSharedTextureProvider : public QQuickAsyncImageProvider { public: QWaylandSharedTextureProvider(); @@ -77,10 +51,10 @@ public: void setExtensionReady(QWaylandTextureSharingExtension *extension); private: - QVector<SharedTextureImageResponse*> m_pendingResponses; + QList<SharedTextureImageResponse*> m_pendingResponses; }; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandTextureSharingExtension +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandTextureSharingExtension : public QWaylandCompositorExtensionTemplate<QWaylandTextureSharingExtension> , public QtWaylandServer::zqt_texture_sharing_v1 { @@ -97,13 +71,13 @@ public: static QWaylandTextureSharingExtension *self() { return s_self; } -public slots: +public Q_SLOTS: void requestBuffer(const QString &key); -signals: +Q_SIGNALS: void bufferResult(const QString &key, QtWayland::ServerBuffer *buffer); -protected slots: +protected Q_SLOTS: void cleanupBuffers(); protected: diff --git a/src/compositor/global/global.pri b/src/compositor/global/global.pri index 172f916bf..e12df2dd1 100644 --- a/src/compositor/global/global.pri +++ b/src/compositor/global/global.pri @@ -2,6 +2,7 @@ INCLUDEPATH += global/ HEADERS += \ global/qtwaylandcompositorglobal.h \ + global/qtwaylandqmlinclude.h \ global/qwaylandcompositorextension.h \ global/qwaylandcompositorextension_p.h \ global/qwaylandutils_p.h \ diff --git a/src/compositor/global/qtwaylandcompositorglobal.h b/src/compositor/global/qtwaylandcompositorglobal.h index 3b5ba5c2f..49b7dc63f 100644 --- a/src/compositor/global/qtwaylandcompositorglobal.h +++ b/src/compositor/global/qtwaylandcompositorglobal.h @@ -1,62 +1,12 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDCOMPOSITORGLOBAL_H #define QWAYLANDCOMPOSITORGLOBAL_H -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - #include <QtGui/qtguiglobal.h> #include <QtWaylandCompositor/qtwaylandcompositor-config.h> - -QT_BEGIN_NAMESPACE - -#if !defined(Q_WAYLAND_COMPOSITOR_EXPORT) -# if defined(QT_SHARED) && defined(QT_BUILD_COMPOSITOR_LIB) -# define Q_WAYLAND_COMPOSITOR_EXPORT Q_DECL_EXPORT -# elif defined(QT_SHARED) -# define Q_WAYLAND_COMPOSITOR_EXPORT Q_DECL_IMPORT -# else -# define Q_WAYLAND_COMPOSITOR_EXPORT -# endif -#endif - -QT_END_NAMESPACE +#include <QtWaylandCompositor/qtwaylandcompositorexports.h> #endif // QWAYLANDCOMPOSITORGLOBAL_H diff --git a/src/compositor/global/qtwaylandcompositorglobal_p.h b/src/compositor/global/qtwaylandcompositorglobal_p.h index 11a4a3d79..4d53a5076 100644 --- a/src/compositor/global/qtwaylandcompositorglobal_p.h +++ b/src/compositor/global/qtwaylandcompositorglobal_p.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDCOMPOSITORGLOBAL_P_H #define QWAYLANDCOMPOSITORGLOBAL_P_H @@ -41,9 +15,18 @@ // We mean it. // +#include <QtWaylandGlobal/private/qtwaylandglobal-config_p.h> #include <QtWaylandCompositor/qtwaylandcompositorglobal.h> #include <QtGui/private/qtguiglobal_p.h> #include <QtWaylandCompositor/private/qtwaylandcompositor-config_p.h> +QT_BEGIN_NAMESPACE + +#if QT_CONFIG(wayland_compositor_quick) +void Q_WAYLANDCOMPOSITOR_EXPORT qml_register_types_QtWayland_Compositor(); +#endif + +QT_END_NAMESPACE + #endif // QWAYLANDCOMPOSITORGLOBAL_P_H diff --git a/src/compositor/global/qtwaylandqmlinclude.h b/src/compositor/global/qtwaylandqmlinclude.h new file mode 100644 index 000000000..b008a8c7f --- /dev/null +++ b/src/compositor/global/qtwaylandqmlinclude.h @@ -0,0 +1,31 @@ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#ifndef QTWAYLANDQMLINCLUDE_H +#define QTWAYLANDQMLINCLUDE_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// +#include <QtCore/qglobal.h> +#include <QtWaylandCompositor/qtwaylandcompositor-config.h> + +#if QT_CONFIG(wayland_compositor_quick) +#include <QtQml/qqml.h> +#else +#define QML_NAMED_ELEMENT(x) +#define QML_UNCREATABLE(x) +#define QML_ADDED_IN_VERSION(x, y) +#endif + +QT_BEGIN_NAMESPACE +QT_END_NAMESPACE + +#endif // QTWAYLANDQMLINCLUDE_H diff --git a/src/compositor/global/qwaylandcompositorextension.cpp b/src/compositor/global/qwaylandcompositorextension.cpp index 6fc665130..3a10d177a 100644 --- a/src/compositor/global/qwaylandcompositorextension.cpp +++ b/src/compositor/global/qwaylandcompositorextension.cpp @@ -1,32 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "qwaylandcompositorextension.h" #include "qwaylandcompositorextension_p.h" @@ -38,11 +11,85 @@ QT_BEGIN_NAMESPACE +/*! + * \class QWaylandCompositorExtensionTemplate + * \inmodule QtWaylandCompositor + * \since 5.8 + * \brief QWaylandCompositorExtensionTemplate is a convenience class for subclassing + * QWaylandCompositorExtension. + * + * QWaylandCompositorExtensionTemplate is a template class which inherits + * QWaylandCompositorExtension and is convenience for building custom Wayland extensions with Qt. + * + * It provides the connection between Qt Wayland Compositor and the class generated by + * \c qtwaylandscanner, based on the XML description of the extension protocol. + * + * It provides two specific pieces of convenience: + * \list + * \li A reimplementation of \l{QWaylandCompositorExtension::extensionInterface()} which returns + * the \c wl_interface pointer for the qtwaylandscanner-generated base class. + * \li A static \l{findIn()} function which searches for an instance of the extension in a + * provided container, and returns this if it is found. + * \endlist + * + * Typically, a new extension will dual-inherit QWaylandCompositorExtensionTemplate and the class + * generated by \c qtwaylandscanner. + * + * QWaylandCompositorExtensionTemplate should be parameterized with the subclass itself: + * \code + * class MyExtension + * : public QWaylandCompositorExtensionTemplate<MyExtension> + * , QtWaylandServer::my_extension + * \endcode + * + * In this example, \c MyExtension is an implementation of the generated interface \c my_extension. + * + * \sa {Custom Shell} + */ + +/*! + * \fn template <typename T> T *QWaylandCompositorExtensionTemplate<T>::findIn(QWaylandObject *container) + * + * If any instance of the interface has been registered with \a container, this is returned. + * Otherwise null is returned. The look-up is based on the generated \c interfaceName() which + * matches the interface name in the protocol description. + */ + +/*! + * \class QWaylandCompositorExtension + * \inmodule QtWaylandCompositor + * \since 5.8 + * \brief QWaylandCompositorExtension is the base class for compositor extensions. + * + * QWaylandCompositorExtension is the base class for implementing Wayland extensions on the + * compositor-side of the connection. If no other extension container is explicitly set, it will + * automatically add itself to its parent object, granted that this inherits from QWaylandObject. + * + * For example, for registering global extensions, you can inherit from QWaylandCompositorExtension + * and pass the QWaylandCompositor object as extension container. + * + * \sa QWaylandCompositorExtensionTemplate, {Custom Shell} + */ + +/*! + * Creates a QWaylandCompositorExtension with no container. + * + * \sa setExtensionContainer() + */ QWaylandCompositorExtension::QWaylandCompositorExtension() : QWaylandObject(*new QWaylandCompositorExtensionPrivate()) { } +/*! + * Creates a QWaylandCompositorExtension and adds it to the extension \a container. The \a container + * does not become the parent of the QWaylandCompositorExtension. + * + * The extension adds itself to \a container later, when \l{initialize()} is called. For this to + * happen automatically, an event loop must be running in the current thread. + * + * The QWaylandCompositorExtension will remove itself again when it is destroyed. + */ QWaylandCompositorExtension::QWaylandCompositorExtension(QWaylandObject *container) : QWaylandObject(*new QWaylandCompositorExtensionPrivate()) { @@ -69,18 +116,42 @@ QWaylandCompositorExtension::~QWaylandCompositorExtension() d->extension_container->removeExtension(this); } +/*! + * \fn const wl_interface *QWaylandCompositorExtension::extensionInterface() const + * + * A pure virtual function which should be reimplemented to return the \c wl_interface which + * corresponds to this QWaylandCompositorExtension. + */ + +/*! + * \return the extension container for this QWaylandCompositorExtension or null if none has been + * set. + */ QWaylandObject *QWaylandCompositorExtension::extensionContainer() const { Q_D(const QWaylandCompositorExtension); return d->extension_container; } +/*! + * Sets the extension container for this QWaylandCompositorExtension to \a container. This must be + * called before \l{initialize()} and cannot be changed once the QWaylandCompositorExtension has + * been initialized. + */ void QWaylandCompositorExtension::setExtensionContainer(QWaylandObject *container) { Q_D(QWaylandCompositorExtension); d->extension_container = container; } +/*! + * Initializes the QWaylandCompositorExtension. The default implementation adopts the parent object + * as extension container if none has been set, and if the parent inherits from QWaylandObject. The + * default implementation also adds the QWaylandCompositorExtension to the list of extensions + * managed by the extension container. + * + * Override this function in subclasses to provide custom initialization code. + */ void QWaylandCompositorExtension::initialize() { Q_D(QWaylandCompositorExtension); @@ -123,6 +194,21 @@ bool QWaylandCompositorExtension::event(QEvent *event) return QWaylandObject::event(event); } +/*! + * \class QWaylandObject + * \inmodule QtWaylandCompositor + * \since 5.8 + * \brief QWaylandObject is the base class for objects that can contain Wayland extensions. + * + * The QWaylandObject encapsulate extension container functionality. Any QWaylandObject object + * will automatically be an extension container and QWaylandCompositorExtension object which is + * a child of this will automatically add itself to its extension list, and remove itself when + * the extension object is destroyed. + */ + +/*! + * Creates a QWaylandObject as a child of \a parent. + */ QWaylandObject::QWaylandObject(QObject *parent) :QObject(parent) { @@ -136,10 +222,15 @@ QWaylandObject::QWaylandObject(QObjectPrivate &d, QObject *parent) QWaylandObject::~QWaylandObject() { - for (QWaylandCompositorExtension *extension : qAsConst(extension_vector)) + for (QWaylandCompositorExtension *extension : std::as_const(extension_vector)) QWaylandCompositorExtensionPrivate::get(extension)->extension_container = nullptr; } +/*! + * Returns the compositor extension which matches \a name if one has been registered with the + * QWaylandObject. If no extension matching the name has been registered, this function returns + * null. + */ QWaylandCompositorExtension *QWaylandObject::extension(const QByteArray &name) { for (int i = 0; i < extension_vector.size(); i++) { @@ -149,6 +240,11 @@ QWaylandCompositorExtension *QWaylandObject::extension(const QByteArray &name) return nullptr; } +/*! + * Returns the compositor extension which matches \a interface if one has been registered with the + * QWaylandObject. If no extension matching the interface has been registered, this function + * returns null. + */ QWaylandCompositorExtension *QWaylandObject::extension(const wl_interface *interface) { for (int i = 0; i < extension_vector.size(); i++) { @@ -158,21 +254,35 @@ QWaylandCompositorExtension *QWaylandObject::extension(const wl_interface *inter return nullptr; } +/*! + * Returns the list of compositor extensions that have been registered with this QWaylandObject. + */ QList<QWaylandCompositorExtension *> QWaylandObject::extensions() const { return extension_vector; } +/*! + * Registers \a extension with this QWaylandObject. + */ void QWaylandObject::addExtension(QWaylandCompositorExtension *extension) { Q_ASSERT(!extension_vector.contains(extension)); extension_vector.append(extension); } +/*! + * Removes \a extension from the list of registered extensions in this QWaylandObject, if it has + * previously been registered using \l{addExtension()}. + */ void QWaylandObject::removeExtension(QWaylandCompositorExtension *extension) { + if (!extension->isInitialized()) + return; Q_ASSERT(extension_vector.contains(extension)); extension_vector.removeOne(extension); } QT_END_NAMESPACE + +#include "moc_qwaylandcompositorextension.cpp" diff --git a/src/compositor/global/qwaylandcompositorextension.h b/src/compositor/global/qwaylandcompositorextension.h index c1553ffa3..cea7c7de0 100644 --- a/src/compositor/global/qwaylandcompositorextension.h +++ b/src/compositor/global/qwaylandcompositorextension.h @@ -1,39 +1,13 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDEXTENSION_H #define QWAYLANDEXTENSION_H #include <QtWaylandCompositor/qtwaylandcompositorglobal.h> +#include <QtWaylandCompositor/qtwaylandqmlinclude.h> #include <QtCore/QObject> -#include <QtCore/QVector> struct wl_interface; @@ -43,7 +17,7 @@ class QWaylandCompositor; class QWaylandCompositorExtension; class QWaylandCompositorExtensionPrivate; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandObject : public QObject +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandObject : public QObject { Q_OBJECT public: @@ -61,10 +35,13 @@ protected: QList<QWaylandCompositorExtension *> extension_vector; }; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandCompositorExtension : public QWaylandObject +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandCompositorExtension : public QWaylandObject { Q_OBJECT Q_DECLARE_PRIVATE(QWaylandCompositorExtension) + QML_NAMED_ELEMENT(WaylandExtension) + QML_ADDED_IN_VERSION(1, 0) + QML_UNCREATABLE("") public: QWaylandCompositorExtension(); QWaylandCompositorExtension(QWaylandObject *container); @@ -86,7 +63,7 @@ protected: }; template <typename T> -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandCompositorExtensionTemplate : public QWaylandCompositorExtension +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandCompositorExtensionTemplate : public QWaylandCompositorExtension { public: QWaylandCompositorExtensionTemplate() diff --git a/src/compositor/global/qwaylandcompositorextension_p.h b/src/compositor/global/qwaylandcompositorextension_p.h index 73278d24b..7af7a6e05 100644 --- a/src/compositor/global/qwaylandcompositorextension_p.h +++ b/src/compositor/global/qwaylandcompositorextension_p.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDEXTENSION_P_H #define QWAYLANDEXTENSION_P_H @@ -47,7 +21,7 @@ QT_BEGIN_NAMESPACE -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandCompositorExtensionPrivate : public QObjectPrivate +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandCompositorExtensionPrivate : public QObjectPrivate { Q_DECLARE_PUBLIC(QWaylandCompositorExtension) diff --git a/src/compositor/global/qwaylandquickextension.cpp b/src/compositor/global/qwaylandquickextension.cpp new file mode 100644 index 000000000..bd594eba2 --- /dev/null +++ b/src/compositor/global/qwaylandquickextension.cpp @@ -0,0 +1,12 @@ +// Copyright (C) 2022 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#include "qwaylandquickextension.h" + +QT_REQUIRE_CONFIG(wayland_compositor_quick); + +QT_BEGIN_NAMESPACE + +QT_END_NAMESPACE + +#include "moc_qwaylandquickextension.cpp" diff --git a/src/compositor/global/qwaylandquickextension.h b/src/compositor/global/qwaylandquickextension.h index 7c4a8f811..5286f120a 100644 --- a/src/compositor/global/qwaylandquickextension.h +++ b/src/compositor/global/qwaylandquickextension.h @@ -1,43 +1,23 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDQUICKEXTENSION_H #define QWAYLANDQUICKEXTENSION_H +#if 0 +#pragma qt_class(QWaylandQuickExtension) +#endif + #include <QtWaylandCompositor/QWaylandCompositorExtension> #include <QtQml/QQmlParserStatus> #include <QtQml/QQmlListProperty> +QT_REQUIRE_CONFIG(wayland_compositor_quick); + QT_BEGIN_NAMESPACE #define Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_CLASS(className) \ - class Q_WAYLAND_COMPOSITOR_EXPORT className##QuickExtension : public className, public QQmlParserStatus \ + class Q_WAYLANDCOMPOSITOR_EXPORT className##QuickExtension : public className, public QQmlParserStatus \ { \ /* qmake ignore Q_OBJECT */ \ Q_OBJECT \ @@ -47,7 +27,7 @@ QT_BEGIN_NAMESPACE public: \ QQmlListProperty<QObject> data() \ { \ - return QQmlListProperty<QObject>(this, m_objects); \ + return QQmlListProperty<QObject>(this, &m_objects); \ } \ void classBegin() override {} \ void componentComplete() override { if (!isInitialized()) initialize(); } \ @@ -56,7 +36,7 @@ QT_BEGIN_NAMESPACE }; #define Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_CONTAINER_CLASS(className) \ - class Q_WAYLAND_COMPOSITOR_EXPORT className##QuickExtensionContainer : public className \ + class Q_WAYLANDCOMPOSITOR_EXPORT className##QuickExtensionContainer : public className \ { \ /* qmake ignore Q_OBJECT */ \ Q_OBJECT \ @@ -66,7 +46,7 @@ QT_BEGIN_NAMESPACE public: \ QQmlListProperty<QObject> data() \ { \ - return QQmlListProperty<QObject>(this, m_objects); \ + return QQmlListProperty<QObject>(this, &m_objects); \ } \ QQmlListProperty<QWaylandCompositorExtension> extensions() \ { \ @@ -97,6 +77,66 @@ QT_BEGIN_NAMESPACE QList<QObject *> m_objects; \ }; +#define Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_NAMED_CLASS(className, QmlType) \ + Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_NAMED_ELEMENT(className, QmlType, 1, 0) + +#define Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_NAMED_ELEMENT(...) \ + QT_OVERLOADED_MACRO(Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_NAMED_ELEMENT, __VA_ARGS__) + +#define Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_NAMED_ELEMENT_4(className, QmlType, versionMajor, \ + versionMinor) \ + class Q_WAYLANDCOMPOSITOR_EXPORT className##QuickExtension : public className, \ + public QQmlParserStatus \ + { \ + /* qmake ignore Q_OBJECT */ \ + Q_OBJECT \ + Q_PROPERTY(QQmlListProperty<QObject> data READ data DESIGNABLE false) \ + Q_CLASSINFO("DefaultProperty", "data") \ + Q_INTERFACES(QQmlParserStatus) \ + QML_NAMED_ELEMENT(QmlType) \ + QML_ADDED_IN_VERSION(versionMajor, versionMinor) \ + public: \ + QQmlListProperty<QObject> data() \ + { \ + return QQmlListProperty<QObject>(this, &m_objects); \ + } \ + void classBegin() override { } \ + void componentComplete() override \ + { \ + if (!isInitialized()) \ + initialize(); \ + } \ + \ + private: \ + QList<QObject *> m_objects; \ + }; + +#define Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_NAMED_ELEMENT_2(className, QmlType) \ + class Q_WAYLANDCOMPOSITOR_EXPORT className##QuickExtension : public className, \ + public QQmlParserStatus \ + { \ + /* qmake ignore Q_OBJECT */ \ + Q_OBJECT \ + Q_PROPERTY(QQmlListProperty<QObject> data READ data DESIGNABLE false) \ + Q_CLASSINFO("DefaultProperty", "data") \ + Q_INTERFACES(QQmlParserStatus) \ + QML_NAMED_ELEMENT(QmlType) \ + public: \ + QQmlListProperty<QObject> data() \ + { \ + return QQmlListProperty<QObject>(this, &m_objects); \ + } \ + void classBegin() override { } \ + void componentComplete() override \ + { \ + if (!isInitialized()) \ + initialize(); \ + } \ + \ + private: \ + QList<QObject *> m_objects; \ + }; + QT_END_NAMESPACE #endif /*QWAYLANDQUICKEXTENSION_H*/ diff --git a/src/compositor/global/qwaylandquickextension.qdoc b/src/compositor/global/qwaylandquickextension.qdoc new file mode 100644 index 000000000..f3a213a11 --- /dev/null +++ b/src/compositor/global/qwaylandquickextension.qdoc @@ -0,0 +1,85 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only + +/*! + * \headerfile <QWaylandQuickExtension> + * \title Qt Wayland Compositor Qt Quick Extension Macro Declarations + * \inmodule QtWaylandCompositor + * \ingroup funclists + * + * \brief The <QWaylandQuickExtension> header file includes macros for creating Qt Quick types + * that correspond to subclasses of QWaylandCompositorExtension and QWaylandObject. + * + * If you are creating extensions to Qt Wayland Compositor, the macros in the QWaylandQuickExtension + * header may be a useful alternative to manually implementing the required parts for each class. + * + * \sa {Custom Shell} + */ + +/*! + * \macro Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_CLASS(className) + * \relates <QWaylandQuickExtension> + * + * This macro can be used to define a Qt Quick class based on a Wayland extension. It defines + * a new class which inherits from \a className and which suffixes the name with "QuickExtension". + * + * The class should be a subclass of QWaylandCompositorExtension, and + * \l{QWaylandCompositorExtension::initialize()} will be called automatically. The type must be + * manually registered in Qt Quick using \l{qmlRegisterType()}. + * + * \sa Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_NAMED_ELEMENT + */ + +/*! + * \macro Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_CONTAINER_CLASS(className) + * \relates <QWaylandQuickExtension> + * + * This macro can be used to define a Qt Quick class intended to contain Wayland extensions. It + * + * It defines a new class which inherits from \a className and which suffixes the name with + * "QuickExtensionContainer". The class given by \a className should inherit from QWaylandObject, + * and the new class will have an \c extensions property which manages the extensions by calling + * \l{QWaylandObject::addExtension()}{addExtension()} and + * \l{QWaylandObject::removeExtension()}{removeExtension()} in the base class. + * + * The type must be manually registered in Qt Quick using \l{qmlRegisterType()}. + */ + +/*! + * \macro Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_NAMED_CLASS(className, QmlType) + * \relates <QWaylandQuickExtension> + * \deprecated [6.8] Use Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_NAMED_ELEMENT instead. + * + * This macro can be used to define a Qt Quick class based on a Wayland extension. It defines + * a new class which inherits from \a className and which suffixes the name with "QuickExtension". + * + * The macro works the same as \l{Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_CLASS}, but will also + * automatically register the new type as \a QmlType in the current QML module with \l + * QML_ADDED_IN_VERSION set to 1.0. + */ + +/*! +\macro Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_NAMED_ELEMENT(className, QmlType) +\relates <QWaylandQuickExtension> +\since 6.8 + +This macro can be used to define a Qt Quick class based on a Wayland extension. It defines +a new class which inherits from \a className and which suffixes the name with "QuickExtension". + +The macro works the same as \l{Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_CLASS}, but will also +automatically register the new type as \a QmlType in the current QML module. +*/ + +/*! +\macro Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_NAMED_ELEMENT(className, QmlType, versionMajor, versionMinor) +\relates <QWaylandQuickExtension> +\internal +\since 6.8 + +This macro can be used to define a Qt Quick class based on a Wayland extension. It defines +a new class which inherits from \a className and which suffixes the name with "QuickExtension". + +The macro works the same as \l{Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_CLASS}, but will also +automatically register the new type as \a QmlType in the current QML module with +\l QML_ADDED_IN_VERSION set to the version passed via \a versionMajor and \a versionMinor. + */ diff --git a/src/compositor/global/qwaylandutils_p.h b/src/compositor/global/qwaylandutils_p.h index b67dc4ced..5c07163bd 100644 --- a/src/compositor/global/qwaylandutils_p.h +++ b/src/compositor/global/qwaylandutils_p.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDUTILS_P_H #define QWAYLANDUTILS_P_H @@ -41,7 +15,7 @@ // We mean it. // -#include <QtCore/qglobal.h> +#include <QtCore/private/qglobal_p.h> struct wl_resource; diff --git a/src/compositor/hardware_integration/hardware_integration.pri b/src/compositor/hardware_integration/hardware_integration.pri index 6bf7a75b5..bb21e3d8b 100644 --- a/src/compositor/hardware_integration/hardware_integration.pri +++ b/src/compositor/hardware_integration/hardware_integration.pri @@ -1,11 +1,17 @@ -qtConfig(opengl) { - CONFIG += wayland-scanner - WAYLANDSERVERSOURCES += \ - ../extensions/server-buffer-extension.xml \ - ../extensions/hardware-integration.xml \ +CONFIG += wayland-scanner +WAYLANDSERVERSOURCES += \ + ../extensions/server-buffer-extension.xml \ + ../extensions/hardware-integration.xml \ + +HEADERS += \ + hardware_integration/qwlclientbufferintegration_p.h \ + +SOURCES += \ + hardware_integration/qwlclientbufferintegration.cpp \ + +qtConfig(opengl) { HEADERS += \ - hardware_integration/qwlclientbufferintegration_p.h \ hardware_integration/qwlclientbufferintegrationfactory_p.h \ hardware_integration/qwlclientbufferintegrationplugin_p.h \ hardware_integration/qwlserverbufferintegration_p.h \ @@ -17,7 +23,6 @@ qtConfig(opengl) { hardware_integration/qwlhardwarelayerintegrationplugin_p.h \ SOURCES += \ - hardware_integration/qwlclientbufferintegration.cpp \ hardware_integration/qwlclientbufferintegrationfactory.cpp \ hardware_integration/qwlclientbufferintegrationplugin.cpp \ hardware_integration/qwlserverbufferintegration.cpp \ diff --git a/src/compositor/hardware_integration/qwlclientbufferintegration.cpp b/src/compositor/hardware_integration/qwlclientbufferintegration.cpp index c8f7b3aa9..db2ebe401 100644 --- a/src/compositor/hardware_integration/qwlclientbufferintegration.cpp +++ b/src/compositor/hardware_integration/qwlclientbufferintegration.cpp @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "qwlclientbufferintegration_p.h" diff --git a/src/compositor/hardware_integration/qwlclientbufferintegration_p.h b/src/compositor/hardware_integration/qwlclientbufferintegration_p.h index 2e962273f..5f9247d6a 100644 --- a/src/compositor/hardware_integration/qwlclientbufferintegration_p.h +++ b/src/compositor/hardware_integration/qwlclientbufferintegration_p.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDCLIENTBUFFERINTEGRATION_H #define QWAYLANDCLIENTBUFFERINTEGRATION_H @@ -45,6 +19,7 @@ #include <QtWaylandCompositor/qwaylandsurface.h> #include <QtWaylandCompositor/qwaylandbufferref.h> #include <QtCore/QSize> +#include <QtCore/private/qglobal_p.h> #include <wayland-server-core.h> QT_BEGIN_NAMESPACE @@ -55,7 +30,7 @@ class QOpenGLTexture; namespace QtWayland { class Display; -class Q_WAYLAND_COMPOSITOR_EXPORT ClientBufferIntegration +class Q_WAYLANDCOMPOSITOR_EXPORT ClientBufferIntegration { public: ClientBufferIntegration(); @@ -64,9 +39,10 @@ public: void setCompositor(QWaylandCompositor *compositor) { m_compositor = compositor; } QWaylandCompositor *compositor() const { return m_compositor; } - virtual bool initializeHardware(struct ::wl_display *display) = 0; + virtual void initializeHardware(struct ::wl_display *display) = 0; virtual ClientBuffer *createBufferFor(struct ::wl_resource *buffer) = 0; + virtual bool isProtected(struct ::wl_resource *buffer) { Q_UNUSED(buffer); return false; } protected: QWaylandCompositor *m_compositor = nullptr; diff --git a/src/compositor/hardware_integration/qwlclientbufferintegrationfactory.cpp b/src/compositor/hardware_integration/qwlclientbufferintegrationfactory.cpp index 982b4ded7..c85cba80f 100644 --- a/src/compositor/hardware_integration/qwlclientbufferintegrationfactory.cpp +++ b/src/compositor/hardware_integration/qwlclientbufferintegrationfactory.cpp @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "qwlclientbufferintegrationfactory_p.h" #include "qwlclientbufferintegrationplugin_p.h" @@ -38,49 +12,17 @@ QT_BEGIN_NAMESPACE namespace QtWayland { -#if QT_CONFIG(library) -Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader, +Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, qwbifiLoader, (QtWaylandClientBufferIntegrationFactoryInterface_iid, QLatin1String("/wayland-graphics-integration-server"), Qt::CaseInsensitive)) -Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, directLoader, - (QtWaylandClientBufferIntegrationFactoryInterface_iid, QLatin1String(""), Qt::CaseInsensitive)) -#endif -QStringList ClientBufferIntegrationFactory::keys(const QString &pluginPath) +QStringList ClientBufferIntegrationFactory::keys() { -#if QT_CONFIG(library) - QStringList list; - if (!pluginPath.isEmpty()) { - QCoreApplication::addLibraryPath(pluginPath); - list = directLoader()->keyMap().values(); - if (!list.isEmpty()) { - const QString postFix = QStringLiteral(" (from ") - + QDir::toNativeSeparators(pluginPath) - + QLatin1Char(')'); - const QStringList::iterator end = list.end(); - for (QStringList::iterator it = list.begin(); it != end; ++it) - (*it).append(postFix); - } - } - list.append(loader()->keyMap().values()); - return list; -#else - return QStringList(); -#endif + return qwbifiLoader->keyMap().values(); } -ClientBufferIntegration *ClientBufferIntegrationFactory::create(const QString &name, const QStringList &args, const QString &pluginPath) +ClientBufferIntegration *ClientBufferIntegrationFactory::create(const QString &name, const QStringList &args) { -#if QT_CONFIG(library) - // Try loading the plugin from platformPluginPath first: - if (!pluginPath.isEmpty()) { - QCoreApplication::addLibraryPath(pluginPath); - if (ClientBufferIntegration *ret = qLoadPlugin<ClientBufferIntegration, ClientBufferIntegrationPlugin>(directLoader(), name, args)) - return ret; - } - if (ClientBufferIntegration *ret = qLoadPlugin<ClientBufferIntegration, ClientBufferIntegrationPlugin>(loader(), name, args)) - return ret; -#endif - return nullptr; + return qLoadPlugin<ClientBufferIntegration, ClientBufferIntegrationPlugin>(qwbifiLoader(), name, args); } } diff --git a/src/compositor/hardware_integration/qwlclientbufferintegrationfactory_p.h b/src/compositor/hardware_integration/qwlclientbufferintegrationfactory_p.h index 0a7c1b845..7d08e25c0 100644 --- a/src/compositor/hardware_integration/qwlclientbufferintegrationfactory_p.h +++ b/src/compositor/hardware_integration/qwlclientbufferintegrationfactory_p.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDCLIENTBUFFERINTEGRATIONFACTORY_H #define QWAYLANDCLIENTBUFFERINTEGRATIONFACTORY_H @@ -43,6 +17,7 @@ #include <QtWaylandCompositor/qtwaylandcompositorglobal.h> #include <QtCore/QStringList> +#include <QtCore/private/qglobal_p.h> QT_BEGIN_NAMESPACE @@ -50,11 +25,11 @@ namespace QtWayland { class ClientBufferIntegration; -class Q_WAYLAND_COMPOSITOR_EXPORT ClientBufferIntegrationFactory +class Q_WAYLANDCOMPOSITOR_EXPORT ClientBufferIntegrationFactory { public: - static QStringList keys(const QString &pluginPath = QString()); - static ClientBufferIntegration *create(const QString &name, const QStringList &args, const QString &pluginPath = QString()); + static QStringList keys(); + static ClientBufferIntegration *create(const QString &name, const QStringList &args); }; } diff --git a/src/compositor/hardware_integration/qwlclientbufferintegrationplugin.cpp b/src/compositor/hardware_integration/qwlclientbufferintegrationplugin.cpp index 8a90139d0..8c3ad8e4f 100644 --- a/src/compositor/hardware_integration/qwlclientbufferintegrationplugin.cpp +++ b/src/compositor/hardware_integration/qwlclientbufferintegrationplugin.cpp @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "qwlclientbufferintegrationplugin_p.h" @@ -45,3 +19,5 @@ ClientBufferIntegrationPlugin::~ClientBufferIntegrationPlugin() } QT_END_NAMESPACE + +#include "moc_qwlclientbufferintegrationplugin_p.cpp" diff --git a/src/compositor/hardware_integration/qwlclientbufferintegrationplugin_p.h b/src/compositor/hardware_integration/qwlclientbufferintegrationplugin_p.h index 838f3ceca..aa6b0f2e6 100644 --- a/src/compositor/hardware_integration/qwlclientbufferintegrationplugin_p.h +++ b/src/compositor/hardware_integration/qwlclientbufferintegrationplugin_p.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDCLIENTBUFFERINTEGRATIONPLUGIN_H #define QWAYLANDCLIENTBUFFERINTEGRATIONPLUGIN_H @@ -45,6 +19,7 @@ #include <QtCore/qplugin.h> #include <QtCore/qfactoryinterface.h> +#include <QtCore/private/qglobal_p.h> QT_BEGIN_NAMESPACE @@ -54,7 +29,7 @@ class ClientBufferIntegration; #define QtWaylandClientBufferIntegrationFactoryInterface_iid "org.qt-project.Qt.WaylandCompositor.QtWaylandClientBufferIntegrationFactoryInterface.5.3" -class Q_WAYLAND_COMPOSITOR_EXPORT ClientBufferIntegrationPlugin : public QObject +class Q_WAYLANDCOMPOSITOR_EXPORT ClientBufferIntegrationPlugin : public QObject { Q_OBJECT public: diff --git a/src/compositor/hardware_integration/qwlhardwarelayerintegration.cpp b/src/compositor/hardware_integration/qwlhardwarelayerintegration.cpp index 7f346e1df..6b6fefe24 100644 --- a/src/compositor/hardware_integration/qwlhardwarelayerintegration.cpp +++ b/src/compositor/hardware_integration/qwlhardwarelayerintegration.cpp @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "qwlhardwarelayerintegration_p.h" @@ -36,3 +10,5 @@ namespace QtWayland { } QT_END_NAMESPACE + +#include "moc_qwlhardwarelayerintegration_p.cpp" diff --git a/src/compositor/hardware_integration/qwlhardwarelayerintegration_p.h b/src/compositor/hardware_integration/qwlhardwarelayerintegration_p.h index a55833ab1..18ede78a6 100644 --- a/src/compositor/hardware_integration/qwlhardwarelayerintegration_p.h +++ b/src/compositor/hardware_integration/qwlhardwarelayerintegration_p.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDHARDWARELAYERINTEGRATION_H #define QWAYLANDHARDWARELAYERINTEGRATION_H @@ -44,6 +18,7 @@ #include <QtWaylandCompositor/qtwaylandcompositorglobal.h> #include <QObject> +#include <private/qglobal_p.h> QT_BEGIN_NAMESPACE @@ -53,7 +28,7 @@ class QWaylandQuickHardwareLayer; namespace QtWayland { -class Q_WAYLAND_COMPOSITOR_EXPORT HardwareLayerIntegration : public QObject +class Q_WAYLANDCOMPOSITOR_EXPORT HardwareLayerIntegration : public QObject { Q_OBJECT public: diff --git a/src/compositor/hardware_integration/qwlhardwarelayerintegrationfactory.cpp b/src/compositor/hardware_integration/qwlhardwarelayerintegrationfactory.cpp index e30f04c54..01c0c95a0 100644 --- a/src/compositor/hardware_integration/qwlhardwarelayerintegrationfactory.cpp +++ b/src/compositor/hardware_integration/qwlhardwarelayerintegrationfactory.cpp @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "qwlhardwarelayerintegrationfactory_p.h" #include "qwlhardwarelayerintegrationplugin_p.h" @@ -39,49 +13,17 @@ QT_BEGIN_NAMESPACE namespace QtWayland { -#if QT_CONFIG(library) -Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader, +Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, qwhlifLoader, (QtWaylandHardwareLayerIntegrationFactoryInterface_iid, QLatin1String("/wayland-hardware-layer-integration"), Qt::CaseInsensitive)) -Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, directLoader, - (QtWaylandHardwareLayerIntegrationFactoryInterface_iid, QLatin1String(""), Qt::CaseInsensitive)) -#endif -QStringList HardwareLayerIntegrationFactory::keys(const QString &pluginPath) +QStringList HardwareLayerIntegrationFactory::keys() { -#if QT_CONFIG(library) - QStringList list; - if (!pluginPath.isEmpty()) { - QCoreApplication::addLibraryPath(pluginPath); - list = directLoader()->keyMap().values(); - if (!list.isEmpty()) { - const QString postFix = QStringLiteral(" (from ") - + QDir::toNativeSeparators(pluginPath) - + QLatin1Char(')'); - const QStringList::iterator end = list.end(); - for (QStringList::iterator it = list.begin(); it != end; ++it) - (*it).append(postFix); - } - } - list.append(loader()->keyMap().values()); - return list; -#else - return QStringList(); -#endif + return qwhlifLoader->keyMap().values(); } -HardwareLayerIntegration *HardwareLayerIntegrationFactory::create(const QString &name, const QStringList &args, const QString &pluginPath) +HardwareLayerIntegration *HardwareLayerIntegrationFactory::create(const QString &name, const QStringList &args) { -#if QT_CONFIG(library) - // Try loading the plugin from platformPluginPath first: - if (!pluginPath.isEmpty()) { - QCoreApplication::addLibraryPath(pluginPath); - if (HardwareLayerIntegration *ret = qLoadPlugin<HardwareLayerIntegration, HardwareLayerIntegrationPlugin>(directLoader(), name, args)) - return ret; - } - if (HardwareLayerIntegration *ret = qLoadPlugin<HardwareLayerIntegration, HardwareLayerIntegrationPlugin>(loader(), name, args)) - return ret; -#endif - return nullptr; + return qLoadPlugin<HardwareLayerIntegration, HardwareLayerIntegrationPlugin>(qwhlifLoader(), name, args); } } diff --git a/src/compositor/hardware_integration/qwlhardwarelayerintegrationfactory_p.h b/src/compositor/hardware_integration/qwlhardwarelayerintegrationfactory_p.h index 0f6dfd5cf..c24c712f7 100644 --- a/src/compositor/hardware_integration/qwlhardwarelayerintegrationfactory_p.h +++ b/src/compositor/hardware_integration/qwlhardwarelayerintegrationfactory_p.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDHARDWARELAYERINTEGRATIONFACTORY_H #define QWAYLANDHARDWARELAYERINTEGRATIONFACTORY_H @@ -43,6 +17,7 @@ #include <QtWaylandCompositor/qtwaylandcompositorglobal.h> #include <QtCore/QStringList> +#include <QtCore/private/qglobal_p.h> QT_BEGIN_NAMESPACE @@ -50,11 +25,11 @@ namespace QtWayland { class HardwareLayerIntegration; -class Q_WAYLAND_COMPOSITOR_EXPORT HardwareLayerIntegrationFactory +class Q_WAYLANDCOMPOSITOR_EXPORT HardwareLayerIntegrationFactory { public: - static QStringList keys(const QString &pluginPath = QString()); - static HardwareLayerIntegration *create(const QString &name, const QStringList &args, const QString &pluginPath = QString()); + static QStringList keys(); + static HardwareLayerIntegration *create(const QString &name, const QStringList &args); }; } diff --git a/src/compositor/hardware_integration/qwlhardwarelayerintegrationplugin.cpp b/src/compositor/hardware_integration/qwlhardwarelayerintegrationplugin.cpp index 4106434ab..541b20de7 100644 --- a/src/compositor/hardware_integration/qwlhardwarelayerintegrationplugin.cpp +++ b/src/compositor/hardware_integration/qwlhardwarelayerintegrationplugin.cpp @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "qwlhardwarelayerintegrationplugin_p.h" @@ -45,3 +19,5 @@ HardwareLayerIntegrationPlugin::~HardwareLayerIntegrationPlugin() } QT_END_NAMESPACE + +#include "moc_qwlhardwarelayerintegrationplugin_p.cpp" diff --git a/src/compositor/hardware_integration/qwlhardwarelayerintegrationplugin_p.h b/src/compositor/hardware_integration/qwlhardwarelayerintegrationplugin_p.h index e663dc903..ce5e1e9a2 100644 --- a/src/compositor/hardware_integration/qwlhardwarelayerintegrationplugin_p.h +++ b/src/compositor/hardware_integration/qwlhardwarelayerintegrationplugin_p.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDHARDWARELAYERINTEGRATIONPLUGIN_H #define QWAYLANDHARDWARELAYERINTEGRATIONPLUGIN_H @@ -45,6 +19,7 @@ #include <QtCore/qplugin.h> #include <QtCore/qfactoryinterface.h> +#include <QtCore/private/qglobal_p.h> QT_BEGIN_NAMESPACE @@ -54,7 +29,7 @@ class HardwareLayerIntegration; #define QtWaylandHardwareLayerIntegrationFactoryInterface_iid "org.qt-project.Qt.Compositor.QtWaylandHardwareLayerIntegrationFactoryInterface.5.11" -class Q_WAYLAND_COMPOSITOR_EXPORT HardwareLayerIntegrationPlugin : public QObject +class Q_WAYLANDCOMPOSITOR_EXPORT HardwareLayerIntegrationPlugin : public QObject { Q_OBJECT public: diff --git a/src/compositor/hardware_integration/qwlhwintegration.cpp b/src/compositor/hardware_integration/qwlhwintegration.cpp index c317f2f28..9882dc280 100644 --- a/src/compositor/hardware_integration/qwlhwintegration.cpp +++ b/src/compositor/hardware_integration/qwlhwintegration.cpp @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "qwlhwintegration_p.h" @@ -41,21 +15,21 @@ HardwareIntegration::HardwareIntegration(QWaylandCompositor *compositor) { } -void HardwareIntegration::setClientBufferIntegration(const QString &name) +void HardwareIntegration::setClientBufferIntegrationName(const QString &name) { - m_client_buffer_integration = name; + m_client_buffer_integration_name = name; } -void HardwareIntegration::setServerBufferIntegration(const QString &name) +void HardwareIntegration::setServerBufferIntegrationName(const QString &name) { - m_server_buffer_integration = name; + m_server_buffer_integration_name = name; } void HardwareIntegration::hardware_integration_bind_resource(Resource *resource) { - if (m_client_buffer_integration.size()) - send_client_backend(resource->handle, m_client_buffer_integration); - if (m_server_buffer_integration.size()) - send_server_backend(resource->handle, m_server_buffer_integration); + if (!m_client_buffer_integration_name.isEmpty()) + send_client_backend(resource->handle, m_client_buffer_integration_name); + if (!m_server_buffer_integration_name.isEmpty()) + send_server_backend(resource->handle, m_server_buffer_integration_name); } } diff --git a/src/compositor/hardware_integration/qwlhwintegration_p.h b/src/compositor/hardware_integration/qwlhwintegration_p.h index c7813a077..bc8ffd227 100644 --- a/src/compositor/hardware_integration/qwlhwintegration_p.h +++ b/src/compositor/hardware_integration/qwlhwintegration_p.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWLHWINTEGRATION_P_H #define QWLHWINTEGRATION_P_H @@ -46,6 +20,7 @@ #include <QtWaylandCompositor/QWaylandCompositorExtension> #include <QtCore/QString> +#include <QtCore/private/qglobal_p.h> QT_BEGIN_NAMESPACE @@ -58,15 +33,15 @@ class HardwareIntegration : public QWaylandCompositorExtensionTemplate<HardwareI public: HardwareIntegration(QWaylandCompositor *compositor); - void setClientBufferIntegration(const QString &name); - void setServerBufferIntegration(const QString &name); + void setClientBufferIntegrationName(const QString &name); + void setServerBufferIntegrationName(const QString &name); protected: void hardware_integration_bind_resource(Resource *resource) override; private: - QString m_client_buffer_integration; - QString m_server_buffer_integration; + QString m_client_buffer_integration_name; + QString m_server_buffer_integration_name; }; } diff --git a/src/compositor/hardware_integration/qwlserverbufferintegration.cpp b/src/compositor/hardware_integration/qwlserverbufferintegration.cpp index e8c1a21fd..e08af0206 100644 --- a/src/compositor/hardware_integration/qwlserverbufferintegration.cpp +++ b/src/compositor/hardware_integration/qwlserverbufferintegration.cpp @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "qwlserverbufferintegration_p.h" diff --git a/src/compositor/hardware_integration/qwlserverbufferintegration_p.h b/src/compositor/hardware_integration/qwlserverbufferintegration_p.h index 96efd9e46..92bbdee4d 100644 --- a/src/compositor/hardware_integration/qwlserverbufferintegration_p.h +++ b/src/compositor/hardware_integration/qwlserverbufferintegration_p.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDSERVERBUFFERINTEGRATION_H #define QWAYLANDSERVERBUFFERINTEGRATION_H @@ -41,7 +15,7 @@ // We mean it. // -#include <QtCore/qglobal.h> +#include <QtCore/private/qglobal_p.h> #include <QtCore/QSize> #include <QtGui/qopengl.h> @@ -60,7 +34,7 @@ class QImage; namespace QtWayland { class Display; -class Q_WAYLAND_COMPOSITOR_EXPORT ServerBuffer +class Q_WAYLANDCOMPOSITOR_EXPORT ServerBuffer { public: enum Format { @@ -87,7 +61,7 @@ protected: Format m_format; }; -class Q_WAYLAND_COMPOSITOR_EXPORT ServerBufferIntegration +class Q_WAYLANDCOMPOSITOR_EXPORT ServerBufferIntegration { public: ServerBufferIntegration(); @@ -97,9 +71,10 @@ public: virtual bool supportsFormat(ServerBuffer::Format format) const = 0; virtual ServerBuffer *createServerBufferFromImage(const QImage &qimage, ServerBuffer::Format format) = 0; - virtual ServerBuffer *createServerBufferFromData(const QByteArray &data, const QSize &size, uint glInternalFormat) + virtual ServerBuffer *createServerBufferFromData(QByteArrayView view, const QSize &size, + uint glInternalFormat) { - Q_UNUSED(data); + Q_UNUSED(view); Q_UNUSED(size); Q_UNUSED(glInternalFormat); return nullptr; diff --git a/src/compositor/hardware_integration/qwlserverbufferintegrationfactory.cpp b/src/compositor/hardware_integration/qwlserverbufferintegrationfactory.cpp index a68a62fc8..a92c3f35e 100644 --- a/src/compositor/hardware_integration/qwlserverbufferintegrationfactory.cpp +++ b/src/compositor/hardware_integration/qwlserverbufferintegrationfactory.cpp @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "qwlserverbufferintegrationfactory_p.h" #include "qwlserverbufferintegrationplugin_p.h" @@ -38,49 +12,17 @@ QT_BEGIN_NAMESPACE namespace QtWayland { -#if QT_CONFIG(library) -Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader, +Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, qwsbifLoader, (QtWaylandServerBufferIntegrationFactoryInterface_iid, QLatin1String("/wayland-graphics-integration-server"), Qt::CaseInsensitive)) -Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, directLoader, - (QtWaylandServerBufferIntegrationFactoryInterface_iid, QLatin1String(""), Qt::CaseInsensitive)) -#endif -QStringList ServerBufferIntegrationFactory::keys(const QString &pluginPath) +QStringList ServerBufferIntegrationFactory::keys() { -#if QT_CONFIG(library) - QStringList list; - if (!pluginPath.isEmpty()) { - QCoreApplication::addLibraryPath(pluginPath); - list = directLoader()->keyMap().values(); - if (!list.isEmpty()) { - const QString postFix = QStringLiteral(" (from ") - + QDir::toNativeSeparators(pluginPath) - + QLatin1Char(')'); - const QStringList::iterator end = list.end(); - for (QStringList::iterator it = list.begin(); it != end; ++it) - (*it).append(postFix); - } - } - list.append(loader()->keyMap().values()); - return list; -#else - return QStringList(); -#endif + return qwsbifLoader->keyMap().values(); } -ServerBufferIntegration *ServerBufferIntegrationFactory::create(const QString &name, const QStringList &args, const QString &pluginPath) +ServerBufferIntegration *ServerBufferIntegrationFactory::create(const QString &name, const QStringList &args) { -#if QT_CONFIG(library) - // Try loading the plugin from platformPluginPath first: - if (!pluginPath.isEmpty()) { - QCoreApplication::addLibraryPath(pluginPath); - if (ServerBufferIntegration *ret = qLoadPlugin<ServerBufferIntegration, ServerBufferIntegrationPlugin>(directLoader(), name, args)) - return ret; - } - if (ServerBufferIntegration *ret = qLoadPlugin<ServerBufferIntegration, ServerBufferIntegrationPlugin>(loader(), name, args)) - return ret; -#endif - return nullptr; + return qLoadPlugin<ServerBufferIntegration, ServerBufferIntegrationPlugin>(qwsbifLoader(), name, args); } } diff --git a/src/compositor/hardware_integration/qwlserverbufferintegrationfactory_p.h b/src/compositor/hardware_integration/qwlserverbufferintegrationfactory_p.h index 9efc4afc8..778399928 100644 --- a/src/compositor/hardware_integration/qwlserverbufferintegrationfactory_p.h +++ b/src/compositor/hardware_integration/qwlserverbufferintegrationfactory_p.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDSERVERBUFFERINTEGRATIONFACTORY_H #define QWAYLANDSERVERBUFFERINTEGRATIONFACTORY_H @@ -43,6 +17,7 @@ #include <QtWaylandCompositor/qtwaylandcompositorglobal.h> #include <QtCore/QStringList> +#include <QtCore/private/qglobal_p.h> QT_BEGIN_NAMESPACE @@ -50,11 +25,11 @@ namespace QtWayland { class ServerBufferIntegration; -class Q_WAYLAND_COMPOSITOR_EXPORT ServerBufferIntegrationFactory +class Q_WAYLANDCOMPOSITOR_EXPORT ServerBufferIntegrationFactory { public: - static QStringList keys(const QString &pluginPath = QString()); - static ServerBufferIntegration *create(const QString &name, const QStringList &args, const QString &pluginPath = QString()); + static QStringList keys(); + static ServerBufferIntegration *create(const QString &name, const QStringList &args); }; } diff --git a/src/compositor/hardware_integration/qwlserverbufferintegrationplugin.cpp b/src/compositor/hardware_integration/qwlserverbufferintegrationplugin.cpp index 0d047d4f1..1e687d17a 100644 --- a/src/compositor/hardware_integration/qwlserverbufferintegrationplugin.cpp +++ b/src/compositor/hardware_integration/qwlserverbufferintegrationplugin.cpp @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "qwlserverbufferintegrationplugin_p.h" @@ -46,3 +20,5 @@ ServerBufferIntegrationPlugin::~ServerBufferIntegrationPlugin() QT_END_NAMESPACE +#include "moc_qwlserverbufferintegrationplugin_p.cpp" + diff --git a/src/compositor/hardware_integration/qwlserverbufferintegrationplugin_p.h b/src/compositor/hardware_integration/qwlserverbufferintegrationplugin_p.h index afc28f2f6..8f64878fe 100644 --- a/src/compositor/hardware_integration/qwlserverbufferintegrationplugin_p.h +++ b/src/compositor/hardware_integration/qwlserverbufferintegrationplugin_p.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDSERVERBUFFERINTEGRATIONPLUGIN_H #define QWAYLANDSERVERBUFFERINTEGRATIONPLUGIN_H @@ -45,6 +19,7 @@ #include <QtCore/qplugin.h> #include <QtCore/qfactoryinterface.h> +#include <QtCore/private/qglobal_p.h> QT_BEGIN_NAMESPACE @@ -54,7 +29,7 @@ class ServerBufferIntegration; #define QtWaylandServerBufferIntegrationFactoryInterface_iid "org.qt-project.Qt.Compositor.QtWaylandServerBufferIntegrationFactoryInterface.5.3" -class Q_WAYLAND_COMPOSITOR_EXPORT ServerBufferIntegrationPlugin : public QObject +class Q_WAYLANDCOMPOSITOR_EXPORT ServerBufferIntegrationPlugin : public QObject { Q_OBJECT public: diff --git a/src/compositor/hardware_integration/qwltextureorphanage.cpp b/src/compositor/hardware_integration/qwltextureorphanage.cpp new file mode 100644 index 000000000..c1ff86977 --- /dev/null +++ b/src/compositor/hardware_integration/qwltextureorphanage.cpp @@ -0,0 +1,108 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#include "qwltextureorphanage_p.h" + +#include <QOpenGLContext> +#include <QOpenGLTexture> +#include <QDebug> +#include <QtTypeTraits> +#include <QMutexLocker> + +QT_BEGIN_NAMESPACE + +Q_LOGGING_CATEGORY(qLcWTO, "qt.waylandcompositor.orphanage") + +Q_GLOBAL_STATIC(QtWayland::QWaylandTextureOrphanage, inst) + +namespace QtWayland { + +QWaylandTextureOrphanage::~QWaylandTextureOrphanage() +{ + QMutexLocker locker(&m_containerLock); + if (!m_orphanedTextures.isEmpty()) { + qCWarning(qLcWTO) << Q_FUNC_INFO << "m_orphanedTextures container isn't empty! content:" + << m_orphanedTextures; + } +} + +QWaylandTextureOrphanage *QWaylandTextureOrphanage::instance() +{ + return inst; +} + +void QWaylandTextureOrphanage::admitTexture(QOpenGLTexture *tex, QOpenGLContext *ctx) +{ + qCDebug(qLcWTO) << Q_FUNC_INFO << "got a texture (" << (void *)tex + << ") ready to be deleted! It's ctx:" << ctx; + + { + QMutexLocker locker(&m_containerLock); + m_orphanedTextures.insert(ctx, tex); + } + + connect(ctx, &QOpenGLContext::aboutToBeDestroyed, this, + [this, ctx]() { this->onContextAboutToBeDestroyed(ctx); }, + Qt::ConnectionType(Qt::DirectConnection)); +} + +void QWaylandTextureOrphanage::deleteTextures() +{ + QOpenGLContext *cCtx = QOpenGLContext::currentContext(); + + if (cCtx == nullptr) { + qCWarning(qLcWTO) << Q_FUNC_INFO << "cannot delete textures without current OpenGL context"; + return; + } + + { + QMutexLocker locker(&m_containerLock); + + for (QOpenGLContext *aCtx : m_orphanedTextures.keys()) { + if (QOpenGLContext::areSharing(cCtx, aCtx)) { + + qCDebug(qLcWTO) << Q_FUNC_INFO << "currentContext (" << cCtx + << ") and ctx of orphane(s) (" << aCtx + << ") are shared! => deleteTexturesByContext"; + + deleteTexturesByContext(aCtx); + } + } + } +} + +void QWaylandTextureOrphanage::onContextAboutToBeDestroyed(QOpenGLContext *ctx) +{ + Q_ASSERT(ctx != nullptr); + + qCDebug(qLcWTO) << Q_FUNC_INFO << " ctx (" << ctx + << ") fired aboutToBeDestroyed => deleteTexturesByContext(ctx)"; + + { + QMutexLocker locker(&m_containerLock); + deleteTexturesByContext(ctx); + } +} + +void QWaylandTextureOrphanage::deleteTexturesByContext(QOpenGLContext *ctx) +{ + // NOTE: We are (by class-internal design) locked (m_containerLock) + // when we enter this function! + // If not (e.g.: someone changes something in/around this class), + // then in a debug-build we will fail below: + Q_ASSERT(!m_containerLock.tryLock()); + + QList<QOpenGLTexture *> texturesToDelete = m_orphanedTextures.values(ctx); + m_orphanedTextures.remove(ctx); + + for (QOpenGLTexture *tex : texturesToDelete) { + delete tex; + qCDebug(qLcWTO) << Q_FUNC_INFO << " texture (" << (void *)tex << ") got deleted"; + } +} + +} // namespace QtWayland + +QT_END_NAMESPACE + +#include "moc_qwltextureorphanage_p.cpp" diff --git a/src/compositor/hardware_integration/qwltextureorphanage_p.h b/src/compositor/hardware_integration/qwltextureorphanage_p.h new file mode 100644 index 000000000..f040ec750 --- /dev/null +++ b/src/compositor/hardware_integration/qwltextureorphanage_p.h @@ -0,0 +1,64 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#ifndef QWLTEXTUREORPHANAGE_P_H +#define QWLTEXTUREORPHANAGE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QObject> +#include <QMutex> +#include <QLoggingCategory> +#include <QtWaylandCompositor/qtwaylandcompositorglobal.h> + +QT_BEGIN_NAMESPACE + +class QOpenGLContext; +class QOpenGLTexture; + +Q_DECLARE_LOGGING_CATEGORY(qLcWTO) + +namespace QtWayland { + +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandTextureOrphanage : public QObject +{ + Q_OBJECT + +public: + QWaylandTextureOrphanage(){}; + ~QWaylandTextureOrphanage(); + + static QWaylandTextureOrphanage *instance(); + + // texture that isn't needed anymore will be "take care of" (killed) appropriately + void admitTexture(QOpenGLTexture *tex, QOpenGLContext *ctx); + + // uses QOpenGLContext::currentContext to call deleteTexturesByContext on all shared ctx + void deleteTextures(); + +public Q_SLOTS: + // uses sender() to call deleteTexturesByContext + void onContextAboutToBeDestroyed(QOpenGLContext *ctx); + +private: + void deleteTexturesByContext(QOpenGLContext *ctx); + + // tracks all the orphanes that need to be deleted + QMultiHash<QOpenGLContext *, QOpenGLTexture *> m_orphanedTextures; + + QMutex m_containerLock; +}; + +} // namespace QtWayland + +QT_END_NAMESPACE +#endif diff --git a/src/compositor/qmlfiles/WaylandCursorItem.qml b/src/compositor/qmlfiles/WaylandCursorItem.qml new file mode 100644 index 000000000..dfa704176 --- /dev/null +++ b/src/compositor/qmlfiles/WaylandCursorItem.qml @@ -0,0 +1,49 @@ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +import QtQuick +import QtWayland.Compositor + +WaylandQuickItem { + id: cursorItem + property QtObject seat + property int hotspotX: 0 + property int hotspotY: 0 + + visible: cursorItem.surface != null + inputEventsEnabled: false + enabled: false + transform: Translate { + // If we've set an output scale factor different from the device pixel ratio + // then the item will be rendered scaled, so we need to shift the hotspot accordingly + x: -hotspotX * (output ? output.scaleFactor / Screen.devicePixelRatio : 1) + y: -hotspotY * (output ? output.scaleFactor / Screen.devicePixelRatio : 1) + } + + Connections { + target: seat + function onCursorSurfaceRequest(surface, hotspotX, hotspotY) { + cursorItem.surface = surface; + cursorItem.hotspotX = hotspotX; + cursorItem.hotspotY = hotspotY; + } + } + + WaylandQuickItem { + id: dragIcon + property point offset + inputEventsEnabled: false + + x: cursorItem.hotspotX + offset.x + y: cursorItem.hotspotY + offset.y + z: -1 + surface: cursorItem.seat ? cursorItem.seat.drag.icon : null + + Connections { + target: dragIcon.surface + function onOffsetForNextFrame(offset) { + dragIcon.offset = offset; + } + } + } +} diff --git a/src/compositor/qmlfiles/WaylandOutputWindow.qml b/src/compositor/qmlfiles/WaylandOutputWindow.qml new file mode 100644 index 000000000..4b5a4529d --- /dev/null +++ b/src/compositor/qmlfiles/WaylandOutputWindow.qml @@ -0,0 +1,21 @@ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +import QtQuick + +Window { + id: window + property QtObject compositor + property QtObject output + property bool automaticFrameCallback: false + + Component.onCompleted: { + if (!compositor) { + console.warn("WaylandOutputWindow initiated without compositor. This leads to undefined behavior"); + return; + } + output = compositor.addOutput(window); + output.automaticFrameCallbacks = window.automaticFrameCallback; + } +} + diff --git a/src/compositor/qt_cmdline.cmake b/src/compositor/qt_cmdline.cmake new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/src/compositor/qt_cmdline.cmake diff --git a/src/compositor/shaders/compile b/src/compositor/shaders/compile new file mode 100644 index 000000000..33c2f34d5 --- /dev/null +++ b/src/compositor/shaders/compile @@ -0,0 +1,9 @@ +qsb -b --glsl "100 es,120,150" -o surface.vert.qsb surface.vert +qsb --glsl "100 es,120,150" -o surface_rgba.frag.qsb surface_rgba.frag +qsb --glsl "100 es,120,150" -o surface_rgbx.frag.qsb surface_rgbx.frag +qsb --glsl "100 es,120,150" -o surface_y_uv.frag.qsb surface_y_uv.frag +qsb --glsl "100 es,120,150" -o surface_y_u_v.frag.qsb surface_y_u_v.frag +qsb --glsl "100 es,120,150" -o surface_y_xuxv.frag.qsb surface_y_xuxv.frag + +# Cannot be precompiled and is handled separately: +# surface_oes_external.frag diff --git a/src/compositor/shaders/surface.vert b/src/compositor/shaders/surface.vert index 848b334f3..bd28d9bf8 100644 --- a/src/compositor/shaders/surface.vert +++ b/src/compositor/shaders/surface.vert @@ -1,9 +1,21 @@ -uniform highp mat4 qt_Matrix; -attribute highp vec2 qt_VertexPosition; -attribute highp vec2 qt_VertexTexCoord; -varying highp vec2 v_texcoord; - -void main() { - gl_Position = qt_Matrix * vec4(qt_VertexPosition, 0.0, 1.0); - v_texcoord = qt_VertexTexCoord; +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#version 440 + +layout(location = 0) in vec2 qt_VertexPosition; +layout(location = 1) in vec2 qt_VertexTexCoord; +layout(location = 0) out vec2 v_texcoord; + +layout(std140, binding = 0) uniform buf { + mat4 qt_Matrix; + float qt_Opacity; +}; + +out gl_PerVertex { vec4 gl_Position; }; + +void main() +{ + gl_Position = qt_Matrix * vec4(qt_VertexPosition, 0.0, 1.0); + v_texcoord = qt_VertexTexCoord; } diff --git a/src/compositor/shaders/surface.vert.qsb b/src/compositor/shaders/surface.vert.qsb Binary files differnew file mode 100644 index 000000000..596dce513 --- /dev/null +++ b/src/compositor/shaders/surface.vert.qsb diff --git a/src/compositor/shaders/surface_oes_external.frag b/src/compositor/shaders/surface_oes_external.frag index 724d06a85..3064bf7b1 100644 --- a/src/compositor/shaders/surface_oes_external.frag +++ b/src/compositor/shaders/surface_oes_external.frag @@ -1,8 +1,18 @@ -#extension GL_OES_EGL_image_external : require -varying highp vec2 v_texcoord; -uniform highp samplerExternalOES tex0; -uniform lowp float qt_Opacity; +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only -void main() { - gl_FragColor = qt_Opacity * texture2D(tex0, v_texcoord); +// This shader stump cannot be precompiled and is compiled at run-time. +// Appropriate target preamble added when it is loaded. + +varying vec2 v_texcoord; +struct buf { + mat4 qt_Matrix; + float qt_Opacity; +}; +uniform buf ubuf; +uniform samplerExternalOES tex0; + +void main() +{ + gl_FragColor = ubuf.qt_Opacity * texture2D(tex0, v_texcoord); } diff --git a/src/compositor/shaders/surface_rgba.frag b/src/compositor/shaders/surface_rgba.frag index f896051ba..8bb48dc15 100644 --- a/src/compositor/shaders/surface_rgba.frag +++ b/src/compositor/shaders/surface_rgba.frag @@ -1,7 +1,19 @@ -varying highp vec2 v_texcoord; -uniform highp sampler2D tex0; -uniform lowp float qt_Opacity; +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only -void main() { - gl_FragColor = qt_Opacity * texture2D(tex0, v_texcoord); +#version 440 + +layout(location = 0) in vec2 v_texcoord; +layout(location = 0) out vec4 fragColor; + +layout(std140, binding = 0) uniform buf { + mat4 qt_Matrix; + float qt_Opacity; +}; + +layout(binding = 1) uniform sampler2D tex0; + +void main() +{ + fragColor = qt_Opacity * texture(tex0, v_texcoord); } diff --git a/src/compositor/shaders/surface_rgba.frag.qsb b/src/compositor/shaders/surface_rgba.frag.qsb Binary files differnew file mode 100644 index 000000000..72abc0f1b --- /dev/null +++ b/src/compositor/shaders/surface_rgba.frag.qsb diff --git a/src/compositor/shaders/surface_rgbx.frag b/src/compositor/shaders/surface_rgbx.frag index 8fb78498c..600c1beae 100644 --- a/src/compositor/shaders/surface_rgbx.frag +++ b/src/compositor/shaders/surface_rgbx.frag @@ -1,8 +1,20 @@ -varying highp vec2 v_texcoord; -uniform highp sampler2D tex0; -uniform lowp float qt_Opacity; +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only -void main() { - gl_FragColor.rgb = qt_Opacity * texture2D(tex0, v_texcoord).rgb; - gl_FragColor.a = qt_Opacity; +#version 440 + +layout(location = 0) in vec2 v_texcoord; +layout(location = 0) out vec4 fragColor; + +layout(std140, binding = 0) uniform buf { + mat4 qt_Matrix; + float qt_Opacity; +}; + +layout(binding = 1) uniform sampler2D tex0; + +void main() +{ + fragColor.rgb = qt_Opacity * texture(tex0, v_texcoord).rgb; + fragColor.a = qt_Opacity; } diff --git a/src/compositor/shaders/surface_rgbx.frag.qsb b/src/compositor/shaders/surface_rgbx.frag.qsb Binary files differnew file mode 100644 index 000000000..5fd9a21ac --- /dev/null +++ b/src/compositor/shaders/surface_rgbx.frag.qsb diff --git a/src/compositor/shaders/surface_y_u_v.frag b/src/compositor/shaders/surface_y_u_v.frag index e739f6fff..3c14036ef 100644 --- a/src/compositor/shaders/surface_y_u_v.frag +++ b/src/compositor/shaders/surface_y_u_v.frag @@ -1,18 +1,30 @@ -uniform highp sampler2D tex0; -uniform highp sampler2D tex1; -uniform highp sampler2D tex2; -varying highp vec2 v_texcoord; -uniform lowp float qt_Opacity; +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only -void main() { - float y = 1.16438356 * (texture2D(tex0, v_texcoord).x - 0.0625); - float u = texture2D(tex1, v_texcoord).x - 0.5; - float v = texture2D(tex2, v_texcoord).x - 0.5; - y *= qt_Opacity; - u *= qt_Opacity; - v *= qt_Opacity; - gl_FragColor.r = y + 1.59602678 * v; - gl_FragColor.g = y - 0.39176229 * u - 0.81296764 * v; - gl_FragColor.b = y + 2.01723214 * u; - gl_FragColor.a = qt_Opacity; +#version 440 + +layout(location = 0) in vec2 v_texcoord; +layout(location = 0) out vec4 fragColor; + +layout(std140, binding = 0) uniform buf { + mat4 qt_Matrix; + float qt_Opacity; +}; + +layout(binding = 1) uniform sampler2D tex0; +layout(binding = 2) uniform sampler2D tex1; +layout(binding = 3) uniform sampler2D tex2; + +void main() +{ + float y = 1.16438356 * (texture(tex0, v_texcoord).x - 0.0625); + float u = texture(tex1, v_texcoord).x - 0.5; + float v = texture(tex2, v_texcoord).x - 0.5; + y *= qt_Opacity; + u *= qt_Opacity; + v *= qt_Opacity; + fragColor.r = y + 1.59602678 * v; + fragColor.g = y - 0.39176229 * u - 0.81296764 * v; + fragColor.b = y + 2.01723214 * u; + fragColor.a = qt_Opacity; } diff --git a/src/compositor/shaders/surface_y_u_v.frag.qsb b/src/compositor/shaders/surface_y_u_v.frag.qsb Binary files differnew file mode 100644 index 000000000..72da0fe85 --- /dev/null +++ b/src/compositor/shaders/surface_y_u_v.frag.qsb diff --git a/src/compositor/shaders/surface_y_uv.frag b/src/compositor/shaders/surface_y_uv.frag index e3fbcdf8d..42b614882 100644 --- a/src/compositor/shaders/surface_y_uv.frag +++ b/src/compositor/shaders/surface_y_uv.frag @@ -1,17 +1,29 @@ -uniform highp sampler2D tex0; -uniform highp sampler2D tex1; -varying highp vec2 v_texcoord; -uniform lowp float qt_Opacity; +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only -void main() { - float y = 1.16438356 * (texture2D(tex0, v_texcoord).x - 0.0625); - float u = texture2D(tex1, v_texcoord).r - 0.5; - float v = texture2D(tex1, v_texcoord).g - 0.5; - y *= qt_Opacity; - u *= qt_Opacity; - v *= qt_Opacity; - gl_FragColor.r = y + 1.59602678 * v; - gl_FragColor.g = y - 0.39176229 * u - 0.81296764 * v; - gl_FragColor.b = y + 2.01723214 * u; - gl_FragColor.a = qt_Opacity; +#version 440 + +layout(location = 0) in vec2 v_texcoord; +layout(location = 0) out vec4 fragColor; + +layout(std140, binding = 0) uniform buf { + mat4 qt_Matrix; + float qt_Opacity; +}; + +layout(binding = 1) uniform sampler2D tex0; +layout(binding = 2) uniform sampler2D tex1; + +void main() +{ + float y = 1.16438356 * (texture(tex0, v_texcoord).x - 0.0625); + float u = texture(tex1, v_texcoord).r - 0.5; + float v = texture(tex1, v_texcoord).g - 0.5; + y *= qt_Opacity; + u *= qt_Opacity; + v *= qt_Opacity; + fragColor.r = y + 1.59602678 * v; + fragColor.g = y - 0.39176229 * u - 0.81296764 * v; + fragColor.b = y + 2.01723214 * u; + fragColor.a = qt_Opacity; } diff --git a/src/compositor/shaders/surface_y_uv.frag.qsb b/src/compositor/shaders/surface_y_uv.frag.qsb Binary files differnew file mode 100644 index 000000000..4cea4838d --- /dev/null +++ b/src/compositor/shaders/surface_y_uv.frag.qsb diff --git a/src/compositor/shaders/surface_y_xuxv.frag b/src/compositor/shaders/surface_y_xuxv.frag index 79f8600e8..57609f4fd 100644 --- a/src/compositor/shaders/surface_y_xuxv.frag +++ b/src/compositor/shaders/surface_y_xuxv.frag @@ -1,17 +1,29 @@ -uniform highp sampler2D tex0; -uniform highp sampler2D tex1; -varying highp vec2 v_texcoord; -uniform lowp float qt_Opacity; +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only -void main() { - float y = 1.16438356 * (texture2D(tex0, v_texcoord).x - 0.0625); - float u = texture2D(tex1, v_texcoord).g - 0.5; - float v = texture2D(tex1, v_texcoord).a - 0.5; - y *= qt_Opacity; - u *= qt_Opacity; - v *= qt_Opacity; - gl_FragColor.r = y + 1.59602678 * v; - gl_FragColor.g = y - 0.39176229 * u - 0.81296764 * v; - gl_FragColor.b = y + 2.01723214 * u; - gl_FragColor.a = qt_Opacity; +#version 440 + +layout(location = 0) in vec2 v_texcoord; +layout(location = 0) out vec4 fragColor; + +layout(std140, binding = 0) uniform buf { + mat4 qt_Matrix; + float qt_Opacity; +}; + +layout(binding = 1) uniform sampler2D tex0; +layout(binding = 2) uniform sampler2D tex1; + +void main() +{ + float y = 1.16438356 * (texture(tex0, v_texcoord).x - 0.0625); + float u = texture(tex1, v_texcoord).g - 0.5; + float v = texture(tex1, v_texcoord).a - 0.5; + y *= qt_Opacity; + u *= qt_Opacity; + v *= qt_Opacity; + fragColor.r = y + 1.59602678 * v; + fragColor.g = y - 0.39176229 * u - 0.81296764 * v; + fragColor.b = y + 2.01723214 * u; + fragColor.a = qt_Opacity; } diff --git a/src/compositor/shaders/surface_y_xuxv.frag.qsb b/src/compositor/shaders/surface_y_xuxv.frag.qsb Binary files differnew file mode 100644 index 000000000..5450935bd --- /dev/null +++ b/src/compositor/shaders/surface_y_xuxv.frag.qsb diff --git a/src/compositor/wayland_wrapper/qwlbuffermanager.cpp b/src/compositor/wayland_wrapper/qwlbuffermanager.cpp index 9a7b58299..7eb000ba4 100644 --- a/src/compositor/wayland_wrapper/qwlbuffermanager.cpp +++ b/src/compositor/wayland_wrapper/qwlbuffermanager.cpp @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "qwlbuffermanager_p.h" #include <QWaylandCompositor> @@ -55,6 +29,16 @@ struct buffer_manager_destroy_listener : wl_listener BufferManager *d = nullptr; }; +void BufferManager::registerBuffer(wl_resource *buffer_resource, ClientBuffer *clientBuffer) +{ + m_buffers[buffer_resource] = clientBuffer; + + auto *destroy_listener = new buffer_manager_destroy_listener; + destroy_listener->d = this; + wl_resource_add_destroy_listener(buffer_resource, destroy_listener); + +} + ClientBuffer *BufferManager::getBuffer(wl_resource *buffer_resource) { if (!buffer_resource) @@ -64,17 +48,19 @@ ClientBuffer *BufferManager::getBuffer(wl_resource *buffer_resource) if (it != m_buffers.end()) return it.value(); - auto bufferIntegration = QWaylandCompositorPrivate::get(m_compositor)->clientBufferIntegration(); ClientBuffer *newBuffer = nullptr; - if (bufferIntegration) - newBuffer = bufferIntegration->createBufferFor(buffer_resource); - if (!newBuffer) - newBuffer = new SharedMemoryBuffer(buffer_resource); - m_buffers[buffer_resource] = newBuffer; - auto *destroy_listener = new buffer_manager_destroy_listener; - destroy_listener->d = this; - wl_resource_add_destroy_listener(buffer_resource, destroy_listener); + for (auto *integration : QWaylandCompositorPrivate::get(m_compositor)->clientBufferIntegrations()) { + newBuffer = integration->createBufferFor(buffer_resource); + if (newBuffer) + break; + } + + if (newBuffer) + registerBuffer(buffer_resource, newBuffer); + else + qCWarning(qLcWaylandCompositorHardwareIntegration) << "Could not create buffer for resource."; + return newBuffer; } diff --git a/src/compositor/wayland_wrapper/qwlbuffermanager_p.h b/src/compositor/wayland_wrapper/qwlbuffermanager_p.h index d6eaeb79d..4a43a1a28 100644 --- a/src/compositor/wayland_wrapper/qwlbuffermanager_p.h +++ b/src/compositor/wayland_wrapper/qwlbuffermanager_p.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWLBUFFERMANAGER_H #define QWLBUFFERMANAGER_H @@ -42,6 +16,7 @@ // #include <QtCore/QObject> +#include <QtCore/QHash> #include "qwlclientbuffer_p.h" QT_BEGIN_NAMESPACE @@ -51,11 +26,12 @@ namespace QtWayland { class ClientBuffer; -class Q_WAYLAND_COMPOSITOR_EXPORT BufferManager : public QObject +class Q_WAYLANDCOMPOSITOR_EXPORT BufferManager : public QObject { public: BufferManager(QWaylandCompositor *compositor); ClientBuffer *getBuffer(struct ::wl_resource *buffer_resource); + void registerBuffer(struct ::wl_resource *buffer_resource, ClientBuffer *clientBuffer); private: friend struct buffer_manager_destroy_listener; static void destroy_listener_callback(wl_listener *listener, void *data); diff --git a/src/compositor/wayland_wrapper/qwlclientbuffer.cpp b/src/compositor/wayland_wrapper/qwlclientbuffer.cpp index 381b173f6..55de6573a 100644 --- a/src/compositor/wayland_wrapper/qwlclientbuffer.cpp +++ b/src/compositor/wayland_wrapper/qwlclientbuffer.cpp @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "qwlclientbuffer_p.h" @@ -123,6 +97,12 @@ QWaylandSurface::Origin SharedMemoryBuffer::origin() const return QWaylandSurface::OriginTopLeft; } +static void shmBufferCleanup(void *data) +{ + auto *pool = static_cast<struct wl_shm_pool *>(data); + wl_shm_pool_unref(pool); +} + QImage SharedMemoryBuffer::image() const { if (wl_shm_buffer *shmBuffer = wl_shm_buffer_get(m_buffer)) { @@ -134,8 +114,9 @@ QImage SharedMemoryBuffer::image() const wl_shm_format shmFormat = wl_shm_format(wl_shm_buffer_get_format(shmBuffer)); QImage::Format format = QWaylandSharedMemoryFormatHelper::fromWaylandShmFormat(shmFormat); + auto *pool = wl_shm_buffer_ref_pool(shmBuffer); uchar *data = static_cast<uchar *>(wl_shm_buffer_get_data(shmBuffer)); - return QImage(data, width, height, bytesPerLine, format); + return QImage(data, width, height, bytesPerLine, format, &shmBufferCleanup, pool); } return QImage(); diff --git a/src/compositor/wayland_wrapper/qwlclientbuffer_p.h b/src/compositor/wayland_wrapper/qwlclientbuffer_p.h index a6503e86e..424243873 100644 --- a/src/compositor/wayland_wrapper/qwlclientbuffer_p.h +++ b/src/compositor/wayland_wrapper/qwlclientbuffer_p.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWLCLIENTBUFFER_P_H #define QWLCLIENTBUFFER_P_H @@ -48,6 +22,7 @@ #include <QtWaylandCompositor/QWaylandSurface> #include <QtWaylandCompositor/QWaylandBufferRef> +#include <QtCore/private/qglobal_p.h> #include <wayland-server-core.h> @@ -66,7 +41,7 @@ struct surface_buffer_destroy_listener class ClientBuffer *surfaceBuffer = nullptr; }; -class Q_WAYLAND_COMPOSITOR_EXPORT ClientBuffer +class Q_WAYLANDCOMPOSITOR_EXPORT ClientBuffer { public: ClientBuffer(struct ::wl_resource *bufferResource); @@ -86,6 +61,8 @@ public: virtual void setCommitted(QRegion &damage); bool isDestroyed() { return m_destroyed; } + virtual bool isProtected() { return false; } + inline struct ::wl_resource *waylandBufferHandle() const { return m_buffer; } bool isSharedMemory() const { return wl_shm_buffer_get(m_buffer); } @@ -95,6 +72,7 @@ public: #endif static bool hasContent(ClientBuffer *buffer) { return buffer && buffer->waylandBufferHandle(); } + static bool hasProtectedContent(ClientBuffer *buffer) { return buffer && buffer->isProtected(); } protected: void ref(); @@ -116,7 +94,7 @@ private: friend class BufferManager; }; -class Q_WAYLAND_COMPOSITOR_EXPORT SharedMemoryBuffer : public ClientBuffer +class Q_WAYLANDCOMPOSITOR_EXPORT SharedMemoryBuffer : public ClientBuffer { public: SharedMemoryBuffer(struct ::wl_resource *bufferResource); diff --git a/src/compositor/wayland_wrapper/qwldatadevice.cpp b/src/compositor/wayland_wrapper/qwldatadevice.cpp index a3a795f9b..440401d05 100644 --- a/src/compositor/wayland_wrapper/qwldatadevice.cpp +++ b/src/compositor/wayland_wrapper/qwldatadevice.cpp @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "qwldatadevice_p.h" @@ -76,6 +50,9 @@ void DataDevice::sourceDestroyed(DataSource *source) { if (m_selectionSource == source) m_selectionSource = nullptr; + + if (m_dragDataSource == source) + m_dragDataSource = nullptr; } #if QT_CONFIG(draganddrop) @@ -105,9 +82,11 @@ void DataDevice::setDragFocus(QWaylandSurface *focus, const QPointF &localPositi if (m_dragDataSource && !offer) return; - send_enter(resource->handle, serial, focus->resource(), - wl_fixed_from_double(localPosition.x()), wl_fixed_from_double(localPosition.y()), - offer->resource()->handle); + if (offer) { + send_enter(resource->handle, serial, focus->resource(), + wl_fixed_from_double(localPosition.x()), wl_fixed_from_double(localPosition.y()), + offer->resource()->handle); + } m_dragFocus = focus; m_dragFocusResource = resource; @@ -127,7 +106,7 @@ void DataDevice::dragMove(QWaylandSurface *target, const QPointF &pos) { if (target != m_dragFocus) setDragFocus(target, pos); - if (!target) + if (!target || !m_dragFocusResource) return; uint time = m_compositor->currentTimeMsecs(); //### should be serial send_motion(m_dragFocusResource->handle, time, @@ -139,7 +118,7 @@ void DataDevice::drop() if (m_dragFocusResource) { send_drop(m_dragFocusResource->handle); setDragFocus(nullptr, QPoint()); - } else { + } else if (m_dragDataSource) { m_dragDataSource->cancel(); } m_dragOrigin = nullptr; @@ -150,11 +129,13 @@ void DataDevice::cancelDrag() { setDragFocus(nullptr, QPoint()); } - + void DataDevice::data_device_start_drag(Resource *resource, struct ::wl_resource *source, struct ::wl_resource *origin, struct ::wl_resource *icon, uint32_t serial) { m_dragClient = resource->client(); m_dragDataSource = source ? DataSource::fromResource(source) : nullptr; + if (m_dragDataSource) + m_dragDataSource->setDevice(this); m_dragOrigin = QWaylandSurface::fromResource(origin); QWaylandDrag *drag = m_seat->drag(); setDragIcon(icon ? QWaylandSurface::fromResource(icon) : nullptr); diff --git a/src/compositor/wayland_wrapper/qwldatadevice_p.h b/src/compositor/wayland_wrapper/qwldatadevice_p.h index 18a97e8ca..839d93881 100644 --- a/src/compositor/wayland_wrapper/qwldatadevice_p.h +++ b/src/compositor/wayland_wrapper/qwldatadevice_p.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef WLDATADEVICE_H #define WLDATADEVICE_H diff --git a/src/compositor/wayland_wrapper/qwldatadevicemanager.cpp b/src/compositor/wayland_wrapper/qwldatadevicemanager.cpp index 46df52109..04add014f 100644 --- a/src/compositor/wayland_wrapper/qwldatadevicemanager.cpp +++ b/src/compositor/wayland_wrapper/qwldatadevicemanager.cpp @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "qwldatadevicemanager_p.h" @@ -93,7 +67,7 @@ void DataDeviceManager::retain() { QList<QString> offers = m_current_selection_source->mimeTypes(); finishReadFromClient(); - if (m_retainedReadIndex >= offers.count()) { + if (m_retainedReadIndex >= offers.size()) { QWaylandCompositorPrivate::get(m_compositor)->feedRetainedSelectionData(&m_retainedData); return; } @@ -107,7 +81,7 @@ void DataDeviceManager::retain() fcntl(fd[0], F_SETFL, fcntl(fd[0], F_GETFL, 0) | O_NONBLOCK); m_current_selection_source->send(mimeType, fd[1]); m_retainedReadNotifier = new QSocketNotifier(fd[0], QSocketNotifier::Read, this); - connect(m_retainedReadNotifier, SIGNAL(activated(int)), SLOT(readFromClient(int))); + connect(m_retainedReadNotifier, &QSocketNotifier::activated, this, &DataDeviceManager::readFromClient); } void DataDeviceManager::finishReadFromClient(bool exhausted) @@ -130,7 +104,7 @@ void DataDeviceManager::finishReadFromClient(bool exhausted) void DataDeviceManager::readFromClient(int fd) { static char buf[4096]; - int obsCount = m_obsoleteRetainedReadNotifiers.count(); + int obsCount = m_obsoleteRetainedReadNotifiers.size(); for (int i = 0; i < obsCount; ++i) { QSocketNotifier *sn = m_obsoleteRetainedReadNotifiers.at(i); if (sn->socket() == fd) { @@ -271,3 +245,5 @@ const struct wl_data_offer_interface DataDeviceManager::compositor_offer_interfa } //namespace QT_END_NAMESPACE + +#include "moc_qwldatadevicemanager_p.cpp" diff --git a/src/compositor/wayland_wrapper/qwldatadevicemanager_p.h b/src/compositor/wayland_wrapper/qwldatadevicemanager_p.h index 730e22190..954a4c355 100644 --- a/src/compositor/wayland_wrapper/qwldatadevicemanager_p.h +++ b/src/compositor/wayland_wrapper/qwldatadevicemanager_p.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef WLDATADEVICEMANAGER_H #define WLDATADEVICEMANAGER_H diff --git a/src/compositor/wayland_wrapper/qwldataoffer.cpp b/src/compositor/wayland_wrapper/qwldataoffer.cpp index 06c5118df..a612ca682 100644 --- a/src/compositor/wayland_wrapper/qwldataoffer.cpp +++ b/src/compositor/wayland_wrapper/qwldataoffer.cpp @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "qwldataoffer_p.h" diff --git a/src/compositor/wayland_wrapper/qwldataoffer_p.h b/src/compositor/wayland_wrapper/qwldataoffer_p.h index ef470a697..aeac6d62f 100644 --- a/src/compositor/wayland_wrapper/qwldataoffer_p.h +++ b/src/compositor/wayland_wrapper/qwldataoffer_p.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef WLDATAOFFER_H #define WLDATAOFFER_H diff --git a/src/compositor/wayland_wrapper/qwldatasource.cpp b/src/compositor/wayland_wrapper/qwldatasource.cpp index ff7ec024d..eba8ae302 100644 --- a/src/compositor/wayland_wrapper/qwldatasource.cpp +++ b/src/compositor/wayland_wrapper/qwldatasource.cpp @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "qwldatasource_p.h" #include "qwldataoffer_p.h" diff --git a/src/compositor/wayland_wrapper/qwldatasource_p.h b/src/compositor/wayland_wrapper/qwldatasource_p.h index 5f6842f73..2f846e8a5 100644 --- a/src/compositor/wayland_wrapper/qwldatasource_p.h +++ b/src/compositor/wayland_wrapper/qwldatasource_p.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef WLDATASOURCE_H #define WLDATASOURCE_H diff --git a/src/compositor/wayland_wrapper/qwlregion.cpp b/src/compositor/wayland_wrapper/qwlregion.cpp index 69032c849..30511b773 100644 --- a/src/compositor/wayland_wrapper/qwlregion.cpp +++ b/src/compositor/wayland_wrapper/qwlregion.cpp @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "qwlregion_p.h" diff --git a/src/compositor/wayland_wrapper/qwlregion_p.h b/src/compositor/wayland_wrapper/qwlregion_p.h index bf036d182..b9e5d42e7 100644 --- a/src/compositor/wayland_wrapper/qwlregion_p.h +++ b/src/compositor/wayland_wrapper/qwlregion_p.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef WL_REGION_H #define WL_REGION_H @@ -44,6 +18,7 @@ #include <QtWaylandCompositor/qtwaylandcompositorglobal.h> #include <QRegion> +#include <private/qglobal_p.h> #include <wayland-util.h> #include <QtWaylandCompositor/private/qwayland-server-wayland.h> @@ -52,7 +27,7 @@ QT_BEGIN_NAMESPACE namespace QtWayland { -class Q_WAYLAND_COMPOSITOR_EXPORT Region : public QtWaylandServer::wl_region +class Q_WAYLANDCOMPOSITOR_EXPORT Region : public QtWaylandServer::wl_region { public: Region(struct wl_client *client, uint32_t id); |