diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 9e1da84f..3bef259e 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -29,6 +29,9 @@ on: snap: description: build linux snap type: boolean + flatpak: + description: build linux flatpak + type: boolean mingw64: description: build win64 mingw64 type: boolean @@ -117,7 +120,7 @@ jobs: submodules: recursive - name: Build snap run: | - docker run --rm --tty -v $PWD:/data -w /data/scripts --privileged diddledani/snapcraft:core20 + docker run --rm --tty --network host -v $PWD:/data -w /data/scripts --privileged diddledani/snapcraft:core20 - name: Set outputs id: vars run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT @@ -127,6 +130,33 @@ jobs: name: switchfin-snap-${{ steps.vars.outputs.sha_short }} path: scripts/*.snap + build-flatpak: + runs-on: ubuntu-latest + if: ${{ inputs.flatpak }} + strategy: + fail-fast: false + matrix: + arch: [ x86_64 ] + container: + image: bilelmoussaoui/flatpak-github-actions:freedesktop-22.08 + options: --privileged + steps: + - uses: actions/checkout@v3 + with: + submodules: recursive + - name: Set workspace permissions + run: git config --system --add safe.directory '*' + - name: Set outputs + id: vars + run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT + - uses: flatpak/flatpak-github-actions/flatpak-builder@v6 + with: + bundle: switchfin-flatpak-${{ steps.vars.outputs.sha_short }}.flatpak + manifest-path: scripts/flatpak.yaml + cache-key: flatpak-builder-${{ hashFiles('scripts/flatpak.yaml') }} + verbose: true + arch: ${{ matrix.arch }} + build-macos: runs-on: macos-latest if: ${{ inputs.macos || github.event_name != 'workflow_dispatch'}} diff --git a/CMakeLists.txt b/CMakeLists.txt index 0cf3b2ec..d1515c99 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -50,7 +50,7 @@ include(${BOREALIS_LIBRARY}/cmake/toolchain.cmake) project(Switchfin) set(VERSION_MAJOR "0") set(VERSION_MINOR "4") -set(VERSION_ALTER "1") +set(VERSION_ALTER "2") set(PROJECT_TITLEID "010ff000ffff0003") set(PROJECT_AUTHOR "dragonflylee") set(PROJECT_ICON ${CMAKE_CURRENT_SOURCE_DIR}/resources/icon/icon.jpg) @@ -198,7 +198,7 @@ if (PLATFORM_DESKTOP) add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND "${CMAKE_COMMAND}" -E copy_directory ${PROJECT_RESOURCES} Resources/resources COMMAND otool -L MacOS/${PROJECT_NAME} - COMMAND dylibbundler -cd -b ${BUNDLE_ARG} -x MacOS/${PROJECT_NAME} -d Frameworks/ -p "@executable_path/../Frameworks/" + COMMAND dylibbundler -cd -ns -b ${BUNDLE_ARG} -x MacOS/${PROJECT_NAME} -d Frameworks/ -p "@executable_path/../Frameworks/" COMMAND codesign --sign - --force Frameworks/* WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/${PROJECT_NAME}.app/Contents" ) diff --git a/app/src/view/video_view.cpp b/app/src/view/video_view.cpp index df63a854..920dc448 100644 --- a/app/src/view/video_view.cpp +++ b/app/src/view/video_view.cpp @@ -219,7 +219,10 @@ VideoView::VideoView(const jellyfin::MediaItem& item) : itemId(item.Id) { this->osdLockBox->registerClickAction([this](...) { return this->toggleOSDLock(); }); this->osdLockBox->addGestureRecognizer(new brls::TapGestureRecognizer(this->osdLockBox)); - this->btnClose->registerClickAction([](...) { return popActivity(); }); + this->btnClose->registerClickAction([](...) { + brls::sync([]() { popActivity(); }); + return true; + }); this->btnClose->addGestureRecognizer(new brls::TapGestureRecognizer(this->btnClose)); /// 播放控制 diff --git a/scripts/flatpak.yaml b/scripts/flatpak.yaml new file mode 100644 index 00000000..694eefc5 --- /dev/null +++ b/scripts/flatpak.yaml @@ -0,0 +1,110 @@ +app-id: org.switchfin.player +runtime: org.freedesktop.Platform +runtime-version: '23.08' +sdk: org.freedesktop.Sdk +command: Switchfin +finish-args: + - --share=ipc + - --socket=fallback-x11 + - --socket=wayland + # This program is designed for controller + - --device=all + - --share=network + - --socket=pulseaudio + # inhibiting screen saver + - --talk-name=org.freedesktop.ScreenSaver + - --talk-name=org.freedesktop.PowerManagement + - --talk-name=org.gnome.SessionManager + - --talk-name=org.mate.SessionManager + # https://github.com/mpv-player/mpv/blob/master/libmpv/client.h#L147-L149 + # will remove it when next version release + - --env=LC_NUMERIC=C +cleanup-commands: + - mkdir -p /app/lib/ffmpeg +cleanup: + - '*.a' + - '*.la' + - /include + - /lib/cmake + - /lib/pkgconfig + - /man + - /share/man + - /share/gtk-doc +add-extensions: + org.freedesktop.Platform.ffmpeg-full: + directory: lib/ffmpeg + version: '23.08' + add-ld-path: "." + +modules: + - name: libmpv + buildsystem: meson + config-opts: + - -Dlibmpv=true + - -Dlua=disabled + - -Ddebug=false + - -Dcplayer=false + - -Dtests=false + - -Dlibarchive=disabled + - -Dmanpage-build=disabled + sources: + - type: archive + url: https://github.com/mpv-player/mpv/archive/v0.36.0.tar.gz + sha256: 29abc44f8ebee013bb2f9fe14d80b30db19b534c679056e4851ceadf5a5e8bf6 + x-checker-data: + type: anitya + project-id: 5348 + stable-only: true + url-template: https://github.com/mpv-player/mpv/archive/v$version.tar.gz + modules: + - name: libXpresent + buildsystem: autotools + sources: + - type: archive + url: https://xorg.freedesktop.org/archive/individual/lib/libXpresent-1.0.1.tar.xz + sha256: b964df9e5a066daa5e08d2dc82692c57ca27d00b8cc257e8e960c9f1cf26231b + x-checker-data: + type: anitya + project-id: 17166 + stable-only: true + url-template: https://xorg.freedesktop.org/archive/individual/lib/libXpresent-$version.tar.xz + + - name: libass + config-opts: + - --disable-static + sources: + - type: archive + url: 'https://github.com/libass/libass/releases/download/0.17.1/libass-0.17.1.tar.gz' + sha256: 'd653be97198a0543c69111122173c41a99e0b91426f9e17f06a858982c2fb03d' + x-checker-data: + type: anitya + project-id: 1560 + stable-only: true + url-template: https://github.com/libass/libass/releases/download/$version/libass-$version.tar.gz + + - name: glfw + buildsystem: cmake-ninja + config-opts: + - -DCMAKE_BUILD_TYPE=Release + - -DGLFW_BUILD_EXAMPLES=OFF + - -DGLFW_BUILD_TESTS=OFF + - -DGLFW_BUILD_DOCS=OFF + - -DBUILD_SHARED_LIBS=ON + - -DGLFW_BUILD_WAYLAND=ON + - -DGLFW_BUILD_X11=ON + sources: + - type: git + url: https://github.com/dragonflylee/glfw.git + branch: switchfin + + - name: switchfin + buildsystem: cmake-ninja + config-opts: + - -DCMAKE_BUILD_TYPE=Release + - -DPLATFORM_DESKTOP=ON + - -DUSE_SYSTEM_GLFW=ON + - -DCMAKE_INSTALL=ON + builddir: true + sources: + - type: dir + path: '..' \ No newline at end of file diff --git a/scripts/snap/snapcraft.yaml b/scripts/snap/snapcraft.yaml index b5f2b15b..98c3d8bc 100644 --- a/scripts/snap/snapcraft.yaml +++ b/scripts/snap/snapcraft.yaml @@ -2,7 +2,7 @@ name: switchfin summary: switchfin description: | third-party PC player for Jellyfin -version: "0.1.0" +version: "0.4.2" grade: stable icon: ../resources/icon/icon.png base: core20 @@ -11,17 +11,14 @@ license: Apache-2.0 apps: switchfin: - command: usr/bin/Switchfin + command: bin/desktop-launch $SNAP/usr/bin/Switchfin plugs: - desktop - - wayland - x11 - opengl - network layout: - /usr/lib/dri: - bind: $SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/dri /usr/resources: bind: $SNAP/usr/resources @@ -38,6 +35,7 @@ parts: - -Dlibmpv=true - -Dtests=false - -Dplain-gl=enabled + - -Dlibarchive=disabled - -Dalsa=disabled - -Dlua=disabled stage-packages: @@ -53,7 +51,7 @@ parts: - libass ffmpeg: - source: https://ffmpeg.org/releases/ffmpeg-5.1.3.tar.gz + source: https://ffmpeg.org/releases/ffmpeg-6.1.tar.xz source-type: tar plugin: autotools autotools-configure-parameters: @@ -65,32 +63,27 @@ parts: - --disable-programs - --disable-encoders - --disable-muxers + - --enable-demuxer=hls + - --enable-runtime-cpudetect - --enable-gpl - - --enable-gnutls - - --enable-encoder=png,libwebp + - --enable-version3 + - --enable-mbedtls - --enable-libdav1d - --enable-libfontconfig - --enable-libfreetype - - --enable-libopus - - --enable-librsvg - --enable-libwebp build-packages: - nasm - libfontconfig1-dev - - libfreetype6-dev - - libopus-dev - - librsvg2-dev - libwebp-dev - - libgnutls28-dev stage-packages: - libfontconfig1 - - libfreetype6 - - libopus0 - - librsvg2-2 - libwebp6 - libxv1 after: - dav1d + - libass + - mbedtls prime: - -etc - -usr/bin @@ -100,9 +93,8 @@ parts: dav1d: plugin: meson - source: https://code.videolan.org/videolan/dav1d.git - source-tag: 1.2.1 - source-depth: 1 + source: https://downloads.videolan.org/pub/videolan/dav1d/1.3.0/dav1d-1.3.0.tar.xz + source-type: tar meson-parameters: - --prefix=/usr - --buildtype=release @@ -129,14 +121,95 @@ parts: build-packages: - libfribidi-dev - libharfbuzz-dev + - libfontconfig1-dev stage-packages: - libfribidi0 - libharfbuzz0b + - libfontconfig1 prime: - -usr/include - -usr/lib/$SNAPCRAFT_ARCH_TRIPLET/pkgconfig - -usr/share + glfw: + plugin: cmake + source: https://github.com/dragonflylee/glfw/archive/switchfin.tar.gz + source-type: tar + cmake-parameters: + - -DCMAKE_INSTALL_PREFIX=/usr + - -DCMAKE_BUILD_TYPE=Release + - -DBUILD_SHARED_LIBS=ON + - -DGLFW_BUILD_EXAMPLES=OFF + - -DGLFW_BUILD_TESTS=OFF + - -DGLFW_BUILD_DOCS=OFF + build-packages: + - xorg-dev + - libdbus-1-dev + stage-packages: + - libx11-6 + prime: + - -usr/include + - -usr/lib/$SNAPCRAFT_ARCH_TRIPLET/cmake + - -usr/lib/$SNAPCRAFT_ARCH_TRIPLET/pkgconfig + - -usr/share + after: + - desktop-glib-only + + desktop-glib-only: + source: https://github.com/ubuntu/snapcraft-desktop-helpers.git + source-subdir: glib-only + plugin: make + build-packages: + - libglib2.0-dev + stage-packages: + - libglib2.0-bin + prime: + - -usr/share + + curl: + source: https://curl.se/download/curl-8.5.0.tar.xz + source-type: tar + plugin: cmake + cmake-parameters: + - -DCMAKE_INSTALL_PREFIX=/usr + - -DCMAKE_BUILD_TYPE=Release + - -DBUILD_SHARED_LIBS=ON + - -DHTTP_ONLY=ON + - -DCURL_USE_MBEDTLS=ON + - -DCURL_DISABLE_PROGRESS_METER=ON + - -DCURL_USE_OPENSSL=OFF + - -DBUILD_CURL_EXE=OFF + - -DBUILD_TESTING=OFF + - -DUSE_LIBIDN2=OFF + - -DCURL_USE_LIBSSH2=OFF + - -DCURL_USE_LIBPSL=OFF + build-environment: + - CMAKE_PREFIX_PATH: $SNAPCRAFT_STAGE/usr + after: + - mbedtls + prime: + - -usr/bin + - -usr/include + - -usr/lib/$SNAPCRAFT_ARCH_TRIPLET/pkgconfig + - -usr/lib/$SNAPCRAFT_ARCH_TRIPLET/cmake + + mbedtls: + plugin: cmake + source: https://github.com/Mbed-TLS/mbedtls/archive/v3.5.1.tar.gz + source-type: tar + cmake-parameters: + - -DCMAKE_INSTALL_PREFIX=/usr + - -DCMAKE_BUILD_TYPE=Release + - -DUSE_STATIC_MBEDTLS_LIBRARY=OFF + - -DUSE_SHARED_MBEDTLS_LIBRARY=ON + - -DENABLE_PROGRAMS=OFF + - -DENABLE_TESTING=OFF + - -DGEN_FILES=OFF + prime: + - -usr/bin + - -usr/include + - -usr/lib/$SNAPCRAFT_ARCH_TRIPLET/cmake + switchfin: plugin: cmake source: ".." @@ -144,22 +217,19 @@ parts: cmake-parameters: - -DPLATFORM_DESKTOP=ON - -DCMAKE_BUILD_TYPE=Release + - -DUSE_SYSTEM_GLFW=ON - -DCMAKE_INSTALL=ON - -DCMAKE_INSTALL_PREFIX=/usr - -DCUSTOM_RESOURCES_DIR=/usr build-environment: - - LD_LIBRARY_PATH: $LD_LIBRARY_PATH:$SNAPCRAFT_STAGE/usr/lib/$SNAPCRAFT_ARCH_TRIPLET + - CMAKE_PREFIX_PATH: $SNAPCRAFT_STAGE/usr + - LD_LIBRARY_PATH: $SNAPCRAFT_STAGE/usr/lib/$SNAPCRAFT_ARCH_TRIPLET build-packages: - g++ - - xorg-dev - - libdbus-1-dev - - libcurl4-gnutls-dev - stage-packages: - - libgl1-mesa-glx - - libcurl3-gnutls after: + - glfw + - curl - libmpv prime: - -etc - -usr/bin/fc-* - - -usr/share