Skip to content

Instantly share code, notes, and snippets.

@icculus
Created August 1, 2024 04:27
Show Gist options
  • Save icculus/2ce8ae160424412b36a8df193a76f8d5 to your computer and use it in GitHub Desktop.
Save icculus/2ce8ae160424412b36a8df193a76f8d5 to your computer and use it in GitHub Desktop.
Patch between SDL 2.0.22 and WhistHQ's fork.
diff -ruBbN '--exclude=.git' SDL-2.0.22/android-project/build.gradle SDL-whisthq/android-project/build.gradle
--- SDL-2.0.22/android-project/build.gradle 2024-08-01 00:22:36.006294486 -0400
+++ SDL-whisthq/android-project/build.gradle 2024-08-01 00:21:19.933039042 -0400
@@ -6,7 +6,7 @@
google()
}
dependencies {
- classpath 'com.android.tools.build:gradle:7.0.3'
+ classpath 'com.android.tools.build:gradle:7.3.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
diff -ruBbN '--exclude=.git' SDL-2.0.22/android-project/gradle/wrapper/gradle-wrapper.properties SDL-whisthq/android-project/gradle/wrapper/gradle-wrapper.properties
--- SDL-2.0.22/android-project/gradle/wrapper/gradle-wrapper.properties 2024-08-01 00:22:36.006294486 -0400
+++ SDL-whisthq/android-project/gradle/wrapper/gradle-wrapper.properties 2024-08-01 00:21:19.933039042 -0400
@@ -1,6 +1,6 @@
#Thu Nov 11 18:20:34 PST 2021
distributionBase=GRADLE_USER_HOME
-distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
diff -ruBbN '--exclude=.git' SDL-2.0.22/CMakeLists.txt SDL-whisthq/CMakeLists.txt
--- SDL-2.0.22/CMakeLists.txt 2024-08-01 00:24:44.624417241 -0400
+++ SDL-whisthq/CMakeLists.txt 2024-08-01 00:21:19.889038316 -0400
@@ -209,6 +209,21 @@
if(MSVC)
set(MSVC_CLANG TRUE)
endif()
+################# Added by Whist #################
+ if(APPLE)
+ # on macOS, detect if we are building arm64 or x86_64
+ # should return "arm64" or "x86_64"
+ execute_process(COMMAND uname -m COMMAND tr -d '\n' OUTPUT_VARIABLE MACOS_ARCHITECTURE)
+ # Use the latest sysroot
+ set(CMAKE_OSX_SYSROOT /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk)
+ # Use an older deployment target so all systems will be happy
+ if(MACOS_ARCHITECTURE MATCHES "arm64")
+ set(CMAKE_OSX_DEPLOYMENT_TARGET "11.0")
+ else()
+ set(CMAKE_OSX_DEPLOYMENT_TARGET "10.13")
+ endif()
+ endif()
+###################################################
elseif(CMAKE_COMPILER_IS_GNUCC)
set(USE_GCC TRUE)
set(OPT_DEF_ASM TRUE)
diff -ruBbN '--exclude=.git' SDL-2.0.22/.github/CODEOWNERS SDL-whisthq/.github/CODEOWNERS
--- SDL-2.0.22/.github/CODEOWNERS 1969-12-31 19:00:00.000000000 -0500
+++ SDL-whisthq/.github/CODEOWNERS 2024-08-01 00:21:19.885038250 -0400
@@ -0,0 +1,15 @@
+# Lines starting with '#' are comments.
+# Each line is a file pattern followed by one or more owners.
+
+# More details are here: https://help.github.com/articles/about-codeowners/
+
+# The '*' pattern is global owners.
+
+# Order is important. The last matching pattern has the most precedence.
+# The folders are ordered as follows:
+
+# In each subsection folders are ordered first by depth, then alphabetically.
+# This should make it easy to add new rules without breaking existing ones.
+
+# Global rule:
+* @whisthq/code-standard-reviewers @rpadaki @sardination @philippemnoel
diff -ruBbN '--exclude=.git' SDL-2.0.22/.github/ISSUE_TEMPLATE/bug_report.md SDL-whisthq/.github/ISSUE_TEMPLATE/bug_report.md
--- SDL-2.0.22/.github/ISSUE_TEMPLATE/bug_report.md 1969-12-31 19:00:00.000000000 -0500
+++ SDL-whisthq/.github/ISSUE_TEMPLATE/bug_report.md 2024-08-01 00:21:19.885038250 -0400
@@ -0,0 +1,17 @@
+---
+name: Bug Report
+about: Report a bug related to this project
+title: ''
+labels: ''
+assignees: ''
+
+---
+
+**Bug Description**
+A clear and concise description of what the bug is.
+
+**How to Reproduce**
+A list of steps to reproduce the bug, if it is reproducible.
+
+**Context**
+List your computer OS, specifications, browser version, etc.; anything that might be relevant to reproducing and diagnosing the bug.
diff -ruBbN '--exclude=.git' SDL-2.0.22/.github/ISSUE_TEMPLATE/config.yml SDL-whisthq/.github/ISSUE_TEMPLATE/config.yml
--- SDL-2.0.22/.github/ISSUE_TEMPLATE/config.yml 1969-12-31 19:00:00.000000000 -0500
+++ SDL-whisthq/.github/ISSUE_TEMPLATE/config.yml 2024-08-01 00:21:19.885038250 -0400
@@ -0,0 +1 @@
+blank_issues_enabled: false
diff -ruBbN '--exclude=.git' SDL-2.0.22/.github/ISSUE_TEMPLATE/feature_request.md SDL-whisthq/.github/ISSUE_TEMPLATE/feature_request.md
--- SDL-2.0.22/.github/ISSUE_TEMPLATE/feature_request.md 1969-12-31 19:00:00.000000000 -0500
+++ SDL-whisthq/.github/ISSUE_TEMPLATE/feature_request.md 2024-08-01 00:21:19.885038250 -0400
@@ -0,0 +1,17 @@
+---
+name: New Feature
+about: Describe a new feature to improve this project
+title: ''
+labels: ''
+assignees: ''
+
+---
+
+**Feature Name & Description**
+A clear and concise high-level description of the feature you want to implement and how it would work.
+
+**The Problem It Fixes**
+A clear and concise of the problem(s) this new feature will fix.
+
+**Feature Implementation**
+A clear and concise description of how this feature will be implemented.
diff -ruBbN '--exclude=.git' SDL-2.0.22/.github/PULL_REQUEST_TEMPLATE.md SDL-whisthq/.github/PULL_REQUEST_TEMPLATE.md
--- SDL-2.0.22/.github/PULL_REQUEST_TEMPLATE.md 2024-08-01 00:22:26.366135390 -0400
+++ SDL-whisthq/.github/PULL_REQUEST_TEMPLATE.md 2024-08-01 00:21:19.885038250 -0400
@@ -1,7 +1,17 @@
-<!--- Provide a general summary of your changes in the Title above -->
+**Ticket(s) Closed**
-## Description
-<!--- Describe your changes in detail -->
+- Closes #
-## Existing Issue(s)
-<!--- If it fixes an open issue, please link to the issue here. -->
+**Description**
+
+**Implementation**
+
+**Documentation & Tests Added**
+
+**Testing Instructions**
+
+**PR Checklist**
+
+- [ ] Did the PR author fully test this PR end-to-end?
+- [ ] Did one PR reviewer fully test this PR end-to-end?
+- [ ] Did one PR reviewer conduct a thorough code design review?
diff -ruBbN '--exclude=.git' SDL-2.0.22/.github/renovate.json5 SDL-whisthq/.github/renovate.json5
--- SDL-2.0.22/.github/renovate.json5 1969-12-31 19:00:00.000000000 -0500
+++ SDL-whisthq/.github/renovate.json5 2024-08-01 00:21:19.885038250 -0400
@@ -0,0 +1,75 @@
+{
+ labels: ["dependencies"],
+
+ // We want at most 10 PRs per hour, at most 2 at a time
+ prHourlyLimit: 10,
+ prConcurrentLimit: 2,
+
+ // We target various path prefixes to group those PRs together
+ packageRules: [
+ {
+ matchPaths: [".github/workflows/"],
+ groupName: ".github/workflows",
+ },
+ {
+ matchPaths: ["VisualC-WinRT/"],
+ groupName: "VisualC-WinRT",
+ },
+ {
+ matchPaths: ["VisualC/"],
+ groupName: "VisualC",
+ },
+ {
+ matchPaths: ["Xcode-iOS/"],
+ groupName: "Xcode-iOS",
+ },
+ {
+ matchPaths: ["Xcode/"],
+ groupName: "Xcode",
+ },
+ {
+ matchPaths: ["acinclude/"],
+ groupName: "acinclude",
+ },
+ {
+ matchPaths: ["android-project-ant/"],
+ groupName: "android-project-ant",
+ },
+ {
+ matchPaths: ["android-project/"],
+ groupName: "android-project",
+ },
+ {
+ matchPaths: ["build-scripts/"],
+ groupName: "build-scripts",
+ },
+ {
+ matchPaths: ["cmake/"],
+ groupName: "cmake",
+ },
+ {
+ matchPaths: ["docs/"],
+ groupName: "docs",
+ },
+ {
+ matchPaths: ["include/"],
+ groupName: "include",
+ },
+ {
+ matchPaths: ["src/"],
+ groupName: "src",
+ },
+ {
+ matchPaths: ["test/"],
+ groupName: "test",
+ },
+ {
+ matchPaths: ["visualtest/"],
+ groupName: "visualtest",
+ },
+ {
+ matchPaths: ["wayland-protocols/"],
+ groupName: "wayland-protocols",
+ },
+ ],
+}
diff -ruBbN '--exclude=.git' SDL-2.0.22/.github/workflows/android.yml SDL-whisthq/.github/workflows/android.yml
--- SDL-2.0.22/.github/workflows/android.yml 2024-08-01 00:22:35.958293694 -0400
+++ SDL-whisthq/.github/workflows/android.yml 1969-12-31 19:00:00.000000000 -0500
@@ -1,14 +0,0 @@
-name: Build (Android)
-
-on: [push, pull_request]
-
-jobs:
- android:
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v2
- - uses: nttld/setup-ndk@v1
- with:
- ndk-version: r21e
- - name: Build
- run: ./build-scripts/androidbuildlibs.sh
diff -ruBbN '--exclude=.git' SDL-2.0.22/.github/workflows/build-and-publish-sdl.yml SDL-whisthq/.github/workflows/build-and-publish-sdl.yml
--- SDL-2.0.22/.github/workflows/build-and-publish-sdl.yml 1969-12-31 19:00:00.000000000 -0500
+++ SDL-whisthq/.github/workflows/build-and-publish-sdl.yml 2024-08-01 00:21:19.885038250 -0400
@@ -0,0 +1,240 @@
+# workflows/build-and-publish-sdl.yml
+#
+# Build & Publish Whist SDL
+# Build and publish the Whist version of SDL by uploading the compiled libs to AWS S3.
+
+name: "Build & Publish Whist SDL"
+
+on:
+ pull_request:
+ branches:
+ - main
+ paths-ignore:
+ - README.md
+ push:
+ branches:
+ - main
+ paths-ignore:
+ - README.md
+ workflow_dispatch:
+
+# This guarantees that if you push many commits to the same PR, only the latest
+# commit will get run (others get cancelled)
+concurrency:
+ group: build-and-publish-sdl-${{ github.head_ref || github.run_id }}
+ cancel-in-progress: true
+
+jobs:
+ build-and-publish-whist-sdl:
+ name: ${{ matrix.config.name }} (${{ matrix.options.name }})
+ runs-on: ${{ matrix.config.os }}
+
+ strategy:
+ matrix:
+ config:
+ - name: "Windows"
+ os: windows-2019 # Same OS as Windows 10
+ - name: "macOS (x64)"
+ os: macos-11 # Xcode and Homebrew come preinstalled
+ - name: "macOS (arm64)"
+ os: macos-11 # Xcode and Homebrew come preinstalled
+ - name: "Linux Ubuntu"
+ os: ubuntu-20.04
+ options:
+ - name: "Default"
+ suffix: ""
+ cmake-flags: ""
+ - name: "Position-Independent Code"
+ suffix: "-pic"
+ cmake-flags: "-D SDL_STATIC_PIC=ON"
+
+ env:
+ binary-location: build
+ windows-tar-name: whist-windows-sdl2-static-lib${{ matrix.options.suffix }}.tar.gz
+ macos-x64-tar-name: whist-macos-x64-sdl2-static-lib${{ matrix.options.suffix }}.tar.gz
+ macos-arm64-tar-name: whist-macos-arm64-sdl2-static-lib${{ matrix.options.suffix }}.tar.gz
+ linux-tar-name: whist-linux-sdl2-static-lib${{ matrix.options.suffix }}.tar.gz
+ s3-bucket-region: us-east-1
+ s3-bucket-uri: s3://whist-protocol-dependencies
+
+ steps:
+ ################################# CONFIG STEPS START ##############################
+
+ - name: Checkout Git Repository
+ uses: actions/checkout@v3
+
+ - name: Configure AWS S3 CLI
+ uses: aws-actions/configure-aws-credentials@v1
+ with:
+ aws-access-key-id: ${{ secrets.AWS_GITHUB_ACTIONS_USER_ACCESS_KEY_ID }}
+ aws-secret-access-key: ${{ secrets.AWS_GITHUB_ACTIONS_USER_SECRET_ACCESS_KEY }}
+ aws-region: ${{ env.s3-bucket-region }}
+
+ ###################################################################################
+ ################################ WINDOWS STEPS START ##############################
+
+ - name: On Windows, Set up Visual Studio Developer Command Prompt (for nmake)
+ if: runner.os == 'Windows'
+ uses: ilammy/msvc-dev-cmd@v1
+
+ - name: Build Whist SDL on Windows
+ if: runner.os == 'Windows'
+ shell: cmd
+ run: |
+ REM create build output folder
+ mkdir ${{ env.binary-location }}
+
+ REM configure Cmake
+ cmake ^
+ -S . ^
+ -B build ^
+ -D HAVE_LIBC=ON ^
+ -D DIRECTX=OFF ^
+ -D CMAKE_BUILD_TYPE=Release ^
+ ${{ matrix.options.cmake-flags }} ^
+ -G "NMake Makefiles"
+
+ REM build SDL
+ cd ${{ env.binary-location }} && nmake SDL2-static
+
+ ###################################################################################
+ ################################# MACOS STEPS START ###############################
+
+ - name: Build Whist SDL on macOS
+ if: runner.os == 'macOS'
+ run: |
+ # create build output folder
+ mkdir ${{ env.binary-location }}
+
+ if [[ "${{ matrix.config.name }}" == "macOS (x64)" ]]; then
+ # configure Cmake for native compilation on x64 systems
+ cmake \
+ -S . \
+ -B build \
+ -D CMAKE_BUILD_TYPE=Release \
+ ${{ matrix.options.cmake-flags }}
+ elif [[ "${{ matrix.config.name }}" == "macOS (arm64)" ]]; then
+ # configure Cmake for cross-compilation to arm64 from x64 systems
+ cmake \
+ -S . \
+ -B build \
+ -D CMAKE_OSX_ARCHITECTURES=arm64 \
+ -D CMAKE_BUILD_TYPE=Release \
+ ${{ matrix.options.cmake-flags }}
+ else
+ echo "Unsupported compilation attempt on macOS"
+ exit
+ fi
+
+ # build SDL
+ cd ${{ env.binary-location }} && make -j SDL2-static
+
+ ###################################################################################
+ ############################# LINUX UBUNTU STEPS START ############################
+
+ - name: On Linux, Install SDL Dependencies
+ if: runner.os == 'Linux'
+ run: sudo apt-get update && sudo apt-get install libasound2-dev xorg-dev
+
+ - name: Build Whist SDL on Linux Ubuntu
+ if: runner.os == 'Linux'
+ run: |
+ # create build output folder
+ mkdir ${{ env.binary-location }}
+
+ # configure Cmake
+ cmake \
+ -S . \
+ -B build \
+ -D CMAKE_BUILD_TYPE=Release \
+ ${{ matrix.options.cmake-flags }}
+
+ # build SDL
+ cd ${{ env.binary-location }}
+ make -j SDL2-static
+
+ ###################################################################################
+ ################################# PUBLISH STEPS START #############################
+
+ # Only publish to AWS S3 on Push/Workflow_dispatch events (code merged into `main`)
+ - name: Tar libSDL and Upload to AWS S3 (Only on Push Events)
+ if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }}
+ shell: bash --noprofile --norc -eo pipefail {0}
+ working-directory: ${{ env.binary-location }}
+ run: |
+ # copy headers, but do not overwrite the generated SDL_config.h (-n)
+ mv -n ../include/*.h include
+ if [ "$RUNNER_OS" == "Linux" ]; then
+ tar -zcvf ${{ env.linux-tar-name }} libSDL2.a include/*.h
+ aws s3 cp ${{ env.linux-tar-name }} ${{ env.s3-bucket-uri }}/${{ env.linux-tar-name }}
+ elif [ "$RUNNER_OS" == "Windows" ]; then
+ tar -zcvf ${{ env.windows-tar-name }} SDL2-static.lib include/*.h
+ aws s3 cp ${{ env.windows-tar-name }} ${{ env.s3-bucket-uri }}/${{ env.windows-tar-name }}
+ else
+ if [[ "${{ matrix.config.name }}" == "macOS (x64)" ]]; then
+ tar -zcvf ${{ env.macos-x64-tar-name }} libSDL2.a include/*.h
+ aws s3 cp ${{ env.macos-x64-tar-name }} ${{ env.s3-bucket-uri }}/${{ env.macos-x64-tar-name }}
+ elif [[ "${{ matrix.config.name }}" == "macOS (arm64)" ]]; then
+ # copy headers, but do not overwrite the generated SDL_config.h (-n)
+ mv -n ../include/*.h include
+ tar -zcvf ${{ env.macos-arm64-tar-name }} libSDL2.a include/*.h
+ aws s3 cp ${{ env.macos-arm64-tar-name }} ${{ env.s3-bucket-uri }}/${{ env.macos-arm64-tar-name }}
+ else
+ echo "Tried to tar and upload libSDL to AWS S3 for an unsupported OS"
+ exit
+ fi
+ fi
+
+ ###################################################################################
+
+ - name: Checkout whisthq/whist Git Repository
+ if: ${{ (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && failure() }}
+ uses: actions/checkout@v3
+ with:
+ repository: whisthq/whist
+ ref: "dev"
+ token: ${{ secrets.GHA_PERSONAL_ACCESS_TOKEN }}
+
+ - name: Setup Python-based Notifications
+ if: ${{ (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && failure() }}
+ working-directory: .github/workflows/helpers
+ run: ./notifications/setup_notifications.sh
+
+ - name: Notify Slack on Workflow Error (Only on Push/Workflow_dispatch Events)
+ if: ${{ (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && failure() }}
+ shell: python3 {0}
+ run: |
+ from notifications.slack_bot import slack_post
+ SLACK_WEBHOOK = "${{ secrets.SLACK_HOOKS_ENDPOINT_PROD }}"
+ BODY = f"@releases :rotating_light: Failed to deploy Whist `SDL ${{ matrix.config.name }}` Static Library to AWS S3, investigate immediately :rotating_light: (<https://github.com/whisthq/SDL/actions/runs/${{ github.run_id }} | see logs>)"
+ slack_post(slack_webhook=SLACK_WEBHOOK, body=BODY)
+
+ #######################################################################################
+ #######################################################################################
+
+ # Notify us in Slack if all jobs from this workflow succeed
+ notify-slack:
+ name: Notify Slack
+ runs-on: ubuntu-20.04
+ needs: [build-and-publish-whist-sdl]
+ if: ${{ (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && success() }}
+ steps:
+ - name: Checkout whisthq/whist Git Repository
+ uses: actions/checkout@v3
+ with:
+ repository: whisthq/whist
+ ref: "dev"
+ token: ${{ secrets.GHA_PERSONAL_ACCESS_TOKEN }}
+
+ - name: Setup Python-based Notifications
+ working-directory: .github/workflows/helpers
+ run: ./notifications/setup_notifications.sh
+
+ - name: Notify Slack on Workflow Success
+ shell: python3 {0}
+ run: |
+ from notifications.slack_bot import slack_post
+ SLACK_WEBHOOK = "${{ secrets.SLACK_HOOKS_ENDPOINT_PROD }}"
+ TITLE = ":sdl: Whist SDL2 Static Libraries Deployed :sdl:"
+ BODY = f"Whist `SDL` Static Libraries deployed to Production via upload to AWS S3 (<https://github.com/whisthq/SDL/actions/runs/${{ github.run_id }} | see logs>)"
+ slack_post(slack_webhook=SLACK_WEBHOOK, title=TITLE, body=BODY)
diff -ruBbN '--exclude=.git' SDL-2.0.22/.github/workflows/emscripten.yml SDL-whisthq/.github/workflows/emscripten.yml
--- SDL-2.0.22/.github/workflows/emscripten.yml 2024-08-01 00:22:35.958293694 -0400
+++ SDL-whisthq/.github/workflows/emscripten.yml 1969-12-31 19:00:00.000000000 -0500
@@ -1,16 +0,0 @@
-name: Build (Emscripten)
-
-on: [push, pull_request]
-
-jobs:
- emscripten:
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v2
- - uses: mymindstorm/setup-emsdk@v10
- with:
- version: 2.0.27
- - name: Configure CMake
- run: emcmake cmake -B build
- - name: Build
- run: cmake --build build/
diff -ruBbN '--exclude=.git' SDL-2.0.22/.github/workflows/ios.yml SDL-whisthq/.github/workflows/ios.yml
--- SDL-2.0.22/.github/workflows/ios.yml 2024-08-01 00:22:35.958293694 -0400
+++ SDL-whisthq/.github/workflows/ios.yml 1969-12-31 19:00:00.000000000 -0500
@@ -1,20 +0,0 @@
-name: Build (iOS/tvOS)
-
-on: [push, pull_request]
-
-jobs:
- Build:
- name: ${{ matrix.platform.name }}
- runs-on: macos-latest
-
- strategy:
- fail-fast: false
- matrix:
- platform:
- - { name: iOS, target: Static Library-iOS, sdk: iphoneos }
- - { name: tvOS, target: Static Library-tvOS, sdk: appletvos }
-
- steps:
- - uses: actions/checkout@v2
- - name: Build
- run: xcodebuild -project Xcode/SDL/SDL.xcodeproj -target '${{ matrix.platform.target }}' -configuration Release -sdk ${{ matrix.platform.sdk }} clean build
\ No newline at end of file
diff -ruBbN '--exclude=.git' SDL-2.0.22/.github/workflows/main.yml SDL-whisthq/.github/workflows/main.yml
--- SDL-2.0.22/.github/workflows/main.yml 2024-08-01 00:24:44.624417241 -0400
+++ SDL-whisthq/.github/workflows/main.yml 1969-12-31 19:00:00.000000000 -0500
@@ -1,83 +0,0 @@
-name: Build
-
-on: [push, pull_request]
-
-jobs:
- Build:
- name: ${{ matrix.platform.name }}
- runs-on: ${{ matrix.platform.os }}
-
- defaults:
- run:
- shell: ${{ matrix.platform.shell }}
-
- strategy:
- fail-fast: false
- matrix:
- platform:
- - { name: Windows (mingw32), os: windows-latest, shell: 'msys2 {0}', msystem: mingw32, msys-env: mingw-w64-i686 }
- - { name: Windows (mingw64), os: windows-latest, shell: 'msys2 {0}', msystem: mingw64, msys-env: mingw-w64-x86_64 }
- - { name: Linux, os: ubuntu-20.04, shell: sh, flags: -GNinja }
- - { name: MacOS, os: macos-latest, shell: sh }
-
- steps:
- - name: Set up MSYS2
- if: matrix.platform.shell == 'msys2 {0}'
- uses: msys2/setup-msys2@v2
- with:
- msystem: ${{ matrix.platform.msystem }}
- install: >-
- ${{ matrix.platform.msys-env }}-gcc
- ${{ matrix.platform.msys-env }}-cmake
- ${{ matrix.platform.msys-env }}-ninja
- ${{ matrix.platform.msys-env }}-pkg-config
-
- - name: Setup Linux dependencies
- if: runner.os == 'Linux'
- run: |
- sudo apt-get update
- sudo apt-get install wayland-protocols \
- pkg-config \
- ninja-build \
- libasound2-dev \
- libdbus-1-dev \
- libegl1-mesa-dev \
- libgl1-mesa-dev \
- libgles2-mesa-dev \
- libglu1-mesa-dev \
- libibus-1.0-dev \
- libpulse-dev \
- libsdl2-2.0-0 \
- libsndio-dev \
- libudev-dev \
- libwayland-dev \
- libwayland-client++0 \
- wayland-scanner++ \
- libwayland-cursor++0 \
- libx11-dev \
- libxcursor-dev \
- libxext-dev \
- libxi-dev \
- libxinerama-dev \
- libxkbcommon-dev \
- libxrandr-dev \
- libxss-dev \
- libxt-dev \
- libxv-dev \
- libxxf86vm-dev \
- libdrm-dev \
- libgbm-dev\
- libpulse-dev \
- libpango1.0-dev
- sudo apt install meson
- git clone --depth 1 https://gitlab.gnome.org/jadahl/libdecor.git --branch 0.1.0
- cd libdecor
- meson build --buildtype release -Ddemo=false -Ddbus=disabled
- ninja -C build
- sudo meson install -C build
- - uses: actions/checkout@v2
- - name: Configure CMake
- run: cmake -B build -DSDL_TEST=ON ${{ matrix.platform.flags }}
- - name: Build
- run: cmake --build build/ --config Release
-
diff -ruBbN '--exclude=.git' SDL-2.0.22/.github/workflows/msvc.yml SDL-whisthq/.github/workflows/msvc.yml
--- SDL-2.0.22/.github/workflows/msvc.yml 2024-08-01 00:24:44.624417241 -0400
+++ SDL-whisthq/.github/workflows/msvc.yml 1969-12-31 19:00:00.000000000 -0500
@@ -1,33 +0,0 @@
-name: Build (MSVC)
-
-on: [push, pull_request]
-
-jobs:
- Build:
- name: ${{ matrix.platform.name }}
- runs-on: windows-latest
-
- strategy:
- fail-fast: false
- matrix:
- platform:
- - { name: Windows (x64), flags: -A x64, project: VisualC/SDL.sln, projectflags: '/p:Platform=x64' }
- - { name: Windows (x86), flags: -A Win32, project: VisualC/SDL.sln, projectflags: '/p:Platform=Win32' }
- - { name: Windows (clang-cl x64), flags: -T ClangCL -A x64 }
- - { name: Windows (clang-cl x86), flags: -T ClangCL -A Win32 }
- - { name: Windows (ARM64), flags: -A ARM64 }
- - { name: UWP (x64), flags: -A x64 -DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION="10.0" -DSDL_TEST=OFF, project: VisualC-WinRT/SDL-UWP.sln, projectflags: '/p:Platform=x64 /p:WindowsTargetPlatformVersion=10.0.17763.0' }
-
- steps:
- - uses: actions/checkout@v2
- - name: Configure CMake
- run: cmake -B build -DSDL_TEST=ON ${{ matrix.platform.flags }}
- - name: Build CMake
- run: cmake --build build/ --config Release --parallel
-
- - name: Add msbuild to PATH
- if: ${{ matrix.platform.project != '' }}
- uses: microsoft/[email protected]
- - name: Build msbuild
- if: ${{ matrix.platform.project != '' }}
- run: msbuild ${{ matrix.platform.project }} /m /p:BuildInParallel=true /p:Configuration=Release ${{ matrix.platform.projectflags }}
diff -ruBbN '--exclude=.git' SDL-2.0.22/.github/workflows/os2.yml SDL-whisthq/.github/workflows/os2.yml
--- SDL-2.0.22/.github/workflows/os2.yml 2024-08-01 00:24:44.624417241 -0400
+++ SDL-whisthq/.github/workflows/os2.yml 1969-12-31 19:00:00.000000000 -0500
@@ -1,22 +0,0 @@
-name: Build (OS/2)
-
-on: [push, pull_request]
-
-jobs:
- os2:
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v2
- - uses: open-watcom/setup-watcom@v0
- - name: Build SDL2
- run: |
- wmake -f Makefile.os2
- - name: Build tests
- run: |
- cd test && wmake -f Makefile.os2
- cd ..
- - name: distclean
- run: |
- wmake -f Makefile.os2 distclean
- cd test && wmake -f Makefile.os2 distclean
- cd ..
diff -ruBbN '--exclude=.git' SDL-2.0.22/.github/workflows/.prettierrc SDL-whisthq/.github/workflows/.prettierrc
--- SDL-2.0.22/.github/workflows/.prettierrc 1969-12-31 19:00:00.000000000 -0500
+++ SDL-whisthq/.github/workflows/.prettierrc 2024-08-01 00:21:19.885038250 -0400
@@ -0,0 +1,5 @@
+{
+ "tabWidth": 2,
+ "semi": false,
+ "singleQuote": false
+}
diff -ruBbN '--exclude=.git' SDL-2.0.22/.github/workflows/psp.yaml SDL-whisthq/.github/workflows/psp.yaml
--- SDL-2.0.22/.github/workflows/psp.yaml 2024-08-01 00:22:35.958293694 -0400
+++ SDL-whisthq/.github/workflows/psp.yaml 1969-12-31 19:00:00.000000000 -0500
@@ -1,18 +0,0 @@
-name: Build (Sony Playstation Portable)
-
-on: [push, pull_request]
-
-jobs:
- psp:
- runs-on: ubuntu-latest
- container: pspdev/pspdev:latest
- steps:
- - uses: actions/checkout@v2
- - name: Setup dependencies
- run: |
- apk update
- apk add cmake gmp mpc1 mpfr4 make
- - name: Configure CMake
- run: cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=$PSPDEV/psp/share/pspdev.cmake -DSDL_TEST=ON
- - name: Build
- run: cmake --build build
diff -ruBbN '--exclude=.git' SDL-2.0.22/.github/workflows/riscos.yml SDL-whisthq/.github/workflows/riscos.yml
--- SDL-2.0.22/.github/workflows/riscos.yml 2024-08-01 00:22:35.958293694 -0400
+++ SDL-whisthq/.github/workflows/riscos.yml 1969-12-31 19:00:00.000000000 -0500
@@ -1,28 +0,0 @@
-name: Build (RISC OS)
-
-on: [push, pull_request]
-
-jobs:
- autotools:
- name: autotools
- runs-on: ubuntu-latest
- container: riscosdotinfo/riscos-gccsdk-4.7:latest
- steps:
- - uses: actions/checkout@v2
- - name: Configure
- run: ./configure --host=arm-unknown-riscos --disable-gcc-atomics
- - name: Build
- run: make -j`nproc`
-
- cmake:
- name: CMake
- runs-on: ubuntu-latest
- container: riscosdotinfo/riscos-gccsdk-4.7:latest
- steps:
- - name: Setup dependencies
- run: apt-get update && apt-get install -y cmake ninja-build
- - uses: actions/checkout@v2
- - name: Configure CMake
- run: cmake -S. -Bbuild -G Ninja -DCMAKE_TOOLCHAIN_FILE=/home/riscos/env/toolchain-riscos.cmake -DRISCOS=ON -DSDL_GCC_ATOMICS=OFF -DCMAKE_BUILD_TYPE=Release
- - name: Build
- run: cmake --build build
diff -ruBbN '--exclude=.git' SDL-2.0.22/.github/workflows/vita.yaml SDL-whisthq/.github/workflows/vita.yaml
--- SDL-2.0.22/.github/workflows/vita.yaml 2024-08-01 00:22:35.958293694 -0400
+++ SDL-whisthq/.github/workflows/vita.yaml 1969-12-31 19:00:00.000000000 -0500
@@ -1,23 +0,0 @@
-name: Build (Sony Playstation Vita)
-
-on: [push, pull_request]
-
-defaults:
- run:
- shell: sh
-
-jobs:
- vita:
- runs-on: ubuntu-latest
- container:
- image: vitasdk/vitasdk:latest
- steps:
- - uses: actions/checkout@v2
- - name: Install CMake and GNU Make
- run: |
- apk update
- apk add cmake make
- - name: Configure CMake
- run: cmake -S. -Bbuild -DCMAKE_TOOLCHAIN_FILE=${VITASDK}/share/vita.toolchain.cmake -DCMAKE_BUILD_TYPE=Release
- - name: Build
- run: cmake --build build
diff -ruBbN '--exclude=.git' SDL-2.0.22/include/SDL_events.h SDL-whisthq/include/SDL_events.h
--- SDL-2.0.22/include/SDL_events.h 2024-08-01 00:24:44.652417703 -0400
+++ SDL-whisthq/include/SDL_events.h 2024-08-01 00:21:19.949039307 -0400
@@ -140,6 +140,7 @@
SDL_DOLLARGESTURE = 0x800,
SDL_DOLLARRECORD,
SDL_MULTIGESTURE,
+ SDL_PINCH,
/* Clipboard events */
SDL_CLIPBOARDUPDATE = 0x900, /**< The clipboard changed */
@@ -312,11 +313,12 @@
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
Uint32 windowID; /**< The window with mouse focus, if any */
Uint32 which; /**< The mouse instance id, or SDL_TOUCH_MOUSEID */
- Sint32 x; /**< The amount scrolled horizontally, positive to the right and negative to the left */
- Sint32 y; /**< The amount scrolled vertically, positive away from the user and negative toward the user */
+ Sint32 x; /**< The integer amount scrolled horizontally, positive to the right and negative to the left */
+ Sint32 y; /**< The integer amount scrolled vertically, positive away from the user and negative toward the user */
+ float preciseX; /**< The precise, floating-point amount scrolled horizontally, positive to the right and negative to the left */
+ float preciseY; /**< The precise, floating-point amount scrolled vertically, positive away from the user and negative towards the user */
Uint32 direction; /**< Set to one of the SDL_MOUSEWHEEL_* defines. When FLIPPED the values in X and Y will be opposite. Multiply by -1 to change them back */
- float preciseX; /**< The amount scrolled horizontally, positive to the right and negative to the left, with float precision (added in 2.0.18) */
- float preciseY; /**< The amount scrolled vertically, positive away from the user and negative toward the user, with float precision (added in 2.0.18) */
+ SDL_MouseWheelMomentumPhase momentum_phase; /**< The momentum phase of the scroll (NONE for non-momentum scrolls) */
} SDL_MouseWheelEvent;
/**
@@ -516,6 +518,19 @@
/**
+ * \brief Finger Pinch Event (event.pinch.*)
+ */
+typedef struct SDL_PinchEvent
+{
+ Uint32 type; /**< ::SDL_PINCH */
+ Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
+ float magnification; /***< The magnification factor */
+ float scroll_amount; /***< Equivalent vertical scroll factor */
+ Uint32 windowID; /**< The window underneath the pinch, if any */
+} SDL_PinchEvent;
+
+
+/**
* \brief Dollar Gesture Event (event.dgesture.*)
*/
typedef struct SDL_DollarGestureEvent
@@ -563,6 +578,8 @@
{
Uint32 type; /**< ::SDL_QUIT */
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
+ // Added by Whist
+ SDL_bool quit_app; /**< Set to true if the application should be quit (e.g. on macOS). */
} SDL_QuitEvent;
/**
@@ -639,6 +656,7 @@
SDL_MultiGestureEvent mgesture; /**< Gesture event data */
SDL_DollarGestureEvent dgesture; /**< Gesture event data */
SDL_DropEvent drop; /**< Drag and drop event data */
+ SDL_PinchEvent pinch; /**< Trackpad pinch event data */
/* This is necessary for ABI compatibility between Visual C++ and GCC.
Visual C++ will respect the push pack pragma and use 52 bytes (size of
diff -ruBbN '--exclude=.git' SDL-2.0.22/include/SDL_hints.h SDL-whisthq/include/SDL_hints.h
--- SDL-2.0.22/include/SDL_hints.h 2024-08-01 00:24:44.652417703 -0400
+++ SDL-whisthq/include/SDL_hints.h 2024-08-01 00:21:19.953039372 -0400
@@ -2039,6 +2038,16 @@
*/
#define SDL_HINT_AUDIODRIVER "SDL_AUDIODRIVER"
+/**
+ * \brief Configure a macOS window as full-size content view.
+ *
+ * If set, this will cause the OS to draw the window controls (for example,
+ * the traffic-light buttons) directly over the SDL-rendered contents,
+ * removing the titlebar altogether. Used by Whist for an integrated
+ * titlebar to present a more native look.
+ *
+ */
+#define SDL_HINT_MAC_USE_WINDOW_STYLE_FULL_SIZE_CONTENT_VIEW "SDL_MAC_USE_WINDOW_STYLE_FULL_SIZE_CONTENT_VIEW"
/**
* \brief An enumeration of hint priorities
diff -ruBbN '--exclude=.git' SDL-2.0.22/include/SDL_mouse.h SDL-whisthq/include/SDL_mouse.h
--- SDL-2.0.22/include/SDL_mouse.h 2024-08-01 00:22:36.038295015 -0400
+++ SDL-whisthq/include/SDL_mouse.h 2024-08-01 00:21:19.953039372 -0400
@@ -69,6 +69,17 @@
SDL_MOUSEWHEEL_FLIPPED /**< The scroll direction is flipped / natural */
} SDL_MouseWheelDirection;
+/**
+ * \brief Scroll momentum phase
+ */
+typedef enum
+{
+ SDL_MOUSEWHEEL_MOMENTUM_NONE, /**< Not a momentum scroll (e.g. fingers are touching mouse) */
+ SDL_MOUSEWHEEL_MOMENTUM_BEGIN, /**< A momentum scroll has begun */
+ SDL_MOUSEWHEEL_MOMENTUM_ACTIVE, /**< A momentum scroll is in effect */
+ SDL_MOUSEWHEEL_MOMENTUM_END, /**< A momentum scroll has completed */
+} SDL_MouseWheelMomentumPhase;
+
/* Function prototypes */
/**
diff -ruBbN '--exclude=.git' SDL-2.0.22/include/SDL_render.h SDL-whisthq/include/SDL_render.h
--- SDL-2.0.22/include/SDL_render.h 2024-08-01 00:24:44.656417769 -0400
+++ SDL-whisthq/include/SDL_render.h 2024-08-01 00:21:19.961039505 -0400
@@ -362,6 +362,52 @@
extern DECLSPEC SDL_Texture * SDLCALL SDL_CreateTextureFromSurface(SDL_Renderer * renderer, SDL_Surface * surface);
/**
+ * Structure used with SDL_CreateTextureFromHandle() under D3D11.
+ */
+typedef struct
+{
+ /** Texture (or array) as D3D11Texture2D.
+ *
+ * This texture must be created on the same device as SDL is using
+ * (retrieved via SDL_RenderGetD3D11Device()).
+ */
+ void *texture;
+ /** Subresource index within an array; zero if not an array. */
+ int index;
+} SDL_TextureHandleD3D11;
+
+/**
+ * Create a texture from a platform-specific handle which refers to a
+ * texture.
+ *
+ * This wraps the given handle inside an SDL texture, allowing use of
+ * external textures within SDL.
+ *
+ * The handle format depends on the platform:
+ * - Windows/D3D11: a pointer to a filled SDL_TextureHandleD3D11
+ * structure.
+ * - macOS/Metal: a pointer to a CVPixelBuffer containing all planes of
+ * the texture.
+ *
+ * The user is responsible for any necessary synchronisation if the
+ * texture may also be accessed from other threads.
+ *
+ * \param renderer the rendering context
+ * \param format one of the enumerated values in SDL_PixelFormatEnum
+ * \param access one of the enumerated values in SDL_TextureAccess
+ * \param w the width of the texture in pixels
+ * \param h the height of the texture in pixels
+ * \param handle platform-specific handle; see notes
+ * \returns a pointer to the created texture or NULL if something went
+ * wrong; call SDL_GetError() for more information.
+ *
+ * \since This function is available in Whist SDL only.
+ */
+extern DECLSPEC SDL_Texture * SDLCALL SDL_CreateTextureFromHandle(SDL_Renderer * renderer,
+ Uint32 format, int access,
+ int w, int h, void * handle);
+
+/**
* Query the attributes of a texture.
*
* \param texture the texture to query
diff -ruBbN '--exclude=.git' SDL-2.0.22/include/SDL_video.h SDL-whisthq/include/SDL_video.h
--- SDL-2.0.22/include/SDL_video.h 2024-08-01 00:24:44.656417769 -0400
+++ SDL-whisthq/include/SDL_video.h 2024-08-01 00:21:19.961039505 -0400
@@ -124,6 +124,7 @@
SDL_WINDOW_TOOLTIP = 0x00040000, /**< window should be treated as a tooltip */
SDL_WINDOW_POPUP_MENU = 0x00080000, /**< window should be treated as a popup menu */
SDL_WINDOW_KEYBOARD_GRABBED = 0x00100000, /**< window has grabbed keyboard input */
+ SDL_WINDOW_OCCLUDED = 0x00200000, /**< window is fully occluded (MacOS only) */
SDL_WINDOW_VULKAN = 0x10000000, /**< window usable for Vulkan surface */
SDL_WINDOW_METAL = 0x20000000, /**< window usable for Metal view */
@@ -176,7 +177,9 @@
SDL_WINDOWEVENT_TAKE_FOCUS, /**< Window is being offered a focus (should SetWindowInputFocus() on itself or a subwindow, or ignore) */
SDL_WINDOWEVENT_HIT_TEST, /**< Window had a hit test that wasn't SDL_HITTEST_NORMAL. */
SDL_WINDOWEVENT_ICCPROF_CHANGED,/**< The ICC profile of the window's display has changed. */
- SDL_WINDOWEVENT_DISPLAY_CHANGED /**< Window has been moved to display data1. */
+ SDL_WINDOWEVENT_DISPLAY_CHANGED,/**< Window has been moved to display data1. */
+ SDL_WINDOWEVENT_OCCLUDED, /**< Window is now fully covered by other windows */
+ SDL_WINDOWEVENT_UNOCCLUDED /**< Window is now at least partially visible on screen */
} SDL_WindowEventID;
/**
diff -ruBbN '--exclude=.git' SDL-2.0.22/README.md SDL-whisthq/README.md
--- SDL-2.0.22/README.md 2024-08-01 00:22:35.962293761 -0400
+++ SDL-whisthq/README.md 2024-08-01 00:21:19.889038316 -0400
@@ -1,5 +1,118 @@
+Whist README
+=============
-# Simple DirectMedia Layer (SDL) Version 2.0
+[![.github/workflows/build-and-publish-sdl.yml](https://github.com/whisthq/SDL/actions/workflows/build-and-publish-sdl.yml/badge.svg)](https://github.com/whisthq/SDL/actions/workflows/build-and-publish-sdl.yml)
+
+This repository is Whist's fork of SDL, with a few modifications. We forked SDL so that we can control and optimize it for better integration with the Whist streaming protocol. For instructions on how to build the Whist version SDL for development on your platform, consult [the SDL wiki](https://wiki.libsdl.org/Installation) or the [Building](#Building) section below. Note that we will be using the CMake build tools instead of `./configure`.
+
+## Whist Changelog
+
+- Copy `README.txt` to `README.md` so that GitHub will render it nicely, and update it with our continuous integration workflow
+
+- Allow `Command+W` to passthrough to the application on macOS, instead of being captured by the "Close Window" shortcut
+
+- Enable capturing macOS pinch gestures using Cocoa, to enable pinch-to-zoom on macOS trackpad devices
+
+- Added SDL events for detection window occlusion on macOS. On Windows, we chose not to implement this feature as it requires complex engineering for little benefits.
+
+- Created a GitHub Actions workflows, `build-and-publish-sdl.yml`, to build, test and publish on Windows, macOS and Linux Ubuntu
+
+- Added SDL hint for setting the SDL window and title bar to be integrated within the SDL window, on macOS
+
+- Fixed an issue with watching videos on the Whist remote browser when the SDL window is in fullscreen mode
+
+- Added an option to set a flag specifying a Cmd+Q force quitting on macOS when exiting the SDL application, to be passed to a frontend framework like Electron
+
+- Added a new function `SDL_CreateTextureFromHandle()` to create SDL textures backed by hardware frames already on the GPU. This allows us to directly pass textures to the renderer instead of copying to a single, repeatedly rendered texture. This is implemented for D3D11 textures on Windows and Metal textures / Core Video buffers on macOS.
+
+- Force SDL to render the sRGB color profile on macOS, to make colors match native macOS more closely
+
+## Development
+
+Before building or modifying the code, you should pull the latest changes from the public [`libsdl-org/SDL`](https://github.com/libsdl-org/SDL) repository that this repository is forked from. To set up your repository, follow these steps:
+
+1. Clone and enter the repository
+
+```
+git clone https://github.com/whisthq/SDL && cd SDL
+```
+
+2. Add the upstream repository as a remote
+
+```
+git remote add upstream https://github.com/libsdl-org/SDL
+```
+
+3. Disable pushing to upstream SDL (ensures that git will push to `whisthq/SDL` instead of erroring out)
+
+```
+git remote set-url --push upstream DISABLE
+```
+
+After this, you should be able to list your remotes with `git remote -v` if you ever need to debug.
+
+Since SDL is quite an active project, we will eventually need to work with the latest code. Meanwhile, we need to make sure that our own repository has a sane commit history -- we cannot simply periodically merge the latest SDL on top of our own modifications.
+
+Instead, perform the following steps to incorporate changes from upstream:
+
+1. Fetch the latest changes to the `upstream` remote
+
+```
+git fetch upstream
+```
+
+2. Rebase on top of your current work
+
+```
+git rebase upstream/main
+# git rebase upstream/<desired branch> for other upstream branches
+```
+
+3. Resolve merge conflicts, if any arise, and push to the Whist SDL repository
+
+```
+git push origin <current branch>
+```
+
+## Building
+
+For most purposes, we need only build the `SDL2-Static` target. As with our other C projects, we prefer to build this using CMake as it is a tool we understand well, rather than the `./configure` script that is also included.
+
+We derive the CMake flags as follows. CMake requires an out-of-tree build, meaning we must create a folder `mkdir build` and specify that folder via `-B build`. Unless you need debugging symbols, we should build an optimized release build via `-D CMAKE_BUILD_TYPE=Release`. Our deployment pipeline will always build an optimized release build.
+
+On Windows, SDL2 assumes that we have no access to standard functions like `memcpy`, and tries to define them for us. This is an issue since the Whist Protocol already does the same, leading to multiple defines. To avoid this, we specify `-D HAVE_LIBC=ON`. To streamline the build, we also specify `-D DIRECTX=OFF` since we don't need it for SDL2. Also, on Windows we must generate NMake Makefiles via `-G "NMake Makefiles"`.
+
+Putting it all together, we build as follows:
+
+```
+mkdir build
+cmake -S . -B build -D HAVE_LIBC=ON -D DIRECTX=OFF -D CMAKE_BUILD_TYPE=Release # -G "NMake Makefiles" on Windows
+cd build
+make SDL2-Static # nmake on Windows
+```
+
+When configuring this way, the non-static targets may fail, so make sure to only make `SDL2-Static`! Once built, the static binary will be in `build/libSDL2.a`, or `build\SDL2-static.lib` on Windows.
+
+For more complete instructions on how to build the Whist SDL for a wider variety of platforms and with far more granular settings, consult [the SDL wiki](https://wiki.libsdl.org/Installation). Whenever possible, we prefer to use the CMake setup instead of `./configure`.
+
+## Publishing
+
+For every push to `main`, for instance when we pull the latest changes from upstream or if we make changes to SDL and merge to `main`, the static version of SDL on Windows, macOS and Linux Ubuntu will be built and published to AWS S3, via the GitHub Actions workflow `.github/workflows/build-and-publish-sdl.yml`, from where the Whist protocol retrieves its libraries. The newly-uploaded SDL libraries will be automatically deployed with the next `whisthq/whist` update. **Only stable changes should make it to `main`.**
+
+See the [Changelog](#Changelog) above for the list of changes on top of the public version of SDL that are incorporated in our internal Whist version of SDL.
+
+---
+
+SDL README
+=============
+
+ Simple DirectMedia Layer
+
+ (SDL)
+
+ Version 2.0
+
+---
https://www.libsdl.org/
diff -ruBbN '--exclude=.git' SDL-2.0.22/README-SDL.txt SDL-whisthq/README-SDL.txt
--- SDL-2.0.22/README-SDL.txt 2024-08-01 00:22:26.370135456 -0400
+++ SDL-whisthq/README-SDL.txt 1969-12-31 19:00:00.000000000 -0500
@@ -1,13 +0,0 @@
-
-Please distribute this file with the SDL runtime environment:
-
-The Simple DirectMedia Layer (SDL for short) is a cross-platform library
-designed to make it easy to write multi-media software, such as games
-and emulators.
-
-The Simple DirectMedia Layer library source code is available from:
-https://www.libsdl.org/
-
-This library is distributed under the terms of the zlib license:
-http://www.zlib.net/zlib_license.html
-
diff -ruBbN '--exclude=.git' SDL-2.0.22/SECURITY.md SDL-whisthq/SECURITY.md
--- SDL-2.0.22/SECURITY.md 1969-12-31 19:00:00.000000000 -0500
+++ SDL-whisthq/SECURITY.md 2024-08-01 00:21:19.889038316 -0400
@@ -0,0 +1,10 @@
+# Security Policy
+
+## Supported Versions
+
+Only the latest version version is supported with security updates.
+
+## Reporting a Vulnerability
+
+To report a vulnerability as a developer, open a GitHub Issue on this repository. To
+report a vulnerability as a user, email [email protected].
diff -ruBbN '--exclude=.git' SDL-2.0.22/src/events/SDL_events.c SDL-whisthq/src/events/SDL_events.c
--- SDL-2.0.22/src/events/SDL_events.c 2024-08-01 00:24:44.668417967 -0400
+++ SDL-whisthq/src/events/SDL_events.c 2024-08-01 00:21:19.981039834 -0400
@@ -1336,6 +1336,21 @@
return (posted);
}
+// Whist: Added to facilitate SDL_SendQuitApp() implementation
+int
+SDL_SendQuitEvent(SDL_bool quit_app) {
+ int posted;
+
+ posted = 0;
+ if (SDL_GetEventState(SDL_QUIT) == SDL_ENABLE) {
+ SDL_Event event;
+ event.type = SDL_QUIT;
+ event.quit.quit_app = quit_app;
+ posted = (SDL_PushEvent(&event) > 0);
+ }
+ return (posted);
+}
+
int
SDL_SendSysWMEvent(SDL_SysWMmsg * message)
{
diff -ruBbN '--exclude=.git' SDL-2.0.22/src/events/SDL_events_c.h SDL-whisthq/src/events/SDL_events_c.h
--- SDL-2.0.22/src/events/SDL_events_c.h 2024-08-01 00:22:36.086295807 -0400
+++ SDL-whisthq/src/events/SDL_events_c.h 2024-08-01 00:21:19.981039834 -0400
@@ -44,11 +44,16 @@
extern void SDL_QuitInterrupt(void);
extern int SDL_SendAppEvent(SDL_EventType eventType);
+// Whist: Added to facilitate SDL_SendQuitApp() implementation
+extern int SDL_SendQuitEvent(SDL_bool quit_app);
extern int SDL_SendSysWMEvent(SDL_SysWMmsg * message);
extern int SDL_SendKeymapChangedEvent(void);
extern int SDL_SendLocaleChangedEvent(void);
extern int SDL_SendQuit(void);
+// Whist: Call this function if the quit should propagate to quitting
+// the macOS application.
+extern int SDL_SendQuitApp(void);
extern int SDL_EventsInit(void);
extern void SDL_EventsQuit(void);
diff -ruBbN '--exclude=.git' SDL-2.0.22/src/events/SDL_mouse.c SDL-whisthq/src/events/SDL_mouse.c
--- SDL-2.0.22/src/events/SDL_mouse.c 2024-08-01 00:24:44.668417967 -0400
+++ SDL-whisthq/src/events/SDL_mouse.c 2024-08-01 00:21:19.981039834 -0400
@@ -746,6 +746,7 @@
event.wheel.preciseX = x;
event.wheel.preciseY = y;
event.wheel.direction = (Uint32)direction;
+ event.wheel.momentum_phase = mouse->scroll_momentum_phase;
posted = (SDL_PushEvent(&event) > 0);
}
return posted;
diff -ruBbN '--exclude=.git' SDL-2.0.22/src/events/SDL_mouse_c.h SDL-whisthq/src/events/SDL_mouse_c.h
--- SDL-2.0.22/src/events/SDL_mouse_c.h 2024-08-01 00:24:44.668417967 -0400
+++ SDL-whisthq/src/events/SDL_mouse_c.h 2024-08-01 00:21:19.981039834 -0400
@@ -107,6 +107,8 @@
SDL_bool capture_desired;
SDL_Window *capture_window;
+ SDL_MouseWheelMomentumPhase scroll_momentum_phase;
+
/* Data for input source state */
int num_sources;
SDL_MouseInputSource *sources;
diff -ruBbN '--exclude=.git' SDL-2.0.22/src/events/SDL_quit.c SDL-whisthq/src/events/SDL_quit.c
--- SDL-2.0.22/src/events/SDL_quit.c 2024-08-01 00:22:36.086295807 -0400
+++ SDL-whisthq/src/events/SDL_quit.c 2024-08-01 00:21:19.981039834 -0400
@@ -203,7 +203,18 @@
#ifdef HAVE_SIGNAL_SUPPORT
send_quit_pending = SDL_FALSE;
#endif
- return SDL_SendAppEvent(SDL_QUIT);
+ return SDL_SendQuitEvent(SDL_FALSE);
+}
+
+// Whist: Call this function if the quit should propagate to quitting
+// the macOS application.
+int
+SDL_SendQuitApp(void)
+{
+#ifdef HAVE_SIGNAL_SUPPORT
+ send_quit_pending = SDL_FALSE;
+#endif
+ return SDL_SendQuitEvent(SDL_TRUE);
}
/* vi: set ts=4 sw=4 expandtab: */
diff -ruBbN '--exclude=.git' SDL-2.0.22/src/events/SDL_touch.c SDL-whisthq/src/events/SDL_touch.c
--- SDL-2.0.22/src/events/SDL_touch.c 2024-08-01 00:24:44.668417967 -0400
+++ SDL-whisthq/src/events/SDL_touch.c 2024-08-01 00:21:19.981039834 -0400
@@ -493,4 +493,19 @@
SDL_GestureQuit();
}
+int
+SDL_SendPinch(SDL_Window* window, float magnification, float scroll_amount)
+{
+ int posted = 0;
+ if (SDL_GetEventState(SDL_PINCH) == SDL_ENABLE) {
+ SDL_Event event;
+ event.pinch.type = SDL_PINCH;
+ event.pinch.magnification = magnification;
+ event.pinch.scroll_amount = scroll_amount;
+ event.pinch.windowID = window ? SDL_GetWindowID(window) : 0;
+ posted = (SDL_PushEvent(&event) > 0);
+ }
+ return posted;
+}
+
/* vi: set ts=4 sw=4 expandtab: */
diff -ruBbN '--exclude=.git' SDL-2.0.22/src/events/SDL_touch_c.h SDL-whisthq/src/events/SDL_touch_c.h
--- SDL-2.0.22/src/events/SDL_touch_c.h 2024-08-01 00:24:44.668417967 -0400
+++ SDL-whisthq/src/events/SDL_touch_c.h 2024-08-01 00:21:19.981039834 -0400
@@ -52,6 +52,8 @@
extern int SDL_SendTouchMotion(SDL_TouchID id, SDL_FingerID fingerid, SDL_Window * window,
float x, float y, float pressure);
+extern int SDL_SendPinch(SDL_Window* window, float magnification, float scroll_amount);
+
/* Remove a touch */
extern void SDL_DelTouch(SDL_TouchID id);
diff -ruBbN '--exclude=.git' SDL-2.0.22/src/events/SDL_windowevents.c SDL-whisthq/src/events/SDL_windowevents.c
--- SDL-2.0.22/src/events/SDL_windowevents.c 2024-08-01 00:24:44.668417967 -0400
+++ SDL-whisthq/src/events/SDL_windowevents.c 2024-08-01 00:21:19.981039834 -0400
@@ -174,6 +174,18 @@
window->flags &= ~SDL_WINDOW_INPUT_FOCUS;
SDL_OnWindowFocusLost(window);
break;
+ case SDL_WINDOWEVENT_OCCLUDED:
+ if (window->flags & SDL_WINDOW_OCCLUDED) {
+ return 0;
+ }
+ window->flags |= SDL_WINDOW_OCCLUDED;
+ break;
+ case SDL_WINDOWEVENT_UNOCCLUDED:
+ if (!(window->flags & SDL_WINDOW_OCCLUDED)) {
+ return 0;
+ }
+ window->flags &= ~SDL_WINDOW_OCCLUDED;
+ break;
}
/* Post the event, if desired */
diff -ruBbN '--exclude=.git' SDL-2.0.22/src/render/direct3d11/SDL_render_d3d11.c SDL-whisthq/src/render/direct3d11/SDL_render_d3d11.c
--- SDL-2.0.22/src/render/direct3d11/SDL_render_d3d11.c 2024-08-01 00:24:44.684418231 -0400
+++ SDL-whisthq/src/render/direct3d11/SDL_render_d3d11.c 2024-08-01 00:21:20.009040297 -0400
@@ -1247,6 +1247,95 @@
return 0;
}
+static int
+D3D11_CreateTextureFromHandle(SDL_Renderer * renderer, SDL_Texture * texture, void * handle)
+{
+ D3D11_RenderData *rendererData = (D3D11_RenderData *) renderer->driverdata;
+ D3D11_TextureData *textureData;
+ DXGI_FORMAT textureFormat = SDLPixelFormatToDXGIFormat(texture->format);
+ D3D11_SHADER_RESOURCE_VIEW_DESC resourceViewDesc;
+ D3D11_TEXTURE2D_DESC textureDesc;
+ HRESULT result;
+
+ SDL_TextureHandleD3D11 *input = handle;
+ ID3D11Texture2D *d3d11_texture = input->texture;
+ int subresource_index = input->index;
+
+ if (textureFormat == DXGI_FORMAT_UNKNOWN) {
+ return SDL_SetError("%s, An unsupported SDL pixel format (0x%x) was specified",
+ __FUNCTION__, texture->format);
+ }
+
+ ID3D11Texture2D_GetDesc(d3d11_texture, &textureDesc);
+
+ if (texture->format == SDL_PIXELFORMAT_NV12) {
+ if (textureDesc.Format != DXGI_FORMAT_NV12) {
+ return SDL_SetError("%s, Texture format is not NV12", __FUNCTION__);
+ }
+ } else {
+ if (textureDesc.Format != textureFormat) {
+ return SDL_SetError("%s, Texture format does not match", __FUNCTION__);
+ }
+ }
+
+ textureData = (D3D11_TextureData*) SDL_calloc(1, sizeof(*textureData));
+ if (!textureData) {
+ SDL_OutOfMemory();
+ return -1;
+ }
+ textureData->scaleMode = (texture->scaleMode == SDL_ScaleModeNearest) ? D3D11_FILTER_MIN_MAG_MIP_POINT : D3D11_FILTER_MIN_MAG_MIP_LINEAR;
+
+ // This reference is added so that DestroyTexture can release it
+ // again cleanly. The user will still need to hold their own
+ // reference if they intend to do anything else with the texture.
+ ID3D11Texture2D_AddRef(d3d11_texture);
+ textureData->mainTexture = d3d11_texture;
+
+ texture->driverdata = textureData;
+
+ if (texture->format == SDL_PIXELFORMAT_NV12) {
+ textureData->nv12 = SDL_TRUE;
+ // We don't set textureData->mainTextureNV - both planes are in
+ // the single input texture.
+ }
+
+ resourceViewDesc.Format = textureFormat;
+ resourceViewDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2DARRAY;
+ resourceViewDesc.Texture2DArray.MostDetailedMip = 0;
+ resourceViewDesc.Texture2DArray.MipLevels = 1;
+ resourceViewDesc.Texture2DArray.FirstArraySlice = subresource_index;
+ resourceViewDesc.Texture2DArray.ArraySize = 1;
+ result = ID3D11Device_CreateShaderResourceView(rendererData->d3dDevice,
+ (ID3D11Resource *)textureData->mainTexture,
+ &resourceViewDesc,
+ &textureData->mainTextureResourceView
+ );
+ if (FAILED(result)) {
+ D3D11_DestroyTexture(renderer, texture);
+ WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateShaderResourceView"), result);
+ return -1;
+ }
+
+ if (textureData->nv12) {
+ D3D11_SHADER_RESOURCE_VIEW_DESC nvResourceViewDesc = resourceViewDesc;
+
+ nvResourceViewDesc.Format = DXGI_FORMAT_R8G8_UNORM;
+
+ result = ID3D11Device_CreateShaderResourceView(rendererData->d3dDevice,
+ (ID3D11Resource *)textureData->mainTexture,
+ &nvResourceViewDesc,
+ &textureData->mainTextureResourceViewNV
+ );
+ if (FAILED(result)) {
+ D3D11_DestroyTexture(renderer, texture);
+ WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateShaderResourceView"), result);
+ return -1;
+ }
+ }
+
+ return 0;
+}
+
static void
D3D11_DestroyTexture(SDL_Renderer * renderer,
SDL_Texture * texture)
@@ -2365,6 +2454,7 @@
renderer->WindowEvent = D3D11_WindowEvent;
renderer->SupportsBlendMode = D3D11_SupportsBlendMode;
renderer->CreateTexture = D3D11_CreateTexture;
+ renderer->CreateTextureFromHandle = D3D11_CreateTextureFromHandle;
renderer->UpdateTexture = D3D11_UpdateTexture;
#if SDL_HAVE_YUV
renderer->UpdateTextureYUV = D3D11_UpdateTextureYUV;
diff -ruBbN '--exclude=.git' SDL-2.0.22/src/render/metal/SDL_render_metal.m SDL-whisthq/src/render/metal/SDL_render_metal.m
--- SDL-2.0.22/src/render/metal/SDL_render_metal.m 2024-08-01 00:24:44.684418231 -0400
+++ SDL-whisthq/src/render/metal/SDL_render_metal.m 2024-08-01 00:21:20.013040362 -0400
@@ -30,6 +30,7 @@
#include <Availability.h>
#import <Metal/Metal.h>
#import <QuartzCore/CAMetalLayer.h>
+#import <VideoToolbox/VideoToolbox.h>
#ifdef __MACOSX__
#import <AppKit/NSWindow.h>
@@ -139,6 +140,7 @@
@property (nonatomic, assign) METAL_ShaderPipelines *activepipelines;
@property (nonatomic, assign) METAL_ShaderPipelines *allpipelines;
@property (nonatomic, assign) int pipelinescount;
+ @property (nonatomic, assign) CVMetalTextureCacheRef cache; // ADDED BY WHIST
@end
@implementation METAL_RenderData
@@ -686,6 +688,114 @@
return 0;
}}
+static int
+METAL_CreateTextureFromHandle(SDL_Renderer * renderer, SDL_Texture * texture, void * handle)
+{ @autoreleasepool {
+ METAL_RenderData *data = (__bridge METAL_RenderData *) renderer->driverdata;
+ MTLPixelFormat pixfmt;
+ switch (texture->format) {
+ case SDL_PIXELFORMAT_NV12:
+ case SDL_PIXELFORMAT_NV21:
+ pixfmt = MTLPixelFormatR8Unorm;
+ break;
+ default:
+ return SDL_SetError("Texture format %s not supported by CreateTextureFromHandle", SDL_GetPixelFormatName(texture->format));
+ }
+
+ // create the texture descriptor for renders, copies
+
+ MTLTextureDescriptor *mtltexdesc = [MTLTextureDescriptor texture2DDescriptorWithPixelFormat:pixfmt
+ width:(NSUInteger)texture->w height:(NSUInteger)texture->h mipmapped:NO];
+
+ /* Not available in iOS 8. */
+ if ([mtltexdesc respondsToSelector:@selector(usage)]) {
+ if (texture->access == SDL_TEXTUREACCESS_TARGET) {
+ mtltexdesc.usage = MTLTextureUsageShaderRead | MTLTextureUsageRenderTarget;
+ } else {
+ mtltexdesc.usage = MTLTextureUsageShaderRead;
+ }
+ }
+ // The + 1 is to round up. The codec will always produce width/height divisible
+ // by two, but if some pixels are cropped the luma plane size could be odd after
+ // that and you then need a whole extra sample on the chroma plane to use half of.
+ mtltexdesc.pixelFormat = MTLPixelFormatRG8Unorm;
+ mtltexdesc.width = (texture->w + 1) / 2;
+ mtltexdesc.height = (texture->h + 1) / 2;
+
+ // Create texturedata
+ METAL_TextureData *texturedata = [[METAL_TextureData alloc] init];
+ if (texture->scaleMode == SDL_ScaleModeNearest) {
+ texturedata.mtlsampler = data.mtlsamplernearest;
+ } else {
+ texturedata.mtlsampler = data.mtlsamplerlinear;
+ }
+
+ // Create Y and UV metal textures from VideoToolbox frame
+ CVPixelBufferRef frame_data = (CVPixelBufferRef) handle;
+ // the width/height is different from the texture width/height which is aligned for FFmpeg reasons
+ int width = CVPixelBufferGetWidth(frame_data);
+ int height = CVPixelBufferGetHeight(frame_data);
+ SDL_Rect UVrect = {0, 0, (width + 1) / 2, (height + 1) / 2};
+ CVReturn status;
+
+ // create wrappers around YPlane and UVplane
+ CVMetalTextureRef cv_y_texture = nil;
+ CVMetalTextureRef cv_uv_texture = nil;
+ status = CVMetalTextureCacheCreateTextureFromImage(kCFAllocatorDefault, data.cache,
+ frame_data, NULL, MTLPixelFormatR8Unorm, width, height, 0, &cv_y_texture);
+ if (status != kCVReturnSuccess || cv_y_texture == nil) {
+ return SDL_SetError("Failed to create texture from Y pixel buffer with status %d", status);
+ }
+ status = CVMetalTextureCacheCreateTextureFromImage(kCFAllocatorDefault, data.cache,
+ frame_data, NULL, MTLPixelFormatRG8Unorm, UVrect.w, UVrect.h, 1, &cv_uv_texture);
+ if (status != kCVReturnSuccess || cv_uv_texture == nil) {
+ return SDL_SetError("Failed to create texture from UV pixel buffer with status %d", status);
+ }
+
+ id<MTLTexture> mtltexture = CVMetalTextureGetTexture(cv_y_texture);
+ id<MTLTexture> mtltexture_uv = CVMetalTextureGetTexture(cv_uv_texture);
+
+ // https://developer.apple.com/forums/thread/694939 according to this,
+ // there should actually be no concurrent GPU access as long as everyone
+ // is using Core Video stuff! (between FFmpeg and SDL)
+ texturedata.hasdata = YES;
+ texturedata.mtltexture = [mtltexture retain];
+ texturedata.mtltexture_uv = [mtltexture_uv retain];
+
+ CVBufferRelease(cv_y_texture);
+ CVBufferRelease(cv_uv_texture);
+
+ // also kept in case we need to handle YUV formats
+ texturedata.yuv = NO;
+ texturedata.nv12 = YES;
+
+ if (texture->format == SDL_PIXELFORMAT_NV12) {
+ texturedata.fragmentFunction = SDL_METAL_FRAGMENT_NV12;
+ } else if (texture->format == SDL_PIXELFORMAT_NV21) {
+ texturedata.fragmentFunction = SDL_METAL_FRAGMENT_NV21;
+ }
+
+ size_t offset = 0;
+ SDL_YUV_CONVERSION_MODE mode = SDL_GetYUVConversionModeForResolution(texture->w, texture->h);
+ switch (mode) {
+ case SDL_YUV_CONVERSION_JPEG: offset = CONSTANTS_OFFSET_DECODE_JPEG; break;
+ case SDL_YUV_CONVERSION_BT601: offset = CONSTANTS_OFFSET_DECODE_BT601; break;
+ case SDL_YUV_CONVERSION_BT709: offset = CONSTANTS_OFFSET_DECODE_BT709; break;
+ default: offset = 0; break;
+ }
+ texturedata.conversionBufferOffset = offset;
+
+ texture->driverdata = (void*)CFBridgingRetain(texturedata);
+
+#if !__has_feature(objc_arc)
+ [texturedata release];
+ [mtltexture release];
+ [mtltexture_uv release];
+#endif
+
+ return 0;
+}}
+
static void
METAL_UploadTextureData(id<MTLTexture> texture, SDL_Rect rect, int slice,
const void * pixels, int pitch)
@@ -1577,6 +1687,10 @@
if (data.mtlcmdencoder != nil) {
[data.mtlcmdencoder endEncoding];
}
+ // ADDED BY WHIST
+ if (data.cache != NULL) {
+ CFRelease(data.cache);
+ }
DestroyAllPipelines(data.allpipelines, data.pipelinescount);
@@ -1763,6 +1877,15 @@
data.mtlcmdqueue.label = @"SDL Metal Renderer";
data.mtlpassdesc = [MTLRenderPassDescriptor renderPassDescriptor];
+ // ADDED BY WHIST: texture cache
+ CVMetalTextureCacheRef cache = NULL;
+ CVReturn status = CVMetalTextureCacheCreate(kCFAllocatorDefault, NULL, data.mtldevice, NULL, &cache);
+ if (status != kCVReturnSuccess || cache == NULL) {
+ SDL_SetError("Failed to create texture cache");
+ return NULL;
+ }
+ data.cache = cache;
+
NSError *err = nil;
// The compiled .metallib is embedded in a static array in a header file
@@ -1888,6 +2011,7 @@
renderer->GetOutputSize = METAL_GetOutputSize;
renderer->SupportsBlendMode = METAL_SupportsBlendMode;
renderer->CreateTexture = METAL_CreateTexture;
+ renderer->CreateTextureFromHandle = METAL_CreateTextureFromHandle;
renderer->UpdateTexture = METAL_UpdateTexture;
#if SDL_HAVE_YUV
renderer->UpdateTextureYUV = METAL_UpdateTextureYUV;
diff -ruBbN '--exclude=.git' SDL-2.0.22/src/render/SDL_render.c SDL-whisthq/src/render/SDL_render.c
--- SDL-2.0.22/src/render/SDL_render.c 2024-08-01 00:24:44.680418165 -0400
+++ SDL-whisthq/src/render/SDL_render.c 2024-08-01 00:21:20.009040297 -0400
@@ -1479,6 +1479,50 @@
return texture;
}
+SDL_Texture *
+SDL_CreateTextureFromHandle(SDL_Renderer * renderer, Uint32 format,
+ int access, int w, int h, void * handle)
+{
+ SDL_Texture *texture;
+
+ CHECK_RENDERER_MAGIC(renderer, NULL);
+
+ if (!renderer->CreateTextureFromHandle) {
+ SDL_SetError("CreateTextureFromHandle is not supported by %s.",
+ renderer->info.name);
+ return NULL;
+ }
+
+ texture = (SDL_Texture *) SDL_calloc(1, sizeof(*texture));
+ if (!texture) {
+ SDL_OutOfMemory();
+ return NULL;
+ }
+ texture->magic = &texture_magic;
+ texture->format = format;
+ texture->access = access;
+ texture->w = w;
+ texture->h = h;
+ texture->color.r = 255;
+ texture->color.g = 255;
+ texture->color.b = 255;
+ texture->color.a = 255;
+ texture->scaleMode = SDL_GetScaleMode();
+ texture->renderer = renderer;
+ texture->next = renderer->textures;
+ if (renderer->textures) {
+ renderer->textures->prev = texture;
+ }
+ renderer->textures = texture;
+
+ if (renderer->CreateTextureFromHandle(renderer, texture, handle) < 0) {
+ SDL_DestroyTexture(texture);
+ return NULL;
+ }
+
+ return texture;
+}
+
int
SDL_QueryTexture(SDL_Texture * texture, Uint32 * format, int *access,
int *w, int *h)
diff -ruBbN '--exclude=.git' SDL-2.0.22/src/render/SDL_sysrender.h SDL-whisthq/src/render/SDL_sysrender.h
--- SDL-2.0.22/src/render/SDL_sysrender.h 2024-08-01 00:24:44.680418165 -0400
+++ SDL-whisthq/src/render/SDL_sysrender.h 2024-08-01 00:21:20.009040297 -0400
@@ -144,6 +144,7 @@
int (*GetOutputSize) (SDL_Renderer * renderer, int *w, int *h);
SDL_bool (*SupportsBlendMode)(SDL_Renderer * renderer, SDL_BlendMode blendMode);
int (*CreateTexture) (SDL_Renderer * renderer, SDL_Texture * texture);
+ int (*CreateTextureFromHandle) (SDL_Renderer * renderer, SDL_Texture * texture, void * handle);
int (*QueueSetViewport) (SDL_Renderer * renderer, SDL_RenderCommand *cmd);
int (*QueueSetDrawColor) (SDL_Renderer * renderer, SDL_RenderCommand *cmd);
int (*QueueDrawPoints) (SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FPoint * points,
diff -ruBbN '--exclude=.git' SDL-2.0.22/src/video/cocoa/SDL_cocoaevents.m SDL-whisthq/src/video/cocoa/SDL_cocoaevents.m
--- SDL-2.0.22/src/video/cocoa/SDL_cocoaevents.m 2024-08-01 00:22:36.170297193 -0400
+++ SDL-whisthq/src/video/cocoa/SDL_cocoaevents.m 2024-08-01 00:21:20.037040758 -0400
@@ -68,7 +68,8 @@
// Override terminate to handle Quit and System Shutdown smoothly.
- (void)terminate:(id)sender
{
- SDL_SendQuit();
+ // Whist: We only want to exit the cocoa application on this event, not on regular SDL_SendQuit()
+ SDL_SendQuitApp();
}
static SDL_bool s_bShouldHandleEventsInSDLApplication = SDL_FALSE;
@@ -116,7 +117,7 @@
+ (void)registerUserDefaults
{
NSDictionary *appDefaults = [[NSDictionary alloc] initWithObjectsAndKeys:
- [NSNumber numberWithBool:NO], @"AppleMomentumScrollSupported",
+ [NSNumber numberWithBool:YES], @"AppleMomentumScrollSupported",
[NSNumber numberWithBool:NO], @"ApplePressAndHoldEnabled",
[NSNumber numberWithBool:YES], @"ApplePersistenceIgnoreState",
nil];
@@ -382,6 +383,9 @@
appleMenu = [[NSMenu alloc] initWithTitle:@""];
/* Add menu items */
+ // Whist: We disable this since we want Cmd+W events to propagate and be handled by the server.
+ // [windowMenu addItemWithTitle:@"Close" action:@selector(performClose:) keyEquivalent:@"w"];
+
title = [@"About " stringByAppendingString:appName];
[appleMenu addItemWithTitle:title action:@selector(orderFrontStandardAboutPanel:) keyEquivalent:@""];
@@ -428,8 +432,6 @@
windowMenu = [[NSMenu alloc] initWithTitle:@"Window"];
/* Add menu items */
- [windowMenu addItemWithTitle:@"Close" action:@selector(performClose:) keyEquivalent:@"w"];
-
[windowMenu addItemWithTitle:@"Minimize" action:@selector(performMiniaturize:) keyEquivalent:@"m"];
[windowMenu addItemWithTitle:@"Zoom" action:@selector(performZoom:) keyEquivalent:@""];
diff -ruBbN '--exclude=.git' SDL-2.0.22/src/video/cocoa/SDL_cocoametalview.m SDL-whisthq/src/video/cocoa/SDL_cocoametalview.m
--- SDL-2.0.22/src/video/cocoa/SDL_cocoametalview.m 2024-08-01 00:22:36.170297193 -0400
+++ SDL-whisthq/src/video/cocoa/SDL_cocoametalview.m 2024-08-01 00:21:20.037040758 -0400
@@ -74,7 +74,19 @@
*/
- (CALayer*)makeBackingLayer
{
- return [self.class.layerClass layer];
+ // Modified by Whist
+ // Removed:
+ // return [self.class.layerClass layer];
+ // Added:
+ CAMetalLayer* metalLayer = [CAMetalLayer new];
+
+ // List of color spaces at https://developer.apple.com/documentation/coregraphics/cgcolorspace/color_space_names?language=objc
+ // Or, you can do colorspace = [[[NSScreen mainScreen] colorSpace] CGColorSpace]; for the current display's color space
+ // There are a variety of other ways to generate CGColorSpaces
+ CGColorSpaceRef colorspace = CGColorSpaceCreateWithName(kCGColorSpaceSRGB);
+ metalLayer.colorspace = colorspace;
+ CGColorSpaceRelease(colorspace);
+ return metalLayer;
}
- (instancetype)initWithFrame:(NSRect)frame
diff -ruBbN '--exclude=.git' SDL-2.0.22/src/video/cocoa/SDL_cocoamouse.m SDL-whisthq/src/video/cocoa/SDL_cocoamouse.m
--- SDL-2.0.22/src/video/cocoa/SDL_cocoamouse.m 2024-08-01 00:24:44.700418495 -0400
+++ SDL-whisthq/src/video/cocoa/SDL_cocoamouse.m 2024-08-01 00:21:20.037040758 -0400
@@ -463,8 +463,13 @@
}
SDL_MouseID mouseID = mouse->mouseID;
- CGFloat x = -[event deltaX];
- CGFloat y = [event deltaY];
+
+ // Word has it that scrollingDeltaX of 80 corresponds to
+ // one discrete mouse tick, at least for applications like Chrome.
+ // Serina, Ming, and Suriya did some manual testing to find that multiplying
+ // by 1.5 yields a more accurate scroll feel, so that's where the 1.5 comes from
+ CGFloat x = -([event scrollingDeltaX] / 80) * 1.5;
+ CGFloat y = ([event scrollingDeltaY] / 80) * 1.5;
SDL_MouseWheelDirection direction = SDL_MOUSEWHEEL_NORMAL;
if ([event respondsToSelector:@selector(isDirectionInvertedFromDevice)]) {
@@ -488,6 +493,31 @@
}
}
+ // Based on the momentumPhase of the scroll, record whether the scroll event is part of a momentum
+ // scroll or not by setting the current mouse scroll momentum phase.
+ // Reference: https://developer.apple.com/documentation/appkit/nsevent/1525439-momentumphase?language=objc
+ switch ([event momentumPhase]) {
+ case NSEventPhaseBegan: {
+ mouse->scroll_momentum_phase = SDL_MOUSEWHEEL_MOMENTUM_BEGIN;
+ break;
+ }
+ case NSEventPhaseStationary:
+ case NSEventPhaseChanged: {
+ mouse->scroll_momentum_phase = SDL_MOUSEWHEEL_MOMENTUM_ACTIVE;
+ break;
+ }
+ case NSEventPhaseEnded:
+ case NSEventPhaseCancelled: {
+ mouse->scroll_momentum_phase = SDL_MOUSEWHEEL_MOMENTUM_END;
+ break;
+ }
+ case NSEventPhaseNone:
+ case NSEventPhaseMayBegin: {
+ mouse->scroll_momentum_phase = SDL_MOUSEWHEEL_MOMENTUM_NONE;
+ break;
+ }
+ }
+
SDL_SendMouseWheel(window, mouseID, x, y, direction);
}
diff -ruBbN '--exclude=.git' SDL-2.0.22/src/video/cocoa/SDL_cocoawindow.h SDL-whisthq/src/video/cocoa/SDL_cocoawindow.h
--- SDL-2.0.22/src/video/cocoa/SDL_cocoawindow.h 2024-08-01 00:22:36.174297260 -0400
+++ SDL-whisthq/src/video/cocoa/SDL_cocoawindow.h 2024-08-01 00:21:20.041040825 -0400
@@ -106,6 +106,7 @@
-(void) touchesMovedWithEvent:(NSEvent *) theEvent;
-(void) touchesEndedWithEvent:(NSEvent *) theEvent;
-(void) touchesCancelledWithEvent:(NSEvent *) theEvent;
+-(void) magnifyWithEvent:(NSEvent *) theEvent;
/* Touch event handling */
-(void) handleTouches:(NSTouchPhase) phase withEvent:(NSEvent*) theEvent;
diff -ruBbN '--exclude=.git' SDL-2.0.22/src/video/cocoa/SDL_cocoawindow.m SDL-whisthq/src/video/cocoa/SDL_cocoawindow.m
--- SDL-2.0.22/src/video/cocoa/SDL_cocoawindow.m 2024-08-01 00:24:44.700418495 -0400
+++ SDL-whisthq/src/video/cocoa/SDL_cocoawindow.m 2024-08-01 00:21:20.041040825 -0400
@@ -284,6 +284,12 @@
return SDL_GetHintBoolean(SDL_HINT_MAC_CTRL_CLICK_EMULATE_RIGHT_CLICK, SDL_FALSE);
}
+static int
+GetHintUseWindowStyleFullStyleContentView()
+{
+ return SDL_GetHintBoolean(SDL_HINT_MAC_USE_WINDOW_STYLE_FULL_SIZE_CONTENT_VIEW, SDL_FALSE);
+}
+
static NSUInteger
GetWindowWindowedStyle(SDL_Window * window)
{
@@ -293,6 +299,9 @@
style = NSWindowStyleMaskBorderless;
} else {
style = (NSWindowStyleMaskTitled|NSWindowStyleMaskClosable|NSWindowStyleMaskMiniaturizable);
+ if (GetHintUseWindowStyleFullStyleContentView()) {
+ style |= NSWindowStyleMaskFullSizeContentView;
+ }
}
if (window->flags & SDL_WINDOW_RESIZABLE) {
style |= NSWindowStyleMaskResizable;
@@ -573,7 +582,7 @@
inFullscreenTransition = YES;
/* you need to be FullScreenPrimary, or toggleFullScreen doesn't work. Unset it again in windowDidExitFullScreen. */
- [nswindow setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
+ [nswindow setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary | NSWindowCollectionBehaviorFullScreenDisallowsTiling];
[nswindow performSelectorOnMainThread: @selector(toggleFullScreen:) withObject:nswindow waitUntilDone:NO];
return YES;
}
@@ -807,6 +816,16 @@
SDL_SendWindowEvent(_data->window, SDL_WINDOWEVENT_RESTORED, 0, 0);
}
+- (void)windowDidChangeOcclusionState:(NSNotification *)aNotification
+{
+ if ([[aNotification object] occlusionState] & NSWindowOcclusionStateVisible) {
+ SDL_SendWindowEvent(_data->window, SDL_WINDOWEVENT_UNOCCLUDED, 0, 0);
+ }
+ else {
+ SDL_SendWindowEvent(_data->window, SDL_WINDOWEVENT_OCCLUDED, 0, 0);
+ }
+}
+
- (void)windowDidBecomeKey:(NSNotification *)aNotification
{
SDL_Window *window = _data->window;
@@ -838,7 +857,8 @@
Cocoa_CheckClipboardUpdate(_data->videodata);
if ((isFullscreenSpace) && ((window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) == SDL_WINDOW_FULLSCREEN_DESKTOP)) {
- [NSMenu setMenuBarVisible:NO];
+ // Whist: We disable this because we do want the menu bar to be visible on hover in triggered fullscreen mode.
+ // [NSMenu setMenuBarVisible:NO];
}
const unsigned int newflags = [NSEvent modifierFlags] & NSEventModifierFlagCapsLock;
@@ -933,7 +953,8 @@
SetWindowStyle(window, [nswindow styleMask] & (~NSWindowStyleMaskResizable));
if ((window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) == SDL_WINDOW_FULLSCREEN_DESKTOP) {
- [NSMenu setMenuBarVisible:NO];
+ // Whist: We disable this because we do want the menu bar to be visible on hover in triggered fullscreen mode.
+ // [NSMenu setMenuBarVisible:NO];
}
pendingWindowOperation = PENDING_OPERATION_NONE;
@@ -1013,9 +1034,9 @@
/* Adjust the fullscreen toggle button and readd menu now that we're here. */
if (window->flags & SDL_WINDOW_RESIZABLE) {
/* resizable windows are Spaces-friendly: they get the "go fullscreen" toggle button on their titlebar. */
- [nswindow setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
+ [nswindow setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary | NSWindowCollectionBehaviorFullScreenDisallowsTiling];
} else {
- [nswindow setCollectionBehavior:NSWindowCollectionBehaviorManaged];
+ [nswindow setCollectionBehavior:NSWindowCollectionBehaviorManaged | NSWindowCollectionBehaviorFullScreenDisallowsTiling];
}
[NSMenu setMenuBarVisible:YES];
@@ -1078,7 +1099,9 @@
-(NSApplicationPresentationOptions)window:(NSWindow *)window willUseFullScreenPresentationOptions:(NSApplicationPresentationOptions)proposedOptions
{
if ((_data->window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) == SDL_WINDOW_FULLSCREEN_DESKTOP) {
- return NSApplicationPresentationFullScreen | NSApplicationPresentationHideDock | NSApplicationPresentationHideMenuBar;
+ // Whist: We disable this because we do want the menu bar to be visible on hover in triggered fullscreen mode.
+ // return NSApplicationPresentationFullScreen | NSApplicationPresentationAutoHideDock | NSApplicationPresentationAutoHideMenuBar;
+ return proposedOptions;
} else {
return proposedOptions;
}
@@ -1404,6 +1427,18 @@
[self handleTouches:NSTouchPhaseCancelled withEvent:theEvent];
}
+- (void)magnifyWithEvent:(NSEvent *) theEvent
+{
+ // The scroll amount is relative to the magnification (a percentage)
+ // and the current height of the window.
+ // Visit `Cocoa_HandleMouseWheel` to understand the division by 80
+ // Ming and Suriya did some manual testing to find that dividing by 2
+ // yields a more accurate zoom feel, so that's where the 2 comes from
+ CGFloat scroll_amount = [theEvent magnification] * _data->window->h / (80 * 2);
+ CGFloat magnification = [theEvent phase] == NSEventPhaseEnded ? 0 : [theEvent magnification];
+ SDL_SendPinch(NULL, magnification, scroll_amount);
+}
+
- (void)handleTouches:(NSTouchPhase) phase withEvent:(NSEvent *) theEvent
{
NSSet *touches = [theEvent touchesMatchingPhase:phase inView:nil];
@@ -1714,7 +1749,7 @@
/* we put FULLSCREEN_DESKTOP windows in their own Space, without a toggle button or menubar, later */
if (window->flags & SDL_WINDOW_RESIZABLE) {
/* resizable windows are Spaces-friendly: they get the "go fullscreen" toggle button on their titlebar. */
- [nswindow setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
+ [nswindow setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary | NSWindowCollectionBehaviorFullScreenDisallowsTiling];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment