From 5a3ef9e8253029569deb645af625e2bdd53e95e9 Mon Sep 17 00:00:00 2001 From: Volker Krause Date: Mon, 2 May 2022 21:49:31 +0200 Subject: [PATCH] Make the screencast code build with Qt6 This needs the latest Plasma Wayland protocols. --- libtaskmanager/declarative/CMakeLists.txt | 11 +++++++---- libtaskmanager/declarative/pipewiresourceitem.cpp | 14 +++++++++++++- .../declarative/pipewiresourcestream.cpp | 2 ++ 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/libtaskmanager/declarative/CMakeLists.txt b/libtaskmanager/declarative/CMakeLists.txt index 433237b06..f4058afe0 100644 --- a/libtaskmanager/declarative/CMakeLists.txt +++ b/libtaskmanager/declarative/CMakeLists.txt @@ -22,25 +22,28 @@ if(TARGET PkgConfig::PipeWire) if (QT_MAJOR_VERSION EQUAL "5") ecm_add_qtwayland_client_protocol(SRCS - PROTOCOL ${PLASMA_WAYLAND_PROTOCOLS_DIR}/screencast.xml + PROTOCOL ${PLASMA_WAYLAND_PROTOCOLS_DIR}/zkde-screencast-unstable-v1.xml BASENAME zkde-screencast-unstable-v1 ) else() qt6_generate_wayland_protocol_client_sources(taskmanagerplugin FILES - ${PLASMA_WAYLAND_PROTOCOLS_DIR}/screencast.xml) + ${PLASMA_WAYLAND_PROTOCOLS_DIR}/zkde-screencast-unstable-v1.xml) endif() target_include_directories(taskmanagerplugin PRIVATE ${Libdrm_INCLUDE_DIR}) target_compile_definitions(taskmanagerplugin PRIVATE -DWITH_PIPEWIRE) target_sources(taskmanagerplugin PUBLIC pipewirecore.cpp pipewiresourceitem.cpp pipewiresourcestream.cpp screencasting.cpp screencastingrequest.cpp ${SRCS}) target_link_libraries(taskmanagerplugin PkgConfig::PipeWire - Qt::Qml Qt5::Gui_EGL Qt::GuiPrivate + Qt::Qml Qt::GuiPrivate KF5::I18n KF5::WaylandClient Wayland::Client) if (${Qt5Gui_OPENGL_IMPLEMENTATION} STREQUAL "GLESv2") target_link_libraries(taskmanagerplugin Qt5::Gui_GLESv2) - else() + elseif(TARGET Qt5::Gui_GL) target_link_libraries(taskmanagerplugin Qt5::Gui_GL) endif() + if (TARGET Qt5::Gui_EGL) + target_link_libraries(taskmanagerplugin Qt5::Gui_EGL) + endif() endif() diff --git a/libtaskmanager/declarative/pipewiresourceitem.cpp b/libtaskmanager/declarative/pipewiresourceitem.cpp index 685cad053..b666a9383 100644 --- a/libtaskmanager/declarative/pipewiresourceitem.cpp +++ b/libtaskmanager/declarative/pipewiresourceitem.cpp @@ -23,7 +23,9 @@ #include #include +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) #include +#endif static void pwInit() { @@ -229,7 +231,12 @@ void PipeWireSourceItem::updateTextureDmaBuf(const QVector &planes, qCWarning(PIPEWIRE_LOGGING) << "glEGLImageTargetTexture2DOES is not available" << window(); return; } - if (!window() || !window()->openglContext() || !m_stream) { +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) + const auto openglContext = window()->openglContext(); +#else + const auto openglContext = static_cast(window()->rendererInterface()->getResource(window(), QSGRendererInterface::OpenGLContextResource)); +#endif + if (!window() || !openglContext || !m_stream) { qCWarning(PIPEWIRE_LOGGING) << "need a window and a context" << window(); return; } @@ -268,7 +275,12 @@ void PipeWireSourceItem::updateTextureDmaBuf(const QVector &planes, int textureId = m_texture->textureId(); QQuickWindow::CreateTextureOption textureOption = format == DRM_FORMAT_ARGB8888 ? QQuickWindow::TextureHasAlphaChannel : QQuickWindow::TextureIsOpaque; setEnabled(true); +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) return window()->createTextureFromNativeObject(QQuickWindow::NativeObjectTexture, &textureId, 0 /*a vulkan thing?*/, size, textureOption); +#else + return QNativeInterface::QSGOpenGLTexture::fromNative(textureId, window(), size, textureOption); +#endif + ; }; if (window()->isVisible()) { update(); diff --git a/libtaskmanager/declarative/pipewiresourcestream.cpp b/libtaskmanager/declarative/pipewiresourcestream.cpp index 0f309bee3..f5b799f47 100644 --- a/libtaskmanager/declarative/pipewiresourcestream.cpp +++ b/libtaskmanager/declarative/pipewiresourcestream.cpp @@ -29,7 +29,9 @@ #include #include +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) #include +#endif #undef Status #if !PW_CHECK_VERSION(0, 3, 29)