Skip to content

Commit dbce229

Browse files
fix(linux): migrate to qt tray (#4907)
Co-authored-by: Kishi <41839133+Kishi85@users.noreply.github.com>
1 parent 0bc26a3 commit dbce229

22 files changed

Lines changed: 206 additions & 119 deletions

File tree

.github/workflows/ci-flatpak.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@ jobs:
1717
name: ${{ matrix.arch }}
1818
env:
1919
APP_ID: dev.lizardbyte.app.Sunshine
20+
FREEDESKTOP_SDK_VERSION: "25.08"
21+
KDE_PLATFORM_VERSION: "6.10"
2022
MATRIX_ARCH: ${{ matrix.arch }}
2123
NODE_VERSION: "20"
22-
PLATFORM_VERSION: "24.08"
2324
permissions:
2425
contents: read
2526
runs-on: ${{ matrix.runner }}
@@ -65,9 +66,9 @@ jobs:
6566
6667
sudo su "$(whoami)" -c "flatpak --user install -y flathub \
6768
org.flatpak.Builder \
68-
org.freedesktop.Platform/${MATRIX_ARCH}/${PLATFORM_VERSION} \
69-
org.freedesktop.Sdk/${MATRIX_ARCH}/${PLATFORM_VERSION} \
70-
org.freedesktop.Sdk.Extension.node${NODE_VERSION}/${MATRIX_ARCH}/${PLATFORM_VERSION} \
69+
org.kde.Platform/${MATRIX_ARCH}/${KDE_PLATFORM_VERSION} \
70+
org.kde.Sdk/${MATRIX_ARCH}/${KDE_PLATFORM_VERSION} \
71+
org.freedesktop.Sdk.Extension.node${NODE_VERSION}/${MATRIX_ARCH}/${FREEDESKTOP_SDK_VERSION} \
7172
"
7273
7374
flatpak run org.flatpak.Builder --version
@@ -84,7 +85,7 @@ jobs:
8485
run: |
8586
python \
8687
./packaging/linux/flatpak/deps/flatpak-builder-tools/pip/flatpak-pip-generator.py \
87-
--runtime="org.freedesktop.Sdk//${PLATFORM_VERSION}" \
88+
--runtime="org.kde.Sdk//${KDE_PLATFORM_VERSION}" \
8889
--output glad-dependencies \
8990
--build-only \
9091
--requirements-file=./third-party/glad/requirements.txt

.github/workflows/ci-freebsd.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,14 +105,15 @@ jobs:
105105
devel/cmake-core \
106106
devel/evdev-proto \
107107
devel/git \
108-
devel/libayatana-appindicator \
109108
devel/libevdev \
110109
devel/libnotify \
111110
devel/llvm${{ env.FREEBSD_CLANG_VERSION }} \
112111
devel/ninja \
113112
devel/pkgconf \
113+
devel/qt6-base \
114114
ftp/curl \
115115
graphics/libdrm \
116+
graphics/qt6-svg \
116117
graphics/shaderc \
117118
graphics/vulkan-headers \
118119
graphics/vulkan-loader \

.gitmodules

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22
path = packaging/linux/flatpak/deps/flatpak-builder-tools
33
url = https://github.com/flatpak/flatpak-builder-tools.git
44
branch = master
5-
[submodule "packaging/linux/flatpak/deps/shared-modules"]
6-
path = packaging/linux/flatpak/deps/shared-modules
7-
url = https://github.com/flathub/shared-modules.git
8-
branch = master
95
[submodule "third-party/build-deps"]
106
path = third-party/build-deps
117
url = https://github.com/LizardByte/build-deps.git

cmake/compile_definitions/common.cmake

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ set(SUNSHINE_TARGET_FILES
6262
"${CMAKE_SOURCE_DIR}/third-party/moonlight-common-c/src/Rtsp.h"
6363
"${CMAKE_SOURCE_DIR}/third-party/moonlight-common-c/src/RtspParser.c"
6464
"${CMAKE_SOURCE_DIR}/third-party/moonlight-common-c/src/Video.h"
65-
"${CMAKE_SOURCE_DIR}/third-party/tray/src/tray.h"
6665
"${CMAKE_SOURCE_DIR}/src/upnp.cpp"
6766
"${CMAKE_SOURCE_DIR}/src/upnp.h"
6867
"${CMAKE_SOURCE_DIR}/src/cbs.cpp"
@@ -159,3 +158,11 @@ list(APPEND SUNSHINE_EXTERNAL_LIBRARIES
159158
${Boost_LIBRARIES}
160159
${OPENSSL_LIBRARIES}
161160
${PLATFORM_LIBRARIES})
161+
162+
# tray icon
163+
if(SUNSHINE_ENABLE_TRAY)
164+
list(APPEND SUNSHINE_EXTERNAL_LIBRARIES tray::tray)
165+
else()
166+
set(SUNSHINE_TRAY 0)
167+
message(STATUS "Tray icon disabled")
168+
endif()

cmake/compile_definitions/linux.cmake

Lines changed: 4 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
if(FREEBSD)
44
add_compile_definitions(SUNSHINE_PLATFORM="freebsd")
5+
# FreeBSD installs packages to /usr/local/lib, which is not in the default linker search path.
6+
# link_directories() is directory-scoped and propagates to all subdirectories (including tests/),
7+
# so all targets (sunshine, test_sunshine) can resolve libraries found via pkg_check_modules.
8+
link_directories(/usr/local/lib)
59
else()
610
add_compile_definitions(SUNSHINE_PLATFORM="linux")
711
endif()
@@ -293,37 +297,6 @@ if(NOT ${CUDA_FOUND}
293297
message(FATAL_ERROR "Couldn't find either cuda, (libdrm and libcap), libva, kwin, pipewire, portal, wayland or x11")
294298
endif()
295299

296-
# tray icon
297-
if(${SUNSHINE_ENABLE_TRAY})
298-
pkg_check_modules(APPINDICATOR ayatana-appindicator3-0.1)
299-
if(APPINDICATOR_FOUND)
300-
list(APPEND SUNSHINE_DEFINITIONS TRAY_AYATANA_APPINDICATOR=1)
301-
else()
302-
pkg_check_modules(APPINDICATOR appindicator3-0.1)
303-
if(APPINDICATOR_FOUND)
304-
list(APPEND SUNSHINE_DEFINITIONS TRAY_LEGACY_APPINDICATOR=1)
305-
endif ()
306-
endif()
307-
pkg_check_modules(LIBNOTIFY libnotify)
308-
if(NOT APPINDICATOR_FOUND OR NOT LIBNOTIFY_FOUND)
309-
message(STATUS "APPINDICATOR_FOUND: ${APPINDICATOR_FOUND}")
310-
message(STATUS "LIBNOTIFY_FOUND: ${LIBNOTIFY_FOUND}")
311-
message(FATAL_ERROR "Couldn't find either appindicator or libnotify")
312-
else()
313-
include_directories(SYSTEM ${APPINDICATOR_INCLUDE_DIRS} ${LIBNOTIFY_INCLUDE_DIRS})
314-
link_directories(${APPINDICATOR_LIBRARY_DIRS} ${LIBNOTIFY_LIBRARY_DIRS})
315-
316-
list(APPEND PLATFORM_TARGET_FILES "${CMAKE_SOURCE_DIR}/third-party/tray/src/tray_linux.c")
317-
list(APPEND SUNSHINE_EXTERNAL_LIBRARIES ${APPINDICATOR_LIBRARIES} ${LIBNOTIFY_LIBRARIES})
318-
endif()
319-
320-
set(SUNSHINE_TRAY_PREFIX "${PROJECT_FQDN}")
321-
list(APPEND SUNSHINE_DEFINITIONS SUNSHINE_TRAY_PREFIX="${SUNSHINE_TRAY_PREFIX}")
322-
else()
323-
set(SUNSHINE_TRAY 0)
324-
message(STATUS "Tray icon disabled")
325-
endif()
326-
327300
# These need to be set before adding the inputtino subdirectory in order for them to be picked up
328301
set(LIBEVDEV_CUSTOM_INCLUDE_DIR "${EVDEV_INCLUDE_DIR}")
329302
set(LIBEVDEV_CUSTOM_LIBRARY "${EVDEV_LIBRARY}")

cmake/compile_definitions/macos.cmake

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,3 @@ set(PLATFORM_TARGET_FILES
5858
"${CMAKE_SOURCE_DIR}/third-party/TPCircularBuffer/TPCircularBuffer.c"
5959
"${CMAKE_SOURCE_DIR}/third-party/TPCircularBuffer/TPCircularBuffer.h"
6060
${APPLE_PLIST_FILE})
61-
62-
if(SUNSHINE_ENABLE_TRAY)
63-
list(APPEND SUNSHINE_EXTERNAL_LIBRARIES
64-
${COCOA})
65-
list(APPEND PLATFORM_TARGET_FILES
66-
"${CMAKE_SOURCE_DIR}/third-party/tray/src/tray_darwin.m")
67-
endif()

cmake/compile_definitions/windows.cmake

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,3 @@ list(PREPEND PLATFORM_LIBRARIES
105105
ws2_32
106106
wsock32
107107
)
108-
109-
if(SUNSHINE_ENABLE_TRAY)
110-
list(APPEND PLATFORM_TARGET_FILES
111-
"${CMAKE_SOURCE_DIR}/third-party/tray/src/tray_windows.c")
112-
endif()

cmake/dependencies/common.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ add_subdirectory("${CMAKE_SOURCE_DIR}/third-party/Simple-Web-Server")
1919
# libdisplaydevice
2020
add_subdirectory("${CMAKE_SOURCE_DIR}/third-party/libdisplaydevice")
2121

22+
if(SUNSHINE_ENABLE_TRAY)
23+
add_subdirectory("${CMAKE_SOURCE_DIR}/third-party/tray")
24+
endif()
25+
2226
# common dependencies
2327
include("${CMAKE_MODULE_PATH}/dependencies/nlohmann_json.cmake")
2428
find_package(PkgConfig REQUIRED)

cmake/packaging/linux.cmake

Lines changed: 42 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -138,33 +138,57 @@ set(CPACK_RPM_PACKAGE_AUTOREQ ON)
138138
install(FILES "${CMAKE_SOURCE_DIR}/sunshine.svg"
139139
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/scalable/apps"
140140
RENAME "${PROJECT_FQDN}.svg")
141+
install(FILES "${CMAKE_SOURCE_DIR}/sunshine.svg"
142+
DESTINATION "${SUNSHINE_ASSETS_DIR}/web/images"
143+
RENAME "logo-sunshine.svg")
141144

142145
# tray icon
143146
if(${SUNSHINE_TRAY} STREQUAL 1)
144-
install(FILES "${CMAKE_SOURCE_DIR}/sunshine.svg"
145-
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/scalable/status"
146-
RENAME "${PROJECT_FQDN}-tray.svg")
147-
install(FILES "${SUNSHINE_SOURCE_ASSETS_DIR}/common/assets/web/public/images/sunshine-playing.svg"
148-
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/scalable/status"
149-
RENAME "${PROJECT_FQDN}-playing.svg")
150-
install(FILES "${SUNSHINE_SOURCE_ASSETS_DIR}/common/assets/web/public/images/sunshine-pausing.svg"
151-
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/scalable/status"
152-
RENAME "${PROJECT_FQDN}-pausing.svg")
153-
install(FILES "${SUNSHINE_SOURCE_ASSETS_DIR}/common/assets/web/public/images/sunshine-locked.svg"
154-
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/scalable/status"
155-
RENAME "${PROJECT_FQDN}-locked.svg")
147+
# Icons used by the Qt tray backend are no longer installed to the hicolor icon theme,
148+
# because Qt6 will not allow icons not part of the theme... so we will use icons from our web directory instead
156149

157150
set(CPACK_DEBIAN_PACKAGE_DEPENDS "\
158-
${CPACK_DEBIAN_PACKAGE_DEPENDS}, \
159-
libayatana-appindicator3-1, \
160-
libnotify4")
151+
${CPACK_DEBIAN_PACKAGE_DEPENDS}, \
152+
libnotify4"
153+
)
161154
set(CPACK_RPM_PACKAGE_REQUIRES "\
162-
${CPACK_RPM_PACKAGE_REQUIRES}, \
163-
libappindicator-gtk3 >= 12.10.0")
155+
${CPACK_RPM_PACKAGE_REQUIRES}, \
156+
libnotify >= 0.8.0"
157+
)
164158
list(APPEND CPACK_FREEBSD_PACKAGE_DEPS
165-
devel/libayatana-appindicator
166159
devel/libnotify
167160
)
161+
if(TRAY_QT_VERSION EQUAL 6)
162+
set(CPACK_DEBIAN_PACKAGE_DEPENDS "\
163+
${CPACK_DEBIAN_PACKAGE_DEPENDS}, \
164+
libqt6widgets6, \
165+
libqt6svg6"
166+
)
167+
set(CPACK_RPM_PACKAGE_REQUIRES "\
168+
${CPACK_RPM_PACKAGE_REQUIRES}, \
169+
qt6-qtbase, \
170+
qt6-qtsvg"
171+
)
172+
list(APPEND CPACK_FREEBSD_PACKAGE_DEPS
173+
x11-toolkits/qt6-widgets
174+
graphics/qt6-svg
175+
)
176+
else()
177+
set(CPACK_DEBIAN_PACKAGE_DEPENDS "\
178+
${CPACK_DEBIAN_PACKAGE_DEPENDS}, \
179+
libqt5widgets5, \
180+
libqt5svg5"
181+
)
182+
set(CPACK_RPM_PACKAGE_REQUIRES "\
183+
${CPACK_RPM_PACKAGE_REQUIRES}, \
184+
qt5-qtbase, \
185+
qt5-qtsvg"
186+
)
187+
list(APPEND CPACK_FREEBSD_PACKAGE_DEPS
188+
x11-toolkits/qt5-widgets
189+
graphics/qt5-svg
190+
)
191+
endif()
168192
endif()
169193

170194
# desktop file

cmake/targets/linux.cmake

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# linux specific target definitions
22

3-
# Using newer c++ compilers / features on older distros causes runtime dyn link errors
4-
list(APPEND SUNSHINE_EXTERNAL_LIBRARIES
5-
-static-libgcc
6-
-static-libstdc++
7-
)
3+
if(NOT FREEBSD)
4+
# Using newer c++ compilers / features on older distros causes runtime dyn link errors
5+
list(APPEND SUNSHINE_EXTERNAL_LIBRARIES
6+
-static-libgcc
7+
-static-libstdc++
8+
)
9+
endif()

0 commit comments

Comments
 (0)