diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..20dfae4 --- /dev/null +++ b/LICENSE @@ -0,0 +1,22 @@ +MIT License + +Copyright (c) Thomas Peterson + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + diff --git a/examples/ServerManager/UI/ServerListTab.php b/examples/ServerManager/UI/ServerListTab.php index 9160e0e..8ca9a91 100644 --- a/examples/ServerManager/UI/ServerListTab.php +++ b/examples/ServerManager/UI/ServerListTab.php @@ -395,6 +395,14 @@ class ServerListTab $serverListTab->table->setData($serverListTab->currentServerData, false); $serverListTab->statusLabel->setText('Server geladen: ' . $result['count'] . ' gefunden'); + if (function_exists('desktop_notify')) { + desktop_notify( + 'Serverliste aktualisiert', + 'Es wurden ' . $result['count'] . ' Server geladen.', + ['timeout' => 4000, 'urgency' => 'normal'], + ); + } + // Danach: pro Server asynchron Docker-Infos und Systemstatus nachladen foreach ($serverListTab->currentServerData as $index => $row) { $ip = $row['ipv4'] ?? ''; @@ -655,8 +663,22 @@ class ServerListTab if ($result['success']) { $serverListTab->statusLabel->setText('Reboot ausgelöst für ' . $name); + if (function_exists('desktop_notify')) { + desktop_notify( + 'Reboot gestartet', + 'Reboot ausgelöst für ' . $name, + ['timeout' => 4000, 'urgency' => 'normal'], + ); + } } elseif (isset($result['error'])) { $serverListTab->statusLabel->setText('Reboot Fehler bei ' . $name . ': ' . $result['error']); + if (function_exists('desktop_notify')) { + desktop_notify( + 'Reboot fehlgeschlagen', + 'Fehler bei ' . $name . ': ' . $result['error'], + ['timeout' => 6000, 'urgency' => 'critical'], + ); + } } }); } @@ -757,8 +779,22 @@ class ServerListTab if ($result['success']) { $serverListTab->statusLabel->setText('Updates ausgeführt für ' . $name); + if (function_exists('desktop_notify')) { + desktop_notify( + 'Update erfolgreich', + 'Updates ausgeführt für ' . $name, + ['timeout' => 5000, 'urgency' => 'normal'], + ); + } } elseif (isset($result['error'])) { $serverListTab->statusLabel->setText('Update Fehler bei ' . $name . ': ' . $result['error']); + if (function_exists('desktop_notify')) { + desktop_notify( + 'Update fehlgeschlagen', + 'Fehler bei ' . $name . ': ' . $result['error'], + ['timeout' => 6000, 'urgency' => 'critical'], + ); + } } }); } diff --git a/php-sdl3/.libs/sdl3.lai b/php-sdl3/.libs/sdl3.lai index b031f4b..d870c9c 100644 --- a/php-sdl3/.libs/sdl3.lai +++ b/php-sdl3/.libs/sdl3.lai @@ -14,7 +14,7 @@ library_names='sdl3.so sdl3.so sdl3.so' old_library='' # Libraries that this one depends upon. -dependency_libs=' -L/usr/local/lib -lSDL3_gfx -lSDL3_image -lSDL3_ttf -lSDL3' +dependency_libs=' -L/usr/local/lib -lSDL3_image -lSDL3_ttf -lSDL3 -lharfbuzz -latomic -lsysprof-capture-4 -lpcre2-8 -lgraphite2 -lfreetype -lbz2 -lpng16 -lm -lz -lbrotlidec -lbrotlicommon -lnotify -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0' # Version information for sdl3. current=0 diff --git a/php-sdl3/.libs/sdl3.o b/php-sdl3/.libs/sdl3.o index dee1ae3..1cb718f 100644 Binary files a/php-sdl3/.libs/sdl3.o and b/php-sdl3/.libs/sdl3.o differ diff --git a/php-sdl3/.libs/sdl3.so b/php-sdl3/.libs/sdl3.so index 8f7238d..ab2993a 100755 Binary files a/php-sdl3/.libs/sdl3.so and b/php-sdl3/.libs/sdl3.so differ diff --git a/php-sdl3/Makefile b/php-sdl3/Makefile index d689883..625eab1 100644 --- a/php-sdl3/Makefile +++ b/php-sdl3/Makefile @@ -18,7 +18,7 @@ exec_prefix = $(prefix) libdir = ${exec_prefix}/lib phpincludedir = /usr/local/include/php CC = cc -CFLAGS = -g -O2 -I/usr/local/include -I/usr/local/include -I/usr/local/include -I/usr/local/include -I/usr/include/harfbuzz -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/sysprof-6 -pthread +CFLAGS = -g -O2 -I/usr/local/include -I/usr/local/include -I/usr/local/include -I/usr/include/harfbuzz -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/sysprof-6 -pthread -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/sysprof-6 -I/usr/include/libpng16 -I/usr/include/x86_64-linux-gnu -I/usr/include/webp -I/usr/include/libmount -I/usr/include/blkid -pthread CFLAGS_CLEAN = $(CFLAGS) -D_GNU_SOURCE CPP = cc -E CPPFLAGS = -DHAVE_CONFIG_H @@ -30,7 +30,7 @@ PHP_EXECUTABLE = /usr/local/bin/php EXTRA_LDFLAGS = EXTRA_LIBS = INCLUDES = -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -LDFLAGS = -L/usr/local/lib -Wl,-rpath,/usr/local/lib -Wl,--enable-new-dtags -lSDL3 -L/usr/local/lib -lSDL3_gfx -Wl,-rpath,/usr/local/lib -Wl,--enable-new-dtags -lSDL3 -L/usr/local/lib -lSDL3_image -Wl,-rpath,/usr/local/lib -Wl,--enable-new-dtags -lSDL3 -L/usr/local/lib -lSDL3_ttf -Wl,-rpath,/usr/local/lib -Wl,--enable-new-dtags -lSDL3 +LDFLAGS = -L/usr/local/lib -Wl,-rpath,/usr/local/lib -Wl,--enable-new-dtags -lSDL3 -pthread -lm -L/usr/local/lib -lSDL3_image -Wl,-rpath,/usr/local/lib -Wl,--enable-new-dtags -lSDL3 -pthread -lm -L/usr/local/lib -lSDL3_ttf -Wl,-rpath,/usr/local/lib -Wl,--enable-new-dtags -lSDL3 -pthread -lm -lharfbuzz -pthread -lm -lz -lz -lm -lz -lbrotlicommon -lglib-2.0 -latomic -lm -pthread -lsysprof-capture-4 -pthread -lpcre2-8 -lgraphite2 -lfreetype -lz -lbz2 -lpng16 -lz -lm -lz -lbrotlidec -lbrotlicommon -lnotify -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 LIBTOOL = $(SHELL) $(top_builddir)/libtool SHELL = /bin/bash INSTALL_HEADERS = diff --git a/php-sdl3/config.h b/php-sdl3/config.h index 788b9a1..e5f07b1 100644 --- a/php-sdl3/config.h +++ b/php-sdl3/config.h @@ -10,6 +10,9 @@ /* Define to 1 if you have the header file. */ #define HAVE_INTTYPES_H 1 +/* Enable libnotify for desktop_notify() */ +#define HAVE_LIBNOTIFY 1 + /* Define to 1 if you have the header file. */ #define HAVE_STDINT_H 1 diff --git a/php-sdl3/config.h.in b/php-sdl3/config.h.in index e2ad4d9..7bb54d7 100644 --- a/php-sdl3/config.h.in +++ b/php-sdl3/config.h.in @@ -9,6 +9,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H +/* Enable libnotify for desktop_notify() */ +#undef HAVE_LIBNOTIFY + /* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H diff --git a/php-sdl3/config.m4 b/php-sdl3/config.m4 index 84e1352..5f4b0ca 100644 --- a/php-sdl3/config.m4 +++ b/php-sdl3/config.m4 @@ -2,10 +2,6 @@ PHP_ARG_WITH(sdl3, [for sdl3 support], [ AS_HELP_STRING([--with-sdl3[=DIR]], [Enable sdl3 support. DIR is the prefix for SDL3 installation.]) ]) -PHP_ARG_WITH(sdl3_gfx, [for sdl3_gfx support], [ -AS_HELP_STRING([--with-sdl3-gfx[=DIR]], [Enable sdl3_gfx support. DIR is the prefix for SDL3_gfx installation.]) -]) - PHP_ARG_WITH(sdl3_image, [for sdl3_image support], [ AS_HELP_STRING([--with-sdl3-image[=DIR]], [Enable sdl3_image support. DIR is the prefix for SDL3_image installation.]) ]) @@ -21,22 +17,19 @@ if test "$PHP_SDL3" != "no"; then PKG_CHECK_MODULES([SDL3], [sdl3 >= 3.0.0], [ CFLAGS="$CFLAGS $SDL3_CFLAGS" - LDFLAGS="$LDFLAGS $SDL3_LIBS" ],[ AC_MSG_ERROR([SDL3 not found. Please check your installation or use --with-sdl3=/path/to/sdl3]) ]) - if test "$PHP_SDL3_GFX" != "no"; then - if test -d "$PHP_SDL3_GFX"; then - PKG_CONFIG_PATH="$PHP_SDL3_GFX/lib/pkgconfig:$PHP_SDL3_GFX/share/pkgconfig:$PKG_CONFIG_PATH" - fi - - PKG_CHECK_MODULES([SDL3_GFX], [sdl3-gfx >= 1.0.0], [ - CFLAGS="$CFLAGS $SDL3_GFX_CFLAGS" - LDFLAGS="$LDFLAGS $SDL3_GFX_LIBS" - ],[ - AC_MSG_ERROR([SDL3_gfx not found. Please check your installation or use --with-sdl3-gfx=/path/to/sdl3_gfx]) - ]) + dnl Prefer static SDL3 libs if available + AC_MSG_CHECKING([for static SDL3 libs]) + SDL3_STATIC_LIBS=`$PKG_CONFIG --libs --static sdl3 2>/dev/null` + if test "x$SDL3_STATIC_LIBS" != "x"; then + AC_MSG_RESULT([$SDL3_STATIC_LIBS]) + LDFLAGS="$LDFLAGS $SDL3_STATIC_LIBS" + else + AC_MSG_RESULT([not found, using shared SDL3 libs]) + LDFLAGS="$LDFLAGS $SDL3_LIBS" fi if test "$PHP_SDL3_IMAGE" != "no"; then @@ -46,10 +39,20 @@ if test "$PHP_SDL3" != "no"; then PKG_CHECK_MODULES([SDL3_IMAGE], [sdl3-image >= 3.0.0], [ CFLAGS="$CFLAGS $SDL3_IMAGE_CFLAGS" - LDFLAGS="$LDFLAGS $SDL3_IMAGE_LIBS" ],[ AC_MSG_ERROR([SDL3_image not found. Please check your installation or use --with-sdl3-image=/path/to/sdl3_image]) ]) + + dnl Prefer static SDL3_image libs if available + AC_MSG_CHECKING([for static SDL3_image libs]) + SDL3_IMAGE_STATIC_LIBS=`$PKG_CONFIG --libs --static sdl3-image 2>/dev/null` + if test "x$SDL3_IMAGE_STATIC_LIBS" != "x"; then + AC_MSG_RESULT([$SDL3_IMAGE_STATIC_LIBS]) + LDFLAGS="$LDFLAGS $SDL3_IMAGE_STATIC_LIBS" + else + AC_MSG_RESULT([not found, using shared SDL3_image libs]) + LDFLAGS="$LDFLAGS $SDL3_IMAGE_LIBS" + fi fi if test "$PHP_SDL3_TTF" != "no"; then @@ -59,12 +62,31 @@ if test "$PHP_SDL3" != "no"; then PKG_CHECK_MODULES([SDL3_TTF], [sdl3-ttf >= 3.0.0], [ CFLAGS="$CFLAGS $SDL3_TTF_CFLAGS" - LDFLAGS="$LDFLAGS $SDL3_TTF_LIBS" ],[ AC_MSG_ERROR([SDL3_ttf not found. Please check your installation or use --with-sdl3-ttf=/path/to/sdl3_ttf]) ]) + + dnl Prefer static SDL3_ttf libs if available + AC_MSG_CHECKING([for static SDL3_ttf libs]) + SDL3_TTF_STATIC_LIBS=`$PKG_CONFIG --libs --static sdl3-ttf 2>/dev/null` + if test "x$SDL3_TTF_STATIC_LIBS" != "x"; then + AC_MSG_RESULT([$SDL3_TTF_STATIC_LIBS]) + LDFLAGS="$LDFLAGS $SDL3_TTF_STATIC_LIBS" + else + AC_MSG_RESULT([not found, using shared SDL3_ttf libs]) + LDFLAGS="$LDFLAGS $SDL3_TTF_LIBS" + fi fi + dnl Optional libnotify support for desktop notifications + PKG_CHECK_MODULES([LIBNOTIFY], [libnotify], [ + AC_DEFINE([HAVE_LIBNOTIFY], [1], [Enable libnotify for desktop_notify()]) + CFLAGS="$CFLAGS $LIBNOTIFY_CFLAGS" + LDFLAGS="$LDFLAGS $LIBNOTIFY_LIBS" + ], [ + AC_MSG_WARN([libnotify not found via pkg-config, desktop_notify() will be disabled]) + ]) + SDL_SOURCE_FILES="sdl3.c helper.c sdl3_image.c sdl3_ttf.c sdl3_events.c" PHP_NEW_EXTENSION(sdl3, $SDL_SOURCE_FILES, $ext_shared) diff --git a/php-sdl3/config.nice b/php-sdl3/config.nice index 5b88163..8553f8e 100755 --- a/php-sdl3/config.nice +++ b/php-sdl3/config.nice @@ -3,5 +3,7 @@ # Created by configure './configure' \ -'--enable-sdl3' \ +'--with-sdl3' \ +'--with-sdl3-image' \ +'--with-sdl3-ttf' \ "$@" diff --git a/php-sdl3/config.status b/php-sdl3/config.status index 883d91d..9c67e06 100755 --- a/php-sdl3/config.status +++ b/php-sdl3/config.status @@ -413,7 +413,7 @@ $config_headers Report bugs to the package provider." -ac_cs_config='--enable-sdl3' +ac_cs_config='--with-sdl3 --with-sdl3-image --with-sdl3-ttf' ac_cs_version="\ config.status configured by ./configure, generated by GNU Autoconf 2.72, @@ -494,7 +494,7 @@ if $ac_cs_silent; then fi if $ac_cs_recheck; then - set X /bin/bash './configure' '--enable-sdl3' $ac_configure_extra_args --no-create --no-recursion + set X /bin/bash './configure' '--with-sdl3' '--with-sdl3-image' '--with-sdl3-ttf' $ac_configure_extra_args --no-create --no-recursion shift \printf "%s\n" "running CONFIG_SHELL=/bin/bash $*" >&6 CONFIG_SHELL='/bin/bash' @@ -570,6 +570,7 @@ D["PACKAGE_VERSION"]=" \"\"" D["PACKAGE_STRING"]=" \"\"" D["PACKAGE_BUGREPORT"]=" \"\"" D["PACKAGE_URL"]=" \"\"" +D["HAVE_LIBNOTIFY"]=" 1" D["COMPILE_DL_SDL3"]=" 1" D["HAVE_STDIO_H"]=" 1" D["HAVE_STDLIB_H"]=" 1" diff --git a/php-sdl3/configure b/php-sdl3/configure index e7a3047..188a98a 100755 --- a/php-sdl3/configure +++ b/php-sdl3/configure @@ -802,12 +802,12 @@ RANLIB AR ECHO LN_S +LIBNOTIFY_LIBS +LIBNOTIFY_CFLAGS SDL3_TTF_LIBS SDL3_TTF_CFLAGS SDL3_IMAGE_LIBS SDL3_IMAGE_CFLAGS -SDL3_GFX_LIBS -SDL3_GFX_CFLAGS SDL3_LIBS SDL3_CFLAGS SHLIB_DL_SUFFIX_NAME @@ -887,7 +887,6 @@ with_libdir with_php_config enable_ with_sdl3 -with_sdl3_gfx with_sdl3_image with_sdl3_ttf enable_shared @@ -912,12 +911,12 @@ CPPFLAGS CPP SDL3_CFLAGS SDL3_LIBS -SDL3_GFX_CFLAGS -SDL3_GFX_LIBS SDL3_IMAGE_CFLAGS SDL3_IMAGE_LIBS SDL3_TTF_CFLAGS -SDL3_TTF_LIBS' +SDL3_TTF_LIBS +LIBNOTIFY_CFLAGS +LIBNOTIFY_LIBS' # Initialize some variables set by options. @@ -1550,10 +1549,6 @@ Extension: installation. - --with-sdl3-gfx=DIR Enable sdl3_gfx support. DIR is the prefix for - SDL3_gfx installation. - - --with-sdl3-image=DIR Enable sdl3_image support. DIR is the prefix for SDL3_image installation. @@ -1589,10 +1584,6 @@ Some influential environment variables: CPP C preprocessor SDL3_CFLAGS C compiler flags for SDL3, overriding pkg-config SDL3_LIBS linker flags for SDL3, overriding pkg-config - SDL3_GFX_CFLAGS - C compiler flags for SDL3_GFX, overriding pkg-config - SDL3_GFX_LIBS - linker flags for SDL3_GFX, overriding pkg-config SDL3_IMAGE_CFLAGS C compiler flags for SDL3_IMAGE, overriding pkg-config SDL3_IMAGE_LIBS @@ -1601,6 +1592,10 @@ Some influential environment variables: C compiler flags for SDL3_TTF, overriding pkg-config SDL3_TTF_LIBS linker flags for SDL3_TTF, overriding pkg-config + LIBNOTIFY_CFLAGS + C compiler flags for LIBNOTIFY, overriding pkg-config + LIBNOTIFY_LIBS + linker flags for LIBNOTIFY, overriding pkg-config Use these variables to override the choices made by 'configure' or to help it to find libraries and programs with nonstandard names/locations. @@ -4777,57 +4772,6 @@ printf "%s\n" "$ext_output" >&6; } -php_with_sdl3_gfx=no - -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for sdl3_gfx support" >&5 -printf %s "checking for sdl3_gfx support... " >&6; } - -# Check whether --with-sdl3_gfx was given. -if test ${with_sdl3_gfx+y} -then : - withval=$with_sdl3_gfx; PHP_SDL3_GFX=$withval -else case e in #( - e) - PHP_SDL3_GFX=no - test "$PHP_ENABLE_ALL" && PHP_SDL3_GFX=$PHP_ENABLE_ALL - ;; -esac -fi - - - -ext_output="yes, shared" -ext_shared=yes -case $PHP_SDL3_GFX in -shared,*) - PHP_SDL3_GFX=$(echo "$PHP_SDL3_GFX"|$SED 's/^shared,//') - ;; -shared) - PHP_SDL3_GFX=yes - ;; -no) - ext_output=no - ext_shared=no - ;; -*) - ext_output=yes - ext_shared=no - ;; -esac - - - ext_output="yes, shared" - ext_shared=yes - test "$PHP_SDL3_GFX" = "no" && PHP_SDL3_GFX=yes - - -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ext_output" >&5 -printf "%s\n" "$ext_output" >&6; } - - - - - php_with_sdl3_image=no { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for sdl3_image support" >&5 @@ -5009,93 +4953,20 @@ else printf "%s\n" "yes" >&6; } CFLAGS="$CFLAGS $SDL3_CFLAGS" + +fi + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for static SDL3 libs" >&5 +printf %s "checking for static SDL3 libs... " >&6; } + SDL3_STATIC_LIBS=`$PKG_CONFIG --libs --static sdl3 2>/dev/null` + if test "x$SDL3_STATIC_LIBS" != "x"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $SDL3_STATIC_LIBS" >&5 +printf "%s\n" "$SDL3_STATIC_LIBS" >&6; } + LDFLAGS="$LDFLAGS $SDL3_STATIC_LIBS" + else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: not found, using shared SDL3 libs" >&5 +printf "%s\n" "not found, using shared SDL3 libs" >&6; } LDFLAGS="$LDFLAGS $SDL3_LIBS" - -fi - - if test "$PHP_SDL3_GFX" != "no"; then - if test -d "$PHP_SDL3_GFX"; then - PKG_CONFIG_PATH="$PHP_SDL3_GFX/lib/pkgconfig:$PHP_SDL3_GFX/share/pkgconfig:$PKG_CONFIG_PATH" - fi - - -pkg_failed=no -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for sdl3-gfx >= 1.0.0" >&5 -printf %s "checking for sdl3-gfx >= 1.0.0... " >&6; } - -if test -n "$SDL3_GFX_CFLAGS"; then - pkg_cv_SDL3_GFX_CFLAGS="$SDL3_GFX_CFLAGS" - elif test -n "$PKG_CONFIG"; then - if test -n "$PKG_CONFIG" && \ - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"sdl3-gfx >= 1.0.0\""; } >&5 - ($PKG_CONFIG --exists --print-errors "sdl3-gfx >= 1.0.0") 2>&5 - ac_status=$? - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then - pkg_cv_SDL3_GFX_CFLAGS=`$PKG_CONFIG --cflags "sdl3-gfx >= 1.0.0" 2>/dev/null` - test "x$?" != "x0" && pkg_failed=yes -else - pkg_failed=yes -fi - else - pkg_failed=untried -fi -if test -n "$SDL3_GFX_LIBS"; then - pkg_cv_SDL3_GFX_LIBS="$SDL3_GFX_LIBS" - elif test -n "$PKG_CONFIG"; then - if test -n "$PKG_CONFIG" && \ - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"sdl3-gfx >= 1.0.0\""; } >&5 - ($PKG_CONFIG --exists --print-errors "sdl3-gfx >= 1.0.0") 2>&5 - ac_status=$? - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then - pkg_cv_SDL3_GFX_LIBS=`$PKG_CONFIG --libs "sdl3-gfx >= 1.0.0" 2>/dev/null` - test "x$?" != "x0" && pkg_failed=yes -else - pkg_failed=yes -fi - else - pkg_failed=untried -fi - - - -if test $pkg_failed = yes; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } - -if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then - _pkg_short_errors_supported=yes -else - _pkg_short_errors_supported=no -fi - if test $_pkg_short_errors_supported = yes; then - SDL3_GFX_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "sdl3-gfx >= 1.0.0" 2>&1` - else - SDL3_GFX_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "sdl3-gfx >= 1.0.0" 2>&1` - fi - # Put the nasty error message in config.log where it belongs - echo "$SDL3_GFX_PKG_ERRORS" >&5 - - - as_fn_error $? "SDL3_gfx not found. Please check your installation or use --with-sdl3-gfx=/path/to/sdl3_gfx" "$LINENO" 5 - -elif test $pkg_failed = untried; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } - - as_fn_error $? "SDL3_gfx not found. Please check your installation or use --with-sdl3-gfx=/path/to/sdl3_gfx" "$LINENO" 5 - -else - SDL3_GFX_CFLAGS=$pkg_cv_SDL3_GFX_CFLAGS - SDL3_GFX_LIBS=$pkg_cv_SDL3_GFX_LIBS - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } - - CFLAGS="$CFLAGS $SDL3_GFX_CFLAGS" - LDFLAGS="$LDFLAGS $SDL3_GFX_LIBS" - -fi fi if test "$PHP_SDL3_IMAGE" != "no"; then @@ -5178,9 +5049,21 @@ else printf "%s\n" "yes" >&6; } CFLAGS="$CFLAGS $SDL3_IMAGE_CFLAGS" - LDFLAGS="$LDFLAGS $SDL3_IMAGE_LIBS" fi + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for static SDL3_image libs" >&5 +printf %s "checking for static SDL3_image libs... " >&6; } + SDL3_IMAGE_STATIC_LIBS=`$PKG_CONFIG --libs --static sdl3-image 2>/dev/null` + if test "x$SDL3_IMAGE_STATIC_LIBS" != "x"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $SDL3_IMAGE_STATIC_LIBS" >&5 +printf "%s\n" "$SDL3_IMAGE_STATIC_LIBS" >&6; } + LDFLAGS="$LDFLAGS $SDL3_IMAGE_STATIC_LIBS" + else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: not found, using shared SDL3_image libs" >&5 +printf "%s\n" "not found, using shared SDL3_image libs" >&6; } + LDFLAGS="$LDFLAGS $SDL3_IMAGE_LIBS" + fi fi if test "$PHP_SDL3_TTF" != "no"; then @@ -5263,11 +5146,107 @@ else printf "%s\n" "yes" >&6; } CFLAGS="$CFLAGS $SDL3_TTF_CFLAGS" - LDFLAGS="$LDFLAGS $SDL3_TTF_LIBS" fi + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for static SDL3_ttf libs" >&5 +printf %s "checking for static SDL3_ttf libs... " >&6; } + SDL3_TTF_STATIC_LIBS=`$PKG_CONFIG --libs --static sdl3-ttf 2>/dev/null` + if test "x$SDL3_TTF_STATIC_LIBS" != "x"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $SDL3_TTF_STATIC_LIBS" >&5 +printf "%s\n" "$SDL3_TTF_STATIC_LIBS" >&6; } + LDFLAGS="$LDFLAGS $SDL3_TTF_STATIC_LIBS" + else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: not found, using shared SDL3_ttf libs" >&5 +printf "%s\n" "not found, using shared SDL3_ttf libs" >&6; } + LDFLAGS="$LDFLAGS $SDL3_TTF_LIBS" + fi fi + +pkg_failed=no +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for libnotify" >&5 +printf %s "checking for libnotify... " >&6; } + +if test -n "$LIBNOTIFY_CFLAGS"; then + pkg_cv_LIBNOTIFY_CFLAGS="$LIBNOTIFY_CFLAGS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libnotify\""; } >&5 + ($PKG_CONFIG --exists --print-errors "libnotify") 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_LIBNOTIFY_CFLAGS=`$PKG_CONFIG --cflags "libnotify" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi +if test -n "$LIBNOTIFY_LIBS"; then + pkg_cv_LIBNOTIFY_LIBS="$LIBNOTIFY_LIBS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libnotify\""; } >&5 + ($PKG_CONFIG --exists --print-errors "libnotify") 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_LIBNOTIFY_LIBS=`$PKG_CONFIG --libs "libnotify" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi + + + +if test $pkg_failed = yes; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } + +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=yes +else + _pkg_short_errors_supported=no +fi + if test $_pkg_short_errors_supported = yes; then + LIBNOTIFY_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libnotify" 2>&1` + else + LIBNOTIFY_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libnotify" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$LIBNOTIFY_PKG_ERRORS" >&5 + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: libnotify not found via pkg-config, desktop_notify() will be disabled" >&5 +printf "%s\n" "$as_me: WARNING: libnotify not found via pkg-config, desktop_notify() will be disabled" >&2;} + +elif test $pkg_failed = untried; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: libnotify not found via pkg-config, desktop_notify() will be disabled" >&5 +printf "%s\n" "$as_me: WARNING: libnotify not found via pkg-config, desktop_notify() will be disabled" >&2;} + +else + LIBNOTIFY_CFLAGS=$pkg_cv_LIBNOTIFY_CFLAGS + LIBNOTIFY_LIBS=$pkg_cv_LIBNOTIFY_LIBS + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +printf "%s\n" "yes" >&6; } + + +printf "%s\n" "#define HAVE_LIBNOTIFY 1" >>confdefs.h + + CFLAGS="$CFLAGS $LIBNOTIFY_CFLAGS" + LDFLAGS="$LDFLAGS $LIBNOTIFY_LIBS" + +fi + SDL_SOURCE_FILES="sdl3.c helper.c sdl3_image.c sdl3_ttf.c sdl3_events.c" @@ -6123,7 +6102,7 @@ ia64-*-hpux*) ;; *-*-irix6*) # Find out which ABI we are using. - echo '#line 6126 "configure"' > conftest.$ac_ext + echo '#line 6105 "configure"' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? @@ -7502,7 +7481,7 @@ else case e in #( LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym" cat > conftest.$ac_ext <&5) + (eval echo "\"configure:7646: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "configure:7671: \$? = $ac_status" >&5 + echo "configure:7650: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -7964,11 +7943,11 @@ else case e in #( -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"configure:7967: $lt_compile\"" >&5) + (eval echo "\"configure:7946: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "configure:7971: \$? = $ac_status" >&5 + echo "configure:7950: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -8072,11 +8051,11 @@ else case e in #( -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"configure:8075: $lt_compile\"" >&5) + (eval echo "\"configure:8054: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "configure:8079: \$? = $ac_status" >&5 + echo "configure:8058: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -8537,7 +8516,7 @@ _LT_EOF # Determine the default libpath from the value encoded in an empty executable. cat > conftest.$ac_ext < conftest.$ac_ext < conftest.$ac_ext < conftest.$ac_ext < conftest.$ac_ext < conftest.$ac_ext <&5) + (eval echo "\"configure:12606: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "configure:12631: \$? = $ac_status" >&5 + echo "configure:12610: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -12732,11 +12711,11 @@ else case e in #( -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"configure:12735: $lt_compile\"" >&5) + (eval echo "\"configure:12714: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "configure:12739: \$? = $ac_status" >&5 + echo "configure:12718: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized diff --git a/php-sdl3/helper.h b/php-sdl3/helper.h index 0a94a91..a77681c 100644 --- a/php-sdl3/helper.h +++ b/php-sdl3/helper.h @@ -2,7 +2,6 @@ #define PHP_SDL3_HELPER #include -#include #include "math.h" // Zeichnet einen gefüllten Viertel-Kreis mit Anti-Aliasing (filled quarter circle). diff --git a/php-sdl3/libtool b/php-sdl3/libtool index c22ceaf..cac7d49 100755 --- a/php-sdl3/libtool +++ b/php-sdl3/libtool @@ -85,7 +85,7 @@ AR_FLAGS="cru" LTCC="cc" # LTCC compiler flags. -LTCFLAGS="-g -O2 -I/usr/local/include -I/usr/local/include -I/usr/local/include -I/usr/local/include -I/usr/include/harfbuzz -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/sysprof-6 -pthread " +LTCFLAGS="-g -O2 -I/usr/local/include -I/usr/local/include -I/usr/local/include -I/usr/include/harfbuzz -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/sysprof-6 -pthread -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/sysprof-6 -I/usr/include/libpng16 -I/usr/include/x86_64-linux-gnu -I/usr/include/webp -I/usr/include/libmount -I/usr/include/blkid -pthread " # A language-specific compiler. CC="cc" diff --git a/php-sdl3/modules/sdl3.la b/php-sdl3/modules/sdl3.la index b031f4b..d870c9c 100644 --- a/php-sdl3/modules/sdl3.la +++ b/php-sdl3/modules/sdl3.la @@ -14,7 +14,7 @@ library_names='sdl3.so sdl3.so sdl3.so' old_library='' # Libraries that this one depends upon. -dependency_libs=' -L/usr/local/lib -lSDL3_gfx -lSDL3_image -lSDL3_ttf -lSDL3' +dependency_libs=' -L/usr/local/lib -lSDL3_image -lSDL3_ttf -lSDL3 -lharfbuzz -latomic -lsysprof-capture-4 -lpcre2-8 -lgraphite2 -lfreetype -lbz2 -lpng16 -lm -lz -lbrotlidec -lbrotlicommon -lnotify -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0' # Version information for sdl3. current=0 diff --git a/php-sdl3/modules/sdl3.so b/php-sdl3/modules/sdl3.so index 8f7238d..ab2993a 100755 Binary files a/php-sdl3/modules/sdl3.so and b/php-sdl3/modules/sdl3.so differ diff --git a/php-sdl3/sdl3.c b/php-sdl3/sdl3.c index 66ac501..93b1ad3 100644 --- a/php-sdl3/sdl3.c +++ b/php-sdl3/sdl3.c @@ -10,9 +10,12 @@ #include "sdl3_ttf.h" #include "sdl3_events.h" #include -#include #include +#ifdef HAVE_LIBNOTIFY +#include +#endif + // Resource handles (nicht static, damit sie in anderen Modulen verfügbar sind) int le_sdl_window; int le_sdl_renderer; @@ -526,6 +529,68 @@ PHP_FUNCTION(sdl_set_texture_alpha_mod) { RETURN_TRUE; } +PHP_FUNCTION(desktop_notify) +{ + char *title, *body; + size_t title_len, body_len; + zval *options = NULL; + + if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss|a", &title, &title_len, &body, &body_len, &options) == FAILURE) { + RETURN_THROWS(); + } + +#ifdef HAVE_LIBNOTIFY + if (!notify_is_initted()) { + if (!notify_init("PHPNative")) { + php_error_docref(NULL, E_WARNING, "Failed to initialize libnotify"); + RETURN_FALSE; + } + } + + NotifyNotification *n = notify_notification_new(title, body, NULL); + if (!n) { + php_error_docref(NULL, E_WARNING, "Failed to create notification"); + RETURN_FALSE; + } + + if (options && Z_TYPE_P(options) == IS_ARRAY) { + zval *timeout = zend_hash_str_find(Z_ARRVAL_P(options), "timeout", sizeof("timeout") - 1); + if (timeout && Z_TYPE_P(timeout) == IS_LONG) { + notify_notification_set_timeout(n, (int) Z_LVAL_P(timeout)); + } + + zval *urgency = zend_hash_str_find(Z_ARRVAL_P(options), "urgency", sizeof("urgency") - 1); + if (urgency && Z_TYPE_P(urgency) == IS_STRING) { + const char *u = Z_STRVAL_P(urgency); + if (strcmp(u, "low") == 0) { + notify_notification_set_urgency(n, NOTIFY_URGENCY_LOW); + } else if (strcmp(u, "critical") == 0) { + notify_notification_set_urgency(n, NOTIFY_URGENCY_CRITICAL); + } else { + notify_notification_set_urgency(n, NOTIFY_URGENCY_NORMAL); + } + } + } + + GError *error = NULL; + gboolean res = notify_notification_show(n, &error); + if (!res) { + if (error) { + php_error_docref(NULL, E_WARNING, "Notification error: %s", error->message); + g_error_free(error); + } + g_object_unref(G_OBJECT(n)); + RETURN_FALSE; + } + + g_object_unref(G_OBJECT(n)); + RETURN_TRUE; +#else + php_error_docref(NULL, E_WARNING, "desktop_notify() not available (libnotify not found at build time)"); + RETURN_FALSE; +#endif +} + PHP_FUNCTION(sdl_create_box_shadow_texture) { zval *ren_res; SDL_Renderer *renderer; @@ -743,10 +808,46 @@ PHP_FUNCTION(sdl_rounded_box) RETURN_FALSE; } - if (roundedBoxRGBA(ren, (Sint16)x1, (Sint16)y1, (Sint16)x2, (Sint16)y2, (Sint16)rad, (Uint8)r, (Uint8)g, (Uint8)b, (Uint8)a) == 0) { - RETURN_TRUE; - } - RETURN_FALSE; + // Zeichne eine Box mit gleichen Radien an allen Ecken (Wrapper um die erweiterte Variante) + SDL_SetRenderDrawColor(ren, (Uint8)r, (Uint8)g, (Uint8)b, (Uint8)a); + + int halfw = ((Sint16)x2 - (Sint16)x1) / 2; + int halfh = ((Sint16)y2 - (Sint16)y1) / 2; + int rad_tl = (int)rad; + int rad_tr = (int)rad; + int rad_br = (int)rad; + int rad_bl = (int)rad; + + if (rad_tl > halfw) rad_tl = halfw; if (rad_tl > halfh) rad_tl = halfh; + if (rad_tr > halfw) rad_tr = halfw; if (rad_tr > halfh) rad_tr = halfh; + if (rad_br > halfw) rad_br = halfw; if (rad_br > halfh) rad_br = halfh; + if (rad_bl > halfw) rad_bl = halfw; if (rad_bl > halfh) rad_bl = halfh; + + SDL_FRect topRect = { x1 + rad_tl, y1, x2 - x1 - rad_tl - rad_tr, rad_tl > rad_tr ? rad_tl : rad_tr }; + if (topRect.w > 0 && topRect.h > 0) SDL_RenderFillRect(ren, &topRect); + + int maxBottomRad = rad_bl > rad_br ? rad_bl : rad_br; + SDL_FRect bottomRect = { x1 + rad_bl, y2 - maxBottomRad, x2 - x1 - rad_bl - rad_br, maxBottomRad }; + if (bottomRect.w > 0 && bottomRect.h > 0) SDL_RenderFillRect(ren, &bottomRect); + + SDL_FRect leftRect = { x1, y1 + rad_tl, rad_tl > rad_bl ? rad_tl : rad_bl, y2 - y1 - rad_tl - rad_bl }; + if (leftRect.w > 0 && leftRect.h > 0) SDL_RenderFillRect(ren, &leftRect); + + int maxRightRad = rad_tr > rad_br ? rad_tr : rad_br; + SDL_FRect rightRect = { x2 - maxRightRad, y1 + rad_tr, maxRightRad, y2 - y1 - rad_tr - rad_br }; + if (rightRect.w > 0 && rightRect.h > 0) SDL_RenderFillRect(ren, &rightRect); + + int maxLeftRad = rad_tl > rad_bl ? rad_tl : rad_bl; + maxRightRad = rad_tr > rad_br ? rad_tr : rad_br; + SDL_FRect centerRect = { x1 + maxLeftRad, y1, x2 - x1 - maxLeftRad - maxRightRad, y2 - y1 }; + if (centerRect.w > 0 && centerRect.h > 0) SDL_RenderFillRect(ren, ¢erRect); + + if (rad_tl > 0) filled_quarter_circle(ren, x1 + rad_tl, y1 + rad_tl, rad_tl, 0); + if (rad_tr > 0) filled_quarter_circle(ren, x2 - rad_tr - 1, y1 + rad_tr, rad_tr, 1); + if (rad_br > 0) filled_quarter_circle(ren, x2 - rad_br - 1, y2 - rad_br - 1, rad_br, 2); + if (rad_bl > 0) filled_quarter_circle(ren, x1 + rad_bl, y2 - rad_bl - 1, rad_bl, 3); + + RETURN_TRUE; } #include @@ -1141,6 +1242,11 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_sdl_set_texture_alpha_mod, 0, 0, 2) ZEND_ARG_INFO(0, alpha) ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_INFO_EX(arginfo_desktop_notify, 0, 0, 2) + ZEND_ARG_INFO(0, title) + ZEND_ARG_INFO(0, body) + ZEND_ARG_ARRAY_INFO(0, options, 0) +ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_sdl_create_box_shadow_texture, 0, 0, 8) ZEND_ARG_INFO(0, renderer) ZEND_ARG_INFO(0, width) @@ -1259,6 +1365,7 @@ const zend_function_entry sdl3_functions[] = { PHP_FE(sdl_update_texture, arginfo_sdl_update_texture) PHP_FE(sdl_set_texture_blend_mode, arginfo_sdl_set_texture_blend_mode) PHP_FE(sdl_set_texture_alpha_mod, arginfo_sdl_set_texture_alpha_mod) + PHP_FE(desktop_notify, arginfo_desktop_notify) PHP_FE(sdl_create_box_shadow_texture, arginfo_sdl_create_box_shadow_texture) PHP_FE(sdl_get_render_target, arginfo_sdl_get_render_target) PHP_FE(sdl_set_render_target, arginfo_sdl_set_render_target) diff --git a/php-sdl3/sdl3.la b/php-sdl3/sdl3.la index db718ad..36d3c49 100644 --- a/php-sdl3/sdl3.la +++ b/php-sdl3/sdl3.la @@ -14,7 +14,7 @@ library_names='sdl3.so sdl3.so sdl3.so' old_library='' # Libraries that this one depends upon. -dependency_libs=' -L/usr/local/lib -lSDL3_gfx -lSDL3_image -lSDL3_ttf -lSDL3' +dependency_libs=' -L/usr/local/lib -lSDL3_image -lSDL3_ttf -lSDL3 -lharfbuzz -latomic -lsysprof-capture-4 -lpcre2-8 -lgraphite2 -lfreetype -lbz2 -lpng16 -lm -lz -lbrotlidec -lbrotlicommon -lnotify -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0' # Version information for sdl3. current=0 diff --git a/src/Tailwind/Model/StyleCollection.php b/src/Tailwind/Model/StyleCollection.php index 6c9a33f..95e461d 100644 --- a/src/Tailwind/Model/StyleCollection.php +++ b/src/Tailwind/Model/StyleCollection.php @@ -36,20 +36,29 @@ class StyleCollection extends TypedCollection $tmp = []; foreach($styles as $style) { - if(isset($tmp[$style->style::class]) && $style->style::class === Padding::class) { - \PHPNative\Tailwind\Parser\Padding::merge($tmp[$style->style::class], $style->style); - }elseif(isset($tmp[$style->style::class]) && $style->style::class === Margin::class) { - \PHPNative\Tailwind\Parser\Margin::merge($tmp[$style->style::class], $style->style); - }elseif(isset($tmp[$style->style::class]) && $style->style::class === Border::class) { - \PHPNative\Tailwind\Parser\Border::merge($tmp[$style->style::class], $style->style); - }elseif(isset($tmp[$style->style::class]) && $style->style::class === Text::class) { - \PHPNative\Tailwind\Parser\Text::merge($tmp[$style->style::class], $style->style); - }elseif(isset($tmp[$style->style::class]) && $style->style::class === Flex::class) { - \PHPNative\Tailwind\Parser\Flex::merge($tmp[$style->style::class], $style->style); - }elseif(isset($tmp[$style->style::class]) && $style->style::class === \PHPNative\Tailwind\Style\Shadow::class) { - \PHPNative\Tailwind\Parser\Shadow::merge($tmp[$style->style::class], $style->style); - }else{ - $tmp[$style->style::class] = $style->style; + $className = $style->style::class; + + // Ensure we always work on cloned styles in the merged result + if (!isset($tmp[$className])) { + $tmp[$className] = clone $style->style; + continue; + } + + if ($className === Padding::class) { + \PHPNative\Tailwind\Parser\Padding::merge($tmp[$className], $style->style); + } elseif ($className === Margin::class) { + \PHPNative\Tailwind\Parser\Margin::merge($tmp[$className], $style->style); + } elseif ($className === Border::class) { + \PHPNative\Tailwind\Parser\Border::merge($tmp[$className], $style->style); + } elseif ($className === Text::class) { + \PHPNative\Tailwind\Parser\Text::merge($tmp[$className], $style->style); + } elseif ($className === Flex::class) { + \PHPNative\Tailwind\Parser\Flex::merge($tmp[$className], $style->style); + } elseif ($className === \PHPNative\Tailwind\Style\Shadow::class) { + \PHPNative\Tailwind\Parser\Shadow::merge($tmp[$className], $style->style); + } else { + // Default: overwrite with cloned instance + $tmp[$className] = clone $style->style; } } diff --git a/src/Tailwind/Style/Shadow.php b/src/Tailwind/Style/Shadow.php index 0e45d7c..a7fc30c 100644 --- a/src/Tailwind/Style/Shadow.php +++ b/src/Tailwind/Style/Shadow.php @@ -11,4 +11,9 @@ class Shadow implements Style public Color $color = new Color(), public ?int $opacity = null, // 0-100, null means use default ) {} + + public function __clone() + { + $this->color = clone $this->color; + } } diff --git a/src/Ui/Component.php b/src/Ui/Component.php index fbfca5b..a4f2b8c 100644 --- a/src/Ui/Component.php +++ b/src/Ui/Component.php @@ -37,8 +37,10 @@ abstract class Component protected bool $useTextureCache = false; protected bool $textureCacheValid = false; - protected $cachedShadowTexture = null; // Cached shadow texture + protected $cachedShadowTexture = null; // Cached shadow texture (normal state) + protected $cachedShadowHoverTexture = null; // Cached shadow texture (hover state) protected bool $shadowCacheValid = false; + protected bool $shadowHoverCacheValid = false; protected Viewport $viewport; @@ -191,8 +193,13 @@ abstract class Component sdl_destroy_texture($this->cachedShadowTexture); $this->cachedShadowTexture = null; } + if ($this->cachedShadowHoverTexture !== null) { + sdl_destroy_texture($this->cachedShadowHoverTexture); + $this->cachedShadowHoverTexture = null; + } $this->textureCacheValid = false; $this->shadowCacheValid = false; + $this->shadowHoverCacheValid = false; $this->renderDirty = true; } @@ -1020,11 +1027,15 @@ abstract class Component $g = $shadow->color->green >= 0 ? $shadow->color->green : 0; $b = $shadow->color->blue >= 0 ? $shadow->color->blue : 0; - // Use cached shadow texture if available and valid - if ($this->shadowCacheValid && $this->cachedShadowTexture !== null) { - $shadowTexture = $this->cachedShadowTexture; + // Choose cache based on current state (normal vs hover) + $isHover = $this->currentState === \PHPNative\Tailwind\Style\StateEnum::hover; + $cacheTexture = $isHover ? $this->cachedShadowHoverTexture : $this->cachedShadowTexture; + $cacheValid = $isHover ? $this->shadowHoverCacheValid : $this->shadowCacheValid; + + if ($cacheValid && $cacheTexture !== null) { + $shadowTexture = $cacheTexture; } else { - // Create shadow texture with blur + // Create shadow texture with blur based on current state's styles $shadowTexture = $this->createShadowTexture( $renderer, (int) $this->viewport->width, @@ -1040,9 +1051,14 @@ abstract class Component return; } - // Cache the shadow texture - $this->cachedShadowTexture = $shadowTexture; - $this->shadowCacheValid = true; + // Cache per state + if ($isHover) { + $this->cachedShadowHoverTexture = $shadowTexture; + $this->shadowHoverCacheValid = true; + } else { + $this->cachedShadowTexture = $shadowTexture; + $this->shadowCacheValid = true; + } } // Render shadow texture with offset