Skip to content

Commit b1dbab7

Browse files
committed
feat(capture/linux): Add KWIN direct screencast capture method
Co-authored-by: Ramalama2 <>
1 parent 8888dae commit b1dbab7

6 files changed

Lines changed: 467 additions & 3 deletions

File tree

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,6 @@
6969
path = third-party/wlr-protocols
7070
url = https://github.com/LizardByte-infrastructure/wlr-protocols.git
7171
branch = master
72+
[submodule "third-party/plasma-wayland-protocols"]
73+
path = third-party/plasma-wayland-protocols
74+
url = https://github.com/KDE/plasma-wayland-protocols.git

cmake/compile_definitions/linux.cmake

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ if(CUDA_FOUND)
7676
add_compile_definitions(SUNSHINE_BUILD_CUDA)
7777
endif()
7878

79-
# libdrm is required for both DRM (KMS) and Wayland
80-
if(${SUNSHINE_ENABLE_DRM} OR ${SUNSHINE_ENABLE_WAYLAND})
79+
# libdrm is required for DRM (KMS), Wayland, and KWin ScreenCast
80+
if(${SUNSHINE_ENABLE_DRM} OR ${SUNSHINE_ENABLE_WAYLAND} OR ${SUNSHINE_ENABLE_KWIN})
8181
find_package(LIBDRM REQUIRED)
8282
else()
8383
set(LIBDRM_FOUND OFF)
@@ -245,7 +245,7 @@ if(GIO_FOUND)
245245
endif()
246246

247247
# Pipewire
248-
if(${SUNSHINE_ENABLE_PORTAL})
248+
if(${SUNSHINE_ENABLE_PORTAL} OR ${SUNSHINE_ENABLE_KWIN})
249249
pkg_check_modules(PIPEWIRE libpipewire-0.3 REQUIRED)
250250
else()
251251
set(PIPEWIRE_FOUND OFF)
@@ -266,10 +266,23 @@ if(PIPEWIRE_FOUND AND GIO_FOUND AND ${SUNSHINE_ENABLE_PORTAL})
266266
"${CMAKE_SOURCE_DIR}/src/platform/linux/portalgrab.cpp")
267267
endif()
268268

269+
# KWin ScreenCast (direct Wayland protocol, bypasses portal)
270+
set(KWIN_FOUND OFF)
271+
if(WAYLAND_FOUND AND PIPEWIRE_FOUND AND ${SUNSHINE_ENABLE_KWIN})
272+
set(KWIN_FOUND ON)
273+
add_compile_definitions(SUNSHINE_BUILD_KWIN)
274+
GEN_WAYLAND("${CMAKE_SOURCE_DIR}/third-party/plasma-wayland-protocols/src/protocols" "" zkde-screencast-unstable-v1)
275+
list(APPEND PLATFORM_TARGET_FILES
276+
"${CMAKE_SOURCE_DIR}/src/platform/linux/kwingrab.cpp")
277+
elseif(${SUNSHINE_ENABLE_KWIN} AND NOT WAYLAND_FOUND)
278+
message(WARNING "SUNSHINE_ENABLE_KWIN requires SUNSHINE_ENABLE_WAYLAND — KWin capture disabled")
279+
endif()
280+
269281
if(NOT ${CUDA_FOUND}
270282
AND NOT ${WAYLAND_FOUND}
271283
AND NOT ${X11_FOUND}
272284
AND NOT ${PORTAL_FOUND}
285+
AND NOT ${KWIN_FOUND}
273286
AND NOT (${LIBDRM_FOUND} AND ${LIBCAP_FOUND})
274287
AND NOT ${LIBVA_FOUND})
275288
message(FATAL_ERROR "Couldn't find either cuda, libva, pipewire, wayland, x11, or (libdrm and libcap)")

cmake/prep/options.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,6 @@ elseif(UNIX) # Linux
6666
"Enable X11 grab if available." ON)
6767
option(SUNSHINE_ENABLE_PORTAL
6868
"Enable XDG portal grab if available" ON)
69+
option(SUNSHINE_ENABLE_KWIN
70+
"Enable KWin ScreenCast grab if available" ON)
6971
endif()

0 commit comments

Comments
 (0)