fix(linux): migrate to qt tray (#4907)

Co-authored-by: Kishi <41839133+Kishi85@users.noreply.github.com>
This commit is contained in:
David Lane
2026-05-24 22:21:24 -04:00
committed by GitHub
parent 0bc26a3f17
commit dbce229174
22 changed files with 206 additions and 119 deletions

View File

@@ -62,7 +62,6 @@ set(SUNSHINE_TARGET_FILES
"${CMAKE_SOURCE_DIR}/third-party/moonlight-common-c/src/Rtsp.h"
"${CMAKE_SOURCE_DIR}/third-party/moonlight-common-c/src/RtspParser.c"
"${CMAKE_SOURCE_DIR}/third-party/moonlight-common-c/src/Video.h"
"${CMAKE_SOURCE_DIR}/third-party/tray/src/tray.h"
"${CMAKE_SOURCE_DIR}/src/upnp.cpp"
"${CMAKE_SOURCE_DIR}/src/upnp.h"
"${CMAKE_SOURCE_DIR}/src/cbs.cpp"
@@ -159,3 +158,11 @@ list(APPEND SUNSHINE_EXTERNAL_LIBRARIES
${Boost_LIBRARIES}
${OPENSSL_LIBRARIES}
${PLATFORM_LIBRARIES})
# tray icon
if(SUNSHINE_ENABLE_TRAY)
list(APPEND SUNSHINE_EXTERNAL_LIBRARIES tray::tray)
else()
set(SUNSHINE_TRAY 0)
message(STATUS "Tray icon disabled")
endif()

View File

@@ -2,6 +2,10 @@
if(FREEBSD)
add_compile_definitions(SUNSHINE_PLATFORM="freebsd")
# FreeBSD installs packages to /usr/local/lib, which is not in the default linker search path.
# link_directories() is directory-scoped and propagates to all subdirectories (including tests/),
# so all targets (sunshine, test_sunshine) can resolve libraries found via pkg_check_modules.
link_directories(/usr/local/lib)
else()
add_compile_definitions(SUNSHINE_PLATFORM="linux")
endif()
@@ -293,37 +297,6 @@ if(NOT ${CUDA_FOUND}
message(FATAL_ERROR "Couldn't find either cuda, (libdrm and libcap), libva, kwin, pipewire, portal, wayland or x11")
endif()
# tray icon
if(${SUNSHINE_ENABLE_TRAY})
pkg_check_modules(APPINDICATOR ayatana-appindicator3-0.1)
if(APPINDICATOR_FOUND)
list(APPEND SUNSHINE_DEFINITIONS TRAY_AYATANA_APPINDICATOR=1)
else()
pkg_check_modules(APPINDICATOR appindicator3-0.1)
if(APPINDICATOR_FOUND)
list(APPEND SUNSHINE_DEFINITIONS TRAY_LEGACY_APPINDICATOR=1)
endif ()
endif()
pkg_check_modules(LIBNOTIFY libnotify)
if(NOT APPINDICATOR_FOUND OR NOT LIBNOTIFY_FOUND)
message(STATUS "APPINDICATOR_FOUND: ${APPINDICATOR_FOUND}")
message(STATUS "LIBNOTIFY_FOUND: ${LIBNOTIFY_FOUND}")
message(FATAL_ERROR "Couldn't find either appindicator or libnotify")
else()
include_directories(SYSTEM ${APPINDICATOR_INCLUDE_DIRS} ${LIBNOTIFY_INCLUDE_DIRS})
link_directories(${APPINDICATOR_LIBRARY_DIRS} ${LIBNOTIFY_LIBRARY_DIRS})
list(APPEND PLATFORM_TARGET_FILES "${CMAKE_SOURCE_DIR}/third-party/tray/src/tray_linux.c")
list(APPEND SUNSHINE_EXTERNAL_LIBRARIES ${APPINDICATOR_LIBRARIES} ${LIBNOTIFY_LIBRARIES})
endif()
set(SUNSHINE_TRAY_PREFIX "${PROJECT_FQDN}")
list(APPEND SUNSHINE_DEFINITIONS SUNSHINE_TRAY_PREFIX="${SUNSHINE_TRAY_PREFIX}")
else()
set(SUNSHINE_TRAY 0)
message(STATUS "Tray icon disabled")
endif()
# These need to be set before adding the inputtino subdirectory in order for them to be picked up
set(LIBEVDEV_CUSTOM_INCLUDE_DIR "${EVDEV_INCLUDE_DIR}")
set(LIBEVDEV_CUSTOM_LIBRARY "${EVDEV_LIBRARY}")

View File

@@ -58,10 +58,3 @@ set(PLATFORM_TARGET_FILES
"${CMAKE_SOURCE_DIR}/third-party/TPCircularBuffer/TPCircularBuffer.c"
"${CMAKE_SOURCE_DIR}/third-party/TPCircularBuffer/TPCircularBuffer.h"
${APPLE_PLIST_FILE})
if(SUNSHINE_ENABLE_TRAY)
list(APPEND SUNSHINE_EXTERNAL_LIBRARIES
${COCOA})
list(APPEND PLATFORM_TARGET_FILES
"${CMAKE_SOURCE_DIR}/third-party/tray/src/tray_darwin.m")
endif()

View File

@@ -105,8 +105,3 @@ list(PREPEND PLATFORM_LIBRARIES
ws2_32
wsock32
)
if(SUNSHINE_ENABLE_TRAY)
list(APPEND PLATFORM_TARGET_FILES
"${CMAKE_SOURCE_DIR}/third-party/tray/src/tray_windows.c")
endif()