Skip to content

Conversation

Jan200101
Copy link
Contributor

builds against the prerelease

wrap is still being worked on

appears to work from simple testing.

@Jan200101
Copy link
Contributor Author

re-tested against the 3.1.1 prerelease
works as intended

@Jan200101
Copy link
Contributor Author

Jan200101 commented Oct 5, 2024

updated to 3.1.3

@Jan200101
Copy link
Contributor Author

SDL 3.2.0 marks the full release of SDL3 🥳
the PR is ready to merge but lacks any support in the CI (due to SDL3 not being available in most distros) and no wrap

@adamharrison
Copy link
Member

This looks good. By default, even with --forcefallback, we still get a dynamically linked SDL (likely because my system doesn't have a static one), but I think that's expected, yes, because we don't have a wrap.

The CI builds it and statically links it in correctly.

I think this is good. I'll look into doing a PR based on this in future where we can just stick the static SDL3 build in build.sh or something. I'm willing to stamp this with the official seal. @Guldoman are you good with this?

@adamharrison
Copy link
Member

Thoughts about adding this as well?

diff --git a/scripts/build.sh b/scripts/build.sh
index 7d73dfdd..fb4c53ea 100755
--- a/scripts/build.sh
+++ b/scripts/build.sh
@@ -183,6 +183,7 @@ main() {
   elif [[ "$build_dir" == "" ]]; then
     build_dir="$(get_default_build_dir)"
   fi
+  build_dir=$(readlink -f $build_dir)
 
   # arch and platform specific stuff
   if [[ "$platform" == "macos" ]]; then
@@ -214,6 +215,21 @@ main() {
     export PATH="$(dirname "$lpm_path"):$PATH"
   fi
 
+  if [[ "$force_fallback" != "" ]]; then
+    git clone --depth=1 --branch release-3.2.8 https://github.com/libsdl-org/SDL.git $build_dir/SDL3 &&
+      pushd $build_dir/SDL3 && mkdir build && cd build && 
+        cmake .. -DCMAKE_BUILD_TYPE=release \
+        -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DSDL_INSTALL=ON -DSDL_INSTALL_DOCS=OFF -DSDL_DEPS_SHARED=ON \
+        -DSDL_DBUS=ON -DSDL_IBUS=ON -DSDL_AUDIO=OFF -DSDL_GPU=OFF -DSDL_RPATH=OFF -DSDL_PIPEWIRE=OFF \
+        -DSDL_CAMERA=OFF -DSDL_JOYSTICK=OFF -DSDL_HAPTIC=OFF -DSDL_HIDAPI=OFF -DSDL_DIALOG=OFF \
+        -DSDL_POWER=OFF -DSDL_SENSOR=OFF -DSDL_VULKAN=OFF -DSDL_LIBUDEV=OFF -DSDL_SHARED=OFF -DSDL_STATIC=ON \
+        -DSDL_X11=ON -DSDL_WAYLAND=ON -DSDL_TESTS=OFF -DSDL_EXAMPLES=OFF -DSDL_VENDOR_INFO=lite-xl \
+        -DCMAKE_INSTALL_PREFIX=$build_dir/prefix && 
+          make -j 8 && make install && popd
+    CFLAGS="-I${build_dir}/prefix/include $CFLAGS"
+    LDFLAGS="-L${build_dir}/prefix/lib $LDFLAGS"
+  fi
+
   CFLAGS=$CFLAGS LDFLAGS=$LDFLAGS meson setup \
     "${build_dir}" \
     --buildtype "$build_type" \

float width = luaL_optnumber(L, 4, 0);
float height = luaL_optnumber(L, 5, 0);

if (width < 1 || height < 1) {
SDL_DisplayMode dm;
SDL_GetCurrentDisplayMode(0, &dm);
const SDL_DisplayMode* dm = SDL_GetCurrentDisplayMode(SDL_GetPrimaryDisplay());
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if we should first create the window then resize it given the display it opened on (SDL_GetDisplayForWindow).

Not really a blocker for this PR, just noting this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this would not work on Wayland

Copy link
Member

Choose a reason for hiding this comment

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

Mmm, I wonder if there's some leeway given that the resize happens just after we create the window.
Or maybe there's a way to know which monitor is active (aka the window will be created on), and use that.

The main issue (that probably currently happens anyways) is that if the user has wildly different sized monitors, the window might get created too big to fit the screen.

Comment on lines 744 to 745
// Seems like SDL doesn't handle clipping as we expect when using
// scaled blitting, so we "clip" manually.
Copy link
Member

Choose a reason for hiding this comment

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

Might be worth it to check if this got fixed.

Copy link
Member

Choose a reason for hiding this comment

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

The code for this did not change in SDL3 (not for the last 5 years).

I looked at the code and I'm not sure what you meant by "doesn't handle clipping as we expect".
It does seemingly clip the rectangles when the coordinates are off-screen,
and your commit was from 2 years ago.

Copy link
Member

Choose a reason for hiding this comment

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

I am talking about my code. At the time I tried to leave the clipping completely to SDL, but it didn't work as expected. I don't remember what was wrong tho.
This is why I'm hoping SDL3 fixed the issue and we can drop the extra code.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, but looking at the code it seems like the kind of clipping we do explicitly is done by SDL_BlitScaled. The code in thst function had not changed since 5 years ago, so I assume whatever problems with it is not fixed.

However, I didn't observe anything off with the clipping. I also don't know what to look for.

Copy link
Member

@Guldoman Guldoman left a comment

Choose a reason for hiding this comment

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

We need to update the docs for the functions that now need a window parameter.

@takase1121
Copy link
Member

Thoughts about adding this as well?

diff --git a/scripts/build.sh b/scripts/build.sh
index 7d73dfdd..fb4c53ea 100755
--- a/scripts/build.sh
+++ b/scripts/build.sh
@@ -183,6 +183,7 @@ main() {
   elif [[ "$build_dir" == "" ]]; then
     build_dir="$(get_default_build_dir)"
   fi
+  build_dir=$(readlink -f $build_dir)
 
   # arch and platform specific stuff
   if [[ "$platform" == "macos" ]]; then
@@ -214,6 +215,21 @@ main() {
     export PATH="$(dirname "$lpm_path"):$PATH"
   fi
 
+  if [[ "$force_fallback" != "" ]]; then
+    git clone --depth=1 --branch release-3.2.8 https://github.com/libsdl-org/SDL.git $build_dir/SDL3 &&
+      pushd $build_dir/SDL3 && mkdir build && cd build && 
+        cmake .. -DCMAKE_BUILD_TYPE=release \
+        -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DSDL_INSTALL=ON -DSDL_INSTALL_DOCS=OFF -DSDL_DEPS_SHARED=ON \
+        -DSDL_DBUS=ON -DSDL_IBUS=ON -DSDL_AUDIO=OFF -DSDL_GPU=OFF -DSDL_RPATH=OFF -DSDL_PIPEWIRE=OFF \
+        -DSDL_CAMERA=OFF -DSDL_JOYSTICK=OFF -DSDL_HAPTIC=OFF -DSDL_HIDAPI=OFF -DSDL_DIALOG=OFF \
+        -DSDL_POWER=OFF -DSDL_SENSOR=OFF -DSDL_VULKAN=OFF -DSDL_LIBUDEV=OFF -DSDL_SHARED=OFF -DSDL_STATIC=ON \
+        -DSDL_X11=ON -DSDL_WAYLAND=ON -DSDL_TESTS=OFF -DSDL_EXAMPLES=OFF -DSDL_VENDOR_INFO=lite-xl \
+        -DCMAKE_INSTALL_PREFIX=$build_dir/prefix && 
+          make -j 8 && make install && popd
+    CFLAGS="-I${build_dir}/prefix/include $CFLAGS"
+    LDFLAGS="-L${build_dir}/prefix/lib $LDFLAGS"
+  fi
+
   CFLAGS=$CFLAGS LDFLAGS=$LDFLAGS meson setup \
     "${build_dir}" \
     --buildtype "$build_type" \

Will do this when I have time in another PR.

@Guldoman Guldoman merged commit 2716f14 into lite-xl:master Apr 7, 2025
9 checks passed
@adamharrison
Copy link
Member

🎉

takase1121 added a commit that referenced this pull request Apr 18, 2025
* update to SDL 3.2.0

* remove SDL wrap

* fix darwin and windows CI

* update build box, correct msys sdl3 dependency

* port leftovers from renderer backend to SDL3

* remove SDL main dep
the main implementation is now included in a header

* main.c: use SDL_main.h

This needs to be included to work.

* ci: use vcpkg and pkgconf to support SDL3 on MSVC

* ci: use 7z to create zip

* renwindow: create texture and surface suitable for the display

* system: remove trailing whitespace

* renderer: fix trailing whitespace

* system: fix checking the wrong argument

* system: port rmdir and stat to SDL3 API

* system: remove unneeded API level check

* system: fix wrong parameter index

* system: make set_window_hit_test and set_window_bordered accept a window

* docs/system: update docs

* system: restore some comments

* docs/system: add missing documentation for system.text_input

* system: use SDL_setenv_unsafe

* system: add back comment for setenv

* system,renderer: remove unnecessary SDL_ClearError calls

---------

Co-authored-by: takase1121 <20792268+takase1121@users.noreply.github.com>
(cherry picked from commit 2716f14)
takase1121 added a commit to takase1121/lite-xl that referenced this pull request Apr 18, 2025
* update to SDL 3.2.0

* remove SDL wrap

* fix darwin and windows CI

* update build box, correct msys sdl3 dependency

* port leftovers from renderer backend to SDL3

* remove SDL main dep
the main implementation is now included in a header

* main.c: use SDL_main.h

This needs to be included to work.

* ci: use vcpkg and pkgconf to support SDL3 on MSVC

* ci: use 7z to create zip

* renwindow: create texture and surface suitable for the display

* system: remove trailing whitespace

* renderer: fix trailing whitespace

* system: fix checking the wrong argument

* system: port rmdir and stat to SDL3 API

* system: remove unneeded API level check

* system: fix wrong parameter index

* system: make set_window_hit_test and set_window_bordered accept a window

* docs/system: update docs

* system: restore some comments

* docs/system: add missing documentation for system.text_input

* system: use SDL_setenv_unsafe

* system: add back comment for setenv

* system,renderer: remove unnecessary SDL_ClearError calls

---------

Co-authored-by: takase1121 <20792268+takase1121@users.noreply.github.com>
(cherry picked from commit 2716f14)
@takase1121 takase1121 moved this from PR to Cherry Picked in Bugfix Release Tracker Apr 18, 2025
takase1121 added a commit that referenced this pull request May 18, 2025
* update to SDL 3.2.0

* remove SDL wrap

* fix darwin and windows CI

* update build box, correct msys sdl3 dependency

* port leftovers from renderer backend to SDL3

* remove SDL main dep
the main implementation is now included in a header

* main.c: use SDL_main.h

This needs to be included to work.

* ci: use vcpkg and pkgconf to support SDL3 on MSVC

* ci: use 7z to create zip

* renwindow: create texture and surface suitable for the display

* system: remove trailing whitespace

* renderer: fix trailing whitespace

* system: fix checking the wrong argument

* system: port rmdir and stat to SDL3 API

* system: remove unneeded API level check

* system: fix wrong parameter index

* system: make set_window_hit_test and set_window_bordered accept a window

* docs/system: update docs

* system: restore some comments

* docs/system: add missing documentation for system.text_input

* system: use SDL_setenv_unsafe

* system: add back comment for setenv

* system,renderer: remove unnecessary SDL_ClearError calls

---------

Co-authored-by: takase1121 <20792268+takase1121@users.noreply.github.com>
(cherry picked from commit 2716f14)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Cherry Picked
Development

Successfully merging this pull request may close these issues.

4 participants