SecBSD's official ports repository

This commit is contained in:
purplerain 2023-08-16 22:26:55 +00:00
commit 2c0afcbbf3
Signed by: purplerain
GPG key ID: F42C07F07E2E35B7
64331 changed files with 5339189 additions and 0 deletions

View file

@ -0,0 +1,11 @@
--- Makefile.in.orig Thu Jan 19 01:30:05 2012
+++ Makefile.in Wed Feb 22 13:39:54 2012
@@ -49,7 +49,7 @@ LT_AGE = @LT_AGE@
LT_CURRENT = @LT_CURRENT@
LT_RELEASE = @LT_RELEASE@
LT_REVISION = @LT_REVISION@
-LT_LDFLAGS = -no-undefined -rpath $(DESTDIR)$(libdir) -release $(LT_RELEASE) -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE)
+LT_LDFLAGS = -no-undefined -rpath $(DESTDIR)$(libdir) -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE)
all: $(srcdir)/configure Makefile $(objects) $(objects)/$(TARGET) $(objects)/$(SDLMAIN_TARGET)

View file

@ -0,0 +1,88 @@
--- configure.in.orig Thu Jan 19 01:30:05 2012
+++ configure.in Thu Dec 5 14:41:54 2013
@@ -486,6 +486,35 @@ AC_HELP_STRING([--enable-esd-shared], [dynamically loa
fi
}
+dnl Find Sndio
+CheckSndio()
+{
+ AC_ARG_ENABLE(sndio,
+AC_HELP_STRING([--enable-sndio], [support the sndio audio API [[default=yes]]]),
+ , enable_sndioaudio=yes)
+ if test x$enable_audio = xyes -a x$enable_sndioaudio = xyes; then
+ AC_CHECK_HEADER(sndio.h, have_sndio_hdr=yes)
+ AC_CHECK_LIB(sndio, sio_open, have_sndio_lib=yes)
+
+ AC_MSG_CHECKING(for sndio support)
+ have_sndio=no
+
+ if test x$have_sndio_hdr = xyes -a x$have_sndio_lib = xyes; then
+ have_sndio=yes
+ SNDIO_LIBS="-lsndio"
+ fi
+
+ AC_MSG_RESULT($have_sndio)
+
+ if test x$have_sndio = xyes; then
+ AC_DEFINE(SDL_AUDIO_DRIVER_SNDIO)
+ SOURCES="$SOURCES $srcdir/src/audio/sndio/*.c"
+ EXTRA_LDFLAGS="$EXTRA_LDFLAGS $SNDIO_LIBS"
+ have_audio=yes
+ fi
+ fi
+}
+
dnl Find PulseAudio
CheckPulseAudio()
{
@@ -860,8 +889,8 @@ CheckVisibilityHidden()
save_CFLAGS="$CFLAGS"
CFLAGS="$save_CFLAGS $visibility_CFLAGS -Werror"
AC_TRY_COMPILE([
- #if !defined(__GNUC__) || __GNUC__ < 4
- #error SDL only uses visibility attributes in GCC 4 or newer
+ #if !defined(__GNUC__) || __GNUC__ < 3
+ #error SDL only uses visibility attributes in GCC 3 or newer
#endif
],[
],[
@@ -1005,6 +1034,12 @@ AC_HELP_STRING([--enable-x11-shared], [dynamically loa
x11_lib='libX11.so'
x11ext_lib='libXext.so'
;;
+ *-*-openbsd*)
+ x11_lib='libX11.so'
+ x11ext_lib='libXext.so'
+ xrender_lib='libXrender.so'
+ xrandr_lib='libXrandr.so'
+ ;;
*)
x11_lib=[`find_lib "libX11.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
x11ext_lib=[`find_lib "libXext.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
@@ -1034,7 +1069,7 @@ AC_HELP_STRING([--enable-x11-shared], [dynamically loa
fi
if test x$x11_symbols_private != xyes && \
test x$enable_x11_shared = xyes; then
- AC_MSG_WARN([You must have gcc4 (-fvisibility=hidden) for dynamic X11 loading])
+ AC_MSG_WARN([You must have gcc3 (-fvisibility=hidden) for dynamic X11 loading])
enable_x11_shared=no
fi
@@ -2358,6 +2393,7 @@ case "$host" in
CheckALSA
CheckARTSC
CheckESD
+ CheckSndio
CheckPulseAudio
CheckNAS
CheckX11
@@ -2390,7 +2426,7 @@ case "$host" in
SOURCES="$SOURCES $srcdir/src/audio/sun/*.c"
have_audio=yes
;;
- netbsd|openbsd)
+ netbsd)
AC_DEFINE(SDL_AUDIO_DRIVER_BSD)
SOURCES="$SOURCES $srcdir/src/audio/bsd/*.c"
have_audio=yes

View file

@ -0,0 +1,10 @@
--- include/SDL_config.h.in.orig Thu Jan 19 01:30:05 2012
+++ include/SDL_config.h.in Wed Feb 22 13:39:54 2012
@@ -184,6 +184,7 @@
#undef SDL_AUDIO_DRIVER_QNXNTO
#undef SDL_AUDIO_DRIVER_SNDMGR
#undef SDL_AUDIO_DRIVER_SUNAUDIO
+#undef SDL_AUDIO_DRIVER_SNDIO
#undef SDL_AUDIO_DRIVER_WAVEOUT
/* Enable various cdrom drivers */

View file

@ -0,0 +1,28 @@
Index: include/SDL_opengl.h
--- include/SDL_opengl.h.orig
+++ include/SDL_opengl.h
@@ -35,7 +35,12 @@
#endif
#ifndef NO_SDL_GLEXT
#define __glext_h_ /* Don't let gl.h include glext.h */
+#define __gl_glext_h_ /* Don't let gl.h include glext.h */
+#ifndef GL_ARB_shader_objects
+#define GL_ARB_shader_objects 0
+#define undef_GL_ARB
#endif
+#endif
#if defined(__MACOSX__)
#include <OpenGL/gl.h> /* Header File For The OpenGL Library */
#include <OpenGL/glu.h> /* Header File For The GLU Library */
@@ -48,6 +53,11 @@
#endif
#ifndef NO_SDL_GLEXT
#undef __glext_h_
+#undef __gl_glext_h_
+#ifdef undef_GL_ARB
+#undef GL_ARB_shader_objects
+#undef undef_GL_ARB
+#endif
#endif
/** @name GLext.h

View file

@ -0,0 +1,11 @@
--- include/begin_code.h.orig Tue Jan 15 19:09:01 2013
+++ include/begin_code.h Tue Jan 15 19:09:45 2013
@@ -77,7 +77,7 @@
# define DECLSPEC
# endif
# else
-# if defined(__GNUC__) && __GNUC__ >= 4
+# if defined(__GNUC__) && __GNUC__ >= 3
# define DECLSPEC __attribute__ ((visibility("default")))
# else
# define DECLSPEC

View file

@ -0,0 +1,15 @@
--- sdl-config.in.orig Sun Dec 30 20:48:39 2007
+++ sdl-config.in Tue Mar 18 20:33:17 2008
@@ -42,10 +42,10 @@ while test $# -gt 0; do
echo @SDL_VERSION@
;;
--cflags)
- echo -I@includedir@/SDL @SDL_CFLAGS@
+ echo -I@includedir@ -I@includedir@/SDL @SDL_CFLAGS@ @X_CFLAGS@
;;
@ENABLE_SHARED_TRUE@ --libs)
-@ENABLE_SHARED_TRUE@ echo -L@libdir@ @SDL_RLD_FLAGS@ @SDL_LIBS@
+@ENABLE_SHARED_TRUE@ echo -L@libdir@ @SDL_RLD_FLAGS@ @SDL_LIBS@ @X_LIBS@
@ENABLE_SHARED_TRUE@ ;;
@ENABLE_STATIC_TRUE@@ENABLE_SHARED_TRUE@ --static-libs)
@ENABLE_STATIC_TRUE@@ENABLE_SHARED_FALSE@ --libs|--static-libs)

View file

@ -0,0 +1,11 @@
--- sdl.pc.in.orig Mon Oct 12 19:07:20 2009
+++ sdl.pc.in Sat Nov 7 13:30:12 2009
@@ -10,6 +10,5 @@ Description: Simple DirectMedia Layer is a cross-platf
Version: @SDL_VERSION@
Requires:
Conflicts:
-Libs: -L${libdir} @SDL_RLD_FLAGS@ @SDL_LIBS@
-Libs.private: @SDL_STATIC_LIBS@
-Cflags: -I${includedir}/SDL @SDL_CFLAGS@
+Libs: -L${libdir} @SDL_RLD_FLAGS@ @SDL_LIBS@ @X_LIBS@
+Cflags: -I${includedir}/SDL @SDL_CFLAGS@ @X_CFLAGS@

View file

@ -0,0 +1,18 @@
--- src/audio/SDL_audio.c.orig Thu Jan 19 01:30:06 2012
+++ src/audio/SDL_audio.c Wed Feb 22 13:41:58 2012
@@ -36,11 +36,15 @@
/* Available audio drivers */
static AudioBootStrap *bootstrap[] = {
+
#if SDL_AUDIO_DRIVER_PULSE
&PULSE_bootstrap,
#endif
#if SDL_AUDIO_DRIVER_ALSA
&ALSA_bootstrap,
+#endif
+#if SDL_AUDIO_DRIVER_SNDIO
+ &SNDIO_bootstrap,
#endif
#if SDL_AUDIO_DRIVER_BSD
&BSD_AUDIO_bootstrap,

View file

@ -0,0 +1,12 @@
--- src/audio/SDL_sysaudio.h.orig Thu Jan 19 01:30:06 2012
+++ src/audio/SDL_sysaudio.h Wed Feb 22 13:39:54 2012
@@ -105,6 +105,9 @@ typedef struct AudioBootStrap {
#if SDL_AUDIO_DRIVER_BSD
extern AudioBootStrap BSD_AUDIO_bootstrap;
#endif
+#if SDL_AUDIO_DRIVER_SNDIO
+extern AudioBootStrap SNDIO_bootstrap;
+#endif
#if SDL_AUDIO_DRIVER_PULSE
extern AudioBootStrap PULSE_bootstrap;
#endif

View file

@ -0,0 +1,37 @@
--- src/cpuinfo/SDL_cpuinfo.c.orig Thu Jan 19 01:30:06 2012
+++ src/cpuinfo/SDL_cpuinfo.c Fri Feb 24 16:08:00 2012
@@ -28,6 +28,10 @@
#if defined(__MACOSX__) && (defined(__ppc__) || defined(__ppc64__))
#include <sys/sysctl.h> /* For AltiVec check */
+#elif defined(__OpenBSD__) && defined(__powerpc__)
+#include <sys/param.h>
+#include <sys/sysctl.h> /* For AltiVec check */
+#include <machine/cpu.h>
#elif SDL_ALTIVEC_BLITTERS && HAVE_SETJMP
#include <signal.h>
#include <setjmp.h>
@@ -42,7 +46,7 @@
#define CPU_HAS_SSE2 0x00000080
#define CPU_HAS_ALTIVEC 0x00000100
-#if SDL_ALTIVEC_BLITTERS && HAVE_SETJMP && !__MACOSX__
+#if SDL_ALTIVEC_BLITTERS && HAVE_SETJMP && !__MACOSX__ && !__OpenBSD__
/* This is the brute force way of detecting instruction sets...
the idea is borrowed from the libmpeg2 library - thanks!
*/
@@ -359,8 +363,12 @@ static __inline__ int CPU_haveSSE2(void)
static __inline__ int CPU_haveAltiVec(void)
{
volatile int altivec = 0;
-#if defined(__MACOSX__) && (defined(__ppc__) || defined(__ppc64__))
- int selectors[2] = { CTL_HW, HW_VECTORUNIT };
+#if (defined(__MACOSX__) && (defined(__ppc__) || defined(__ppc64__))) || (defined(__OpenBSD__) && defined(__powerpc__))
+# ifdef __OpenBSD__
+ int selectors[2] = { CTL_MACHDEP, CPU_ALTIVEC };
+# else
+ int selectors[2] = { CTL_HW, HW_VECTORUNIT };
+# endif
int hasVectorUnit = 0;
size_t length = sizeof(hasVectorUnit);
int error = sysctl(selectors, 2, &hasVectorUnit, &length, NULL, 0);

View file

@ -0,0 +1,24 @@
It is easy to exhaust uhid devices in this day and age.
use ujoy(4) device nodes
Index: src/joystick/bsd/SDL_sysjoystick.c
--- src/joystick/bsd/SDL_sysjoystick.c.orig
+++ src/joystick/bsd/SDL_sysjoystick.c
@@ -77,7 +77,7 @@
#include "../SDL_sysjoystick.h"
#include "../SDL_joystick_c.h"
-#define MAX_UHID_JOYS 4
+#define MAX_UHID_JOYS 16
#define MAX_JOY_JOYS 2
#define MAX_JOYS (MAX_UHID_JOYS + MAX_JOY_JOYS)
@@ -170,7 +170,7 @@ SDL_SYS_JoystickInit(void)
for (i = 0; i < MAX_UHID_JOYS; i++) {
SDL_Joystick nj;
- SDL_snprintf(s, SDL_arraysize(s), "/dev/uhid%d", i);
+ SDL_snprintf(s, SDL_arraysize(s), "/dev/ujoy/%d", i);
nj.index = SDL_numjoysticks;
joynames[nj.index] = strdup(s);

View file

@ -0,0 +1,22 @@
Fixed bug 1426 - SDL_SemWaitTimeout returns -1 and sets error instead of
SDL_MUTEX_TIMEDOUT on time out
--- src/thread/pthread/SDL_syssem.c.orig Fri Mar 2 04:42:50 2012
+++ src/thread/pthread/SDL_syssem.c Fri Mar 2 04:44:23 2012
@@ -144,8 +144,14 @@ int SDL_SemWaitTimeout(SDL_sem *sem, Uint32 timeout)
retval = sem_timedwait(&sem->sem, &ts_timeout);
while (retval == -1 && errno == EINTR);
- if (retval == -1)
- SDL_SetError(strerror(errno));
+ if (retval == -1) {
+ if (errno == ETIMEDOUT) {
+ retval = SDL_MUTEX_TIMEDOUT;
+ }
+ else {
+ SDL_SetError(strerror(errno));
+ }
+ }
#else
end = SDL_GetTicks() + timeout;
while ((retval = SDL_SemTryWait(sem)) == SDL_MUTEX_TIMEDOUT) {

View file

@ -0,0 +1,59 @@
- Fixed bug 1424 - Handling of alpha channel in Altivec accelerated blit functions
- Use fast path for RGB 565 -> 32-bit XRGB 8888
--- src/video/SDL_blit_N.c.orig Thu Jan 19 01:30:06 2012
+++ src/video/SDL_blit_N.c Thu Oct 25 21:57:48 2012
@@ -689,6 +689,8 @@ static void ConvertAltivec32to32_noprefetch(SDL_BlitIn
while ((UNALIGNED_PTR(dst)) && (width)) {
bits = *(src++);
RGBA_FROM_8888(bits, srcfmt, r, g, b, a);
+ if(!srcfmt->Amask)
+ a = srcfmt->alpha;
*(dst++) = MAKE8888(dstfmt, r, g, b, a);
width--;
}
@@ -716,6 +718,8 @@ static void ConvertAltivec32to32_noprefetch(SDL_BlitIn
while (extrawidth) {
bits = *(src++); /* max 7 pixels, don't bother with prefetch. */
RGBA_FROM_8888(bits, srcfmt, r, g, b, a);
+ if(!srcfmt->Amask)
+ a = srcfmt->alpha;
*(dst++) = MAKE8888(dstfmt, r, g, b, a);
extrawidth--;
}
@@ -769,6 +773,8 @@ static void ConvertAltivec32to32_prefetch(SDL_BlitInfo
vec_dstst(dst+scalar_dst_lead, DST_CTRL(2,32,1024), DST_CHAN_DEST);
bits = *(src++);
RGBA_FROM_8888(bits, srcfmt, r, g, b, a);
+ if(!srcfmt->Amask)
+ a = srcfmt->alpha;
*(dst++) = MAKE8888(dstfmt, r, g, b, a);
width--;
}
@@ -798,6 +804,8 @@ static void ConvertAltivec32to32_prefetch(SDL_BlitInfo
while (extrawidth) {
bits = *(src++); /* max 7 pixels, don't bother with prefetch. */
RGBA_FROM_8888(bits, srcfmt, r, g, b, a);
+ if(!srcfmt->Amask)
+ a = srcfmt->alpha;
*(dst++) = MAKE8888(dstfmt, r, g, b, a);
extrawidth--;
}
@@ -2299,13 +2307,13 @@ static const struct blit_table normal_blit_2[] = {
2, NULL, Blit_RGB555_32Altivec, NO_ALPHA | COPY_ALPHA | SET_ALPHA },
#endif
{ 0x0000F800,0x000007E0,0x0000001F, 4, 0x00FF0000,0x0000FF00,0x000000FF,
- 0, NULL, Blit_RGB565_ARGB8888, SET_ALPHA },
+ 0, NULL, Blit_RGB565_ARGB8888, NO_ALPHA | COPY_ALPHA | SET_ALPHA },
{ 0x0000F800,0x000007E0,0x0000001F, 4, 0x000000FF,0x0000FF00,0x00FF0000,
- 0, NULL, Blit_RGB565_ABGR8888, SET_ALPHA },
+ 0, NULL, Blit_RGB565_ABGR8888, NO_ALPHA | COPY_ALPHA | SET_ALPHA },
{ 0x0000F800,0x000007E0,0x0000001F, 4, 0xFF000000,0x00FF0000,0x0000FF00,
- 0, NULL, Blit_RGB565_RGBA8888, SET_ALPHA },
+ 0, NULL, Blit_RGB565_RGBA8888, NO_ALPHA | COPY_ALPHA | SET_ALPHA },
{ 0x0000F800,0x000007E0,0x0000001F, 4, 0x0000FF00,0x00FF0000,0xFF000000,
- 0, NULL, Blit_RGB565_BGRA8888, SET_ALPHA },
+ 0, NULL, Blit_RGB565_BGRA8888, NO_ALPHA | COPY_ALPHA | SET_ALPHA },
/* Default for 16-bit RGB source, used if no other blitter matches */
{ 0,0,0, 0, 0,0,0, 0, NULL, BlitNtoN, 0 }

View file

@ -0,0 +1,28 @@
Fixed bug 1390 - X11_KeyToUnicode
--- src/video/x11/SDL_x11events.c.orig Wed Feb 22 19:31:47 2012
+++ src/video/x11/SDL_x11events.c Wed Feb 22 19:33:27 2012
@@ -1246,14 +1246,23 @@ static void get_modifier_masks(Display *display)
* sequences (dead accents, compose key sequences) will not work since the
* state has been irrevocably lost.
*/
+extern DECLSPEC Uint16 SDLCALL X11_KeyToUnicode(SDLKey, SDLMod);
+
Uint16 X11_KeyToUnicode(SDLKey keysym, SDLMod modifiers)
{
+ static int warning = 0;
struct SDL_VideoDevice *this = current_video;
char keybuf[32];
int i;
KeySym xsym = 0;
XKeyEvent xkey;
Uint16 unicode;
+
+ if ( warning ) {
+ warning = 0;
+ fprintf(stderr, "WARNING: Application is using X11_KeyToUnicode().\n");
+ fprintf(stderr, "This is not an official SDL function, please report this as a bug.\n");
+ }
if ( !this || !SDL_Display ) {
return 0;

View file

@ -0,0 +1,11 @@
--- src/video/x11/SDL_x11gl.c.orig Thu Jan 19 01:30:06 2012
+++ src/video/x11/SDL_x11gl.c Wed Feb 22 13:39:54 2012
@@ -34,7 +34,7 @@
#elif defined(__QNXNTO__)
#define DEFAULT_OPENGL "libGL.so.3"
#elif defined(__OpenBSD__)
-#define DEFAULT_OPENGL "libGL.so.4.0"
+#define DEFAULT_OPENGL "libGL.so"
#else
#define DEFAULT_OPENGL "libGL.so.1"
#endif

View file

@ -0,0 +1,11 @@
--- src/video/x11/SDL_x11sym.h.orig Tue Apr 30 00:39:44 2013
+++ src/video/x11/SDL_x11sym.h Tue Apr 30 00:40:30 2013
@@ -165,7 +165,7 @@ SDL_X11_SYM(Bool,XShmQueryExtension,(Display* a),(a),r
*/
#ifdef LONG64
SDL_X11_MODULE(IO_32BIT)
-SDL_X11_SYM(int,_XData32,(Display *dpy,register long *data,unsigned len),(dpy,data,len),return)
+SDL_X11_SYM(int,_XData32,(Display *dpy,register const long *data,unsigned len),(dpy,data,len),return)
SDL_X11_SYM(void,_XRead32,(Display *dpy,register long *data,long len),(dpy,data,len),)
#endif

View file

@ -0,0 +1,29 @@
Fixed bug 1427 - integer passed to XChangeProperty() causes crash
--- src/video/x11/SDL_x11video.c.orig Wed Feb 22 19:34:11 2012
+++ src/video/x11/SDL_x11video.c Wed Feb 22 19:36:25 2012
@@ -418,16 +418,21 @@ static void create_aux_windows(_THIS)
}
{
- pid_t pid = getpid();
+ union align_pid {
+ pid_t pid;
+ long dummy;
+ } a_pid;
char hostname[256];
- if (pid > 0 && gethostname(hostname, sizeof(hostname)) > -1) {
+ a_pid.pid = getpid();
+
+ if (a_pid.pid > 0 && gethostname(hostname, sizeof(hostname)) > -1) {
Atom _NET_WM_PID = XInternAtom(SDL_Display, "_NET_WM_PID", False);
Atom WM_CLIENT_MACHINE = XInternAtom(SDL_Display, "WM_CLIENT_MACHINE", False);
hostname[sizeof(hostname)-1] = '\0';
XChangeProperty(SDL_Display, WMwindow, _NET_WM_PID, XA_CARDINAL, 32,
- PropModeReplace, (unsigned char *)&pid, 1);
+ PropModeReplace, (unsigned char *)&a_pid.pid, 1);
XChangeProperty(SDL_Display, WMwindow, WM_CLIENT_MACHINE, XA_STRING, 8,
PropModeReplace, (unsigned char *)hostname, SDL_strlen(hostname));
}

View file

@ -0,0 +1,94 @@
Use _NET_WM_ICON if possible for X11's SDL_WM_SetIcon() implementation.
--- src/video/x11/SDL_x11wm.c.orig Thu Oct 25 21:58:52 2012
+++ src/video/x11/SDL_x11wm.c Thu Oct 25 22:01:06 2012
@@ -43,6 +43,7 @@ static Uint8 reverse_byte(Uint8 x)
void X11_SetIcon(_THIS, SDL_Surface *icon, Uint8 *mask)
{
+ Atom _NET_WM_ICON = XInternAtom(SDL_Display, "_NET_WM_ICON", False);
SDL_Surface *sicon;
XWMHints *wmhints;
XImage *icon_image;
@@ -59,6 +60,81 @@ void X11_SetIcon(_THIS, SDL_Surface *icon, Uint8 *mask
int masksize;
SDL_Lock_EventThread();
+
+ if (_NET_WM_ICON) { /* better interface for modern systems. */
+ SDL_PixelFormat format;
+ SDL_Surface *surface;
+ int propsize;
+ long *propdata;
+
+ /* Convert the icon to ARGB for modern window managers */
+ SDL_memset(&format, 0, sizeof (format));
+ format.BitsPerPixel = 32;
+ format.BytesPerPixel = 4;
+ #if SDL_BYTEORDER == SDL_BIG_ENDIAN
+ format.Rshift = 8;
+ format.Gshift = 16;
+ format.Bshift = 24;
+ format.Ashift = 0;
+ #else
+ format.Rshift = 16;
+ format.Gshift = 8;
+ format.Bshift = 0;
+ format.Ashift = 24;
+ #endif
+ format.Rmask = 0xFF << format.Rshift;
+ format.Gmask = 0xFF << format.Gshift;
+ format.Bmask = 0xFF << format.Bshift;
+ format.Amask = 0xFF << format.Ashift;
+ format.alpha = SDL_ALPHA_OPAQUE;
+
+ surface = SDL_ConvertSurface(icon, &format, 0);
+ if (!surface) {
+ return;
+ }
+
+ /* Set the _NET_WM_ICON property */
+ propsize = 2 + (icon->w * icon->h);
+ propdata = SDL_malloc(propsize * sizeof(long));
+ if (propdata) {
+ const Uint32 alpha = format.Amask;
+ int x, y;
+ Uint32 *src;
+ long *dst;
+
+ propdata[0] = icon->w;
+ propdata[1] = icon->h;
+ dst = &propdata[2];
+
+ size_t maskidx = 0;
+ for (y = 0; y < icon->h; ++y) {
+ src = (Uint32*)((Uint8*)surface->pixels + y * surface->pitch);
+ for (x = 0; x < icon->w; ++x) {
+ const Uint32 pixel = *(src++);
+ if (mask[maskidx / 8] & (1<<(7-(maskidx % 8)))) {
+ *dst++ = pixel | alpha;
+ } else {
+ *dst++ = pixel & ~alpha;
+ }
+ maskidx++;
+ }
+ }
+
+ XChangeProperty(SDL_Display, WMwindow, _NET_WM_ICON, XA_CARDINAL,
+ 32, PropModeReplace, (unsigned char *) propdata,
+ propsize);
+ }
+
+ SDL_FreeSurface(surface);
+ SDL_free(propdata);
+
+ XFlush(SDL_Display);
+ SDL_Unlock_EventThread();
+
+ return;
+ }
+
+ /* Do it the old way... */
/* The icon must use the default visual, depth and colormap of the
screen, so it might need a conversion */