From 55e97877556c73cf707c2f9753c6dea85b51dfd7 Mon Sep 17 00:00:00 2001 From: Ozkan Sezer Date: Thu, 10 May 2018 08:47:00 +0300 Subject: [PATCH] backport fixes for bug #4159 --- include/SDL_stdinc.h | 44 ++++++++++++++-------------- include/SDL_syswm.h | 68 ++++++++++++++++++++++++-------------------- 2 files changed, 59 insertions(+), 53 deletions(-) diff --git a/include/SDL_stdinc.h b/include/SDL_stdinc.h index fb3b6a3c9..d6d29fb06 100644 --- a/include/SDL_stdinc.h +++ b/include/SDL_stdinc.h @@ -73,6 +73,28 @@ #if defined(HAVE_ICONV) && defined(HAVE_ICONV_H) # include #endif +#if defined(HAVE_ALLOCA) && !defined(alloca) +# if defined(HAVE_ALLOCA_H) +# include +# elif defined(__GNUC__) +# define alloca __builtin_alloca +# elif defined(_MSC_VER) +# include +# define alloca _alloca +# elif defined(__WATCOMC__) +# include +# elif defined(__BORLANDC__) +# include +# elif defined(__DMC__) +# include +# elif defined(__AIX__) + #pragma alloca +# elif defined(__MRC__) + void *alloca (unsigned); +# else + char *alloca (); +# endif +#endif /** The number of elements in an array */ #define SDL_arraysize(array) (sizeof(array)/sizeof(array[0])) @@ -182,28 +204,6 @@ extern DECLSPEC void * SDLCALL SDL_realloc(void *mem, size_t size); extern DECLSPEC void SDLCALL SDL_free(void *mem); #endif -#if defined(HAVE_ALLOCA) && !defined(alloca) -# if defined(HAVE_ALLOCA_H) -# include -# elif defined(__GNUC__) -# define alloca __builtin_alloca -# elif defined(_MSC_VER) -# include -# define alloca _alloca -# elif defined(__WATCOMC__) -# include -# elif defined(__BORLANDC__) -# include -# elif defined(__DMC__) -# include -# elif defined(__AIX__) - #pragma alloca -# elif defined(__MRC__) - void *alloca (unsigned); -# else - char *alloca (); -# endif -#endif #ifdef HAVE_ALLOCA #define SDL_stack_alloc(type, count) (type*)alloca(sizeof(type)*(count)) #define SDL_stack_free(data) diff --git a/include/SDL_syswm.h b/include/SDL_syswm.h index 78433c6aa..40845b641 100644 --- a/include/SDL_syswm.h +++ b/include/SDL_syswm.h @@ -31,6 +31,29 @@ #include "SDL_error.h" #include "SDL_version.h" +#ifndef SDL_PROTOTYPES_ONLY +# if defined(SDL_VIDEO_DRIVER_X11) +# if defined(__APPLE__) && defined(__MACH__) +# define Cursor X11Cursor /* conflicts with Quickdraw.h */ +# endif +# include +# include +# if defined(__APPLE__) && defined(__MACH__) +# undef Cursor +# endif +# elif defined(SDL_VIDEO_DRIVER_NANOX) +# include +# elif defined(SDL_VIDEO_DRIVER_WINDIB) || defined(SDL_VIDEO_DRIVER_DDRAW) || defined(SDL_VIDEO_DRIVER_GAPI) +# ifndef WIN32_LEAN_AND_MEAN +# define WIN32_LEAN_AND_MEAN +# endif +# include +# elif defined(SDL_VIDEO_DRIVER_PHOTON) +# include +# include +# endif +#endif + #include "begin_code.h" /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus @@ -43,25 +66,13 @@ extern "C" { * an unhandled window event occurs. This event is ignored by default, but * you can enable it with SDL_EventState() */ -#ifdef SDL_PROTOTYPES_ONLY struct SDL_SysWMinfo; typedef struct SDL_SysWMinfo SDL_SysWMinfo; -#else + +#ifndef SDL_PROTOTYPES_ONLY /* This is the structure for custom window manager events */ #if defined(SDL_VIDEO_DRIVER_X11) -#if defined(__APPLE__) && defined(__MACH__) -/* conflicts with Quickdraw.h */ -#define Cursor X11Cursor -#endif - -#include -#include - -#if defined(__APPLE__) && defined(__MACH__) -/* matches the re-define above */ -#undef Cursor -#endif /** These are the various supported subsystems under UNIX */ typedef enum { @@ -81,7 +92,7 @@ struct SDL_SysWMmsg { * When this structure is returned, it holds information about which * low level system it is using, and will be one of SDL_SYSWM_TYPE. */ -typedef struct SDL_SysWMinfo { +struct SDL_SysWMinfo { SDL_version version; SDL_SYSWM_TYPE subsystem; union { @@ -111,10 +122,9 @@ typedef struct SDL_SysWMinfo { /*@}*/ } x11; } info; -} SDL_SysWMinfo; +}; #elif defined(SDL_VIDEO_DRIVER_NANOX) -#include /** The generic custom event structure */ struct SDL_SysWMmsg { @@ -123,14 +133,12 @@ struct SDL_SysWMmsg { }; /** The windows custom window manager information structure */ -typedef struct SDL_SysWMinfo { +struct SDL_SysWMinfo { SDL_version version ; GR_WINDOW_ID window ; /* The display window */ -} SDL_SysWMinfo; +}; #elif defined(SDL_VIDEO_DRIVER_WINDIB) || defined(SDL_VIDEO_DRIVER_DDRAW) || defined(SDL_VIDEO_DRIVER_GAPI) -#define WIN32_LEAN_AND_MEAN -#include /** The windows custom event structure */ struct SDL_SysWMmsg { @@ -142,11 +150,11 @@ struct SDL_SysWMmsg { }; /** The windows custom window manager information structure */ -typedef struct SDL_SysWMinfo { +struct SDL_SysWMinfo { SDL_version version; HWND window; /**< The Win32 display window */ HGLRC hglrc; /**< The OpenGL context, if any */ -} SDL_SysWMinfo; +}; #elif defined(SDL_VIDEO_DRIVER_RISCOS) @@ -158,16 +166,14 @@ struct SDL_SysWMmsg { }; /** The RISC OS custom window manager information structure */ -typedef struct SDL_SysWMinfo { +struct SDL_SysWMinfo { SDL_version version; int wimpVersion; /**< Wimp version running under */ int taskHandle; /**< The RISC OS task handle */ int window; /**< The RISC OS display window */ -} SDL_SysWMinfo; +}; #elif defined(SDL_VIDEO_DRIVER_PHOTON) -#include -#include /** The QNX custom event structure */ struct SDL_SysWMmsg { @@ -176,10 +182,10 @@ struct SDL_SysWMmsg { }; /** The QNX custom window manager information structure */ -typedef struct SDL_SysWMinfo { +struct SDL_SysWMinfo { SDL_version version; int data; -} SDL_SysWMinfo; +}; #else @@ -190,10 +196,10 @@ struct SDL_SysWMmsg { }; /** The generic custom window manager information structure */ -typedef struct SDL_SysWMinfo { +struct SDL_SysWMinfo { SDL_version version; int data; -} SDL_SysWMinfo; +}; #endif /* video driver type */