feat(capture/linux): add KWin direct screencast capture method (#5009)

Co-authored-by: Ramalama2 <6314556+Ramalama2@users.noreply.github.com>
This commit is contained in:
Kishi
2026-05-05 02:58:35 +02:00
committed by GitHub
parent bdef150c6b
commit a90d3068e9
17 changed files with 813 additions and 18 deletions
+22 -8
View File
@@ -76,8 +76,8 @@ if(CUDA_FOUND)
add_compile_definitions(SUNSHINE_BUILD_CUDA)
endif()
# libdrm is required for both DRM (KMS) and Wayland
if(${SUNSHINE_ENABLE_DRM} OR ${SUNSHINE_ENABLE_WAYLAND})
# libdrm is required for DRM (KMS), KWin ScreenCast and Wayland
if(${SUNSHINE_ENABLE_DRM} OR ${SUNSHINE_ENABLE_KWIN} OR ${SUNSHINE_ENABLE_WAYLAND})
find_package(LIBDRM REQUIRED)
else()
set(LIBDRM_FOUND OFF)
@@ -243,7 +243,7 @@ if(GIO_FOUND)
endif()
# Pipewire
if(${SUNSHINE_ENABLE_PORTAL})
if(${SUNSHINE_ENABLE_KWIN} OR ${SUNSHINE_ENABLE_PORTAL})
pkg_check_modules(PIPEWIRE libpipewire-0.3 REQUIRED)
else()
set(PIPEWIRE_FOUND OFF)
@@ -264,13 +264,27 @@ if(PIPEWIRE_FOUND AND GIO_FOUND AND ${SUNSHINE_ENABLE_PORTAL})
"${CMAKE_SOURCE_DIR}/src/platform/linux/portalgrab.cpp")
endif()
# KWin ScreenCast (direct Wayland protocol, bypasses portal)
set(KWIN_FOUND OFF)
if(PIPEWIRE_FOUND AND WAYLAND_FOUND AND ${SUNSHINE_ENABLE_KWIN})
set(KWIN_FOUND ON)
add_compile_definitions(SUNSHINE_BUILD_KWIN)
GEN_WAYLAND("${CMAKE_SOURCE_DIR}/third-party/plasma-wayland-protocols/src/protocols" "" kde-output-order-v1)
GEN_WAYLAND("${CMAKE_SOURCE_DIR}/third-party/plasma-wayland-protocols/src/protocols" "" zkde-screencast-unstable-v1)
list(APPEND PLATFORM_TARGET_FILES
"${CMAKE_SOURCE_DIR}/src/platform/linux/kwingrab.cpp")
elseif(${SUNSHINE_ENABLE_KWIN} AND NOT WAYLAND_FOUND)
message(FATAL_ERROR "SUNSHINE_ENABLE_KWIN requires SUNSHINE_ENABLE_WAYLAND — KWin capture disabled")
endif()
if(NOT ${CUDA_FOUND}
AND NOT ${WAYLAND_FOUND}
AND NOT ${X11_FOUND}
AND NOT ${PORTAL_FOUND}
AND NOT (${LIBDRM_FOUND} AND ${LIBCAP_FOUND})
AND NOT ${LIBVA_FOUND})
message(FATAL_ERROR "Couldn't find either cuda, libva, pipewire, wayland, x11, or (libdrm and libcap)")
AND NOT ${LIBVA_FOUND}
AND NOT ${KWIN_FOUND}
AND NOT ${PORTAL_FOUND}
AND NOT ${WAYLAND_FOUND}
AND NOT ${X11_FOUND})
message(FATAL_ERROR "Couldn't find either cuda, (libdrm and libcap), libva, kwin, pipewire, portal, wayland or x11")
endif()
# tray icon