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:
@@ -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
|
||||
|
||||
@@ -173,6 +173,10 @@ install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_FQDN}.desktop"
|
||||
if(NOT ${SUNSHINE_BUILD_APPIMAGE} AND NOT ${SUNSHINE_BUILD_FLATPAK})
|
||||
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_FQDN}.terminal.desktop"
|
||||
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/applications")
|
||||
if(${SUNSHINE_ENABLE_KWIN})
|
||||
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_FQDN}.kwin.desktop"
|
||||
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/applications")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# metadata file
|
||||
|
||||
@@ -64,6 +64,8 @@ elseif(UNIX) # Linux
|
||||
"Enable building wayland specific code." ON)
|
||||
option(SUNSHINE_ENABLE_X11
|
||||
"Enable X11 grab if available." ON)
|
||||
option(SUNSHINE_ENABLE_KWIN
|
||||
"Enable KWin ScreenCast grab if available" ON)
|
||||
option(SUNSHINE_ENABLE_PORTAL
|
||||
"Enable XDG portal grab if available" ON)
|
||||
endif()
|
||||
|
||||
@@ -26,6 +26,11 @@ elseif(UNIX)
|
||||
# configure service
|
||||
configure_file(packaging/linux/app-${PROJECT_FQDN}.service.in app-${PROJECT_FQDN}.service @ONLY)
|
||||
|
||||
# configure kwin desktop permission file
|
||||
if (${SUNSHINE_ENABLE_KWIN})
|
||||
configure_file(packaging/linux/${PROJECT_FQDN}.kwin.desktop.in ${PROJECT_FQDN}.kwin.desktop @ONLY)
|
||||
endif()
|
||||
|
||||
# configure the arch linux pkgbuild
|
||||
if(${SUNSHINE_CONFIGURE_PKGBUILD})
|
||||
configure_file(packaging/linux/Arch/PKGBUILD PKGBUILD @ONLY)
|
||||
|
||||
@@ -31,15 +31,7 @@ endif()
|
||||
|
||||
target_link_libraries(sunshine ${SUNSHINE_EXTERNAL_LIBRARIES} ${EXTRA_LIBS})
|
||||
target_compile_definitions(sunshine PUBLIC ${SUNSHINE_DEFINITIONS})
|
||||
if(APPLE AND NOT SUNSHINE_BUILD_HOMEBREW)
|
||||
# codesign on Mac won't sign an .app that uses a symlink
|
||||
set_target_properties(sunshine PROPERTIES CXX_STANDARD 23)
|
||||
else()
|
||||
# symlink sunshine -> sunshine-PROJECT_VERSION
|
||||
set_target_properties(sunshine PROPERTIES CXX_STANDARD 23
|
||||
VERSION ${PROJECT_VERSION}
|
||||
SOVERSION ${PROJECT_VERSION_MAJOR})
|
||||
endif()
|
||||
set_target_properties(sunshine PROPERTIES CXX_STANDARD 23)
|
||||
|
||||
# CLion complains about unknown flags after running cmake, and cannot add symbols to the index for cuda files
|
||||
if(CUDA_INHERIT_COMPILE_OPTIONS)
|
||||
|
||||
Reference in New Issue
Block a user