Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 25 additions & 2 deletions cmake/compile_definitions/linux.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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), Wayland, and KWin ScreenCast
if(${SUNSHINE_ENABLE_DRM} OR ${SUNSHINE_ENABLE_WAYLAND} OR ${SUNSHINE_ENABLE_KWIN})
find_package(LIBDRM REQUIRED)
else()
set(LIBDRM_FOUND OFF)
Expand Down Expand Up @@ -184,10 +184,33 @@ if(PIPEWIRE_FOUND)
"${CMAKE_SOURCE_DIR}/src/platform/linux/portalgrab.cpp")
endif()

# KWin ScreenCast (direct Wayland protocol, bypasses portal)
# Requires WAYLAND for wl::display_t and PipeWire for frame transport
if(${SUNSHINE_ENABLE_KWIN})
if(NOT PIPEWIRE_FOUND)
pkg_check_modules(PIPEWIRE libpipewire-0.3 REQUIRED)
endif()
endif()
Comment on lines +189 to +193
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be better to a section above XDG portal that checks if portal or kwin are set, and does the pkg_check_modules for the shared dependencies once.

set(KWIN_FOUND OFF)
if(WAYLAND_FOUND AND PIPEWIRE_FOUND AND ${SUNSHINE_ENABLE_KWIN})
set(KWIN_FOUND ON)
add_compile_definitions(SUNSHINE_BUILD_KWIN)

GEN_WAYLAND("${CMAKE_SOURCE_DIR}/third-party/kde-protocols" "" zkde-screencast-unstable-v1)

include_directories(SYSTEM ${PIPEWIRE_INCLUDE_DIRS})
list(APPEND PLATFORM_LIBRARIES ${PIPEWIRE_LIBRARIES})
list(APPEND PLATFORM_TARGET_FILES
"${CMAKE_SOURCE_DIR}/src/platform/linux/kwingrab.cpp")
elseif(${SUNSHINE_ENABLE_KWIN} AND NOT WAYLAND_FOUND)
message(WARNING "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 ${PIPEWIRE_FOUND}
AND NOT ${KWIN_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)")
Expand Down
2 changes: 2 additions & 0 deletions cmake/prep/options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,6 @@ elseif(UNIX) # Linux
"Enable X11 grab if available." ON)
option(SUNSHINE_ENABLE_PORTAL
"Enable XDG portal grab if available" ON)
option(SUNSHINE_ENABLE_KWIN
"Enable KWin ScreenCast grab if available" ON)
endif()
Loading