diff options
Diffstat (limited to 'src/compositor')
213 files changed, 4771 insertions, 6388 deletions
diff --git a/src/compositor/.prev_CMakeLists.txt b/src/compositor/.prev_CMakeLists.txt deleted file mode 100644 index c79764e2c..000000000 --- a/src/compositor/.prev_CMakeLists.txt +++ /dev/null @@ -1,199 +0,0 @@ -# Generated from compositor.pro. - -##################################################################### -## WaylandCompositor Module: -##################################################################### - -qt_internal_add_module(WaylandCompositor - PLUGIN_TYPES wayland-graphics-integration-server wayland-hardware-layer-integration - SOURCES - ../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/qwaylandtextinput.cpp extensions/qwaylandtextinput.h extensions/qwaylandtextinput_p.h - extensions/qwaylandtextinputmanager.cpp extensions/qwaylandtextinputmanager.h extensions/qwaylandtextinputmanager_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/qwlqtkey.cpp extensions/qwlqtkey_p.h - extensions/qwlqttouch.cpp extensions/qwlqttouch_p.h - global/qtwaylandcompositorglobal.h - global/qtwaylandqmlinclude.h - global/qwaylandcompositorextension.cpp global/qwaylandcompositorextension.h global/qwaylandcompositorextension_p.h - global/qwaylandquickextension.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 - PUBLIC_LIBRARIES - Qt::Core - Qt::Gui - Wayland::Server - PRIVATE_MODULE_INTERFACE - Qt::CorePrivate - Qt::GuiPrivate -) - -# 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" -) - -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/scaler.xml - ${CMAKE_CURRENT_SOURCE_DIR}/../3rdparty/protocol/text-input-unstable-v2.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}/../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 - 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_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 - 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 - LIBRARIES - Qt::QmlPrivate - Qt::QuickPrivate - PUBLIC_LIBRARIES - Qt::Qml - Qt::Quick - PRIVATE_MODULE_INTERFACE - Qt::QmlPrivate - Qt::QuickPrivate -) - -#### Keys ignored in scope 4:.:.:compositor.pro:QT_FEATURE_wayland_compositor_quick: -# QMLTYPES_FILENAME = "plugins.qmltypes" -# QMLTYPES_INSTALL_DIR = "$$[QT_INSTALL_QML]/QtWayland/Compositor" -# QML_IMPORT_NAME = "QtWayland.Compositor" -# QML_IMPORT_VERSION = "$$QT_VERSION" - -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_xkbcommon - PUBLIC_LIBRARIES - XKB::XKB -) - -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 -) - diff --git a/src/compositor/CMakeLists.txt b/src/compositor/CMakeLists.txt index bb8879422..fc742c7a1 100644 --- a/src/compositor/CMakeLists.txt +++ b/src/compositor/CMakeLists.txt @@ -1,20 +1,16 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + # Generated from compositor.pro. ##################################################################### ## WaylandCompositor Module: ##################################################################### -# special case begin -set(__qt_wayland_compositor_module_args "") -if(QT_FEATURE_wayland_compositor_quick) - list(APPEND __qt_wayland_compositor_module_args "GENERATE_METATYPES") -endif() -# special case end - qt_internal_add_module(WaylandCompositor - ${__qt_wayland_compositor_module_args} # special case 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 @@ -40,20 +36,22 @@ qt_internal_add_module(WaylandCompositor 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.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.h global/qtwaylandcompositorglobal_p.h global/qtwaylandqmlinclude.h global/qwaylandcompositorextension.cpp global/qwaylandcompositorextension.h global/qwaylandcompositorextension_p.h - global/qwaylandquickextension.h global/qwaylandutils_p.h hardware_integration/qwlclientbufferintegration.cpp hardware_integration/qwlclientbufferintegration_p.h wayland_wrapper/qwlbuffermanager.cpp wayland_wrapper/qwlbuffermanager_p.h @@ -68,6 +66,7 @@ qt_internal_add_module(WaylandCompositor LIBRARIES Qt::CorePrivate Qt::GuiPrivate + Qt::WaylandGlobalPrivate PUBLIC_LIBRARIES Qt::Core Qt::Gui @@ -75,8 +74,25 @@ qt_internal_add_module(WaylandCompositor 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" @@ -85,6 +101,7 @@ set(compositor_resource_files "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" @@ -94,18 +111,20 @@ qt_internal_add_resource(WaylandCompositor "compositor" ${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 @@ -132,6 +151,7 @@ qt_internal_extend_target(WaylandCompositor CONDITION QT_FEATURE_opengl 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 ) @@ -143,19 +163,21 @@ qt_internal_extend_target(WaylandCompositor CONDITION TARGET Qt::Quick qt_internal_extend_target(WaylandCompositor CONDITION QT_FEATURE_wayland_compositor_quick SOURCES - compositor_api/qwaylandcompositorquickextensions_p.h + 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.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 @@ -167,11 +189,6 @@ qt_internal_extend_target(WaylandCompositor CONDITION QT_FEATURE_wayland_composi Qt::QuickPrivate ) -#### Keys ignored in scope 4:.:.:compositor.pro:QT_FEATURE_wayland_compositor_quick: -# QMLTYPES_FILENAME = "plugins.qmltypes" -# QMLTYPES_INSTALL_DIR = "$$[QT_INSTALL_QML]/QtWayland/Compositor" -# QML_IMPORT_NAME = "QtWayland.Compositor" -# QML_IMPORT_VERSION = "$$QT_VERSION" qt_internal_extend_target(WaylandCompositor CONDITION QT_FEATURE_wayland_datadevice SOURCES @@ -181,16 +198,6 @@ qt_internal_extend_target(WaylandCompositor CONDITION QT_FEATURE_wayland_datadev wayland_wrapper/qwldatasource.cpp wayland_wrapper/qwldatasource_p.h ) -# special case begin -# -# Do not explicitly add XKB::XKB. This is already done by Qt::GuiPrivate. -# -#qt_internal_extend_target(WaylandCompositor CONDITION QT_FEATURE_xkbcommon -# PUBLIC_LIBRARIES -# XKB::XKB -#) -# special case end - qt_internal_extend_target(WaylandCompositor CONDITION QT_FEATURE_im SOURCES compositor_api/qwaylandinputmethodcontrol.cpp compositor_api/qwaylandinputmethodcontrol.h compositor_api/qwaylandinputmethodcontrol_p.h @@ -210,19 +217,21 @@ qt_internal_add_docs(WaylandCompositor doc/qtwaylandcompositor.qdocconf ) -# special case begin if (TARGET Qt::Qml) - set_target_properties(WaylandCompositor PROPERTIES - QT_QML_MODULE_INSTALL_QMLTYPES TRUE - QT_QML_MODULE_VERSION ${CMAKE_PROJECT_VERSION} - QT_QML_MODULE_URI QtWayland.Compositor - QT_QMLTYPES_FILENAME plugins.qmltypes - QT_QML_MODULE_INSTALL_DIR "${INSTALL_QMLDIR}/QtWayland/Compositor" + 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 ) - - qt6_qml_type_registration(WaylandCompositor) endif() qt_record_extra_qt_main_tools_package_dependency(WaylandCompositor WaylandScannerTools "${PROJECT_VERSION}") -# special case end - +qt_record_extra_qt_package_dependency(WaylandCompositor WaylandGlobalPrivate "${PROJECT_VERSION}") diff --git a/src/compositor/Qt6WaylandCompositorMacros.cmake b/src/compositor/Qt6WaylandCompositorMacros.cmake index 4e25916d4..05d16af6c 100644 --- a/src/compositor/Qt6WaylandCompositorMacros.cmake +++ b/src/compositor/Qt6WaylandCompositorMacros.cmake @@ -1,5 +1,12 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + function(qt6_generate_wayland_protocol_server_sources target) - qt_parse_all_arguments(arg "qt6_generate_wayland_protocol_server_sources" "" "" "FILES" ${ARGN}) + 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) @@ -10,6 +17,11 @@ function(qt6_generate_wayland_protocol_server_sources target) 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) @@ -21,29 +33,46 @@ function(qt6_generate_wayland_protocol_server_sources target) add_custom_command( OUTPUT "${waylandscanner_header_output}" #TODO: Maybe put the files in ${CMAKE_CURRENT_BINARY_DIR/wayland_generated instead? - COMMAND Wayland::Scanner --strict --include-core-only server-header < "${protocol_file}" > "${waylandscanner_header_output}" + 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 --strict --include-core-only public-code < "${protocol_file}" > "${waylandscanner_code_output}" + COMMAND Wayland::Scanner --include-core-only public-code < "${protocol_file}" > "${waylandscanner_code_output}" + DEPENDS ${protocol_file} Wayland::Scanner ) - # TODO: make this less hacky set(wayland_include_dir "") - #get_target_property(qt_module "${target}" QT_MODULE) - get_target_property(is_for_module "${target}" INTERFACE_MODULE_HAS_HEADERS) - if (is_for_module) - set(wayland_include_dir "QtWaylandCompositor/private") + 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}" "${wayland_include_dir}" > "${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}" "${wayland_include_dir}" > "${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 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 4fbbb2bc4..000000000 --- a/src/compositor/compositor.pro +++ /dev/null @@ -1,47 +0,0 @@ -TARGET = QtWaylandCompositor -MODULE = waylandcompositor - -QT = core gui-private - -qtConfig(opengl): QT += opengl - -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) - -qtConfig(wayland-compositor-quick) { - QMLTYPES_FILENAME = plugins.qmltypes - QMLTYPES_INSTALL_DIR = $$[QT_INSTALL_QML]/QtWayland/Compositor - QML_IMPORT_NAME = QtWayland.Compositor - QML_IMPORT_VERSION = $$QT_VERSION - CONFIG += qmltypes install_qmltypes -} - diff --git a/src/compositor/compositor.qrc b/src/compositor/compositor.qrc deleted file mode 100644 index 1b8c0f5d3..000000000 --- a/src/compositor/compositor.qrc +++ /dev/null @@ -1,10 +0,0 @@ -<RCC> - <qresource prefix="/qt-project.org/wayland/compositor"> - <file>shaders/surface.vert.qsb</file> - <file>shaders/surface_rgba.frag.qsb</file> - <file>shaders/surface_rgbx.frag.qsb</file> - <file>shaders/surface_y_u_v.frag.qsb</file> - <file>shaders/surface_y_uv.frag.qsb</file> - <file>shaders/surface_y_xuxv.frag.qsb</file> - </qresource> -</RCC> diff --git a/src/compositor/compositor_api/compositor_api.pri b/src/compositor/compositor_api/compositor_api.pri index 342e1841a..d8cfcaad3 100644 --- a/src/compositor/compositor_api/compositor_api.pri +++ b/src/compositor/compositor_api/compositor_api.pri @@ -77,6 +77,7 @@ qtConfig(wayland-compositor-quick) { 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 950424adb..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,6 +249,19 @@ 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 3d215aa74..fd6172a4f 100644 --- a/src/compositor/compositor_api/qwaylandclient.h +++ b/src/compositor/compositor_api/qwaylandclient.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 QWAYLANDCLIENT_H #define QWAYLANDCLIENT_H @@ -33,7 +7,7 @@ #include <QtWaylandCompositor/qtwaylandcompositorglobal.h> #include <QtWaylandCompositor/qtwaylandqmlinclude.h> -#include <QObject> +#include <QtCore/QObject> #include <signal.h> @@ -44,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) @@ -61,6 +35,22 @@ class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandClient : public QObject 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 3102177c9..b3433f426 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) 2020 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> @@ -85,9 +60,19 @@ QT_BEGIN_NAMESPACE -Q_LOGGING_CATEGORY(qLcWaylandCompositor, "qt.waylandcompositor") -Q_LOGGING_CATEGORY(qLcWaylandCompositorHardwareIntegration, "qt.waylandcompositor.hardwareintegration") -Q_LOGGING_CATEGORY(qLcWaylandCompositorInputMethods, "qt.waylandcompositor.inputmethods") +// These logging categories are public symbols. To remain binary-compatible we cannot hide them in +// a namespace like we do for all Qt-internal logging categories. +#define Q_PUBLIC_LOGGING_CATEGORY(name, ...) \ + const QLoggingCategory &name() \ + { \ + static const QLoggingCategory category(__VA_ARGS__); \ + return category; \ + } + +Q_PUBLIC_LOGGING_CATEGORY(qLcWaylandCompositor, "qt.waylandcompositor") +Q_PUBLIC_LOGGING_CATEGORY(qLcWaylandCompositorHardwareIntegration, "qt.waylandcompositor.hardwareintegration") +Q_PUBLIC_LOGGING_CATEGORY(qLcWaylandCompositorInputMethods, "qt.waylandcompositor.inputmethods") +Q_PUBLIC_LOGGING_CATEGORY(qLcWaylandCompositorTextInput, "qt.waylandcompositor.textinput") namespace QtWayland { @@ -124,13 +109,15 @@ public: 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); @@ -158,6 +145,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")); @@ -189,6 +179,8 @@ 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, 4); wl_subcompositor::init(display, 1); @@ -226,12 +218,17 @@ void QWaylandCompositorPrivate::init() 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); @@ -307,7 +304,7 @@ void QWaylandCompositorPrivate::addPolishObject(QObject *object) 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"; } @@ -391,14 +388,14 @@ void QWaylandCompositorPrivate::initializeHardwareIntegration() loadClientBufferIntegration(); loadServerBufferIntegration(); - for (auto *integration : qAsConst(client_buffer_integrations)) + 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(); } @@ -428,7 +425,7 @@ void QWaylandCompositorPrivate::loadClientBufferIntegration() QString hwIntegrationName; - for (auto targetKey : qAsConst(targetKeys)) { + for (auto targetKey : std::as_const(targetKeys)) { auto *integration = QtWayland::ClientBufferIntegrationFactory::create(targetKey, QStringList()); if (integration) { integration->setCompositor(q); @@ -475,8 +472,22 @@ void QWaylandCompositorPrivate::loadServerBufferIntegration() #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. @@ -508,7 +519,7 @@ 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 \a client has created a surface with id \a id. The interface \a version is also available. @@ -530,7 +541,7 @@ void QWaylandCompositorPrivate::loadServerBufferIntegration() */ /*! - \qmlsignal void QtWaylandCompositor::WaylandCompositor::surfaceCreated(WaylandSurface surface) + \qmlsignal void QtWayland.Compositor::WaylandCompositor::surfaceCreated(WaylandSurface surface) This signal is emitted when a new WaylandSurface instance \a surface has been created. */ @@ -577,7 +588,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. @@ -596,7 +607,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. @@ -639,7 +650,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 @@ -702,7 +713,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. */ @@ -716,7 +727,7 @@ void QWaylandCompositor::destroyClientForSurface(QWaylandSurface *surface) } /*! - * \qmlmethod QtWaylandCompositor::WaylandCompositor::destroyClient(client) + * \qmlmethod QtWayland.Compositor::WaylandCompositor::destroyClient(client) * * Destroys the given WaylandClient \a client. */ @@ -774,7 +785,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. @@ -875,7 +886,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. */ @@ -921,7 +932,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. @@ -942,27 +953,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. @@ -1048,7 +1049,7 @@ void QWaylandCompositor::grabSurface(QWaylandSurfaceGrabber *grabber, const QWay } /*! - * \qmlproperty list<enum> QtWaylandCompositor::WaylandCompositor::additionalShmFormats + * \qmlproperty list<enum> QtWayland.Compositor::WaylandCompositor::additionalShmFormats * * This property holds the list of additional wl_shm formats advertised as supported by the * compositor. @@ -1093,6 +1094,21 @@ QVector<QWaylandCompositor::ShmFormat> QWaylandCompositor::additionalShmFormats( 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 f7715107b..58b053d4e 100644 --- a/src/compositor/compositor_api/qwaylandcompositor.h +++ b/src/compositor/compositor_api/qwaylandcompositor.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2020 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 @@ -35,10 +9,10 @@ #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; @@ -53,7 +27,6 @@ class QWaylandCompositorPrivate; class QWaylandClient; class QWaylandSurface; class QWaylandSeat; -class QWaylandGlobalInterface; class QWaylandView; class QWaylandPointer; class QWaylandKeyboard; @@ -61,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_DECLARE_LOGGING_CATEGORY(qLcWaylandCompositorInputMethods) +Q_WAYLANDCOMPOSITOR_EXPORT const QLoggingCategory &qLcWaylandCompositor(); +Q_WAYLANDCOMPOSITOR_EXPORT const QLoggingCategory &qLcWaylandCompositorHardwareIntegration(); +const QLoggingCategory &qLcWaylandCompositorInputMethods(); +const QLoggingCategory &qLcWaylandCompositorTextInput(); -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandCompositor : public QWaylandObject +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandCompositor : public QWaylandObject { Q_OBJECT Q_DECLARE_PRIVATE(QWaylandCompositor) @@ -93,6 +67,7 @@ public: ShmFormat_RGB888 = 0x34324752, ShmFormat_XBGR8888 = 0x34324258, ShmFormat_ABGR8888 = 0x34324241, + ShmFormat_BGR888 = 0x34324742, ShmFormat_XRGB2101010 = 0x30335258, ShmFormat_XBGR2101010 = 0x30334258, ShmFormat_ARGB2101010 = 0x30335241, @@ -148,6 +123,9 @@ public: public Q_SLOTS: void processWaylandEvents(); +private Q_SLOTS: + void applicationStateChanged(Qt::ApplicationState state); + Q_SIGNALS: void createdChanged(); void socketNameChanged(const QByteArray &socketName); diff --git a/src/compositor/compositor_api/qwaylandcompositor_p.h b/src/compositor/compositor_api/qwaylandcompositor_p.h index 81f7155e4..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,6 +24,8 @@ #include <QtWaylandCompositor/private/qwayland-server-wayland.h> +#include <QtCore/qpointer.h> + #include <vector> #if QT_CONFIG(xkbcommon) @@ -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(); } @@ -115,6 +91,8 @@ public: void connectToExternalSockets(); + virtual QWaylandSeat *seatFor(QInputEvent *inputEvent); + protected: void compositor_create_surface(wl_compositor::Resource *resource, uint32_t id) override; void compositor_create_region(wl_compositor::Resource *resource, uint32_t id) override; 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 index 4a1763884..7e59a5d6e 100644 --- a/src/compositor/compositor_api/qwaylandcompositorquickextensions_p.h +++ b/src/compositor/compositor_api/qwaylandcompositorquickextensions_p.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2020 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 QWAYLANDCOMPOSITORQUICKEXTENSIONS_P_H #define QWAYLANDCOMPOSITORQUICKEXTENSIONS_P_H @@ -49,12 +23,14 @@ #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_WAYLAND_COMPOSITOR_EXPORT QWaylandQuickCompositorQuickExtensionContainer : public QWaylandQuickCompositor +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandQuickCompositorQuickExtensionContainer : public QWaylandQuickCompositor { Q_OBJECT Q_PROPERTY(QQmlListProperty<QWaylandCompositorExtension> extensions READ extensions) @@ -77,12 +53,12 @@ public: &clearFunction); } - static int countFunction(QQmlListProperty<QWaylandCompositorExtension> *list) + static qsizetype countFunction(QQmlListProperty<QWaylandCompositorExtension> *list) { return static_cast<QWaylandQuickCompositorQuickExtensionContainer *>(list->data)->extension_vector.size(); } - static QWaylandCompositorExtension *atFunction(QQmlListProperty<QWaylandCompositorExtension> *list, int index) + static QWaylandCompositorExtension *atFunction(QQmlListProperty<QWaylandCompositorExtension> *list, qsizetype index) { return static_cast<QWaylandQuickCompositorQuickExtensionContainer *>(list->data)->extension_vector.at(index); } @@ -104,10 +80,14 @@ private: // 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_CLASS(QWaylandQtWindowManager, QtWindowManager) -Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_NAMED_CLASS(QWaylandIdleInhibitManagerV1, IdleInhibitManagerV1) -Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_NAMED_CLASS(QWaylandTextInputManager, TextInputManager) -Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_NAMED_CLASS(QWaylandQtTextInputMethodManager, QtTextInputMethodManager) +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 diff --git a/src/compositor/compositor_api/qwaylanddestroylistener.cpp b/src/compositor/compositor_api/qwaylanddestroylistener.cpp index a243e032c..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" 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 9bb48b4c3..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" diff --git a/src/compositor/compositor_api/qwaylanddrag.h b/src/compositor/compositor_api/qwaylanddrag.h index 8e6861fb7..599b79c98 100644 --- a/src/compositor/compositor_api/qwaylanddrag.h +++ b/src/compositor/compositor_api/qwaylanddrag.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 QWAYLANDDRAG_H #define QWAYLANDDRAG_H @@ -44,7 +18,7 @@ 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) diff --git a/src/compositor/compositor_api/qwaylandinputmethodcontrol.cpp b/src/compositor/compositor_api/qwaylandinputmethodcontrol.cpp index 31d6757b5..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,7 @@ #include "qwaylandsurface.h" #include "qwaylandview.h" #include "qwaylandtextinput.h" +#include "qwaylandtextinputv3.h" #include "qwaylandqttextinputmethod.h" #include <QtGui/QInputMethodEvent> @@ -44,11 +19,14 @@ 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(); @@ -67,6 +45,10 @@ QVariant QWaylandInputMethodControl::inputMethodQuery(Qt::InputMethodQuery query 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); @@ -78,9 +60,10 @@ 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 { @@ -133,20 +116,35 @@ void QWaylandInputMethodControl::setSurface(QWaylandSurface *surface) d->surface = surface; QWaylandTextInput *textInput = d->textInput(); + 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() { 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) { @@ -154,12 +152,18 @@ void QWaylandInputMethodControl::defaultSeatChanged() connect(textInput, &QWaylandTextInput::surfaceDisabled, this, &QWaylandInputMethodControl::surfaceDisabled); } + if (textInputV3) { + connect(textInputV3, &QWaylandTextInputV3::surfaceEnabled, this, &QWaylandInputMethodControl::surfaceEnabled); + connect(textInputV3, &QWaylandTextInputV3::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)) + || (textInputV3 && textInputV3->isSurfaceEnabled(d->surface)) || (textInputMethod && textInputMethod->isSurfaceEnabled(d->surface))); } @@ -172,12 +176,21 @@ 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 e25ac48c5..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,9 +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) @@ -62,6 +37,7 @@ public: explicit QWaylandInputMethodControlPrivate(QWaylandSurface *surface); QWaylandTextInput *textInput() const; + QWaylandTextInputV3 *textInputV3() const; QWaylandQtTextInputMethod *textInputMethod() const; QWaylandCompositor *compositor = nullptr; diff --git a/src/compositor/compositor_api/qwaylandkeyboard.cpp b/src/compositor/compositor_api/qwaylandkeyboard.cpp index 223f19738..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. */ 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 1799ba05a..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 @@ -61,7 +35,7 @@ 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(); @@ -119,6 +96,12 @@ private: 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 d2f67192d..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" diff --git a/src/compositor/compositor_api/qwaylandkeymap.h b/src/compositor/compositor_api/qwaylandkeymap.h index 425277613..a919160b2 100644 --- a/src/compositor/compositor_api/qwaylandkeymap.h +++ b/src/compositor/compositor_api/qwaylandkeymap.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_H #define QWAYLANDKEYMAP_H @@ -33,17 +7,21 @@ #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) 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 index c195f03c0..efc539779 100644 --- a/src/compositor/compositor_api/qwaylandmousetracker.cpp +++ b/src/compositor/compositor_api/qwaylandmousetracker.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 "qwaylandmousetracker_p.h" @@ -165,3 +139,5 @@ void QWaylandMouseTracker::hoverLeaveEvent(QHoverEvent *event) } 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 index 178c00657..efc49c3f5 100644 --- a/src/compositor/compositor_api/qwaylandmousetracker_p.h +++ b/src/compositor/compositor_api/qwaylandmousetracker_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 QWAYLANDMOUSETRACKER_P_H #define QWAYLANDMOUSETRACKER_P_H @@ -49,7 +23,7 @@ QT_BEGIN_NAMESPACE class QWaylandMouseTrackerPrivate; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandMouseTracker : public QQuickItem +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandMouseTracker : public QQuickItem { Q_OBJECT Q_DECLARE_PRIVATE(QWaylandMouseTracker) @@ -70,7 +44,7 @@ public: bool windowSystemCursorEnabled() const; bool hovered() const; -signals: +Q_SIGNALS: void mouseXChanged(); void mouseYChanged(); void windowSystemCursorEnabledChanged(); 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 d8cc18da9..a45fa5756 100644 --- a/src/compositor/compositor_api/qwaylandoutput.h +++ b/src/compositor/compositor_api/qwaylandoutput.h @@ -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 #ifndef QWAYLANDOUTPUT_H #define QWAYLANDOUTPUT_H @@ -35,10 +9,8 @@ #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; @@ -50,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) @@ -68,7 +39,6 @@ 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) diff --git a/src/compositor/compositor_api/qwaylandoutput_p.h b/src/compositor/compositor_api/qwaylandoutput_p.h index ac62b0102..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 @@ -55,6 +29,7 @@ #include <QtCore/QRect> #include <QtCore/private/qobject_p.h> +#include <QtCore/qpointer.h> QT_BEGIN_NAMESPACE @@ -82,9 +57,11 @@ struct QWaylandSurfaceViewMapper 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; @@ -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 3a3ecde47..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,10 +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(); - seat->cursorSurfaceRequest(nullptr, 0, 0); + enteredSurface = nullptr; } void QWaylandPointerPrivate::ensureEntered(QWaylandSurface *surface) @@ -115,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; } @@ -134,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())); } } @@ -418,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 e6592718c..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 @@ -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); \ } \ diff --git a/src/compositor/compositor_api/qwaylandquickcompositor.cpp b/src/compositor/compositor_api/qwaylandquickcompositor.cpp index 49f0860e6..43cc8c3e2 100644 --- a/src/compositor/compositor_api/qwaylandquickcompositor.cpp +++ b/src/compositor/compositor_api/qwaylandquickcompositor.cpp @@ -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 #include <QtQml/QQmlEngine> #include <QQuickWindow> @@ -73,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, @@ -82,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 { @@ -161,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 90eaf85b0..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,12 +16,13 @@ // #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) @@ -67,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 891823c6b..c643598be 100644 --- a/src/compositor/compositor_api/qwaylandquickitem.cpp +++ b/src/compositor/compositor_api/qwaylandquickitem.cpp @@ -1,37 +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 #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> @@ -56,12 +31,17 @@ #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 @@ -72,75 +52,155 @@ 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, false, {}, {} }, - // BufferFormatEgl_RGB + // BufferFormatEgl_RGB (GL_TEXTURE_2D) { ":/qt-project.org/wayland/compositor/shaders/surface.vert.qsb", ":/qt-project.org/wayland/compositor/shaders/surface_rgbx.frag.qsb", - GL_TEXTURE_2D, 1, true, + 1, true, QSGMaterial::Blending, {} }, - // BufferFormatEgl_RGBA + // BufferFormatEgl_RGBA (GL_TEXTURE_2D) { ":/qt-project.org/wayland/compositor/shaders/surface.vert.qsb", ":/qt-project.org/wayland/compositor/shaders/surface_rgba.frag.qsb", - GL_TEXTURE_2D, 1, true, + 1, true, QSGMaterial::Blending, {} }, - // BufferFormatEgl_EXTERNAL_OES + // BufferFormatEgl_EXTERNAL_OES (GL_TEXTURE_EXTERNAL_OES) { ":/qt-project.org/wayland/compositor/shaders/surface.vert.qsb", - ":/qt-project.org/wayland/compositor/shaders/surface_oes_external.frag.qsb", - GL_TEXTURE_EXTERNAL_OES, 1, false, + ":/qt-project.org/wayland/compositor/shaders/surface_oes_external.frag", + 1, false, QSGMaterial::Blending, {} }, - // BufferFormatEgl_Y_U_V + // BufferFormatEgl_Y_U_V (GL_TEXTURE_2D) { ":/qt-project.org/wayland/compositor/shaders/surface.vert.qsb", ":/qt-project.org/wayland/compositor/shaders/surface_y_u_v.frag.qsb", - GL_TEXTURE_2D, 3, false, + 3, false, QSGMaterial::Blending, {} }, - // BufferFormatEgl_Y_UV + // BufferFormatEgl_Y_UV (GL_TEXTURE_2D) { ":/qt-project.org/wayland/compositor/shaders/surface.vert.qsb", ":/qt-project.org/wayland/compositor/shaders/surface_y_uv.frag.qsb", - GL_TEXTURE_2D, 2, false, + 2, false, QSGMaterial::Blending, {} }, - // BufferFormatEgl_Y_XUXV + // BufferFormatEgl_Y_XUXV (GL_TEXTURE_2D) { ":/qt-project.org/wayland/compositor/shaders/surface.vert.qsb", ":/qt-project.org/wayland/compositor/shaders/surface_y_xuxv.frag.qsb", - GL_TEXTURE_2D, 2, false, + 2, false, QSGMaterial::Blending, {} } }; QWaylandBufferMaterialShader::QWaylandBufferMaterialShader(QWaylandBufferRef::BufferFormatEgl format) - : m_format(format) { + Q_UNUSED(format); setShaderFileName(VertexStage, QString::fromLatin1(bufferTypes[format].vertexShaderSourceFile)); - setShaderFileName(FragmentStage, QString::fromLatin1(bufferTypes[format].fragmentShaderSourceFile)); + auto fragmentShaderSourceFile = QString::fromLatin1(bufferTypes[format].fragmentShaderSourceFile); + + if (format == QWaylandBufferRef::BufferFormatEgl_EXTERNAL_OES) + setupExternalOESShader(fragmentShaderSourceFile); + else + setShaderFileName(FragmentStage, fragmentShaderSourceFile); +} + +void QWaylandBufferMaterialShader::setupExternalOESShader(const QString &shaderFilename) +{ +#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 } bool QWaylandBufferMaterialShader::updateUniformData(RenderState &state, QSGMaterial *, QSGMaterial *) @@ -275,6 +335,35 @@ void QWaylandBufferMaterial::ensureTextures(int count) 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; @@ -288,8 +377,7 @@ public: ~QWaylandSurfaceTextureProvider() override { - if (m_sgTex) - m_sgTex->deleteLater(); + delete m_sgTex; } void setBufferRef(QWaylandQuickItem *surfaceItem, const QWaylandBufferRef &buffer) @@ -305,7 +393,7 @@ public: #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; } @@ -337,6 +425,7 @@ private: /*! * \qmltype WaylandQuickItem + * \instantiates QWaylandQuickItem * \inqmlmodule QtWayland.Compositor * \since 5.8 * \brief Provides a Qt Quick item that represents a WaylandView. @@ -361,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(); } /*! @@ -373,6 +461,7 @@ QWaylandQuickItem::QWaylandQuickItem(QWaylandQuickItemPrivate &dd, QQuickItem *p : QQuickItem(dd, parent) { d_func()->init(); + connect(this, &QQuickItem::activeFocusChanged, this, &QWaylandQuickItem::updateFocus); } /*! @@ -382,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. */ @@ -414,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. */ @@ -442,11 +534,13 @@ void QWaylandQuickItem::setSurface(QWaylandSurface *surface) 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. */ @@ -665,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 { @@ -683,7 +777,7 @@ 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).position(); @@ -754,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()"); } } @@ -796,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. @@ -809,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 @@ -835,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. @@ -852,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. @@ -877,6 +990,10 @@ void QWaylandQuickItem::setBufferLocked(bool locked) { Q_D(QWaylandQuickItem); d->view->setBufferLocked(locked); + + // Apply the latest surface size + if (!locked) + updateSize(); } /*! @@ -986,7 +1103,7 @@ void QWaylandQuickItem::takeFocus(QWaylandSeat *device) { forceActiveFocus(); - if (!surface()) + if (!surface() || !surface()->client()) return; QWaylandSeat *target = device; @@ -995,13 +1112,22 @@ void QWaylandQuickItem::takeFocus(QWaylandSeat *device) } target->setKeyboardFocus(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()); @@ -1038,6 +1164,12 @@ 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(); @@ -1046,7 +1178,7 @@ void QWaylandQuickItem::updateSize() } /*! - * \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. @@ -1161,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 @@ -1196,7 +1328,7 @@ void QWaylandQuickItem::setPaintEnabled(bool enabled) } /*! - \qmlproperty bool QtWaylandCompositor::WaylandQuickItem::touchEventsEnabled + \qmlproperty bool QtWayland.Compositor::WaylandQuickItem::touchEventsEnabled This property holds \c true if touch events are forwarded to the client surface, \c false otherwise. @@ -1242,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() @@ -1291,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 @@ -1322,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()) { @@ -1340,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; @@ -1370,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) { @@ -1388,23 +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)) { - QQuickWindow::CreateTextureOptions opt; - QWaylandQuickSurface *waylandSurface = qobject_cast<QWaylandQuickSurface *>(surface()); - if (waylandSurface != nullptr && waylandSurface->useTextureAlpha()) - opt |= QQuickWindow::TextureHasAlphaChannel; - QSGTexture *scenegraphTexture = QNativeInterface::QSGOpenGLTexture::fromNative(texture->textureId(), - window(), - ref.size(), - opt); - scenegraphTexture->setFiltering(smooth() ? QSGTexture::Linear : QSGTexture::Nearest); - material->setTextureForPlane(plane, texture, scenegraphTexture); - } - 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); @@ -1447,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) @@ -1590,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 acef82d37..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,12 +16,14 @@ 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) @@ -164,6 +140,7 @@ private Q_SLOTS: #if QT_CONFIG(im) void updateInputMethod(Qt::InputMethodQueries queries); #endif + void updateFocus(); Q_SIGNALS: void surfaceChanged(); diff --git a/src/compositor/compositor_api/qwaylandquickitem_p.h b/src/compositor/compositor_api/qwaylandquickitem_p.h index 4ee3ca056..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; @@ -64,9 +40,7 @@ public: QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override; void updateSampledImage(RenderState &state, int binding, QSGTexture **texture, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override; - -private: - const QWaylandBufferRef::BufferFormatEgl m_format; + void setupExternalOESShader(const QString &shaderFilename); }; class QWaylandBufferMaterial : public QSGMaterial @@ -76,6 +50,7 @@ public: ~QWaylandBufferMaterial() override; void setTextureForPlane(int plane, QOpenGLTexture *texture, QSGTexture *scenegraphTexture); + void setBufferRef(QWaylandQuickItem *surfaceItem, const QWaylandBufferRef &ref); void bind(); void updateScenegraphTextures(QRhi *rhi); @@ -92,6 +67,7 @@ private: 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,11 +127,15 @@ 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; @@ -162,6 +143,9 @@ public: bool newTexture = false; bool focusOnClick = true; bool belowParent = false; +#if QT_CONFIG(opengl) + bool paintByProvider = false; +#endif QPointF hoverPos; QMatrix4x4 lastMatrix; 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 da466b134..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,12 +9,14 @@ #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 diff --git a/src/compositor/compositor_api/qwaylandquicksurface.cpp b/src/compositor/compositor_api/qwaylandquicksurface.cpp index 694d640ff..920415d68 100644 --- a/src/compositor/compositor_api/qwaylandquicksurface.cpp +++ b/src/compositor/compositor_api/qwaylandquicksurface.cpp @@ -1,37 +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 <QQuickWindow> #include <QDebug> #include "qwaylandquicksurface.h" +#include "qwaylandquicksurface_p.h" #include "qwaylandquickcompositor.h" #include "qwaylandquickitem.h" #include <QtWaylandCompositor/qwaylandbufferref.h> @@ -40,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()) { @@ -67,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,3 +58,5 @@ void QWaylandQuickSurface::setUseTextureAlpha(bool useTextureAlpha) } QT_END_NAMESPACE + +#include "moc_qwaylandquicksurface.cpp" diff --git a/src/compositor/compositor_api/qwaylandquicksurface.h b/src/compositor/compositor_api/qwaylandquicksurface.h index e33815254..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,12 +9,14 @@ 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) @@ -56,6 +32,9 @@ public: bool useTextureAlpha() const; void setUseTextureAlpha(bool useTextureAlpha); +protected: + QWaylandQuickSurface(QWaylandQuickSurfacePrivate &dptr); + Q_SIGNALS: void useTextureAlphaChanged(); }; 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 6532804be..ab8897700 100644 --- a/src/compositor/compositor_api/qwaylandresource.h +++ b/src/compositor/compositor_api/qwaylandresource.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 QWAYLANDRESOURCE_H #define QWAYLANDRESOURCE_H @@ -38,7 +12,7 @@ struct wl_resource; QT_BEGIN_NAMESPACE -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandResource +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandResource { Q_GADGET QML_NAMED_ELEMENT(waylandresource) diff --git a/src/compositor/compositor_api/qwaylandseat.cpp b/src/compositor/compositor_api/qwaylandseat.cpp index b0db245eb..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,7 @@ #include "extensions/qwlqtkey_p.h" #include "extensions/qwaylandtextinput.h" +#include "extensions/qwaylandtextinputv3.h" #include "extensions/qwaylandqttextinputmethod.h" QT_BEGIN_NAMESPACE @@ -137,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. @@ -178,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); } /*! @@ -297,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. @@ -331,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. @@ -365,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. @@ -399,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. @@ -417,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. */ @@ -435,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. @@ -452,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) { @@ -465,16 +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; + } } - QWaylandQtTextInputMethod *textInputMethod = QWaylandQtTextInputMethod::findIn(this); - if (textInputMethod) { - textInputMethod->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 @@ -494,15 +493,17 @@ 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 (if \a pressed is \c true) or release (if \a pressed is \c false) @@ -513,6 +514,9 @@ void QWaylandSeat::sendFullKeyEvent(QKeyEvent *event) * 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 */ void QWaylandSeat::sendKeyEvent(int qtKey, bool pressed) @@ -534,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 @@ -705,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. @@ -725,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 @@ -770,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 e77126e28..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 @@ -53,7 +27,7 @@ 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) @@ -97,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); @@ -134,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 efd186fc5..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(); } @@ -203,18 +177,12 @@ void QWaylandSurfacePrivate::surface_attach(Resource *, struct wl_resource *buff void QWaylandSurfacePrivate::surface_damage(Resource *, int32_t x, int32_t y, int32_t width, int32_t height) { - if (Q_UNLIKELY(pending.damageInBufferCoordinates && !pending.damage.isNull())) - qCWarning(qLcWaylandCompositor) << "Unsupported: Client is using both wl_surface.damage_buffer and wl_surface.damage."; - pending.damage = pending.damage.united(QRect(x, y, width, height)); - pending.damageInBufferCoordinates = false; + 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) { - if (Q_UNLIKELY(!pending.damageInBufferCoordinates && !pending.damage.isNull())) - qCWarning(qLcWaylandCompositor) << "Unsupported: Client is using both wl_surface.damage_buffer and wl_surface.damage."; - pending.damage = pending.damage.united(QRect(x, y, width, height)); - pending.damageInBufferCoordinates = true; + pending.bufferDamage = pending.bufferDamage.united(QRect(x, y, width, height)); } void QWaylandSurfacePrivate::surface_frame(Resource *resource, uint32_t callback) @@ -257,28 +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; - if (!pending.damageInBufferCoordinates || pending.bufferScale == 1) { - // pending.damage is already in surface coordinates - damage = pending.damage.intersected(QRect(QPoint(), destinationSize)); - } 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 } + 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; }; - return res; - }; - damage = {}; - for (const QRect &r : pending.damage) { - damage |= xform(r, bufferScale).intersected(QRect{{}, destinationSize}); + 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) @@ -288,14 +264,14 @@ void QWaylandSurfacePrivate::surface_commit(Resource *) pending.buffer = QWaylandBufferRef(); pending.offset = QPoint(); pending.newlyAttached = false; - pending.damage = QRegion(); - pending.damageInBufferCoordinates = false; + 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 @@ -362,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. @@ -419,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. @@ -454,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. */ @@ -485,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. */ @@ -502,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 @@ -533,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. @@ -558,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. @@ -587,7 +610,7 @@ QSize QWaylandSurface::bufferSize() const } /*! - * \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 @@ -608,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. * @@ -638,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. @@ -677,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; } @@ -729,7 +752,7 @@ bool QWaylandSurface::inputRegionContains(const QPointF &position) const } /*! - * \qmlmethod void QtWaylandCompositor::WaylandSurface::destroy() + * \qmlmethod void QtWayland.Compositor::WaylandSurface::destroy() * * Destroys the WaylandSurface. */ @@ -744,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. */ @@ -759,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. */ @@ -786,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 @@ -810,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 { @@ -911,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. */ @@ -1022,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. */ @@ -1034,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. */ @@ -1046,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. */ @@ -1075,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 7fe9d3fd9..0494a091e 100644 --- a/src/compositor/compositor_api/qwaylandsurface.h +++ b/src/compositor/compositor_api/qwaylandsurface.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 QWAYLANDSURFACE_H #define QWAYLANDSURFACE_H @@ -51,7 +25,6 @@ class QTouchEvent; class QWaylandSurfacePrivate; class QWaylandBufferRef; class QWaylandView; -class QWaylandSurfaceOp; class QWaylandInputMethodControl; class QWaylandSurfaceRole @@ -65,7 +38,7 @@ 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) @@ -79,6 +52,7 @@ class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandSurface : public QWaylandObject 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(1, 14)) + Q_PROPERTY(bool isOpaque READ isOpaque NOTIFY isOpaqueChanged REVISION(6, 4)) Q_MOC_INCLUDE("qwaylanddrag.h") Q_MOC_INCLUDE("qwaylandcompositor.h") @@ -139,6 +113,7 @@ public: bool isCursorSurface() const; bool inhibitsIdle() const; + bool isOpaque() const; #if QT_CONFIG(im) QWaylandInputMethodControl *inputMethodControl() const; @@ -171,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 1150ccf91..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 @@ -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); @@ -141,8 +116,8 @@ public: //member variables struct { QWaylandBufferRef buffer; - QRegion damage; - bool damageInBufferCoordinates = false; + QRegion surfaceDamage; + QRegion bufferDamage; QPoint offset; bool newlyAttached = false; QRegion inputRegion; @@ -173,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 03ccdbbc4..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,11 +185,11 @@ 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. @@ -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 9a8247974..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) 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 index 9c5864e39..10f1d4a20 100644 --- a/src/compositor/configure.cmake +++ b/src/compositor/configure.cmake @@ -1,4 +1,5 @@ - +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause #### Inputs @@ -7,106 +8,20 @@ #### Libraries if((LINUX) OR QT_FIND_ALL_PACKAGES_ALWAYS) - qt_find_package(Wayland PROVIDED_TARGETS Wayland::Server MODULE_NAME waylandcompositor QMAKE_LIB wayland-server) -endif() -if((LINUX) OR QT_FIND_ALL_PACKAGES_ALWAYS) - qt_find_package(Wayland PROVIDED_TARGETS Wayland::Egl MODULE_NAME waylandcompositor QMAKE_LIB wayland-egl) -endif() -if((LINUX) OR QT_FIND_ALL_PACKAGES_ALWAYS) qt_find_package(Waylandkms PROVIDED_TARGETS PkgConfig::Waylandkms MODULE_NAME waylandcompositor QMAKE_LIB wayland-kms) endif() -qt_find_package(XComposite PROVIDED_TARGETS PkgConfig::XComposite MODULE_NAME waylandcompositor QMAKE_LIB xcomposite) # special case begin -# X11 is not a public dependency of QtGui anymore, so we need to find it manually in a shared build. -# In a static build the dependency is still propagated, so check for the target existence to prevent -# the 'Attempt to promote imported target "X11::X11" to global scope' issue. -if(NOT TARGET X11::X11) - qt_find_package(X11 PROVIDED_TARGETS X11::X11 MODULE_NAME gui QMAKE_LIB xlib) -endif() -# Same for XKB. -if(NOT TARGET XKB::XKB) - qt_find_package(XKB 0.5.0 PROVIDED_TARGETS XKB::XKB MODULE_NAME gui QMAKE_LIB xkbcommon MARK_OPTIONAL) + +# 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 -# drm-egl-server -qt_config_compile_test(drm_egl_server - LIBRARIES - EGL::EGL - CODE -" -#include <EGL/egl.h> -#include <EGL/eglext.h> - -int main(int argc, char **argv) -{ - (void)argc; (void)argv; - /* BEGIN TEST: */ -#ifdef EGL_MESA_drm_image -return 0; -#else -#error Requires EGL_MESA_drm_image to be defined -return 1; -#endif - /* END TEST: */ - return 0; -} -") - -# libhybris-egl-server -qt_config_compile_test(libhybris_egl_server - LIBRARIES - EGL::EGL - CODE -" -#include <EGL/egl.h> -#include <EGL/eglext.h> -#include <hybris/eglplatformcommon/hybris_nativebufferext.h> - -int main(int argc, char **argv) -{ - (void)argc; (void)argv; - /* BEGIN TEST: */ -#ifdef EGL_HYBRIS_native_buffer -return 0; -#else -#error Requires EGL_HYBRIS_native_buffer to be defined -return 1; -#endif - /* END TEST: */ - return 0; -} -") - -# dmabuf-server-buffer -qt_config_compile_test(dmabuf_server_buffer - LABEL "Linux dma-buf Buffer Sharing" - LIBRARIES - EGL::EGL - Libdrm::Libdrm - CODE -" -#include <EGL/egl.h> -#include <EGL/eglext.h> -#include <drm_fourcc.h> - -int main(int argc, char **argv) -{ - (void)argc; (void)argv; - /* BEGIN TEST: */ -#ifdef EGL_LINUX_DMA_BUF_EXT -return 0; -#else -#error Requires EGL_LINUX_DMA_BUF_EXT -return 1; -#endif - /* END TEST: */ - return 0; -} -") - # dmabuf-client-buffer qt_config_compile_test(dmabuf_client_buffer LABEL "Linux Client dma-buf Buffer Sharing" @@ -138,77 +53,13 @@ return 0; } ") -# vulkan-server-buffer -qt_config_compile_test(vulkan_server_buffer - LABEL "Vulkan Buffer Sharing" - CODE -"#define VK_USE_PLATFORM_WAYLAND_KHR 1 -#include <vulkan/vulkan.h> - -int main(int argc, char **argv) -{ - (void)argc; (void)argv; - /* BEGIN TEST: */ -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; - /* END TEST: */ - return 0; -} -") - - #### Features -qt_feature("wayland-server" PRIVATE - LABEL "Qt Wayland Compositor" - CONDITION NOT WIN32 AND Wayland_FOUND AND WaylandScanner_FOUND -) -qt_feature("wayland-datadevice" PRIVATE - CONDITION QT_FEATURE_draganddrop OR QT_FEATURE_clipboard -) -qt_feature("wayland-egl" PRIVATE - LABEL "EGL" - CONDITION QT_FEATURE_wayland_server AND QT_FEATURE_opengl AND QT_FEATURE_egl AND Wayland_FOUND -) -qt_feature("wayland-brcm" PRIVATE - LABEL "Raspberry Pi" - CONDITION QT_FEATURE_wayland_server AND QT_FEATURE_eglfs_brcm -) -qt_feature("xcomposite-egl" PRIVATE - LABEL "XComposite EGL" - CONDITION QT_FEATURE_wayland_server AND QT_FEATURE_egl AND QT_FEATURE_opengl AND XComposite_FOUND -) -qt_feature("xcomposite-glx" PRIVATE - LABEL "XComposite EGL" - CONDITION QT_FEATURE_wayland_server AND QT_FEATURE_opengl AND NOT QT_FEATURE_opengles2 AND QT_FEATURE_xlib AND XComposite_FOUND -) -qt_feature("wayland-drm-egl-server-buffer" PRIVATE - LABEL "DRM EGL" - CONDITION QT_FEATURE_wayland_server AND QT_FEATURE_opengl AND QT_FEATURE_egl AND TEST_drm_egl_server -) -qt_feature("wayland-libhybris-egl-server-buffer" PRIVATE - LABEL "libhybris EGL" - CONDITION QT_FEATURE_wayland_server AND QT_FEATURE_opengl AND QT_FEATURE_egl AND TEST_libhybris_egl_server -) -qt_feature("wayland-dmabuf-server-buffer" PRIVATE - LABEL "Linux dma-buf server buffer integration" - CONDITION QT_FEATURE_wayland_server AND QT_FEATURE_opengl AND QT_FEATURE_egl AND TEST_dmabuf_server_buffer -) 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-vulkan-server-buffer" PRIVATE - LABEL "Vulkan-based server buffer integration" - CONDITION QT_FEATURE_wayland_server AND QT_FEATURE_vulkan AND QT_FEATURE_opengl AND QT_FEATURE_egl AND TEST_vulkan_server_buffer -) -qt_feature("wayland-shm-emulation-server-buffer" PRIVATE - LABEL "Shm emulation server buffer" - CONDITION QT_FEATURE_wayland_server AND QT_FEATURE_opengl -) 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 @@ -218,7 +69,6 @@ qt_feature("wayland-compositor-quick" PUBLIC PURPOSE "Allows QtWayland compositor types to be used with QtQuick" CONDITION QT_FEATURE_wayland_server AND TARGET Qt::Quick ) -qt_configure_add_summary_entry(ARGS "wayland-server") 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 0d389d98e..000000000 --- a/src/compositor/configure.json +++ /dev/null @@ -1,271 +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.15.0 or higher required", - "#endif", - "#if WAYLAND_VERSION_MAJOR == 1", - "# if WAYLAND_VERSION_MINOR < 15", - "# error Wayland 1.15.0 or higher required", - "# endif", - "# if WAYLAND_VERSION_MINOR == 15", - "# if WAYLAND_VERSION_MICRO < 0", - "# error Wayland 1.15.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" - ] - } - }, - - "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" - ] - }, - "libs": "-ldrm", - "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;" - ] - }, - "libs": "-ldrm", - "use": "egl" - }, - "vulkan-server-buffer": { - "label": "Vulkan Buffer Sharing", - "type": "compile", - "test": { - "head": [ - "#define VK_USE_PLATFORM_WAYLAND_KHR 1" - ], - "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 && features.xlib && libs.xcomposite", - "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.vulkan && 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", - "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 index e77b201f0..7a9a12016 100644 --- a/src/compositor/doc/src/qt6-changes.qdoc +++ b/src/compositor/doc/src/qt6-changes.qdoc @@ -1,29 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2020 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) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only /*! \page qtwayland-changes-qt6.html @@ -39,5 +15,16 @@ In this topic we summarize those changes in Qt Wayland Compositor, and provide guidance to handle them. - \section1 ADD STUFF HERE + \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 4e401f849..a61278d73 100644 --- a/src/compositor/doc/src/qtwaylandcompositor-cpp.qdoc +++ b/src/compositor/doc/src/qtwaylandcompositor-cpp.qdoc @@ -1,50 +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 + \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 4dc0a3d31..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 @@ -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,6 +141,9 @@ \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. @@ -119,7 +156,7 @@ 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 General Public License, version 3} or 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. diff --git a/src/compositor/doc/src/qtwaylandcompositor-qmltypes.qdoc b/src/compositor/doc/src/qtwaylandcompositor-qmltypes.qdoc index 255f49a4d..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 - \endqml + \section1 Using the Module + + \include {module-use.qdocinc} {using the c++ api} {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} - To link against the module, add this line to your \l qmake \c .pro file: + \section2 QML import - \code - QT += waylandcompositor + \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 f00eae571..a3d329b8f 100644 --- a/src/compositor/extensions/extensions.pri +++ b/src/compositor/extensions/extensions.pri @@ -18,6 +18,7 @@ WAYLANDSERVERSOURCES += \ ../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 \ @@ -82,6 +83,8 @@ qtConfig(wayland-compositor-quick) { extensions/qwaylandwlshellintegration_p.h \ extensions/qwaylandquickxdgoutputv1.h \ extensions/qwaylandxdgshellintegration_p.h \ + extensions/qwaylandpresentationtime_p.h \ + extensions/qwaylandpresentationtime_p_p.h \ SOURCES += \ extensions/qwaylandquickshellintegration.cpp \ @@ -90,6 +93,7 @@ qtConfig(wayland-compositor-quick) { extensions/qwaylandwlshellintegration.cpp \ extensions/qwaylandquickxdgoutputv1.cpp \ extensions/qwaylandxdgshellintegration.cpp \ + extensions/qwaylandpresentationtime.cpp \ qtConfig(opengl) { HEADERS += \ diff --git a/src/compositor/extensions/qwaylandidleinhibitv1.cpp b/src/compositor/extensions/qwaylandidleinhibitv1.cpp index 3d7e4d135..dc90fb637 100644 --- a/src/compositor/extensions/qwaylandidleinhibitv1.cpp +++ b/src/compositor/extensions/qwaylandidleinhibitv1.cpp @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2019 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) 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> @@ -51,6 +25,7 @@ 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. @@ -64,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 { @@ -181,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 390ef9df6..5d3dc3eca 100644 --- a/src/compositor/extensions/qwaylandidleinhibitv1.h +++ b/src/compositor/extensions/qwaylandidleinhibitv1.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2019 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) 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 @@ -36,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 a87fa8719..1899c109e 100644 --- a/src/compositor/extensions/qwaylandidleinhibitv1_p.h +++ b/src/compositor/extensions/qwaylandidleinhibitv1_p.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2019 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) 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 @@ -35,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 // ------------- @@ -48,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 { @@ -56,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 3dd35f1ce..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,6 +13,7 @@ QT_BEGIN_NAMESPACE /*! * \qmltype IviApplication + * \instantiates QWaylandIviApplication * \inqmlmodule QtWayland.Compositor.IviApplication * \since 5.8 * \brief Provides a shell extension for embedded-style user interfaces. @@ -53,7 +28,7 @@ QT_BEGIN_NAMESPACE * an instance of the IviApplication component and add it to the list of extensions * supported by the compositor: * - * \qml \QtMinorVersion + * \qml * import QtWayland.Compositor.IviApplication * * WaylandCompositor { @@ -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 @@ -150,7 +125,7 @@ QByteArray QWaylandIviApplication::interfaceName() */ /*! - * \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 382edb2ca..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,6 +19,7 @@ QWaylandSurfaceRole QWaylandIviSurfacePrivate::s_role("ivi_surface"); /*! * \qmltype IviSurface + * \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 acdff548f..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,11 +19,13 @@ 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") 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 index 5119373a6..edcf28d30 100644 --- a/src/compositor/extensions/qwaylandqttextinputmethod.cpp +++ b/src/compositor/extensions/qwaylandqttextinputmethod.cpp @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2020 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 #include "qwaylandqttextinputmethod.h" #include "qwaylandqttextinputmethod_p.h" @@ -123,7 +97,7 @@ void QWaylandQtTextInputMethodPrivate::text_input_method_v1_start_update(Resourc void QWaylandQtTextInputMethodPrivate::text_input_method_v1_update_hints(Resource *resource, int32_t hints) { if (this->resource == resource) - hints = Qt::InputMethodHints(hints); + this->hints = Qt::InputMethodHints(hints); } void QWaylandQtTextInputMethodPrivate::text_input_method_v1_update_anchor_position(Resource *resource, int32_t anchorPosition) @@ -306,7 +280,7 @@ void QWaylandQtTextInputMethod::sendInputMethodEvent(QInputMethodEvent *event) attribute.type, attribute.start, attribute.length, - attribute.value.type() == QVariant::Color ? attribute.value.value<QColor>().name() : QString()); + 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(); @@ -457,3 +431,5 @@ QByteArray QWaylandQtTextInputMethod::interfaceName() } QT_END_NAMESPACE + +#include "moc_qwaylandqttextinputmethod.cpp" diff --git a/src/compositor/extensions/qwaylandqttextinputmethod.h b/src/compositor/extensions/qwaylandqttextinputmethod.h index 734eb6adc..99f7cb4b2 100644 --- a/src/compositor/extensions/qwaylandqttextinputmethod.h +++ b/src/compositor/extensions/qwaylandqttextinputmethod.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2020 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 QWAYLANDQTTEXTINPUTMETHOD_H #define QWAYLANDQTTEXTINPUTMETHOD_H diff --git a/src/compositor/extensions/qwaylandqttextinputmethod_p.h b/src/compositor/extensions/qwaylandqttextinputmethod_p.h index 9be085996..2ca1e9213 100644 --- a/src/compositor/extensions/qwaylandqttextinputmethod_p.h +++ b/src/compositor/extensions/qwaylandqttextinputmethod_p.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2020 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 QWAYLANDQTTEXTINPUTMETHOD_P_H #define QWAYLANDQTTEXTINPUTMETHOD_P_H @@ -38,6 +12,7 @@ #include <QtWaylandCompositor/qwaylanddestroylistener.h> #include <QtCore/qrect.h> +#include <QtCore/qhash.h> // // W A R N I N G @@ -55,7 +30,7 @@ QT_BEGIN_NAMESPACE class QWaylandCompositor; class QWaylandSurface; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandQtTextInputMethodPrivate : public QWaylandCompositorExtensionPrivate, public QtWaylandServer::qt_text_input_method_v1 +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandQtTextInputMethodPrivate : public QWaylandCompositorExtensionPrivate, public QtWaylandServer::qt_text_input_method_v1 { Q_DECLARE_PUBLIC(QWaylandQtTextInputMethod) public: diff --git a/src/compositor/extensions/qwaylandqttextinputmethodmanager.cpp b/src/compositor/extensions/qwaylandqttextinputmethodmanager.cpp index b37c1a9b8..355e77338 100644 --- a/src/compositor/extensions/qwaylandqttextinputmethodmanager.cpp +++ b/src/compositor/extensions/qwaylandqttextinputmethodmanager.cpp @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2020 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 #include "qwaylandqttextinputmethodmanager.h" #include "qwaylandqttextinputmethodmanager_p.h" @@ -50,10 +24,17 @@ void QWaylandQtTextInputMethodManagerPrivate::text_input_method_manager_v1_get_t 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. @@ -62,7 +43,9 @@ void QWaylandQtTextInputMethodManagerPrivate::text_input_method_manager_v1_get_t 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. - To use it, simply instanitate a \c QtTextInputMethodManager object inside the \l WaylandCompositor. + 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. */ /*! @@ -75,7 +58,9 @@ void QWaylandQtTextInputMethodManagerPrivate::text_input_method_manager_v1_get_t 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. - To use it, simply instanitate a \c QtTextInputMethodManager object as a child of the \l QWaylandCompositor. + 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() @@ -113,3 +98,5 @@ QByteArray QWaylandQtTextInputMethodManager::interfaceName() } QT_END_NAMESPACE + +#include "moc_qwaylandqttextinputmethodmanager.cpp" diff --git a/src/compositor/extensions/qwaylandqttextinputmethodmanager.h b/src/compositor/extensions/qwaylandqttextinputmethodmanager.h index 6e0751a2e..ded6a3aae 100644 --- a/src/compositor/extensions/qwaylandqttextinputmethodmanager.h +++ b/src/compositor/extensions/qwaylandqttextinputmethodmanager.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2020 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 QWAYLANDQTTEXTINPUTMETHODMANAGER_H #define QWAYLANDQTTEXTINPUTMETHODMANAGER_H @@ -38,7 +12,7 @@ QT_BEGIN_NAMESPACE class QWaylandQtTextInputMethodManagerPrivate; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandQtTextInputMethodManager : public QWaylandCompositorExtensionTemplate<QWaylandQtTextInputMethodManager> +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandQtTextInputMethodManager : public QWaylandCompositorExtensionTemplate<QWaylandQtTextInputMethodManager> { Q_OBJECT Q_DECLARE_PRIVATE(QWaylandQtTextInputMethodManager) diff --git a/src/compositor/extensions/qwaylandqttextinputmethodmanager_p.h b/src/compositor/extensions/qwaylandqttextinputmethodmanager_p.h index c730a402b..71be87e85 100644 --- a/src/compositor/extensions/qwaylandqttextinputmethodmanager_p.h +++ b/src/compositor/extensions/qwaylandqttextinputmethodmanager_p.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2020 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 QWAYLANDQTTEXTINPUTMETHODMANAGER_P_H #define QWAYLANDQTTEXTINPUTMETHODMANAGER_P_H @@ -47,7 +21,7 @@ QT_BEGIN_NAMESPACE -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandQtTextInputMethodManagerPrivate : public QWaylandCompositorExtensionPrivate, public QtWaylandServer::qt_text_input_method_manager_v1 +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandQtTextInputMethodManagerPrivate : public QWaylandCompositorExtensionPrivate, public QtWaylandServer::qt_text_input_method_manager_v1 { Q_DECLARE_PUBLIC(QWaylandQtTextInputMethodManager) public: 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 100e4bd59..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" @@ -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..aa7d70133 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->isModal()) 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()->isModal(); +} + +static inline bool onBottom(QWaylandQuickShellSurfaceItem *surf) +{ + return surf->staysOnBottom() && !surf->shellSurface()->isModal(); +} + +/* + 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->isModal(); + const bool putOnBottom = staysOnBottom && !m_shellSurface->isModal(); + + 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->isModal(); + const bool putOnBottom = staysOnBottom && !m_shellSurface->isModal(); + + 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 9307909e1..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,22 @@ #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) @@ -61,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 24f381602..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,13 +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 = 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 b61cc490e..c637280c1 100644 --- a/src/compositor/extensions/qwaylandquickxdgoutputv1.cpp +++ b/src/compositor/extensions/qwaylandquickxdgoutputv1.cpp @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2019 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) 2019 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <QWaylandCompositor> #include <QWaylandOutput> @@ -33,6 +7,8 @@ #include "qwaylandquickxdgoutputv1.h" #include "qwaylandxdgoutputv1_p.h" +QT_BEGIN_NAMESPACE + QWaylandQuickXdgOutputV1::QWaylandQuickXdgOutputV1() : QWaylandXdgOutputV1() { @@ -64,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 d6701cc8b..c607cf649 100644 --- a/src/compositor/extensions/qwaylandquickxdgoutputv1.h +++ b/src/compositor/extensions/qwaylandquickxdgoutputv1.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2019 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) 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 @@ -34,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 dcb8875d4..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. */ @@ -93,3 +67,5 @@ QWaylandShell::QWaylandShell(QWaylandObject *container, QWaylandShellPrivate &dd } QT_END_NAMESPACE + +#include "moc_qwaylandshell.cpp" diff --git a/src/compositor/extensions/qwaylandshell.h b/src/compositor/extensions/qwaylandshell.h index 987f728fb..765d4f0eb 100644 --- a/src/compositor/extensions/qwaylandshell.h +++ b/src/compositor/extensions/qwaylandshell.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_H #define QWAYLANDSHELL_H @@ -37,7 +11,7 @@ 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) @@ -68,7 +42,7 @@ protected: }; 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 74194b35e..0daa07221 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) @@ -71,7 +81,7 @@ #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::isModal() 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 ae2a1b2ac..7f8ad1f37 100644 --- a/src/compositor/extensions/qwaylandshellsurface.h +++ b/src/compositor/extensions/qwaylandshellsurface.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 QWAYLANDSHELLSURFACE_H #define QWAYLANDSHELLSURFACE_H @@ -38,12 +12,14 @@ 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 isModal NOTIFY modalChanged FINAL REVISION(6, 8)) QML_NAMED_ELEMENT(ShellSurface) QML_UNCREATABLE("") QML_ADDED_IN_VERSION(1, 0) @@ -51,22 +27,26 @@ 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 isModal() 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) { } @@ -82,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 6be9c0cde..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,6 +10,7 @@ #include "qwaylandsurface.h" #include "qwaylandview.h" #include "qwaylandinputmethodeventbuilder_p.h" +#include "qwaylandinputmethodcontrol.h" #include <QGuiApplication> #include <QInputMethodEvent> @@ -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 d510f56f3..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,6 +10,7 @@ #include <QtCore/QObject> #include <QtCore/QMap> +#include <QtCore/QHash> #include <QtCore/QRect> #include <QtGui/QInputMethod> #include <QtWaylandCompositor/QWaylandSurface> @@ -75,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: @@ -86,6 +61,7 @@ public: void sendInputPanelState(); void sendTextDirection(); void sendLocale(); + void sendModifiersMap(const QByteArray &modifiersMap); QVariant inputMethodQuery(Qt::InputMethodQuery property, QVariant argument) const; @@ -99,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; @@ -120,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..7109b73e0 --- /dev/null +++ b/src/compositor/extensions/qwaylandtextinputv3.cpp @@ -0,0 +1,521 @@ +// 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 + +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 b98274b1b..c44bcca15 100644 --- a/src/compositor/extensions/qwaylandviewporter.cpp +++ b/src/compositor/extensions/qwaylandviewporter.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 "qwaylandviewporter_p.h" @@ -149,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; + } } } @@ -234,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 fb640a49e..0c87a936d 100644 --- a/src/compositor/extensions/qwaylandviewporter.h +++ b/src/compositor/extensions/qwaylandviewporter.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 QWAYLANDVIEWPORTER_H #define QWAYLANDVIEWPORTER_H @@ -36,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 bf9e197a0..84e0c90fc 100644 --- a/src/compositor/extensions/qwaylandviewporter_p.h +++ b/src/compositor/extensions/qwaylandviewporter_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 QWAYLANDVIEWPORTER_P_H #define QWAYLANDVIEWPORTER_P_H @@ -35,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 // ------------- @@ -50,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 { @@ -58,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/qwaylandwlshell.cpp b/src/compositor/extensions/qwaylandwlshell.cpp index c708ca045..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,6 +218,7 @@ void QWaylandWlShellSurfacePrivate::shell_surface_set_class(Resource *resource, /*! * \qmltype WlShell + * \instantiates QWaylandWlShell * \inqmlmodule QtWayland.Compositor.WlShell * \since 5.8 * \brief Provides an extension for desktop-style user interfaces. @@ -258,7 +233,7 @@ 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 + * \qml * import QtWayland.Compositor.WlShell * * WaylandCompositor { @@ -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,6 +388,7 @@ QByteArray QWaylandWlShell::interfaceName() /*! * \qmltype WlShellSurface + * \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 8f9ed09df..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,11 +50,13 @@ 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) 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 4c4e2b899..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" @@ -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 7b80cf014..c7af0bca5 100644 --- a/src/compositor/extensions/qwaylandxdgdecorationv1.cpp +++ b/src/compositor/extensions/qwaylandxdgdecorationv1.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 "qwaylandxdgdecorationv1_p.h" @@ -39,6 +13,7 @@ QT_BEGIN_NAMESPACE /*! \qmltype XdgDecorationManagerV1 + \instantiates QWaylandXdgDecorationManagerV1 \inqmlmodule QtWayland.Compositor.XdgShell \since 5.12 \brief Provides an extension for negotiation of server-side and client-side window decorations. @@ -52,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 @@ -68,7 +43,7 @@ QT_BEGIN_NAMESPACE } \endqml - \sa QWaylandXdgToplevel::decorationMode + \sa QWaylandXdgToplevel::decorationMode, {Server Side Decoration Compositor} */ /*! @@ -111,7 +86,7 @@ void QWaylandXdgDecorationManagerV1::initialize() } /*! - \qmlproperty string QtWaylandCompositor::XdgDecorationManagerV1::preferredMode + \qmlproperty string XdgDecorationManagerV1::preferredMode This property holds the decoration mode the compositor prefers. @@ -251,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 7b39091f0..263504cf1 100644 --- a/src/compositor/extensions/qwaylandxdgdecorationv1.h +++ b/src/compositor/extensions/qwaylandxdgdecorationv1.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 QWAYLANDXDGDECORATIONV1_H #define QWAYLANDXDGDECORATIONV1_H @@ -37,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 cd9c38c22..8d06f6a57 100644 --- a/src/compositor/extensions/qwaylandxdgdecorationv1_p.h +++ b/src/compositor/extensions/qwaylandxdgdecorationv1_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 QWAYLANDXDGDECORATIONV1_P_H #define QWAYLANDXDGDECORATIONV1_P_H @@ -52,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 { @@ -68,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 e99499475..035d8dd3d 100644 --- a/src/compositor/extensions/qwaylandxdgoutputv1.cpp +++ b/src/compositor/extensions/qwaylandxdgoutputv1.cpp @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2019 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) 2019 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <QWaylandCompositor> @@ -38,6 +12,7 @@ QT_BEGIN_NAMESPACE /*! * \qmltype XdgOutputManagerV1 + * \instantiates QWaylandXdgOutputManagerV1 * \inqmlmodule QtWayland.Compositor.XdgShell * \since 5.14 * \brief Provides an extension for describing outputs in a desktop oriented fashion. @@ -56,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 { @@ -231,7 +206,7 @@ QWaylandXdgOutputV1::~QWaylandXdgOutputV1() } /*! - * \qmlproperty XdgOutputManagerV1 QtWaylandCompositor::XdgOutputV1::manager + * \qmlproperty XdgOutputManagerV1 XdgOutputV1::manager * \readonly * * This property holds the object that manages this XdgOutputV1. @@ -249,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. @@ -267,7 +242,7 @@ QWaylandOutput *QWaylandXdgOutputV1::output() const } /*! - * \qmlproperty string QtWaylandCompositor::XdgOutputV1::name + * \qmlproperty string XdgOutputV1::name * * This property holds the name of this output. * @@ -318,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. * @@ -359,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. * @@ -395,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. * @@ -447,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. @@ -586,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 d6c002128..79a6235c7 100644 --- a/src/compositor/extensions/qwaylandxdgoutputv1.h +++ b/src/compositor/extensions/qwaylandxdgoutputv1.h @@ -1,38 +1,14 @@ -/**************************************************************************** -** -** Copyright (C) 2019 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) 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 @@ -41,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 @@ -55,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) diff --git a/src/compositor/extensions/qwaylandxdgoutputv1_p.h b/src/compositor/extensions/qwaylandxdgoutputv1_p.h index ab08f5d4f..9db3703fc 100644 --- a/src/compositor/extensions/qwaylandxdgoutputv1_p.h +++ b/src/compositor/extensions/qwaylandxdgoutputv1_p.h @@ -1,35 +1,11 @@ -/**************************************************************************** -** -** Copyright (C) 2019 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) 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> @@ -48,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 { @@ -69,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 3d2b9e3c9..8e69caaa4 100644 --- a/src/compositor/extensions/qwaylandxdgshell.cpp +++ b/src/compositor/extensions/qwaylandxdgshell.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 "qwaylandxdgshell.h" #include "qwaylandxdgshell_p.h" @@ -35,6 +9,8 @@ #endif #include <QtWaylandCompositor/private/qwaylandutils_p.h> +#include "qwaylandxdgdialogv1_p.h" + #include <QtWaylandCompositor/QWaylandCompositor> #include <QtWaylandCompositor/QWaylandSeat> #include <QtWaylandCompositor/QWaylandSurface> @@ -71,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; } @@ -134,6 +110,7 @@ void QWaylandXdgShellPrivate::xdg_wm_base_pong(Resource *resource, uint32_t seri /*! * \qmltype XdgShell + * \instantiates QWaylandXdgShell * \inqmlmodule QtWayland.Compositor.XdgShell * \since 5.12 * \brief Provides an extension for desktop-style user interfaces. @@ -148,7 +125,7 @@ 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 + * \qml * import QtWayland.Compositor.XdgShell * * WaylandCompositor { @@ -206,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); } /*! @@ -222,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. @@ -355,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->isModal()); + }); } void QWaylandXdgSurfacePrivate::xdg_surface_get_popup(QtWaylandServer::xdg_surface::Resource *resource, uint32_t id, wl_resource *parentResource, wl_resource *positionerResource) @@ -454,6 +438,7 @@ void QWaylandXdgSurfacePrivate::xdg_surface_set_window_geometry(QtWaylandServer: /*! * \qmltype XdgSurface + * \instantiates QWaylandXdgSurface * \inqmlmodule QtWayland.Compositor.XdgShell * \since 5.12 * \brief XdgSurface provides desktop-style compositor-specific features to an xdg surface. @@ -499,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. @@ -525,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. */ @@ -536,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. @@ -581,7 +566,7 @@ void QWaylandXdgSurface::handleBufferScaleChanged() } /*! - * \qmlproperty XdgShell QtWaylandCompositor::XdgSurface::shell + * \qmlproperty XdgShell XdgSurface::shell * * This property holds the shell associated with this XdgSurface. */ @@ -598,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. */ @@ -615,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. @@ -638,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. @@ -703,6 +688,7 @@ QWaylandQuickShellIntegration *QWaylandXdgSurface::createIntegration(QWaylandQui /*! * \qmltype XdgToplevel + * \instantiates QWaylandXdgToplevel * \inqmlmodule QtWayland.Compositor.XdgShell * \since 5.12 * \brief XdgToplevel represents the toplevel window specific parts of an xdg surface. @@ -748,7 +734,7 @@ QWaylandXdgToplevel::~QWaylandXdgToplevel() } /*! - * \qmlproperty XdgSurface QtWaylandCompositor::XdgToplevel::xdgSurface + * \qmlproperty XdgSurface XdgToplevel::xdgSurface * * This property holds the XdgSurface for this XdgToplevel. */ @@ -765,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. */ @@ -783,7 +769,7 @@ QWaylandXdgToplevel *QWaylandXdgToplevel::parentToplevel() const } /*! - * \qmlproperty string QtWaylandCompositor::XdgToplevel::title + * \qmlproperty string XdgToplevel::title * * This property holds the title of the XdgToplevel. */ @@ -800,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. */ @@ -817,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. * @@ -838,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,7 +856,7 @@ QList<QWaylandXdgToplevel::State> QWaylandXdgToplevel::states() const } /*! - * \qmlproperty bool QtWaylandCompositor::XdgToplevel::maximized + * \qmlproperty bool XdgToplevel::maximized * * This property holds whether the client has acknowledged that it should be maximized. */ @@ -887,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. */ @@ -904,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. */ @@ -921,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. */ @@ -938,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::isModal() 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. @@ -947,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. * @@ -972,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. @@ -1028,7 +1042,7 @@ uint QWaylandXdgToplevel::sendConfigure(const QSize &size, const QList<QWaylandX } /*! - * \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. @@ -1043,7 +1057,7 @@ uint QWaylandXdgToplevel::sendConfigure(const QSize &size, const QList<int> &sta } /*! - * \qmlmethod void QtWaylandCompositor::XdgToplevel::sendClose() + * \qmlmethod void XdgToplevel::sendClose() * * Sends a close event to the client. The client may choose to ignore the event. */ @@ -1058,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. @@ -1086,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 @@ -1116,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. @@ -1148,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. @@ -1194,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 @@ -1214,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 @@ -1234,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 @@ -1254,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. * @@ -1540,6 +1554,7 @@ void QWaylandXdgToplevelPrivate::xdg_toplevel_set_minimized(QtWaylandServer::xdg /*! * \qmltype XdgPopup + * \instantiates QWaylandXdgPopup * \inqmlmodule QtWayland.Compositor.XdgShell * \since 5.12 * \brief XdgPopup represents the popup specific parts of and xdg surface. @@ -1574,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. */ @@ -1591,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. */ @@ -1609,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. @@ -1628,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. @@ -1647,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 @@ -1674,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. @@ -1699,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. * @@ -1729,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. * @@ -1759,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. * @@ -1789,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. @@ -1808,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. */ @@ -1825,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. @@ -1844,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. @@ -1866,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 @@ -2126,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 df72a879d..69dd3b35e 100644 --- a/src/compositor/extensions/qwaylandxdgshell.h +++ b/src/compositor/extensions/qwaylandxdgshell.h @@ -1,31 +1,6 @@ -/**************************************************************************** -** -** 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 QWAYLANDXDGSHELL_H #define QWAYLANDXDGSHELL_H @@ -34,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> @@ -56,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) @@ -83,11 +60,13 @@ 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) @@ -132,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) @@ -147,12 +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) -// QDoc fails to parse the property type that includes the keyword 'enum' -#ifndef Q_CLANG_QDOC + Q_PROPERTY(bool modal READ isModal NOTIFY modalChanged FINAL REVISION(6,8)) Q_PROPERTY(enum DecorationMode decorationMode READ decorationMode NOTIFY decorationModeChanged) -#else - Q_PROPERTY(DecorationMode decorationMode READ decorationMode NOTIFY decorationModeChanged) -#endif + public: enum State : uint { MaximizedState = 1, @@ -197,6 +173,8 @@ public: static QWaylandSurfaceRole *role(); static QWaylandXdgToplevel *fromResource(::wl_resource *resource); + bool isModal() const; + Q_SIGNALS: void parentToplevelChanged(); void titleChanged(); @@ -220,11 +198,15 @@ 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) diff --git a/src/compositor/extensions/qwaylandxdgshell_p.h b/src/compositor/extensions/qwaylandxdgshell_p.h index 8a2b390b0..9ab188a44 100644 --- a/src/compositor/extensions/qwaylandxdgshell_p.h +++ b/src/compositor/extensions/qwaylandxdgshell_p.h @@ -1,36 +1,10 @@ -/**************************************************************************** -** -** 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 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> @@ -53,7 +27,7 @@ QT_BEGIN_NAMESPACE -struct Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgPositionerData { +struct Q_WAYLANDCOMPOSITOR_EXPORT QWaylandXdgPositionerData { QSize size; QRect anchorRect; Qt::Edges anchorEdges = {}; @@ -66,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 { @@ -91,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) @@ -125,7 +99,7 @@ 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: @@ -179,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: @@ -216,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 1a920749c..643ad65ba 100644 --- a/src/compositor/extensions/qwaylandxdgshellintegration.cpp +++ b/src/compositor/extensions/qwaylandxdgshellintegration.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 "qwaylandxdgshellintegration_p.h" @@ -75,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->scenePosition(); + resizeState.initialMousePos = scenePosition; resizeState.initialized = true; return true; } - QPointF delta = m_item->mapToSurface(event->scenePosition() - 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->scenePosition()); + moveState.initialOffset = moveItem->mapFromItem(nullptr, scenePosition); moveState.initialized = true; return true; } if (!moveItem->parentItem()) return true; - QPointF parentPos = moveItem->parentItem()->mapFromItem(nullptr, event->scenePosition()); + 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; @@ -311,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 16bb33541..eba397678 100644 --- a/src/compositor/extensions/qwaylandxdgshellintegration_p.h +++ b/src/compositor/extensions/qwaylandxdgshellintegration_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 QWAYLANDXDGSHELLINTEGRATION_H #define QWAYLANDXDGSHELLINTEGRATION_H @@ -115,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/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 2df661216..1435dde1e 100644 --- a/src/compositor/extensions/qwlqttouch.cpp +++ b/src/compositor/extensions/qwlqttouch.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 "qwlqttouch_p.h" #include "qwaylandview.h" @@ -58,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); @@ -93,8 +67,8 @@ bool TouchExtensionGlobal::postTouchEvent(QTouchEvent *event, QWaylandSurface *s int x = toFixed(tp.position().x()); int y = toFixed(tp.position().y()); - int nx = toFixed(tp.normalizedPos().x()); - int ny = toFixed(tp.normalizedPos().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()); @@ -138,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 0db977bee..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> diff --git a/src/compositor/extensions/qwltexturesharingextension.cpp b/src/compositor/extensions/qwltexturesharingextension.cpp index ef1d82fe2..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" @@ -50,74 +24,6 @@ QT_BEGIN_NAMESPACE -class SharedTexture : public QSGTexture -{ - Q_OBJECT -public: - SharedTexture(QtWayland::ServerBuffer *buffer); - - //TODO: QRhiTexture - - int textureId() const;//######### override; - qint64 comparisonKey() 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; -} - -qint64 SharedTexture::comparisonKey() const -{ - return m_tex ? qint64(m_tex->textureId()) : qint64(this); -} - -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: @@ -142,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: @@ -185,7 +99,7 @@ public: return m_errorString; } -public slots: +public Q_SLOTS: void doResponse(const QString &key, QtWayland::ServerBuffer *buffer) { if (key != m_id) @@ -230,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(); @@ -285,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; @@ -310,13 +224,13 @@ QString QWaylandTextureSharingExtension::getExistingFilePath(const QString &key) if (key.contains(QLatin1String("../"))) return QString(); - for (auto dir : qAsConst(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 : qAsConst(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; @@ -464,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() @@ -486,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 6c7de27a6..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(); @@ -80,7 +54,7 @@ private: 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/qtwaylandcompositorglobal.h b/src/compositor/global/qtwaylandcompositorglobal.h index 4c5e51edf..49b7dc63f 100644 --- a/src/compositor/global/qtwaylandcompositorglobal.h +++ b/src/compositor/global/qtwaylandcompositorglobal.h @@ -1,66 +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 - -#if QT_CONFIG(wayland_compositor_quick) -void Q_WAYLAND_COMPOSITOR_EXPORT qml_register_types_QtWayland_Compositor(); -#endif +#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 index 3e4b758e7..b008a8c7f 100644 --- a/src/compositor/global/qtwaylandqmlinclude.h +++ b/src/compositor/global/qtwaylandqmlinclude.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2020 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 QTWAYLANDQMLINCLUDE_H #define 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 e9bebebb3..cea7c7de0 100644 --- a/src/compositor/global/qwaylandcompositorextension.h +++ b/src/compositor/global/qwaylandcompositorextension.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_H #define QWAYLANDEXTENSION_H @@ -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,7 +35,7 @@ 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) @@ -89,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 f6426c7c0..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 \ @@ -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 \ @@ -98,24 +78,63 @@ QT_BEGIN_NAMESPACE }; #define Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_NAMED_CLASS(className, QmlType) \ - class Q_WAYLAND_COMPOSITOR_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(1, 0) \ - public: \ - QQmlListProperty<QObject> data() \ - { \ - return QQmlListProperty<QObject>(this, &m_objects); \ - } \ - void classBegin() override {} \ - void componentComplete() override { if (!isInitialized()) initialize(); } \ - private: \ - QList<QObject *> m_objects; \ + 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 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/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 0195f3d4b..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(); @@ -67,6 +42,7 @@ public: 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 06834bc50..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" diff --git a/src/compositor/hardware_integration/qwlhwintegration_p.h b/src/compositor/hardware_integration/qwlhwintegration_p.h index f60f41874..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 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 index e7981b1fe..33c2f34d5 100644 --- a/src/compositor/shaders/compile +++ b/src/compositor/shaders/compile @@ -5,6 +5,5 @@ 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 -# Does not compile for whatever reason. We may not support that externalOES -# thing at run time either, so skip for now. -# qsb --glsl "100 es,120,150" -o surface_oes_external.frag.qsb surface_oes_external.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 7b891c77d..bd28d9bf8 100644 --- a/src/compositor/shaders/surface.vert +++ b/src/compositor/shaders/surface.vert @@ -1,3 +1,6 @@ +// 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; diff --git a/src/compositor/shaders/surface_oes_external.frag b/src/compositor/shaders/surface_oes_external.frag index 37ae36680..3064bf7b1 100644 --- a/src/compositor/shaders/surface_oes_external.frag +++ b/src/compositor/shaders/surface_oes_external.frag @@ -1,17 +1,18 @@ -#version 440 -#extension GL_OES_EGL_image_external_essl3 : require +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only -layout(location = 0) in vec2 v_texcoord; -layout(location = 0) out vec4 fragColor; +// This shader stump cannot be precompiled and is compiled at run-time. +// Appropriate target preamble added when it is loaded. -layout(std140, binding = 0) uniform buf { +varying vec2 v_texcoord; +struct buf { mat4 qt_Matrix; float qt_Opacity; }; - -layout(binding = 1) uniform samplerExternalOES tex0; +uniform buf ubuf; +uniform samplerExternalOES tex0; void main() { - fragColor = qt_Opacity * texture(tex0, v_texcoord); + 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 f6a7732a4..8bb48dc15 100644 --- a/src/compositor/shaders/surface_rgba.frag +++ b/src/compositor/shaders/surface_rgba.frag @@ -1,3 +1,6 @@ +// 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 v_texcoord; diff --git a/src/compositor/shaders/surface_rgbx.frag b/src/compositor/shaders/surface_rgbx.frag index 37ad3fd21..600c1beae 100644 --- a/src/compositor/shaders/surface_rgbx.frag +++ b/src/compositor/shaders/surface_rgbx.frag @@ -1,3 +1,6 @@ +// 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 v_texcoord; diff --git a/src/compositor/shaders/surface_y_u_v.frag b/src/compositor/shaders/surface_y_u_v.frag index f8fa1010d..3c14036ef 100644 --- a/src/compositor/shaders/surface_y_u_v.frag +++ b/src/compositor/shaders/surface_y_u_v.frag @@ -1,3 +1,6 @@ +// 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 v_texcoord; diff --git a/src/compositor/shaders/surface_y_uv.frag b/src/compositor/shaders/surface_y_uv.frag index 107c30009..42b614882 100644 --- a/src/compositor/shaders/surface_y_uv.frag +++ b/src/compositor/shaders/surface_y_uv.frag @@ -1,3 +1,6 @@ +// 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 v_texcoord; diff --git a/src/compositor/shaders/surface_y_xuxv.frag b/src/compositor/shaders/surface_y_xuxv.frag index cf554db7c..57609f4fd 100644 --- a/src/compositor/shaders/surface_y_xuxv.frag +++ b/src/compositor/shaders/surface_y_xuxv.frag @@ -1,3 +1,6 @@ +// 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 v_texcoord; diff --git a/src/compositor/wayland_wrapper/qwlbuffermanager.cpp b/src/compositor/wayland_wrapper/qwlbuffermanager.cpp index 6966148f1..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> diff --git a/src/compositor/wayland_wrapper/qwlbuffermanager_p.h b/src/compositor/wayland_wrapper/qwlbuffermanager_p.h index 7bfedbeee..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,7 +26,7 @@ namespace QtWayland { class ClientBuffer; -class Q_WAYLAND_COMPOSITOR_EXPORT BufferManager : public QObject +class Q_WAYLANDCOMPOSITOR_EXPORT BufferManager : public QObject { public: BufferManager(QWaylandCompositor *compositor); 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 d72bdf36d..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; } @@ -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); |