Make the screencast code build with Qt6

This needs the latest Plasma Wayland protocols.
wilder-5.25
Volker Krause 4 years ago
parent 4ba66e7ed0
commit 5a3ef9e825
  1. 11
      libtaskmanager/declarative/CMakeLists.txt
  2. 14
      libtaskmanager/declarative/pipewiresourceitem.cpp
  3. 2
      libtaskmanager/declarative/pipewiresourcestream.cpp

@ -22,25 +22,28 @@ if(TARGET PkgConfig::PipeWire)
if (QT_MAJOR_VERSION EQUAL "5") if (QT_MAJOR_VERSION EQUAL "5")
ecm_add_qtwayland_client_protocol(SRCS 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 BASENAME zkde-screencast-unstable-v1
) )
else() else()
qt6_generate_wayland_protocol_client_sources(taskmanagerplugin FILES qt6_generate_wayland_protocol_client_sources(taskmanagerplugin FILES
${PLASMA_WAYLAND_PROTOCOLS_DIR}/screencast.xml) ${PLASMA_WAYLAND_PROTOCOLS_DIR}/zkde-screencast-unstable-v1.xml)
endif() endif()
target_include_directories(taskmanagerplugin PRIVATE ${Libdrm_INCLUDE_DIR}) target_include_directories(taskmanagerplugin PRIVATE ${Libdrm_INCLUDE_DIR})
target_compile_definitions(taskmanagerplugin PRIVATE -DWITH_PIPEWIRE) target_compile_definitions(taskmanagerplugin PRIVATE -DWITH_PIPEWIRE)
target_sources(taskmanagerplugin PUBLIC pipewirecore.cpp pipewiresourceitem.cpp pipewiresourcestream.cpp screencasting.cpp screencastingrequest.cpp ${SRCS}) target_sources(taskmanagerplugin PUBLIC pipewirecore.cpp pipewiresourceitem.cpp pipewiresourcestream.cpp screencasting.cpp screencastingrequest.cpp ${SRCS})
target_link_libraries(taskmanagerplugin PkgConfig::PipeWire target_link_libraries(taskmanagerplugin PkgConfig::PipeWire
Qt::Qml Qt5::Gui_EGL Qt::GuiPrivate Qt::Qml Qt::GuiPrivate
KF5::I18n KF5::I18n
KF5::WaylandClient KF5::WaylandClient
Wayland::Client) Wayland::Client)
if (${Qt5Gui_OPENGL_IMPLEMENTATION} STREQUAL "GLESv2") if (${Qt5Gui_OPENGL_IMPLEMENTATION} STREQUAL "GLESv2")
target_link_libraries(taskmanagerplugin Qt5::Gui_GLESv2) target_link_libraries(taskmanagerplugin Qt5::Gui_GLESv2)
else() elseif(TARGET Qt5::Gui_GL)
target_link_libraries(taskmanagerplugin Qt5::Gui_GL) target_link_libraries(taskmanagerplugin Qt5::Gui_GL)
endif() endif()
if (TARGET Qt5::Gui_EGL)
target_link_libraries(taskmanagerplugin Qt5::Gui_EGL)
endif()
endif() endif()

@ -23,7 +23,9 @@
#include <EGL/eglext.h> #include <EGL/eglext.h>
#include <libdrm/drm_fourcc.h> #include <libdrm/drm_fourcc.h>
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
#include <QtPlatformHeaders/QEGLNativeContext> #include <QtPlatformHeaders/QEGLNativeContext>
#endif
static void pwInit() static void pwInit()
{ {
@ -229,7 +231,12 @@ void PipeWireSourceItem::updateTextureDmaBuf(const QVector<DmaBufPlane> &planes,
qCWarning(PIPEWIRE_LOGGING) << "glEGLImageTargetTexture2DOES is not available" << window(); qCWarning(PIPEWIRE_LOGGING) << "glEGLImageTargetTexture2DOES is not available" << window();
return; 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<QOpenGLContext *>(window()->rendererInterface()->getResource(window(), QSGRendererInterface::OpenGLContextResource));
#endif
if (!window() || !openglContext || !m_stream) {
qCWarning(PIPEWIRE_LOGGING) << "need a window and a context" << window(); qCWarning(PIPEWIRE_LOGGING) << "need a window and a context" << window();
return; return;
} }
@ -268,7 +275,12 @@ void PipeWireSourceItem::updateTextureDmaBuf(const QVector<DmaBufPlane> &planes,
int textureId = m_texture->textureId(); int textureId = m_texture->textureId();
QQuickWindow::CreateTextureOption textureOption = format == DRM_FORMAT_ARGB8888 ? QQuickWindow::TextureHasAlphaChannel : QQuickWindow::TextureIsOpaque; QQuickWindow::CreateTextureOption textureOption = format == DRM_FORMAT_ARGB8888 ? QQuickWindow::TextureHasAlphaChannel : QQuickWindow::TextureIsOpaque;
setEnabled(true); setEnabled(true);
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
return window()->createTextureFromNativeObject(QQuickWindow::NativeObjectTexture, &textureId, 0 /*a vulkan thing?*/, size, textureOption); 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()) { if (window()->isVisible()) {
update(); update();

@ -29,7 +29,9 @@
#include <EGL/egl.h> #include <EGL/egl.h>
#include <EGL/eglext.h> #include <EGL/eglext.h>
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
#include <QtPlatformHeaders/QEGLNativeContext> #include <QtPlatformHeaders/QEGLNativeContext>
#endif
#undef Status #undef Status
#if !PW_CHECK_VERSION(0, 3, 29) #if !PW_CHECK_VERSION(0, 3, 29)

Loading…
Cancel
Save