src/SDL12_compat.c
author Ryan C. Gordon <icculus@icculus.org>
Wed, 06 Mar 2013 01:48:25 -0500
changeset 9 408821d72ab2
child 10 e6176c053187
permissions -rw-r--r--
sdl12-compat: Renamed a source file.
icculus@9
     1
/*
icculus@9
     2
  Simple DirectMedia Layer
icculus@9
     3
  Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
icculus@9
     4
icculus@9
     5
  This software is provided 'as-is', without any express or implied
icculus@9
     6
  warranty.  In no event will the authors be held liable for any damages
icculus@9
     7
  arising from the use of this software.
icculus@9
     8
icculus@9
     9
  Permission is granted to anyone to use this software for any purpose,
icculus@9
    10
  including commercial applications, and to alter it and redistribute it
icculus@9
    11
  freely, subject to the following restrictions:
icculus@9
    12
icculus@9
    13
  1. The origin of this software must not be misrepresented; you must not
icculus@9
    14
     claim that you wrote the original software. If you use this software
icculus@9
    15
     in a product, an acknowledgment in the product documentation would be
icculus@9
    16
     appreciated but is not required.
icculus@9
    17
  2. Altered source versions must be plainly marked as such, and must not be
icculus@9
    18
     misrepresented as being the original software.
icculus@9
    19
  3. This notice may not be removed or altered from any source distribution.
icculus@9
    20
*/
icculus@9
    21
icculus@9
    22
/* This file contains functions for backwards compatibility with SDL 1.2 */
icculus@9
    23
icculus@9
    24
#include "SDL.h"
icculus@9
    25
icculus@9
    26
#if !SDL_VERSION_ATLEAST(2,0,0)
icculus@9
    27
#error You need to compile against SDL 2.0 headers.
icculus@9
    28
#endif
icculus@9
    29
icculus@9
    30
#include "SDL_syswm.h"
icculus@9
    31
icculus@9
    32
//#include "video/SDL_sysvideo.h"
icculus@9
    33
//#include "video/SDL_pixels_c.h"
icculus@9
    34
//#include "render/SDL_yuv_sw_c.h"
icculus@9
    35
icculus@9
    36
// !!! IMPLEMENT_ME SDL_AddTimer
icculus@9
    37
// !!! IMPLEMENT_ME SDL_AllocRW
icculus@9
    38
// !!! IMPLEMENT_ME SDL_AudioInit
icculus@9
    39
// !!! IMPLEMENT_ME SDL_AudioQuit
icculus@9
    40
// !!! IMPLEMENT_ME SDL_ConvertSurface
icculus@9
    41
// !!! IMPLEMENT_ME SDL_CreateCursor
icculus@9
    42
// !!! IMPLEMENT_ME SDL_CreateRGBSurface
icculus@9
    43
// !!! IMPLEMENT_ME SDL_CreateRGBSurfaceFrom
icculus@9
    44
// !!! IMPLEMENT_ME SDL_CreateThread
icculus@9
    45
// !!! IMPLEMENT_ME SDL_Error
icculus@9
    46
// !!! IMPLEMENT_ME SDL_EventState
icculus@9
    47
// !!! IMPLEMENT_ME SDL_FillRect
icculus@9
    48
// !!! IMPLEMENT_ME SDL_FreeCursor
icculus@9
    49
// !!! IMPLEMENT_ME SDL_FreeRW
icculus@9
    50
// !!! IMPLEMENT_ME SDL_FreeSurface
icculus@9
    51
// !!! IMPLEMENT_ME SDL_GL_GetAttribute
icculus@9
    52
// !!! IMPLEMENT_ME SDL_GL_GetProcAddress
icculus@9
    53
// !!! IMPLEMENT_ME SDL_GL_LoadLibrary
icculus@9
    54
// !!! IMPLEMENT_ME SDL_GL_Lock
icculus@9
    55
// !!! IMPLEMENT_ME SDL_GL_SetAttribute
icculus@9
    56
// !!! IMPLEMENT_ME SDL_GL_Unlock
icculus@9
    57
// !!! IMPLEMENT_ME SDL_GL_UpdateRects
icculus@9
    58
// !!! IMPLEMENT_ME SDL_GetClipRect
icculus@9
    59
// !!! IMPLEMENT_ME SDL_GetCursor
icculus@9
    60
// !!! IMPLEMENT_ME SDL_GetEventFilter
icculus@9
    61
// !!! IMPLEMENT_ME SDL_GetKeyName
icculus@9
    62
// !!! IMPLEMENT_ME SDL_GetKeyState
icculus@9
    63
// !!! IMPLEMENT_ME SDL_GetModState
icculus@9
    64
// !!! IMPLEMENT_ME SDL_GetMouseState
icculus@9
    65
// !!! IMPLEMENT_ME SDL_GetRGB
icculus@9
    66
// !!! IMPLEMENT_ME SDL_GetRGBA
icculus@9
    67
// !!! IMPLEMENT_ME SDL_GetRelativeMouseState
icculus@9
    68
// !!! IMPLEMENT_ME SDL_GetThreadID
icculus@9
    69
// !!! IMPLEMENT_ME SDL_Init
icculus@9
    70
// !!! IMPLEMENT_ME SDL_InitSubSystem
icculus@9
    71
// !!! IMPLEMENT_ME SDL_LoadBMP_RW
icculus@9
    72
// !!! IMPLEMENT_ME SDL_LoadWAV_RW
icculus@9
    73
// !!! IMPLEMENT_ME SDL_LockSurface
icculus@9
    74
// !!! IMPLEMENT_ME SDL_LowerBlit
icculus@9
    75
// !!! IMPLEMENT_ME SDL_MapRGB
icculus@9
    76
// !!! IMPLEMENT_ME SDL_MapRGBA
icculus@9
    77
// !!! IMPLEMENT_ME SDL_PeepEvents
icculus@9
    78
// !!! IMPLEMENT_ME SDL_PollEvent
icculus@9
    79
// !!! IMPLEMENT_ME SDL_PumpEvents
icculus@9
    80
// !!! IMPLEMENT_ME SDL_PushEvent
icculus@9
    81
// !!! IMPLEMENT_ME SDL_QuitSubSystem
icculus@9
    82
// !!! IMPLEMENT_ME SDL_RWFromConstMem
icculus@9
    83
// !!! IMPLEMENT_ME SDL_RWFromFP
icculus@9
    84
// !!! IMPLEMENT_ME SDL_RWFromFile
icculus@9
    85
// !!! IMPLEMENT_ME SDL_RWFromMem
icculus@9
    86
// !!! IMPLEMENT_ME SDL_ReadBE16
icculus@9
    87
// !!! IMPLEMENT_ME SDL_ReadBE32
icculus@9
    88
// !!! IMPLEMENT_ME SDL_ReadBE64
icculus@9
    89
// !!! IMPLEMENT_ME SDL_ReadLE16
icculus@9
    90
// !!! IMPLEMENT_ME SDL_ReadLE32
icculus@9
    91
// !!! IMPLEMENT_ME SDL_ReadLE64
icculus@9
    92
// !!! IMPLEMENT_ME SDL_RemoveTimer
icculus@9
    93
// !!! IMPLEMENT_ME SDL_SaveBMP_RW
icculus@9
    94
// !!! IMPLEMENT_ME SDL_SetClipRect
icculus@9
    95
// !!! IMPLEMENT_ME SDL_SetColorKey
icculus@9
    96
// !!! IMPLEMENT_ME SDL_SetCursor
icculus@9
    97
// !!! IMPLEMENT_ME SDL_SetError
icculus@9
    98
// !!! IMPLEMENT_ME SDL_SetEventFilter
icculus@9
    99
// !!! IMPLEMENT_ME SDL_SetModState
icculus@9
   100
// !!! IMPLEMENT_ME SDL_ShowCursor
icculus@9
   101
// !!! IMPLEMENT_ME SDL_SoftStretch
icculus@9
   102
// !!! IMPLEMENT_ME SDL_UnlockSurface
icculus@9
   103
// !!! IMPLEMENT_ME SDL_UpperBlit
icculus@9
   104
// !!! IMPLEMENT_ME SDL_VideoInit
icculus@9
   105
// !!! IMPLEMENT_ME SDL_VideoQuit
icculus@9
   106
// !!! IMPLEMENT_ME SDL_WaitEvent
icculus@9
   107
// !!! IMPLEMENT_ME SDL_WasInit
icculus@9
   108
// !!! IMPLEMENT_ME SDL_WriteBE16
icculus@9
   109
// !!! IMPLEMENT_ME SDL_WriteBE32
icculus@9
   110
// !!! IMPLEMENT_ME SDL_WriteBE64
icculus@9
   111
// !!! IMPLEMENT_ME SDL_WriteLE16
icculus@9
   112
// !!! IMPLEMENT_ME SDL_WriteLE32
icculus@9
   113
// !!! IMPLEMENT_ME SDL_WriteLE64
icculus@9
   114
// !!! IMPLEMENT_ME SDL_iconv
icculus@9
   115
// !!! IMPLEMENT_ME SDL_iconv_string
icculus@9
   116
// !!! IMPLEMENT_ME SDL_lltoa
icculus@9
   117
// !!! IMPLEMENT_ME SDL_ltoa
icculus@9
   118
// !!! IMPLEMENT_ME SDL_revcpy
icculus@9
   119
// !!! IMPLEMENT_ME SDL_strlcat
icculus@9
   120
// !!! IMPLEMENT_ME SDL_strlcpy
icculus@9
   121
// !!! IMPLEMENT_ME SDL_strlwr
icculus@9
   122
// !!! IMPLEMENT_ME SDL_strrev
icculus@9
   123
// !!! IMPLEMENT_ME SDL_strupr
icculus@9
   124
// !!! IMPLEMENT_ME SDL_ulltoa
icculus@9
   125
// !!! IMPLEMENT_ME SDL_ultoa
icculus@9
   126
// !!! IMPLEMENT_ME X11_KeyToUnicode
icculus@9
   127
icculus@9
   128
icculus@9
   129
#define SDL20_SYM(rc,fn,params,args,ret) \
icculus@9
   130
    typedef rc (*SDL20_##fn##_t) params; \
icculus@9
   131
    static SDL20_##fn##_t SDL20_##fn = NULL;
icculus@9
   132
#define SDL20_SYM_PASSTHROUGH(rc,fn,params,args,ret) \
icculus@9
   133
    SDL20_SYM(rc,fn,params,args,ret)
icculus@9
   134
#include "SDL20_syms.h"
icculus@9
   135
#undef SDL20_SYM_PASSTHROUGH
icculus@9
   136
#undef SDL20_SYM
icculus@9
   137
icculus@9
   138
icculus@9
   139
icculus@9
   140
icculus@9
   141
#define SDL12_INIT_TIMER       0x00000001
icculus@9
   142
#define SDL12_INIT_AUDIO       0x00000010
icculus@9
   143
#define SDL12_INIT_VIDEO       0x00000020
icculus@9
   144
#define SDL12_INIT_CDROM       0x00000100
icculus@9
   145
#define SDL12_INIT_JOYSTICK    0x00000200
icculus@9
   146
#define SDL12_INIT_NOPARACHUTE 0x00100000
icculus@9
   147
#define SDL12_INIT_EVENTTHREAD 0x01000000
icculus@9
   148
#define SDL12_INIT_EVERYTHING  0x0000FFFF
icculus@9
   149
icculus@9
   150
typedef struct
icculus@9
   151
{
icculus@9
   152
	Uint32 hw_available :1;	/**< Flag: Can you create hardware surfaces? */
icculus@9
   153
	Uint32 wm_available :1;	/**< Flag: Can you talk to a window manager? */
icculus@9
   154
	Uint32 UnusedBits1  :6;
icculus@9
   155
	Uint32 UnusedBits2  :1;
icculus@9
   156
	Uint32 blit_hw      :1;	/**< Flag: Accelerated blits HW --> HW */
icculus@9
   157
	Uint32 blit_hw_CC   :1;	/**< Flag: Accelerated blits with Colorkey */
icculus@9
   158
	Uint32 blit_hw_A    :1;	/**< Flag: Accelerated blits with Alpha */
icculus@9
   159
	Uint32 blit_sw      :1;	/**< Flag: Accelerated blits SW --> HW */
icculus@9
   160
	Uint32 blit_sw_CC   :1;	/**< Flag: Accelerated blits with Colorkey */
icculus@9
   161
	Uint32 blit_sw_A    :1;	/**< Flag: Accelerated blits with Alpha */
icculus@9
   162
	Uint32 blit_fill    :1;	/**< Flag: Accelerated color fill */
icculus@9
   163
	Uint32 UnusedBits3  :16;
icculus@9
   164
	Uint32 video_mem;	/**< The total amount of video memory (in K) */
icculus@9
   165
	SDL_PixelFormat *vfmt;	/**< Value: The format of the video surface */
icculus@9
   166
	int    current_w;	/**< Value: The current video mode width */
icculus@9
   167
	int    current_h;	/**< Value: The current video mode height */
icculus@9
   168
} SDL12_VideoInfo;
icculus@9
   169
icculus@9
   170
typedef struct SDL12_Palette {
icculus@9
   171
	int       ncolors;
icculus@9
   172
	SDL_Color *colors;
icculus@9
   173
} SDL12_Palette;
icculus@9
   174
icculus@9
   175
/** Everything in the pixel format structure is read-only */
icculus@9
   176
typedef struct SDL12_PixelFormat {
icculus@9
   177
	SDL12_Palette *palette;
icculus@9
   178
	Uint8  BitsPerPixel;
icculus@9
   179
	Uint8  BytesPerPixel;
icculus@9
   180
	Uint8  Rloss;
icculus@9
   181
	Uint8  Gloss;
icculus@9
   182
	Uint8  Bloss;
icculus@9
   183
	Uint8  Aloss;
icculus@9
   184
	Uint8  Rshift;
icculus@9
   185
	Uint8  Gshift;
icculus@9
   186
	Uint8  Bshift;
icculus@9
   187
	Uint8  Ashift;
icculus@9
   188
	Uint32 Rmask;
icculus@9
   189
	Uint32 Gmask;
icculus@9
   190
	Uint32 Bmask;
icculus@9
   191
	Uint32 Amask;
icculus@9
   192
icculus@9
   193
	/** RGB color key information */
icculus@9
   194
	Uint32 colorkey;
icculus@9
   195
	/** Alpha value information (per-surface alpha) */
icculus@9
   196
	Uint8  alpha;
icculus@9
   197
} SDL12_PixelFormat;
icculus@9
   198
icculus@9
   199
#define SDL12_SWSURFACE	0x00000000	/**< Surface is in system memory */
icculus@9
   200
#define SDL12_HWSURFACE	0x00000001	/**< Surface is in video memory */
icculus@9
   201
#define SDL12_ASYNCBLIT	0x00000004	/**< Use asynchronous blits if possible */
icculus@9
   202
#define SDL12_ANYFORMAT	0x10000000	/**< Allow any video depth/pixel-format */
icculus@9
   203
#define SDL12_HWPALETTE	0x20000000	/**< Surface has exclusive palette */
icculus@9
   204
#define SDL12_DOUBLEBUF	0x40000000	/**< Set up double-buffered video mode */
icculus@9
   205
#define SDL12_FULLSCREEN	0x80000000	/**< Surface is a full screen display */
icculus@9
   206
#define SDL12_OPENGL      0x00000002      /**< Create an OpenGL rendering context */
icculus@9
   207
#define SDL12_OPENGLBLIT	0x0000000A	/**< Create an OpenGL rendering context and use it for blitting */
icculus@9
   208
#define SDL12_RESIZABLE	0x00000010	/**< This video mode may be resized */
icculus@9
   209
#define SDL12_NOFRAME	0x00000020	/**< No window caption or edge frame */
icculus@9
   210
icculus@9
   211
#define SDL12_HWACCEL	0x00000100	/**< Blit uses hardware acceleration */
icculus@9
   212
#define SDL12_SRCCOLORKEY	0x00001000	/**< Blit uses a source color key */
icculus@9
   213
#define SDL12_RLEACCELOK	0x00002000	/**< Private flag */
icculus@9
   214
#define SDL12_RLEACCEL	0x00004000	/**< Surface is RLE encoded */
icculus@9
   215
#define SDL12_SRCALPHA	0x00010000	/**< Blit uses source alpha blending */
icculus@9
   216
#define SDL12_PREALLOC	0x01000000	/**< Surface uses preallocated memory */
icculus@9
   217
icculus@9
   218
icculus@9
   219
static SDL_Window *SDL_VideoWindow = NULL;
icculus@9
   220
static SDL_Surface *SDL_WindowSurface = NULL;
icculus@9
   221
static SDL_Surface *SDL_VideoSurface = NULL;
icculus@9
   222
static SDL_Surface *SDL_ShadowSurface = NULL;
icculus@9
   223
static SDL_Surface *SDL_PublicSurface = NULL;
icculus@9
   224
static SDL_GLContext *SDL_VideoContext = NULL;
icculus@9
   225
static Uint32 SDL_VideoFlags = 0;
icculus@9
   226
static SDL_Rect SDL_VideoViewport;
icculus@9
   227
static char *wm_title = NULL;
icculus@9
   228
static char *wm_icon_caption = NULL;
icculus@9
   229
static SDL_Surface *SDL_VideoIcon;
icculus@9
   230
static int SDL_enabled_UNICODE = 0;
icculus@9
   231
static int SDL_VideoDisplayIndex = 0;
icculus@9
   232
icculus@9
   233
/* Obviously we can't use SDL_LoadObject() to load SDL2.  :)  */
icculus@9
   234
#if defined(_WINDOWS)
icculus@9
   235
    #define SDL20_LIBNAME "SDL2.dll"
icculus@9
   236
    static HANDLE Loaded_SDL20 = NULL;
icculus@9
   237
    #define LoadSDL20Library() ((Loaded_SDL20 = LoadLibraryA(SDL20_LIBNAME)) != NULL)
icculus@9
   238
    #define LookupSDL20Sym(sym) GetProcAddress(Loaded_SDL20, sym)
icculus@9
   239
    #define CloseSDL20Library() { { if (Loaded_SDL20) { FreeLibrary(Loaded_SDL20); Loaded_SDL20 = NULL; } }
icculus@9
   240
#elif defined(unix)
icculus@9
   241
    #ifdef __APPLE__
icculus@9
   242
    #define SDL20_LIBNAME "libSDL2.dylib"
icculus@9
   243
    #else
icculus@9
   244
    #define SDL20_LIBNAME "libSDL2-2.0.so.0"
icculus@9
   245
    #endif
icculus@9
   246
    static void *Loaded_SDL20 = NULL;
icculus@9
   247
    #define LoadSDL20Library() ((Loaded_SDL20 = dlopen(SDL20_LIBNAME, RTLD_LOCAL)) != NULL)
icculus@9
   248
    #define LookupSDL20Sym(sym) dlsym(Loaded_SDL20, sym)
icculus@9
   249
    #define CloseSDL20Library() { if (Loaded_SDL20) { dlclose(Loaded_SDL20); Loaded_SDL20 = NULL; } }
icculus@9
   250
#else
icculus@9
   251
    #error Please define your platform.
icculus@9
   252
#endif
icculus@9
   253
icculus@9
   254
static void *
icculus@9
   255
LoadSDL20Symbol(const char *fn, int *okay)
icculus@9
   256
{
icculus@9
   257
    void *retval = NULL;
icculus@9
   258
    if (*okay)  /* only bother trying if we haven't previously failed. */
icculus@9
   259
    {
icculus@9
   260
        retval = LookupSDL20Sym(fn);
icculus@9
   261
        if (retval == NULL)
icculus@9
   262
            *okay = 0;
icculus@9
   263
    }
icculus@9
   264
    return retval;
icculus@9
   265
}
icculus@9
   266
icculus@9
   267
static void
icculus@9
   268
UnloadSDL20(void)
icculus@9
   269
{
icculus@9
   270
    #define SDL20_SYM(rc,fn,params,args,ret) SDL20_##fn = NULL;
icculus@9
   271
    #define SDL20_SYM_PASSTHROUGH(rc,fn,params,args,ret) SDL20_##fn = NULL;
icculus@9
   272
    #include "SDL20_syms.h"
icculus@9
   273
    #undef SDL20_SYM_PASSTHROUGH
icculus@9
   274
    #undef SDL20_SYM
icculus@9
   275
    CloseSDL20Library();
icculus@9
   276
}
icculus@9
   277
icculus@9
   278
static int
icculus@9
   279
LoadSDL20(void)
icculus@9
   280
{
icculus@9
   281
    int okay = 1;
icculus@9
   282
    if (!Loaded_SDL20)
icculus@9
   283
    {
icculus@9
   284
        okay = LoadSDL20Library();
icculus@9
   285
        #define SDL20_SYM(rc,fn,params,args,ret) SDL20_##fn = (SDL20_##fn##_t) LoadSDL20Symbol("SDL_" #fn, &okay);
icculus@9
   286
        #define SDL20_SYM_PASSTHROUGH(rc,fn,params,args,ret) SDL20_SYM(rc,fn,params,args,ret)
icculus@9
   287
        #include "SDL20_syms.h"
icculus@9
   288
        #undef SDL20_SYM_PASSTHROUGH
icculus@9
   289
        #undef SDL20_SYM
icculus@9
   290
        if (!okay)
icculus@9
   291
            UnloadSDL20();
icculus@9
   292
    }
icculus@9
   293
    return okay;
icculus@9
   294
}
icculus@9
   295
icculus@9
   296
icculus@9
   297
static int
icculus@9
   298
GetVideoDisplay()
icculus@9
   299
{
icculus@9
   300
    // !!! FIXME: cache this value during SDL_Init() so it doesn't change.
icculus@9
   301
    const char *variable = SDL_getenv("SDL_VIDEO_FULLSCREEN_DISPLAY");
icculus@9
   302
    if ( !variable ) {
icculus@9
   303
        variable = SDL_getenv("SDL_VIDEO_FULLSCREEN_HEAD");
icculus@9
   304
    }
icculus@9
   305
    if ( variable ) {
icculus@9
   306
        return SDL_atoi(variable);
icculus@9
   307
    } else {
icculus@9
   308
        return 0;
icculus@9
   309
    }
icculus@9
   310
}
icculus@9
   311
icculus@9
   312
int
icculus@9
   313
SDL_Init(Uint32 sdl12flags)
icculus@9
   314
{
icculus@9
   315
    Uint32 sdl20flags = 0;
icculus@9
   316
    int rc;
icculus@9
   317
icculus@9
   318
    if (!LoadSDL20())
icculus@9
   319
        return -1;
icculus@9
   320
icculus@9
   321
    #define SETFLAG(x) if (sdl12flags & SDL12_INIT_##flag) sdl20flags |= SDL_INIT_##flag)
icculus@9
   322
    SETFLAG(TIMER);
icculus@9
   323
    SETFLAG(AUDIO);
icculus@9
   324
    SETFLAG(VIDEO);
icculus@9
   325
    SETFLAG(JOYSTICK);
icculus@9
   326
    SETFLAG(NOPARACHUTE);
icculus@9
   327
    // There's no CDROM in 2.0, but we'll just pretend it succeeded.
icculus@9
   328
    #undef SETFLAG
icculus@9
   329
icculus@9
   330
    // !!! FIXME: do something about SDL12_INIT_EVENTTHREAD
icculus@9
   331
icculus@9
   332
    rc = SDL20_Init(sdl20flags);
icculus@9
   333
    if ((rc == 0) && (sdl20flags & SDL_INIT_VIDEO))
icculus@9
   334
        SDL_VideoDisplayIndex = GetVideoDisplay();
icculus@9
   335
    return rc;
icculus@9
   336
}
icculus@9
   337
icculus@9
   338
void
icculus@9
   339
SDL_Quit(void)
icculus@9
   340
{
icculus@9
   341
    SDL20_Quit();
icculus@9
   342
    UnloadSDL20();
icculus@9
   343
}
icculus@9
   344
icculus@9
   345
icculus@9
   346
char *
icculus@9
   347
SDL_GetError(void)
icculus@9
   348
{
icculus@9
   349
    if (!Loaded_SDL20)
icculus@9
   350
    {
icculus@9
   351
        static char noload_errstr[] = "Failed to load SDL 2.0 shared library";
icculus@9
   352
        return noload_errstr;
icculus@9
   353
    }
icculus@9
   354
    return SDL20_GetError();
icculus@9
   355
}
icculus@9
   356
icculus@9
   357
icculus@9
   358
static const char *
icculus@9
   359
GetDriverName(const char *name, char *namebuf, int maxlen)
icculus@9
   360
{
icculus@9
   361
    if (name) {
icculus@9
   362
        if (namebuf) {
icculus@9
   363
            SDL20_strlcpy(namebuf, name, maxlen);
icculus@9
   364
            return namebuf;
icculus@9
   365
        } else {
icculus@9
   366
            return name;
icculus@9
   367
        }
icculus@9
   368
    }
icculus@9
   369
    return NULL;
icculus@9
   370
}
icculus@9
   371
icculus@9
   372
const char *
icculus@9
   373
SDL_AudioDriverName(char *namebuf, int maxlen)
icculus@9
   374
{
icculus@9
   375
    return GetDriverName(SDL20_GetCurrentAudioDriver(), namebuf, maxlen);
icculus@9
   376
}
icculus@9
   377
icculus@9
   378
const char *
icculus@9
   379
SDL_VideoDriverName(char *namebuf, int maxlen)
icculus@9
   380
{
icculus@9
   381
    return GetDriverName(SDL20_GetCurrentVideoDriver(), namebuf, maxlen);
icculus@9
   382
}
icculus@9
   383
icculus@9
   384
const SDL12_VideoInfo *
icculus@9
   385
SDL_GetVideoInfo(void)
icculus@9
   386
{
icculus@9
   387
    static SDL12_VideoInfo info;
icculus@9
   388
    SDL_DisplayMode mode;
icculus@9
   389
icculus@9
   390
    /* !!! FIXME: Memory leak, compatibility code, who cares? */
icculus@9
   391
    if (!info.vfmt && SDL20_GetDesktopDisplayMode(SDL_VideoDisplayIndex, &mode) == 0) {
icculus@9
   392
        info.vfmt = SDL20_AllocFormat(mode.format);
icculus@9
   393
        info.current_w = mode.w;
icculus@9
   394
        info.current_h = mode.h;
icculus@9
   395
        // !!! FIXME
icculus@9
   396
        //info.wm_available = 1;
icculus@9
   397
        //info.video_mem = 1024 * 256;
icculus@9
   398
    }
icculus@9
   399
    return &info;
icculus@9
   400
}
icculus@9
   401
icculus@9
   402
int
icculus@9
   403
SDL_VideoModeOK(int width, int height, int bpp, Uint32 sdl12flags)
icculus@9
   404
{
icculus@9
   405
    int i, nummodes, actual_bpp = 0;
icculus@9
   406
icculus@9
   407
    if (!SDL20_WasInit(SDL_INIT_VIDEO)) {
icculus@9
   408
        return 0;
icculus@9
   409
    }
icculus@9
   410
icculus@9
   411
    if (!(sdl12flags & SDL12_FULLSCREEN)) {
icculus@9
   412
        SDL_DisplayMode mode;
icculus@9
   413
        SDL20_GetDesktopDisplayMode(SDL_VideoDisplayIndex, &mode);
icculus@9
   414
        return SDL_BITSPERPIXEL(mode.format);
icculus@9
   415
    }
icculus@9
   416
icculus@9
   417
    nummodes = SDL20_GetNumDisplayModes(SDL_VideoDisplayIndex);
icculus@9
   418
    for (i = 0; i < nummodes; ++i) {
icculus@9
   419
        SDL_DisplayMode mode;
icculus@9
   420
        SDL20_GetDisplayMode(SDL_VideoDisplayIndex, i, &mode);
icculus@9
   421
        if (!mode.w || !mode.h || (width == mode.w && height == mode.h)) {
icculus@9
   422
            if (!mode.format) {
icculus@9
   423
                return bpp;
icculus@9
   424
            }
icculus@9
   425
            if (SDL_BITSPERPIXEL(mode.format) >= (Uint32) bpp) {
icculus@9
   426
                actual_bpp = SDL_BITSPERPIXEL(mode.format);
icculus@9
   427
            }
icculus@9
   428
        }
icculus@9
   429
    }
icculus@9
   430
    return actual_bpp;
icculus@9
   431
}
icculus@9
   432
icculus@9
   433
SDL_Rect **
icculus@9
   434
SDL_ListModes(const SDL12_PixelFormat * format, Uint32 flags)
icculus@9
   435
{
icculus@9
   436
    int i, nmodes;
icculus@9
   437
    SDL_Rect **modes;
icculus@9
   438
icculus@9
   439
    if (!SDL20_WasInit(SDL_INIT_VIDEO)) {
icculus@9
   440
        return NULL;
icculus@9
   441
    }
icculus@9
   442
icculus@9
   443
    if (!(flags & SDL12_FULLSCREEN)) {
icculus@9
   444
        return (SDL_Rect **) (-1);
icculus@9
   445
    }
icculus@9
   446
icculus@9
   447
    if (!format) {
icculus@9
   448
        format = SDL_GetVideoInfo()->vfmt;
icculus@9
   449
    }
icculus@9
   450
icculus@9
   451
    /* Memory leak, but this is a compatibility function, who cares? */
icculus@9
   452
    nmodes = 0;
icculus@9
   453
    modes = NULL;
icculus@9
   454
    for (i = 0; i < SDL20_GetNumDisplayModes(SDL_VideoDisplayIndex); ++i) {
icculus@9
   455
        SDL_DisplayMode mode;
icculus@9
   456
        int bpp;
icculus@9
   457
icculus@9
   458
        SDL20_GetDisplayMode(SDL_VideoDisplayIndex, i, &mode);
icculus@9
   459
        if (!mode.w || !mode.h) {
icculus@9
   460
            return (SDL_Rect **) (-1);
icculus@9
   461
        }
icculus@9
   462
        
icculus@9
   463
        /* Copied from src/video/SDL_pixels.c:SDL_PixelFormatEnumToMasks */
icculus@9
   464
        if (SDL_BYTESPERPIXEL(mode.format) <= 2) {
icculus@9
   465
            bpp = SDL_BITSPERPIXEL(mode.format);
icculus@9
   466
        } else {
icculus@9
   467
            bpp = SDL_BYTESPERPIXEL(mode.format) * 8;
icculus@9
   468
        }
icculus@9
   469
icculus@9
   470
        if (bpp != format->BitsPerPixel) {
icculus@9
   471
            continue;
icculus@9
   472
        }
icculus@9
   473
        if (nmodes > 0 && modes[nmodes - 1]->w == mode.w
icculus@9
   474
            && modes[nmodes - 1]->h == mode.h) {
icculus@9
   475
            continue;
icculus@9
   476
        }
icculus@9
   477
icculus@9
   478
        modes = SDL_realloc(modes, (nmodes + 2) * sizeof(*modes));
icculus@9
   479
        if (!modes) {
icculus@9
   480
            return NULL;
icculus@9
   481
        }
icculus@9
   482
        modes[nmodes] = (SDL_Rect *) SDL_malloc(sizeof(SDL_Rect));
icculus@9
   483
        if (!modes[nmodes]) {
icculus@9
   484
            return NULL;
icculus@9
   485
        }
icculus@9
   486
        modes[nmodes]->x = 0;
icculus@9
   487
        modes[nmodes]->y = 0;
icculus@9
   488
        modes[nmodes]->w = mode.w;
icculus@9
   489
        modes[nmodes]->h = mode.h;
icculus@9
   490
        ++nmodes;
icculus@9
   491
    }
icculus@9
   492
    if (modes) {
icculus@9
   493
        modes[nmodes] = NULL;
icculus@9
   494
    }
icculus@9
   495
    return modes;
icculus@9
   496
}
icculus@9
   497
icculus@9
   498
static int
icculus@9
   499
SDL_CompatEventFilter(void *userdata, SDL_Event * event)
icculus@9
   500
{
icculus@9
   501
    SDL_Event fake;
icculus@9
   502
icculus@9
   503
    switch (event->type) {
icculus@9
   504
    case SDL_WINDOWEVENT:
icculus@9
   505
        switch (event->window.event) {
icculus@9
   506
        case SDL_WINDOWEVENT_EXPOSED:
icculus@9
   507
            if (!SDL_HasEvent(SDL_VIDEOEXPOSE)) {
icculus@9
   508
                fake.type = SDL_VIDEOEXPOSE;
icculus@9
   509
                SDL_PushEvent(&fake);
icculus@9
   510
            }
icculus@9
   511
            break;
icculus@9
   512
        case SDL_WINDOWEVENT_RESIZED:
icculus@9
   513
            SDL_FlushEvent(SDL_VIDEORESIZE);
icculus@9
   514
            /* We don't want to expose that the window width and height will
icculus@9
   515
               be different if we don't get the desired fullscreen mode.
icculus@9
   516
            */
icculus@9
   517
            if (SDL_VideoWindow && !(SDL_GetWindowFlags(SDL_VideoWindow) & SDL_WINDOW_FULLSCREEN)) {
icculus@9
   518
                fake.type = SDL_VIDEORESIZE;
icculus@9
   519
                fake.resize.w = event->window.data1;
icculus@9
   520
                fake.resize.h = event->window.data2;
icculus@9
   521
                SDL_PushEvent(&fake);
icculus@9
   522
            }
icculus@9
   523
            break;
icculus@9
   524
        case SDL_WINDOWEVENT_MINIMIZED:
icculus@9
   525
            fake.type = SDL_ACTIVEEVENT;
icculus@9
   526
            fake.active.gain = 0;
icculus@9
   527
            fake.active.state = SDL_APPACTIVE;
icculus@9
   528
            SDL_PushEvent(&fake);
icculus@9
   529
            break;
icculus@9
   530
        case SDL_WINDOWEVENT_RESTORED:
icculus@9
   531
            fake.type = SDL_ACTIVEEVENT;
icculus@9
   532
            fake.active.gain = 1;
icculus@9
   533
            fake.active.state = SDL_APPACTIVE;
icculus@9
   534
            SDL_PushEvent(&fake);
icculus@9
   535
            break;
icculus@9
   536
        case SDL_WINDOWEVENT_ENTER:
icculus@9
   537
            fake.type = SDL_ACTIVEEVENT;
icculus@9
   538
            fake.active.gain = 1;
icculus@9
   539
            fake.active.state = SDL_APPMOUSEFOCUS;
icculus@9
   540
            SDL_PushEvent(&fake);
icculus@9
   541
            break;
icculus@9
   542
        case SDL_WINDOWEVENT_LEAVE:
icculus@9
   543
            fake.type = SDL_ACTIVEEVENT;
icculus@9
   544
            fake.active.gain = 0;
icculus@9
   545
            fake.active.state = SDL_APPMOUSEFOCUS;
icculus@9
   546
            SDL_PushEvent(&fake);
icculus@9
   547
            break;
icculus@9
   548
        case SDL_WINDOWEVENT_FOCUS_GAINED:
icculus@9
   549
            fake.type = SDL_ACTIVEEVENT;
icculus@9
   550
            fake.active.gain = 1;
icculus@9
   551
            fake.active.state = SDL_APPINPUTFOCUS;
icculus@9
   552
            SDL_PushEvent(&fake);
icculus@9
   553
            break;
icculus@9
   554
        case SDL_WINDOWEVENT_FOCUS_LOST:
icculus@9
   555
            fake.type = SDL_ACTIVEEVENT;
icculus@9
   556
            fake.active.gain = 0;
icculus@9
   557
            fake.active.state = SDL_APPINPUTFOCUS;
icculus@9
   558
            SDL_PushEvent(&fake);
icculus@9
   559
            break;
icculus@9
   560
        case SDL_WINDOWEVENT_CLOSE:
icculus@9
   561
            fake.type = SDL_QUIT;
icculus@9
   562
            SDL_PushEvent(&fake);
icculus@9
   563
            break;
icculus@9
   564
        }
icculus@9
   565
    case SDL_KEYDOWN:
icculus@9
   566
    case SDL_KEYUP:
icculus@9
   567
        {
icculus@9
   568
            Uint32 unicode = 0;
icculus@9
   569
            if (event->key.type == SDL_KEYDOWN && event->key.keysym.sym < 256) {
icculus@9
   570
                unicode = event->key.keysym.sym;
icculus@9
   571
                if (unicode >= 'a' && unicode <= 'z') {
icculus@9
   572
                    int shifted = !!(event->key.keysym.mod & KMOD_SHIFT);
icculus@9
   573
                    int capslock = !!(event->key.keysym.mod & KMOD_CAPS);
icculus@9
   574
                    if ((shifted ^ capslock) != 0) {
icculus@9
   575
                        unicode = SDL_toupper(unicode);
icculus@9
   576
                    }
icculus@9
   577
                }
icculus@9
   578
            }
icculus@9
   579
            if (unicode) {
icculus@9
   580
                event->key.keysym.unicode = unicode;
icculus@9
   581
            }
icculus@9
   582
            break;
icculus@9
   583
        }
icculus@9
   584
    case SDL_TEXTINPUT:
icculus@9
   585
        {
icculus@9
   586
            /* FIXME: Generate an old style key repeat event if needed */
icculus@9
   587
            //printf("TEXTINPUT: '%s'\n", event->text.text);
icculus@9
   588
            break;
icculus@9
   589
        }
icculus@9
   590
    case SDL_MOUSEMOTION:
icculus@9
   591
        {
icculus@9
   592
            event->motion.x -= SDL_VideoViewport.x;
icculus@9
   593
            event->motion.y -= SDL_VideoViewport.y;
icculus@9
   594
            break;
icculus@9
   595
        }
icculus@9
   596
    case SDL_MOUSEBUTTONDOWN:
icculus@9
   597
    case SDL_MOUSEBUTTONUP:
icculus@9
   598
        {
icculus@9
   599
            event->button.x -= SDL_VideoViewport.x;
icculus@9
   600
            event->button.y -= SDL_VideoViewport.y;
icculus@9
   601
            break;
icculus@9
   602
        }
icculus@9
   603
    case SDL_MOUSEWHEEL:
icculus@9
   604
        {
icculus@9
   605
            Uint8 button;
icculus@9
   606
            int x, y;
icculus@9
   607
icculus@9
   608
            if (event->wheel.y == 0) {
icculus@9
   609
                break;
icculus@9
   610
            }
icculus@9
   611
icculus@9
   612
            SDL_GetMouseState(&x, &y);
icculus@9
   613
icculus@9
   614
            if (event->wheel.y > 0) {
icculus@9
   615
                button = SDL_BUTTON_WHEELUP;
icculus@9
   616
            } else {
icculus@9
   617
                button = SDL_BUTTON_WHEELDOWN;
icculus@9
   618
            }
icculus@9
   619
icculus@9
   620
            fake.button.button = button;
icculus@9
   621
            fake.button.x = x;
icculus@9
   622
            fake.button.y = y;
icculus@9
   623
            fake.button.windowID = event->wheel.windowID;
icculus@9
   624
icculus@9
   625
            fake.type = SDL_MOUSEBUTTONDOWN;
icculus@9
   626
            fake.button.state = SDL_PRESSED;
icculus@9
   627
            SDL_PushEvent(&fake);
icculus@9
   628
icculus@9
   629
            fake.type = SDL_MOUSEBUTTONUP;
icculus@9
   630
            fake.button.state = SDL_RELEASED;
icculus@9
   631
            SDL_PushEvent(&fake);
icculus@9
   632
            break;
icculus@9
   633
        }
icculus@9
   634
icculus@9
   635
    }
icculus@9
   636
    return 1;
icculus@9
   637
}
icculus@9
   638
icculus@9
   639
static void
icculus@9
   640
GetEnvironmentWindowPosition(int w, int h, int *x, int *y)
icculus@9
   641
{
icculus@9
   642
    int display = SDL_VideoDisplayIndex;
icculus@9
   643
    const char *window = SDL_getenv("SDL_VIDEO_WINDOW_POS");
icculus@9
   644
    const char *center = SDL_getenv("SDL_VIDEO_CENTERED");
icculus@9
   645
    if (window) {
icculus@9
   646
        if (SDL_sscanf(window, "%d,%d", x, y) == 2) {
icculus@9
   647
            return;
icculus@9
   648
        }
icculus@9
   649
        if (SDL_strcmp(window, "center") == 0) {
icculus@9
   650
            center = window;
icculus@9
   651
        }
icculus@9
   652
    }
icculus@9
   653
    if (center) {
icculus@9
   654
        *x = SDL_WINDOWPOS_CENTERED_DISPLAY(display);
icculus@9
   655
        *y = SDL_WINDOWPOS_CENTERED_DISPLAY(display);
icculus@9
   656
    }
icculus@9
   657
}
icculus@9
   658
icculus@9
   659
static void
icculus@9
   660
ClearVideoSurface()
icculus@9
   661
{
icculus@9
   662
    if (SDL_ShadowSurface) {
icculus@9
   663
        SDL_FillRect(SDL_ShadowSurface, NULL,
icculus@9
   664
            SDL_MapRGB(SDL_ShadowSurface->format, 0, 0, 0));
icculus@9
   665
    }
icculus@9
   666
    SDL_FillRect(SDL_WindowSurface, NULL, 0);
icculus@9
   667
    SDL_UpdateWindowSurface(SDL_VideoWindow);
icculus@9
   668
}
icculus@9
   669
icculus@9
   670
static void
icculus@9
   671
SetupScreenSaver(int flags)
icculus@9
   672
{
icculus@9
   673
    const char *env;
icculus@9
   674
    SDL_bool allow_screensaver;
icculus@9
   675
icculus@9
   676
    /* Allow environment override of screensaver disable */
icculus@9
   677
    env = SDL_getenv("SDL_VIDEO_ALLOW_SCREENSAVER");
icculus@9
   678
    if (env) {
icculus@9
   679
        allow_screensaver = SDL_atoi(env) ? SDL_TRUE : SDL_FALSE;
icculus@9
   680
    } else if (flags & SDL_FULLSCREEN) {
icculus@9
   681
        allow_screensaver = SDL_FALSE;
icculus@9
   682
    } else {
icculus@9
   683
        allow_screensaver = SDL_TRUE;
icculus@9
   684
    }
icculus@9
   685
    if (allow_screensaver) {
icculus@9
   686
        SDL_EnableScreenSaver();
icculus@9
   687
    } else {
icculus@9
   688
        SDL_DisableScreenSaver();
icculus@9
   689
    }
icculus@9
   690
}
icculus@9
   691
icculus@9
   692
static int
icculus@9
   693
SDL_ResizeVideoMode(int width, int height, int bpp, Uint32 flags)
icculus@9
   694
{
icculus@9
   695
    int w, h;
icculus@9
   696
icculus@9
   697
    /* We can't resize something we don't have... */
icculus@9
   698
    if (!SDL_VideoSurface) {
icculus@9
   699
        return -1;
icculus@9
   700
    }
icculus@9
   701
icculus@9
   702
    /* We probably have to recreate the window in fullscreen mode */
icculus@9
   703
    if (flags & SDL_FULLSCREEN) {
icculus@9
   704
        return -1;
icculus@9
   705
    }
icculus@9
   706
icculus@9
   707
    /* I don't think there's any change we can gracefully make in flags */
icculus@9
   708
    if (flags != SDL_VideoFlags) {
icculus@9
   709
        return -1;
icculus@9
   710
    }
icculus@9
   711
    if (bpp != SDL_VideoSurface->format->BitsPerPixel) {
icculus@9
   712
        return -1;
icculus@9
   713
    }
icculus@9
   714
icculus@9
   715
    /* Resize the window */
icculus@9
   716
    SDL_GetWindowSize(SDL_VideoWindow, &w, &h);
icculus@9
   717
    if (w != width || h != height) {
icculus@9
   718
        SDL_SetWindowSize(SDL_VideoWindow, width, height);
icculus@9
   719
    }
icculus@9
   720
icculus@9
   721
    /* If we're in OpenGL mode, just resize the stub surface and we're done! */
icculus@9
   722
    if (flags & SDL_OPENGL) {
icculus@9
   723
        SDL_VideoSurface->w = width;
icculus@9
   724
        SDL_VideoSurface->h = height;
icculus@9
   725
        return 0;
icculus@9
   726
    }
icculus@9
   727
icculus@9
   728
    SDL_WindowSurface = SDL_GetWindowSurface(SDL_VideoWindow);
icculus@9
   729
    if (!SDL_WindowSurface) {
icculus@9
   730
        return -1;
icculus@9
   731
    }
icculus@9
   732
    if (SDL_VideoSurface->format != SDL_WindowSurface->format) {
icculus@9
   733
        return -1;
icculus@9
   734
    }
icculus@9
   735
    SDL_VideoSurface->w = width;
icculus@9
   736
    SDL_VideoSurface->h = height;
icculus@9
   737
    SDL_VideoSurface->pixels = SDL_WindowSurface->pixels;
icculus@9
   738
    SDL_VideoSurface->pitch = SDL_WindowSurface->pitch;
icculus@9
   739
    SDL_SetClipRect(SDL_VideoSurface, NULL);
icculus@9
   740
icculus@9
   741
    if (SDL_ShadowSurface) {
icculus@9
   742
        SDL_ShadowSurface->w = width;
icculus@9
   743
        SDL_ShadowSurface->h = height;
icculus@9
   744
        SDL_ShadowSurface->pitch = SDL_CalculatePitch(SDL_ShadowSurface);
icculus@9
   745
        SDL_ShadowSurface->pixels =
icculus@9
   746
            SDL_realloc(SDL_ShadowSurface->pixels,
icculus@9
   747
                        SDL_ShadowSurface->h * SDL_ShadowSurface->pitch);
icculus@9
   748
        SDL_SetClipRect(SDL_ShadowSurface, NULL);
icculus@9
   749
        SDL_InvalidateMap(SDL_ShadowSurface->map);
icculus@9
   750
    } else {
icculus@9
   751
        SDL_PublicSurface = SDL_VideoSurface;
icculus@9
   752
    }
icculus@9
   753
icculus@9
   754
    ClearVideoSurface();
icculus@9
   755
icculus@9
   756
    return 0;
icculus@9
   757
}
icculus@9
   758
icculus@9
   759
SDL_Surface *
icculus@9
   760
SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags)
icculus@9
   761
{
icculus@9
   762
    SDL_DisplayMode desktop_mode;
icculus@9
   763
    int display = SDL_VideoDisplayIndex;
icculus@9
   764
    int window_x = SDL_WINDOWPOS_UNDEFINED_DISPLAY(display);
icculus@9
   765
    int window_y = SDL_WINDOWPOS_UNDEFINED_DISPLAY(display);
icculus@9
   766
    int window_w;
icculus@9
   767
    int window_h;
icculus@9
   768
    Uint32 window_flags;
icculus@9
   769
    Uint32 surface_flags;
icculus@9
   770
icculus@9
   771
    if (!SDL_GetVideoDevice()) {
icculus@9
   772
        if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE) < 0) {
icculus@9
   773
            return NULL;
icculus@9
   774
        }
icculus@9
   775
    }
icculus@9
   776
icculus@9
   777
    SDL_GetDesktopDisplayMode(display, &desktop_mode);
icculus@9
   778
icculus@9
   779
    if (width == 0) {
icculus@9
   780
        width = desktop_mode.w;
icculus@9
   781
    }
icculus@9
   782
    if (height == 0) {
icculus@9
   783
        height = desktop_mode.h;
icculus@9
   784
    }
icculus@9
   785
    if (bpp == 0) {
icculus@9
   786
        bpp = SDL_BITSPERPIXEL(desktop_mode.format);
icculus@9
   787
    }
icculus@9
   788
icculus@9
   789
    /* See if we can simply resize the existing window and surface */
icculus@9
   790
    if (SDL_ResizeVideoMode(width, height, bpp, flags) == 0) {
icculus@9
   791
        return SDL_PublicSurface;
icculus@9
   792
    }
icculus@9
   793
icculus@9
   794
    /* Destroy existing window */
icculus@9
   795
    SDL_PublicSurface = NULL;
icculus@9
   796
    if (SDL_ShadowSurface) {
icculus@9
   797
        SDL_ShadowSurface->flags &= ~SDL_DONTFREE;
icculus@9
   798
        SDL_FreeSurface(SDL_ShadowSurface);
icculus@9
   799
        SDL_ShadowSurface = NULL;
icculus@9
   800
    }
icculus@9
   801
    if (SDL_VideoSurface) {
icculus@9
   802
        SDL_VideoSurface->flags &= ~SDL_DONTFREE;
icculus@9
   803
        SDL_FreeSurface(SDL_VideoSurface);
icculus@9
   804
        SDL_VideoSurface = NULL;
icculus@9
   805
    }
icculus@9
   806
    if (SDL_VideoContext) {
icculus@9
   807
        /* SDL_GL_MakeCurrent(0, NULL); *//* Doesn't do anything */
icculus@9
   808
        SDL_GL_DeleteContext(SDL_VideoContext);
icculus@9
   809
        SDL_VideoContext = NULL;
icculus@9
   810
    }
icculus@9
   811
    if (SDL_VideoWindow) {
icculus@9
   812
        SDL_GetWindowPosition(SDL_VideoWindow, &window_x, &window_y);
icculus@9
   813
        SDL_DestroyWindow(SDL_VideoWindow);
icculus@9
   814
    }
icculus@9
   815
icculus@9
   816
    /* Set up the event filter */
icculus@9
   817
    if (!SDL_GetEventFilter(NULL, NULL)) {
icculus@9
   818
        SDL_SetEventFilter(SDL_CompatEventFilter, NULL);
icculus@9
   819
    }
icculus@9
   820
icculus@9
   821
    /* Create a new window */
icculus@9
   822
    window_flags = SDL_WINDOW_SHOWN;
icculus@9
   823
    if (flags & SDL_FULLSCREEN) {
icculus@9
   824
        window_flags |= SDL_WINDOW_FULLSCREEN;
icculus@9
   825
    }
icculus@9
   826
    if (flags & SDL_OPENGL) {
icculus@9
   827
        window_flags |= SDL_WINDOW_OPENGL;
icculus@9
   828
    }
icculus@9
   829
    if (flags & SDL_RESIZABLE) {
icculus@9
   830
        window_flags |= SDL_WINDOW_RESIZABLE;
icculus@9
   831
    }
icculus@9
   832
    if (flags & SDL_NOFRAME) {
icculus@9
   833
        window_flags |= SDL_WINDOW_BORDERLESS;
icculus@9
   834
    }
icculus@9
   835
    GetEnvironmentWindowPosition(width, height, &window_x, &window_y);
icculus@9
   836
    SDL_VideoWindow =
icculus@9
   837
        SDL_CreateWindow(wm_title, window_x, window_y, width, height,
icculus@9
   838
                         window_flags);
icculus@9
   839
    if (!SDL_VideoWindow) {
icculus@9
   840
        return NULL;
icculus@9
   841
    }
icculus@9
   842
    SDL_SetWindowIcon(SDL_VideoWindow, SDL_VideoIcon);
icculus@9
   843
icculus@9
   844
    SetupScreenSaver(flags);
icculus@9
   845
icculus@9
   846
    window_flags = SDL_GetWindowFlags(SDL_VideoWindow);
icculus@9
   847
    surface_flags = 0;
icculus@9
   848
    if (window_flags & SDL_WINDOW_FULLSCREEN) {
icculus@9
   849
        surface_flags |= SDL_FULLSCREEN;
icculus@9
   850
    }
icculus@9
   851
    if ((window_flags & SDL_WINDOW_OPENGL) && (flags & SDL_OPENGL)) {
icculus@9
   852
        surface_flags |= SDL_OPENGL;
icculus@9
   853
    }
icculus@9
   854
    if (window_flags & SDL_WINDOW_RESIZABLE) {
icculus@9
   855
        surface_flags |= SDL_RESIZABLE;
icculus@9
   856
    }
icculus@9
   857
    if (window_flags & SDL_WINDOW_BORDERLESS) {
icculus@9
   858
        surface_flags |= SDL_NOFRAME;
icculus@9
   859
    }
icculus@9
   860
icculus@9
   861
    SDL_VideoFlags = flags;
icculus@9
   862
icculus@9
   863
    /* If we're in OpenGL mode, just create a stub surface and we're done! */
icculus@9
   864
    if (flags & SDL_OPENGL) {
icculus@9
   865
        SDL_VideoContext = SDL_GL_CreateContext(SDL_VideoWindow);
icculus@9
   866
        if (!SDL_VideoContext) {
icculus@9
   867
            return NULL;
icculus@9
   868
        }
icculus@9
   869
        if (SDL_GL_MakeCurrent(SDL_VideoWindow, SDL_VideoContext) < 0) {
icculus@9
   870
            return NULL;
icculus@9
   871
        }
icculus@9
   872
        SDL_VideoSurface =
icculus@9
   873
            SDL_CreateRGBSurfaceFrom(NULL, width, height, bpp, 0, 0, 0, 0, 0);
icculus@9
   874
        if (!SDL_VideoSurface) {
icculus@9
   875
            return NULL;
icculus@9
   876
        }
icculus@9
   877
        SDL_VideoSurface->flags |= surface_flags;
icculus@9
   878
        SDL_PublicSurface = SDL_VideoSurface;
icculus@9
   879
        return SDL_PublicSurface;
icculus@9
   880
    }
icculus@9
   881
icculus@9
   882
    /* Create the screen surface */
icculus@9
   883
    SDL_WindowSurface = SDL_GetWindowSurface(SDL_VideoWindow);
icculus@9
   884
    if (!SDL_WindowSurface) {
icculus@9
   885
        return NULL;
icculus@9
   886
    }
icculus@9
   887
icculus@9
   888
    /* Center the public surface in the window surface */
icculus@9
   889
    SDL_GetWindowSize(SDL_VideoWindow, &window_w, &window_h);
icculus@9
   890
    SDL_VideoViewport.x = (window_w - width)/2;
icculus@9
   891
    SDL_VideoViewport.y = (window_h - height)/2;
icculus@9
   892
    SDL_VideoViewport.w = width;
icculus@9
   893
    SDL_VideoViewport.h = height;
icculus@9
   894
icculus@9
   895
    SDL_VideoSurface = SDL_CreateRGBSurfaceFrom(NULL, 0, 0, 32, 0, 0, 0, 0, 0);
icculus@9
   896
    SDL_VideoSurface->flags |= surface_flags;
icculus@9
   897
    SDL_VideoSurface->flags |= SDL_DONTFREE;
icculus@9
   898
    SDL_FreeFormat(SDL_VideoSurface->format);
icculus@9
   899
    SDL_VideoSurface->format = SDL_WindowSurface->format;
icculus@9
   900
    SDL_VideoSurface->format->refcount++;
icculus@9
   901
    SDL_VideoSurface->w = width;
icculus@9
   902
    SDL_VideoSurface->h = height;
icculus@9
   903
    SDL_VideoSurface->pitch = SDL_WindowSurface->pitch;
icculus@9
   904
    SDL_VideoSurface->pixels = (void *)((Uint8 *)SDL_WindowSurface->pixels +
icculus@9
   905
        SDL_VideoViewport.y * SDL_VideoSurface->pitch +
icculus@9
   906
        SDL_VideoViewport.x  * SDL_VideoSurface->format->BytesPerPixel);
icculus@9
   907
    SDL_SetClipRect(SDL_VideoSurface, NULL);
icculus@9
   908
icculus@9
   909
    /* Create a shadow surface if necessary */
icculus@9
   910
    if ((bpp != SDL_VideoSurface->format->BitsPerPixel)
icculus@9
   911
        && !(flags & SDL_ANYFORMAT)) {
icculus@9
   912
        SDL_ShadowSurface =
icculus@9
   913
            SDL_CreateRGBSurface(0, width, height, bpp, 0, 0, 0, 0);
icculus@9
   914
        if (!SDL_ShadowSurface) {
icculus@9
   915
            return NULL;
icculus@9
   916
        }
icculus@9
   917
        SDL_ShadowSurface->flags |= surface_flags;
icculus@9
   918
        SDL_ShadowSurface->flags |= SDL_DONTFREE;
icculus@9
   919
icculus@9
   920
        /* 8-bit SDL_ShadowSurface surfaces report that they have exclusive palette */
icculus@9
   921
        if (SDL_ShadowSurface->format->palette) {
icculus@9
   922
            SDL_ShadowSurface->flags |= SDL_HWPALETTE;
icculus@9
   923
            SDL_DitherColors(SDL_ShadowSurface->format->palette->colors,
icculus@9
   924
                             SDL_ShadowSurface->format->BitsPerPixel);
icculus@9
   925
        }
icculus@9
   926
        SDL_FillRect(SDL_ShadowSurface, NULL,
icculus@9
   927
            SDL_MapRGB(SDL_ShadowSurface->format, 0, 0, 0));
icculus@9
   928
    }
icculus@9
   929
    SDL_PublicSurface =
icculus@9
   930
        (SDL_ShadowSurface ? SDL_ShadowSurface : SDL_VideoSurface);
icculus@9
   931
icculus@9
   932
    ClearVideoSurface();
icculus@9
   933
icculus@9
   934
    /* We're finally done! */
icculus@9
   935
    return SDL_PublicSurface;
icculus@9
   936
}
icculus@9
   937
icculus@9
   938
SDL_Surface *
icculus@9
   939
SDL_GetVideoSurface(void)
icculus@9
   940
{
icculus@9
   941
    return SDL_PublicSurface;
icculus@9
   942
}
icculus@9
   943
icculus@9
   944
int
icculus@9
   945
SDL_SetAlpha(SDL_Surface * surface, Uint32 flag, Uint8 value)
icculus@9
   946
{
icculus@9
   947
    if (flag & SDL_SRCALPHA) {
icculus@9
   948
        /* According to the docs, value is ignored for alpha surfaces */
icculus@9
   949
        if (surface->format->Amask) {
icculus@9
   950
            value = 0xFF;
icculus@9
   951
        }
icculus@9
   952
        SDL_SetSurfaceAlphaMod(surface, value);
icculus@9
   953
        SDL_SetSurfaceBlendMode(surface, SDL_BLENDMODE_BLEND);
icculus@9
   954
    } else {
icculus@9
   955
        SDL_SetSurfaceAlphaMod(surface, 0xFF);
icculus@9
   956
        SDL_SetSurfaceBlendMode(surface, SDL_BLENDMODE_NONE);
icculus@9
   957
    }
icculus@9
   958
    SDL_SetSurfaceRLE(surface, (flag & SDL_RLEACCEL));
icculus@9
   959
icculus@9
   960
    return 0;
icculus@9
   961
}
icculus@9
   962
icculus@9
   963
SDL_Surface *
icculus@9
   964
SDL_DisplayFormat(SDL_Surface * surface)
icculus@9
   965
{
icculus@9
   966
    SDL_PixelFormat *format;
icculus@9
   967
icculus@9
   968
    if (!SDL_PublicSurface) {
icculus@9
   969
        SDL_SetError("No video mode has been set");
icculus@9
   970
        return NULL;
icculus@9
   971
    }
icculus@9
   972
    format = SDL_PublicSurface->format;
icculus@9
   973
icculus@9
   974
    /* Set the flags appropriate for copying to display surface */
icculus@9
   975
    return SDL_ConvertSurface(surface, format, SDL_RLEACCEL);
icculus@9
   976
}
icculus@9
   977
icculus@9
   978
SDL_Surface *
icculus@9
   979
SDL_DisplayFormatAlpha(SDL_Surface * surface)
icculus@9
   980
{
icculus@9
   981
    SDL_PixelFormat *vf;
icculus@9
   982
    SDL_PixelFormat *format;
icculus@9
   983
    SDL_Surface *converted;
icculus@9
   984
    /* default to ARGB8888 */
icculus@9
   985
    Uint32 amask = 0xff000000;
icculus@9
   986
    Uint32 rmask = 0x00ff0000;
icculus@9
   987
    Uint32 gmask = 0x0000ff00;
icculus@9
   988
    Uint32 bmask = 0x000000ff;
icculus@9
   989
icculus@9
   990
    if (!SDL_PublicSurface) {
icculus@9
   991
        SDL_SetError("No video mode has been set");
icculus@9
   992
        return NULL;
icculus@9
   993
    }
icculus@9
   994
    vf = SDL_PublicSurface->format;
icculus@9
   995
icculus@9
   996
    switch (vf->BytesPerPixel) {
icculus@9
   997
    case 2:
icculus@9
   998
        /* For XGY5[56]5, use, AXGY8888, where {X, Y} = {R, B}.
icculus@9
   999
           For anything else (like ARGB4444) it doesn't matter
icculus@9
  1000
           since we have no special code for it anyway */
icculus@9
  1001
        if ((vf->Rmask == 0x1f) &&
icculus@9
  1002
            (vf->Bmask == 0xf800 || vf->Bmask == 0x7c00)) {
icculus@9
  1003
            rmask = 0xff;
icculus@9
  1004
            bmask = 0xff0000;
icculus@9
  1005
        }
icculus@9
  1006
        break;
icculus@9
  1007
icculus@9
  1008
    case 3:
icculus@9
  1009
    case 4:
icculus@9
  1010
        /* Keep the video format, as long as the high 8 bits are
icculus@9
  1011
           unused or alpha */
icculus@9
  1012
        if ((vf->Rmask == 0xff) && (vf->Bmask == 0xff0000)) {
icculus@9
  1013
            rmask = 0xff;
icculus@9
  1014
            bmask = 0xff0000;
icculus@9
  1015
        }
icculus@9
  1016
        break;
icculus@9
  1017
icculus@9
  1018
    default:
icculus@9
  1019
        /* We have no other optimised formats right now. When/if a new
icculus@9
  1020
           optimised alpha format is written, add the converter here */
icculus@9
  1021
        break;
icculus@9
  1022
    }
icculus@9
  1023
    format = SDL_AllocFormat(SDL_MasksToPixelFormatEnum(32, rmask,
icculus@9
  1024
                                                            gmask,
icculus@9
  1025
                                                            bmask,
icculus@9
  1026
                                                            amask));
icculus@9
  1027
    if (!format) {
icculus@9
  1028
        return NULL;
icculus@9
  1029
    }
icculus@9
  1030
    converted = SDL_ConvertSurface(surface, format, SDL_RLEACCEL);
icculus@9
  1031
    SDL_FreeFormat(format);
icculus@9
  1032
    return converted;
icculus@9
  1033
}
icculus@9
  1034
icculus@9
  1035
int
icculus@9
  1036
SDL_Flip(SDL_Surface * screen)
icculus@9
  1037
{
icculus@9
  1038
    SDL_UpdateRect(screen, 0, 0, 0, 0);
icculus@9
  1039
    return 0;
icculus@9
  1040
}
icculus@9
  1041
icculus@9
  1042
void
icculus@9
  1043
SDL_UpdateRect(SDL_Surface * screen, Sint32 x, Sint32 y, Uint32 w, Uint32 h)
icculus@9
  1044
{
icculus@9
  1045
    if (screen) {
icculus@9
  1046
        SDL_Rect rect;
icculus@9
  1047
icculus@9
  1048
        /* Fill the rectangle */
icculus@9
  1049
        rect.x = (int) x;
icculus@9
  1050
        rect.y = (int) y;
icculus@9
  1051
        rect.w = (int) (w ? w : screen->w);
icculus@9
  1052
        rect.h = (int) (h ? h : screen->h);
icculus@9
  1053
        SDL_UpdateRects(screen, 1, &rect);
icculus@9
  1054
    }
icculus@9
  1055
}
icculus@9
  1056
icculus@9
  1057
void
icculus@9
  1058
SDL_UpdateRects(SDL_Surface * screen, int numrects, SDL_Rect * rects)
icculus@9
  1059
{
icculus@9
  1060
    int i;
icculus@9
  1061
icculus@9
  1062
    if (screen == SDL_ShadowSurface) {
icculus@9
  1063
        for (i = 0; i < numrects; ++i) {
icculus@9
  1064
            SDL_BlitSurface(SDL_ShadowSurface, &rects[i], SDL_VideoSurface,
icculus@9
  1065
                            &rects[i]);
icculus@9
  1066
        }
icculus@9
  1067
icculus@9
  1068
        /* Fall through to video surface update */
icculus@9
  1069
        screen = SDL_VideoSurface;
icculus@9
  1070
    }
icculus@9
  1071
    if (screen == SDL_VideoSurface) {
icculus@9
  1072
        if (SDL_VideoViewport.x || SDL_VideoViewport.y) {
icculus@9
  1073
            SDL_Rect *stackrects = SDL_stack_alloc(SDL_Rect, numrects);
icculus@9
  1074
            SDL_Rect *stackrect;
icculus@9
  1075
            const SDL_Rect *rect;
icculus@9
  1076
            
icculus@9
  1077
            /* Offset all the rectangles before updating */
icculus@9
  1078
            for (i = 0; i < numrects; ++i) {
icculus@9
  1079
                rect = &rects[i];
icculus@9
  1080
                stackrect = &stackrects[i];
icculus@9
  1081
                stackrect->x = SDL_VideoViewport.x + rect->x;
icculus@9
  1082
                stackrect->y = SDL_VideoViewport.y + rect->y;
icculus@9
  1083
                stackrect->w = rect->w;
icculus@9
  1084
                stackrect->h = rect->h;
icculus@9
  1085
            }
icculus@9
  1086
            SDL_UpdateWindowSurfaceRects(SDL_VideoWindow, stackrects, numrects);
icculus@9
  1087
            SDL_stack_free(stackrects);
icculus@9
  1088
        } else {
icculus@9
  1089
            SDL_UpdateWindowSurfaceRects(SDL_VideoWindow, rects, numrects);
icculus@9
  1090
        }
icculus@9
  1091
    }
icculus@9
  1092
}
icculus@9
  1093
icculus@9
  1094
void
icculus@9
  1095
SDL_WM_SetCaption(const char *title, const char *icon)
icculus@9
  1096
{
icculus@9
  1097
    if (wm_title) {
icculus@9
  1098
        SDL_free(wm_title);
icculus@9
  1099
    }
icculus@9
  1100
    if (wm_icon_caption) {
icculus@9
  1101
        SDL_free(wm_icon_caption);
icculus@9
  1102
    }
icculus@9
  1103
    wm_title = title ? SDL_strdup(title) : NULL;
icculus@9
  1104
    wm_icon_caption = icon ? SDL_strdup(icon) : NULL;
icculus@9
  1105
    SDL_SetWindowTitle(SDL_VideoWindow, wm_title);
icculus@9
  1106
}
icculus@9
  1107
icculus@9
  1108
void
icculus@9
  1109
SDL_WM_GetCaption(const char **title, const char **icon)
icculus@9
  1110
{
icculus@9
  1111
    if (title) {
icculus@9
  1112
        *title = wm_title;
icculus@9
  1113
    }
icculus@9
  1114
    if (icon) {
icculus@9
  1115
        *icon = wm_icon_caption;
icculus@9
  1116
    }
icculus@9
  1117
}
icculus@9
  1118
icculus@9
  1119
void
icculus@9
  1120
SDL_WM_SetIcon(SDL_Surface * icon, Uint8 * mask)
icculus@9
  1121
{
icculus@9
  1122
    // !!! FIXME: free previous icon?
icculus@9
  1123
    SDL_VideoIcon = icon;
icculus@9
  1124
    ++SDL_VideoIcon->refcount;
icculus@9
  1125
}
icculus@9
  1126
icculus@9
  1127
int
icculus@9
  1128
SDL_WM_IconifyWindow(void)
icculus@9
  1129
{
icculus@9
  1130
    SDL_MinimizeWindow(SDL_VideoWindow);
icculus@9
  1131
    return 0;
icculus@9
  1132
}
icculus@9
  1133
icculus@9
  1134
int
icculus@9
  1135
SDL_WM_ToggleFullScreen(SDL_Surface * surface)
icculus@9
  1136
{
icculus@9
  1137
    int length;
icculus@9
  1138
    void *pixels;
icculus@9
  1139
    Uint8 *src, *dst;
icculus@9
  1140
    int row;
icculus@9
  1141
    int window_w;
icculus@9
  1142
    int window_h;
icculus@9
  1143
icculus@9
  1144
    if (!SDL_PublicSurface) {
icculus@9
  1145
        SDL_SetError("SDL_SetVideoMode() hasn't been called");
icculus@9
  1146
        return 0;
icculus@9
  1147
    }
icculus@9
  1148
icculus@9
  1149
    /* Copy the old bits out */
icculus@9
  1150
    length = SDL_PublicSurface->w * SDL_PublicSurface->format->BytesPerPixel;
icculus@9
  1151
    pixels = SDL_malloc(SDL_PublicSurface->h * length);
icculus@9
  1152
    if (pixels && SDL_PublicSurface->pixels) {
icculus@9
  1153
        src = (Uint8*)SDL_PublicSurface->pixels;
icculus@9
  1154
        dst = (Uint8*)pixels;
icculus@9
  1155
        for (row = 0; row < SDL_PublicSurface->h; ++row) {
icculus@9
  1156
            SDL_memcpy(dst, src, length);
icculus@9
  1157
            src += SDL_PublicSurface->pitch;
icculus@9
  1158
            dst += length;
icculus@9
  1159
        }
icculus@9
  1160
    }
icculus@9
  1161
icculus@9
  1162
    /* Do the physical mode switch */
icculus@9
  1163
    if (SDL_GetWindowFlags(SDL_VideoWindow) & SDL_WINDOW_FULLSCREEN) {
icculus@9
  1164
        if (SDL_SetWindowFullscreen(SDL_VideoWindow, 0) < 0) {
icculus@9
  1165
            return 0;
icculus@9
  1166
        }
icculus@9
  1167
        SDL_PublicSurface->flags &= ~SDL_FULLSCREEN;
icculus@9
  1168
    } else {
icculus@9
  1169
        if (SDL_SetWindowFullscreen(SDL_VideoWindow, 1) < 0) {
icculus@9
  1170
            return 0;
icculus@9
  1171
        }
icculus@9
  1172
        SDL_PublicSurface->flags |= SDL_FULLSCREEN;
icculus@9
  1173
    }
icculus@9
  1174
icculus@9
  1175
    /* Recreate the screen surface */
icculus@9
  1176
    SDL_WindowSurface = SDL_GetWindowSurface(SDL_VideoWindow);
icculus@9
  1177
    if (!SDL_WindowSurface) {
icculus@9
  1178
        /* We're totally hosed... */
icculus@9
  1179
        return 0;
icculus@9
  1180
    }
icculus@9
  1181
icculus@9
  1182
    /* Center the public surface in the window surface */
icculus@9
  1183
    SDL_GetWindowSize(SDL_VideoWindow, &window_w, &window_h);
icculus@9
  1184
    SDL_VideoViewport.x = (window_w - SDL_VideoSurface->w)/2;
icculus@9
  1185
    SDL_VideoViewport.y = (window_h - SDL_VideoSurface->h)/2;
icculus@9
  1186
    SDL_VideoViewport.w = SDL_VideoSurface->w;
icculus@9
  1187
    SDL_VideoViewport.h = SDL_VideoSurface->h;
icculus@9
  1188
icculus@9
  1189
    /* Do some shuffling behind the application's back if format changes */
icculus@9
  1190
    if (SDL_VideoSurface->format->format != SDL_WindowSurface->format->format) {
icculus@9
  1191
        if (SDL_ShadowSurface) {
icculus@9
  1192
            if (SDL_ShadowSurface->format->format == SDL_WindowSurface->format->format) {
icculus@9
  1193
                /* Whee!  We don't need a shadow surface anymore! */
icculus@9
  1194
                SDL_VideoSurface->flags &= ~SDL_DONTFREE;
icculus@9
  1195
                SDL_FreeSurface(SDL_VideoSurface);
icculus@9
  1196
                SDL_free(SDL_ShadowSurface->pixels);
icculus@9
  1197
                SDL_VideoSurface = SDL_ShadowSurface;
icculus@9
  1198
                SDL_VideoSurface->flags |= SDL_PREALLOC;
icculus@9
  1199
                SDL_ShadowSurface = NULL;
icculus@9
  1200
            } else {
icculus@9
  1201
                /* No problem, just change the video surface format */
icculus@9
  1202
                SDL_FreeFormat(SDL_VideoSurface->format);
icculus@9
  1203
                SDL_VideoSurface->format = SDL_WindowSurface->format;
icculus@9
  1204
                SDL_VideoSurface->format->refcount++;
icculus@9
  1205
                SDL_InvalidateMap(SDL_ShadowSurface->map);
icculus@9
  1206
            }
icculus@9
  1207
        } else {
icculus@9
  1208
            /* We can make the video surface the shadow surface */
icculus@9
  1209
            SDL_ShadowSurface = SDL_VideoSurface;
icculus@9
  1210
            SDL_ShadowSurface->pitch = SDL_CalculatePitch(SDL_ShadowSurface);
icculus@9
  1211
            SDL_ShadowSurface->pixels = SDL_malloc(SDL_ShadowSurface->h * SDL_ShadowSurface->pitch);
icculus@9
  1212
            if (!SDL_ShadowSurface->pixels) {
icculus@9
  1213
                /* Uh oh, we're hosed */
icculus@9
  1214
                SDL_ShadowSurface = NULL;
icculus@9
  1215
                return 0;
icculus@9
  1216
            }
icculus@9
  1217
            SDL_ShadowSurface->flags &= ~SDL_PREALLOC;
icculus@9
  1218
icculus@9
  1219
            SDL_VideoSurface = SDL_CreateRGBSurfaceFrom(NULL, 0, 0, 32, 0, 0, 0, 0, 0);
icculus@9
  1220
            SDL_VideoSurface->flags = SDL_ShadowSurface->flags;
icculus@9
  1221
            SDL_VideoSurface->flags |= SDL_PREALLOC;
icculus@9
  1222
            SDL_FreeFormat(SDL_VideoSurface->format);
icculus@9
  1223
            SDL_VideoSurface->format = SDL_WindowSurface->format;
icculus@9
  1224
            SDL_VideoSurface->format->refcount++;
icculus@9
  1225
            SDL_VideoSurface->w = SDL_ShadowSurface->w;
icculus@9
  1226
            SDL_VideoSurface->h = SDL_ShadowSurface->h;
icculus@9
  1227
        }
icculus@9
  1228
    }
icculus@9
  1229
icculus@9
  1230
    /* Update the video surface */
icculus@9
  1231
    SDL_VideoSurface->pitch = SDL_WindowSurface->pitch;
icculus@9
  1232
    SDL_VideoSurface->pixels = (void *)((Uint8 *)SDL_WindowSurface->pixels +
icculus@9
  1233
        SDL_VideoViewport.y * SDL_VideoSurface->pitch +
icculus@9
  1234
        SDL_VideoViewport.x  * SDL_VideoSurface->format->BytesPerPixel);
icculus@9
  1235
    SDL_SetClipRect(SDL_VideoSurface, NULL);
icculus@9
  1236
icculus@9
  1237
    /* Copy the old bits back */
icculus@9
  1238
    if (pixels) {
icculus@9
  1239
        src = (Uint8*)pixels;
icculus@9
  1240
        dst = (Uint8*)SDL_PublicSurface->pixels;
icculus@9
  1241
        for (row = 0; row < SDL_PublicSurface->h; ++row) {
icculus@9
  1242
            SDL_memcpy(dst, src, length);
icculus@9
  1243
            src += length;
icculus@9
  1244
            dst += SDL_PublicSurface->pitch;
icculus@9
  1245
        }
icculus@9
  1246
        SDL_Flip(SDL_PublicSurface);
icculus@9
  1247
        SDL_free(pixels);
icculus@9
  1248
    }
icculus@9
  1249
icculus@9
  1250
    /* We're done! */
icculus@9
  1251
    return 1;
icculus@9
  1252
}
icculus@9
  1253
icculus@9
  1254
SDL_GrabMode
icculus@9
  1255
SDL_WM_GrabInput(SDL_GrabMode mode)
icculus@9
  1256
{
icculus@9
  1257
    if (mode != SDL_GRAB_QUERY) {
icculus@9
  1258
        SDL_SetWindowGrab(SDL_VideoWindow, mode);
icculus@9
  1259
    }
icculus@9
  1260
    return (SDL_GrabMode) SDL_GetWindowGrab(SDL_VideoWindow);
icculus@9
  1261
}
icculus@9
  1262
icculus@9
  1263
void
icculus@9
  1264
SDL_WarpMouse(Uint16 x, Uint16 y)
icculus@9
  1265
{
icculus@9
  1266
    SDL_WarpMouseInWindow(SDL_VideoWindow, x, y);
icculus@9
  1267
}
icculus@9
  1268
icculus@9
  1269
Uint8
icculus@9
  1270
SDL_GetAppState(void)
icculus@9
  1271
{
icculus@9
  1272
    Uint8 state = 0;
icculus@9
  1273
    Uint32 flags = 0;
icculus@9
  1274
icculus@9
  1275
    flags = SDL_GetWindowFlags(SDL_VideoWindow);
icculus@9
  1276
    if ((flags & SDL_WINDOW_SHOWN) && !(flags & SDL_WINDOW_MINIMIZED)) {
icculus@9
  1277
        state |= SDL_APPACTIVE;
icculus@9
  1278
    }
icculus@9
  1279
    if (flags & SDL_WINDOW_INPUT_FOCUS) {
icculus@9
  1280
        state |= SDL_APPINPUTFOCUS;
icculus@9
  1281
    }
icculus@9
  1282
    if (flags & SDL_WINDOW_MOUSE_FOCUS) {
icculus@9
  1283
        state |= SDL_APPMOUSEFOCUS;
icculus@9
  1284
    }
icculus@9
  1285
    return state;
icculus@9
  1286
}
icculus@9
  1287
icculus@9
  1288
const SDL_version *
icculus@9
  1289
SDL_Linked_Version(void)
icculus@9
  1290
{
icculus@9
  1291
    static SDL_version version;
icculus@9
  1292
    SDL_VERSION(&version);
icculus@9
  1293
    return &version;
icculus@9
  1294
}
icculus@9
  1295
icculus@9
  1296
int
icculus@9
  1297
SDL_SetPalette(SDL_Surface * surface, int flags, const SDL_Color * colors,
icculus@9
  1298
               int firstcolor, int ncolors)
icculus@9
  1299
{
icculus@9
  1300
    return SDL_SetColors(surface, colors, firstcolor, ncolors);
icculus@9
  1301
}
icculus@9
  1302
icculus@9
  1303
int
icculus@9
  1304
SDL_SetColors(SDL_Surface * surface, const SDL_Color * colors, int firstcolor,
icculus@9
  1305
              int ncolors)
icculus@9
  1306
{
icculus@9
  1307
    if (SDL_SetPaletteColors
icculus@9
  1308
        (surface->format->palette, colors, firstcolor, ncolors) == 0) {
icculus@9
  1309
        return 1;
icculus@9
  1310
    } else {
icculus@9
  1311
        return 0;
icculus@9
  1312
    }
icculus@9
  1313
}
icculus@9
  1314
icculus@9
  1315
int
icculus@9
  1316
SDL_GetWMInfo(SDL_SysWMinfo * info)
icculus@9
  1317
{
icculus@9
  1318
    return SDL_GetWindowWMInfo(SDL_VideoWindow, info);
icculus@9
  1319
}
icculus@9
  1320
icculus@9
  1321
#if 0
icculus@9
  1322
void
icculus@9
  1323
SDL_MoveCursor(int x, int y)
icculus@9
  1324
{
icculus@9
  1325
    SDL_VideoDevice *_this = SDL_GetVideoDevice();
icculus@9
  1326
icculus@9
  1327
    /* Erase and update the current mouse position */
icculus@9
  1328
    if (SHOULD_DRAWCURSOR(SDL_cursorstate)) {
icculus@9
  1329
        /* Erase and redraw mouse cursor in new position */
icculus@9
  1330
        SDL_LockCursor();
icculus@9
  1331
        SDL_EraseCursor(SDL_VideoSurface);
icculus@9
  1332
        SDL_cursor->area.x = (x - SDL_cursor->hot_x);
icculus@9
  1333
        SDL_cursor->area.y = (y - SDL_cursor->hot_y);
icculus@9
  1334
        SDL_DrawCursor(SDL_VideoSurface);
icculus@9
  1335
        SDL_UnlockCursor();
icculus@9
  1336
    } else if (_this->MoveWMCursor) {
icculus@9
  1337
        _this->MoveWMCursor(_this, x, y);
icculus@9
  1338
    }
icculus@9
  1339
}
icculus@9
  1340
icculus@9
  1341
/* Keep track of the current cursor colors */
icculus@9
  1342
static int palette_changed = 1;
icculus@9
  1343
static Uint8 pixels8[2];
icculus@9
  1344
icculus@9
  1345
void
icculus@9
  1346
SDL_CursorPaletteChanged(void)
icculus@9
  1347
{
icculus@9
  1348
    palette_changed = 1;
icculus@9
  1349
}
icculus@9
  1350
icculus@9
  1351
void
icculus@9
  1352
SDL_MouseRect(SDL_Rect * area)
icculus@9
  1353
{
icculus@9
  1354
    SDL_VideoDevice *_this = SDL_GetVideoDevice();
icculus@9
  1355
    int clip_diff;
icculus@9
  1356
icculus@9
  1357
    *area = SDL_cursor->area;
icculus@9
  1358
    if (area->x < 0) {
icculus@9
  1359
        area->w += area->x;
icculus@9
  1360
        area->x = 0;
icculus@9
  1361
    }
icculus@9
  1362
    if (area->y < 0) {
icculus@9
  1363
        area->h += area->y;
icculus@9
  1364
        area->y = 0;
icculus@9
  1365
    }
icculus@9
  1366
    clip_diff = (area->x + area->w) - SDL_VideoSurface->w;
icculus@9
  1367
    if (clip_diff > 0) {
icculus@9
  1368
        area->w = area->w < clip_diff ? 0 : area->w - clip_diff;
icculus@9
  1369
    }
icculus@9
  1370
    clip_diff = (area->y + area->h) - SDL_VideoSurface->h;
icculus@9
  1371
    if (clip_diff > 0) {
icculus@9
  1372
        area->h = area->h < clip_diff ? 0 : area->h - clip_diff;
icculus@9
  1373
    }
icculus@9
  1374
}
icculus@9
  1375
icculus@9
  1376
static void
icculus@9
  1377
SDL_DrawCursorFast(SDL_Surface * screen, SDL_Rect * area)
icculus@9
  1378
{
icculus@9
  1379
    const Uint32 pixels[2] = { 0xFFFFFFFF, 0x00000000 };
icculus@9
  1380
    int i, w, h;
icculus@9
  1381
    Uint8 *data, datab;
icculus@9
  1382
    Uint8 *mask, maskb;
icculus@9
  1383
icculus@9
  1384
    data = SDL_cursor->data + area->y * SDL_cursor->area.w / 8;
icculus@9
  1385
    mask = SDL_cursor->mask + area->y * SDL_cursor->area.w / 8;
icculus@9
  1386
    switch (screen->format->BytesPerPixel) {
icculus@9
  1387
icculus@9
  1388
    case 1:
icculus@9
  1389
        {
icculus@9
  1390
            Uint8 *dst;
icculus@9
  1391
            int dstskip;
icculus@9
  1392
icculus@9
  1393
            if (palette_changed) {
icculus@9
  1394
                pixels8[0] =
icculus@9
  1395
                    (Uint8) SDL_MapRGB(screen->format, 255, 255, 255);
icculus@9
  1396
                pixels8[1] = (Uint8) SDL_MapRGB(screen->format, 0, 0, 0);
icculus@9
  1397
                palette_changed = 0;
icculus@9
  1398
            }
icculus@9
  1399
            dst = (Uint8 *) screen->pixels +
icculus@9
  1400
                (SDL_cursor->area.y + area->y) * screen->pitch +
icculus@9
  1401
                SDL_cursor->area.x;
icculus@9
  1402
            dstskip = screen->pitch - area->w;
icculus@9
  1403
icculus@9
  1404
            for (h = area->h; h; h--) {
icculus@9
  1405
                for (w = area->w / 8; w; w--) {
icculus@9
  1406
                    maskb = *mask++;
icculus@9
  1407
                    datab = *data++;
icculus@9
  1408
                    for (i = 0; i < 8; ++i) {
icculus@9
  1409
                        if (maskb & 0x80) {
icculus@9
  1410
                            *dst = pixels8[datab >> 7];
icculus@9
  1411
                        }
icculus@9
  1412
                        maskb <<= 1;
icculus@9
  1413
                        datab <<= 1;
icculus@9
  1414
                        dst++;
icculus@9
  1415
                    }
icculus@9
  1416
                }
icculus@9
  1417
                dst += dstskip;
icculus@9
  1418
            }
icculus@9
  1419
        }
icculus@9
  1420
        break;
icculus@9
  1421
icculus@9
  1422
    case 2:
icculus@9
  1423
        {
icculus@9
  1424
            Uint16 *dst;
icculus@9
  1425
            int dstskip;
icculus@9
  1426
icculus@9
  1427
            dst = (Uint16 *) screen->pixels +
icculus@9
  1428
                (SDL_cursor->area.y + area->y) * screen->pitch / 2 +
icculus@9
  1429
                SDL_cursor->area.x;
icculus@9
  1430
            dstskip = (screen->pitch / 2) - area->w;
icculus@9
  1431
icculus@9
  1432
            for (h = area->h; h; h--) {
icculus@9
  1433
                for (w = area->w / 8; w; w--) {
icculus@9
  1434
                    maskb = *mask++;
icculus@9
  1435
                    datab = *data++;
icculus@9
  1436
                    for (i = 0; i < 8; ++i) {
icculus@9
  1437
                        if (maskb & 0x80) {
icculus@9
  1438
                            *dst = (Uint16) pixels[datab >> 7];
icculus@9
  1439
                        }
icculus@9
  1440
                        maskb <<= 1;
icculus@9
  1441
                        datab <<= 1;
icculus@9
  1442
                        dst++;
icculus@9
  1443
                    }
icculus@9
  1444
                }
icculus@9
  1445
                dst += dstskip;
icculus@9
  1446
            }
icculus@9
  1447
        }
icculus@9
  1448
        break;
icculus@9
  1449
icculus@9
  1450
    case 3:
icculus@9
  1451
        {
icculus@9
  1452
            Uint8 *dst;
icculus@9
  1453
            int dstskip;
icculus@9
  1454
icculus@9
  1455
            dst = (Uint8 *) screen->pixels +
icculus@9
  1456
                (SDL_cursor->area.y + area->y) * screen->pitch +
icculus@9
  1457
                SDL_cursor->area.x * 3;
icculus@9
  1458
            dstskip = screen->pitch - area->w * 3;
icculus@9
  1459
icculus@9
  1460
            for (h = area->h; h; h--) {
icculus@9
  1461
                for (w = area->w / 8; w; w--) {
icculus@9
  1462
                    maskb = *mask++;
icculus@9
  1463
                    datab = *data++;
icculus@9
  1464
                    for (i = 0; i < 8; ++i) {
icculus@9
  1465
                        if (maskb & 0x80) {
icculus@9
  1466
                            SDL_memset(dst, pixels[datab >> 7], 3);
icculus@9
  1467
                        }
icculus@9
  1468
                        maskb <<= 1;
icculus@9
  1469
                        datab <<= 1;
icculus@9
  1470
                        dst += 3;
icculus@9
  1471
                    }
icculus@9
  1472
                }
icculus@9
  1473
                dst += dstskip;
icculus@9
  1474
            }
icculus@9
  1475
        }
icculus@9
  1476
        break;
icculus@9
  1477
icculus@9
  1478
    case 4:
icculus@9
  1479
        {
icculus@9
  1480
            Uint32 *dst;
icculus@9
  1481
            int dstskip;
icculus@9
  1482
icculus@9
  1483
            dst = (Uint32 *) screen->pixels +
icculus@9
  1484
                (SDL_cursor->area.y + area->y) * screen->pitch / 4 +
icculus@9
  1485
                SDL_cursor->area.x;
icculus@9
  1486
            dstskip = (screen->pitch / 4) - area->w;
icculus@9
  1487
icculus@9
  1488
            for (h = area->h; h; h--) {
icculus@9
  1489
                for (w = area->w / 8; w; w--) {
icculus@9
  1490
                    maskb = *mask++;
icculus@9
  1491
                    datab = *data++;
icculus@9
  1492
                    for (i = 0; i < 8; ++i) {
icculus@9
  1493
                        if (maskb & 0x80) {
icculus@9
  1494
                            *dst = pixels[datab >> 7];
icculus@9
  1495
                        }
icculus@9
  1496
                        maskb <<= 1;
icculus@9
  1497
                        datab <<= 1;
icculus@9
  1498
                        dst++;
icculus@9
  1499
                    }
icculus@9
  1500
                }
icculus@9
  1501
                dst += dstskip;
icculus@9
  1502
            }
icculus@9
  1503
        }
icculus@9
  1504
        break;
icculus@9
  1505
    }
icculus@9
  1506
}
icculus@9
  1507
icculus@9
  1508
static void
icculus@9
  1509
SDL_DrawCursorSlow(SDL_Surface * screen, SDL_Rect * area)
icculus@9
  1510
{
icculus@9
  1511
    const Uint32 pixels[2] = { 0xFFFFFF, 0x000000 };
icculus@9
  1512
    int h;
icculus@9
  1513
    int x, minx, maxx;
icculus@9
  1514
    Uint8 *data, datab = 0;
icculus@9
  1515
    Uint8 *mask, maskb = 0;
icculus@9
  1516
    Uint8 *dst;
icculus@9
  1517
    int dstbpp, dstskip;
icculus@9
  1518
icculus@9
  1519
    data = SDL_cursor->data + area->y * SDL_cursor->area.w / 8;
icculus@9
  1520
    mask = SDL_cursor->mask + area->y * SDL_cursor->area.w / 8;
icculus@9
  1521
    dstbpp = screen->format->BytesPerPixel;
icculus@9
  1522
    dst = (Uint8 *) screen->pixels +
icculus@9
  1523
        (SDL_cursor->area.y + area->y) * screen->pitch +
icculus@9
  1524
        SDL_cursor->area.x * dstbpp;
icculus@9
  1525
    dstskip = screen->pitch - SDL_cursor->area.w * dstbpp;
icculus@9
  1526
icculus@9
  1527
    minx = area->x;
icculus@9
  1528
    maxx = area->x + area->w;
icculus@9
  1529
    if (screen->format->BytesPerPixel == 1) {
icculus@9
  1530
        if (palette_changed) {
icculus@9
  1531
            pixels8[0] = (Uint8) SDL_MapRGB(screen->format, 255, 255, 255);
icculus@9
  1532
            pixels8[1] = (Uint8) SDL_MapRGB(screen->format, 0, 0, 0);
icculus@9
  1533
            palette_changed = 0;
icculus@9
  1534
        }
icculus@9
  1535
        for (h = area->h; h; h--) {
icculus@9
  1536
            for (x = 0; x < SDL_cursor->area.w; ++x) {
icculus@9
  1537
                if ((x % 8) == 0) {
icculus@9
  1538
                    maskb = *mask++;
icculus@9
  1539
                    datab = *data++;
icculus@9
  1540
                }
icculus@9
  1541
                if ((x >= minx) && (x < maxx)) {
icculus@9
  1542
                    if (maskb & 0x80) {
icculus@9
  1543
                        SDL_memset(dst, pixels8[datab >> 7], dstbpp);
icculus@9
  1544
                    }
icculus@9
  1545
                }
icculus@9
  1546
                maskb <<= 1;
icculus@9
  1547
                datab <<= 1;
icculus@9
  1548
                dst += dstbpp;
icculus@9
  1549
            }
icculus@9
  1550
            dst += dstskip;
icculus@9
  1551
        }
icculus@9
  1552
    } else {
icculus@9
  1553
        for (h = area->h; h; h--) {
icculus@9
  1554
            for (x = 0; x < SDL_cursor->area.w; ++x) {
icculus@9
  1555
                if ((x % 8) == 0) {
icculus@9
  1556
                    maskb = *mask++;
icculus@9
  1557
                    datab = *data++;
icculus@9
  1558
                }
icculus@9
  1559
                if ((x >= minx) && (x < maxx)) {
icculus@9
  1560
                    if (maskb & 0x80) {
icculus@9
  1561
                        SDL_memset(dst, pixels[datab >> 7], dstbpp);
icculus@9
  1562
                    }
icculus@9
  1563
                }
icculus@9
  1564
                maskb <<= 1;
icculus@9
  1565
                datab <<= 1;
icculus@9
  1566
                dst += dstbpp;
icculus@9
  1567
            }
icculus@9
  1568
            dst += dstskip;
icculus@9
  1569
        }
icculus@9
  1570
    }
icculus@9
  1571
}
icculus@9
  1572
icculus@9
  1573
/* This handles the ugly work of converting the saved cursor background from
icculus@9
  1574
   the pixel format of the shadow surface to that of the video surface.
icculus@9
  1575
   This is only necessary when blitting from a shadow surface of a different
icculus@9
  1576
   pixel format than the video surface, and using a software rendered cursor.
icculus@9
  1577
*/
icculus@9
  1578
static void
icculus@9
  1579
SDL_ConvertCursorSave(SDL_Surface * screen, int w, int h)
icculus@9
  1580
{
icculus@9
  1581
    SDL_VideoDevice *_this = SDL_GetVideoDevice();
icculus@9
  1582
    SDL_BlitInfo info;
icculus@9
  1583
    SDL_loblit RunBlit;
icculus@9
  1584
icculus@9
  1585
    /* Make sure we can steal the blit mapping */
icculus@9
  1586
    if (screen->map->dst != SDL_VideoSurface) {
icculus@9
  1587
        return;
icculus@9
  1588
    }
icculus@9
  1589
icculus@9
  1590
    /* Set up the blit information */
icculus@9
  1591
    info.s_pixels = SDL_cursor->save[1];
icculus@9
  1592
    info.s_width = w;
icculus@9
  1593
    info.s_height = h;
icculus@9
  1594
    info.s_skip = 0;
icculus@9
  1595
    info.d_pixels = SDL_cursor->save[0];
icculus@9
  1596
    info.d_width = w;
icculus@9
  1597
    info.d_height = h;
icculus@9
  1598
    info.d_skip = 0;
icculus@9
  1599
    info.aux_data = screen->map->sw_data->aux_data;
icculus@9
  1600
    info.src = screen->format;
icculus@9
  1601
    info.table = screen->map->table;
icculus@9
  1602
    info.dst = SDL_VideoSurface->format;
icculus@9
  1603
    RunBlit = screen->map->sw_data->blit;
icculus@9
  1604
icculus@9
  1605
    /* Run the actual software blit */
icculus@9
  1606
    RunBlit(&info);
icculus@9
  1607
}
icculus@9
  1608
icculus@9
  1609
void
icculus@9
  1610
SDL_DrawCursorNoLock(SDL_Surface * screen)
icculus@9
  1611
{
icculus@9
  1612
    SDL_VideoDevice *_this = SDL_GetVideoDevice();
icculus@9
  1613
    SDL_Rect area;
icculus@9
  1614
icculus@9
  1615
    /* Get the mouse rectangle, clipped to the screen */
icculus@9
  1616
    SDL_MouseRect(&area);
icculus@9
  1617
    if ((area.w == 0) || (area.h == 0)) {
icculus@9
  1618
        return;
icculus@9
  1619
    }
icculus@9
  1620
icculus@9
  1621
    /* Copy mouse background */
icculus@9
  1622
    {
icculus@9
  1623
        int w, h, screenbpp;
icculus@9
  1624
        Uint8 *src, *dst;
icculus@9
  1625
icculus@9
  1626
        /* Set up the copy pointers */
icculus@9
  1627
        screenbpp = screen->format->BytesPerPixel;
icculus@9
  1628
        if ((screen == SDL_VideoSurface) ||
icculus@9
  1629
            FORMAT_EQUAL(screen->format, SDL_VideoSurface->format)) {
icculus@9
  1630
            dst = SDL_cursor->save[0];
icculus@9
  1631
        } else {
icculus@9
  1632
            dst = SDL_cursor->save[1];
icculus@9
  1633
        }
icculus@9
  1634
        src = (Uint8 *) screen->pixels + area.y * screen->pitch +
icculus@9
  1635
            area.x * screenbpp;
icculus@9
  1636
icculus@9
  1637
        /* Perform the copy */
icculus@9
  1638
        w = area.w * screenbpp;
icculus@9
  1639
        h = area.h;
icculus@9
  1640
        while (h--) {
icculus@9
  1641
            SDL_memcpy(dst, src, w);
icculus@9
  1642
            dst += w;
icculus@9
  1643
            src += screen->pitch;
icculus@9
  1644
        }
icculus@9
  1645
    }
icculus@9
  1646
icculus@9
  1647
    /* Draw the mouse cursor */
icculus@9
  1648
    area.x -= SDL_cursor->area.x;
icculus@9
  1649
    area.y -= SDL_cursor->area.y;
icculus@9
  1650
    if ((area.x == 0) && (area.w == SDL_cursor->area.w)) {
icculus@9
  1651
        SDL_DrawCursorFast(screen, &area);
icculus@9
  1652
    } else {
icculus@9
  1653
        SDL_DrawCursorSlow(screen, &area);
icculus@9
  1654
    }
icculus@9
  1655
}
icculus@9
  1656
icculus@9
  1657
void
icculus@9
  1658
SDL_DrawCursor(SDL_Surface * screen)
icculus@9
  1659
{
icculus@9
  1660
    /* Lock the screen if necessary */
icculus@9
  1661
    if (screen == NULL) {
icculus@9
  1662
        return;
icculus@9
  1663
    }
icculus@9
  1664
    if (SDL_MUSTLOCK(screen)) {
icculus@9
  1665
        if (SDL_LockSurface(screen) < 0) {
icculus@9
  1666
            return;
icculus@9
  1667
        }
icculus@9
  1668
    }
icculus@9
  1669
icculus@9
  1670
    SDL_DrawCursorNoLock(screen);
icculus@9
  1671
icculus@9
  1672
    /* Unlock the screen and update if necessary */
icculus@9
  1673
    if (SDL_MUSTLOCK(screen)) {
icculus@9
  1674
        SDL_UnlockSurface(screen);
icculus@9
  1675
    }
icculus@9
  1676
    if (screen->flags & SDL_SCREEN_SURFACE) {
icculus@9
  1677
        SDL_VideoDevice *_this = SDL_GetVideoDevice();
icculus@9
  1678
        SDL_Window *window;
icculus@9
  1679
        SDL_Rect area;
icculus@9
  1680
icculus@9
  1681
        window = SDL_GetWindowFromSurface(screen);
icculus@9
  1682
        if (!window) {
icculus@9
  1683
            return;
icculus@9
  1684
        }
icculus@9
  1685
icculus@9
  1686
        SDL_MouseRect(&area);
icculus@9
  1687
icculus@9
  1688
        if (_this->UpdateWindowSurface) {
icculus@9
  1689
            _this->UpdateWindowSurface(_this, window, 1, &area);
icculus@9
  1690
        }
icculus@9
  1691
    }
icculus@9
  1692
}
icculus@9
  1693
icculus@9
  1694
void
icculus@9
  1695
SDL_EraseCursorNoLock(SDL_Surface * screen)
icculus@9
  1696
{
icculus@9
  1697
    SDL_VideoDevice *_this = SDL_GetVideoDevice();
icculus@9
  1698
    SDL_Window *window;
icculus@9
  1699
    SDL_Rect area;
icculus@9
  1700
icculus@9
  1701
    /* Get the window associated with the surface */
icculus@9
  1702
    window = SDL_GetWindowFromSurface(screen);
icculus@9
  1703
    if (!window || !window->surface) {
icculus@9
  1704
        return;
icculus@9
  1705
    }
icculus@9
  1706
icculus@9
  1707
    /* Get the mouse rectangle, clipped to the screen */
icculus@9
  1708
    SDL_MouseRect(&area);
icculus@9
  1709
    if ((area.w == 0) || (area.h == 0)) {
icculus@9
  1710
        return;
icculus@9
  1711
    }
icculus@9
  1712
icculus@9
  1713
    /* Copy mouse background */
icculus@9
  1714
    {
icculus@9
  1715
        int w, h, screenbpp;
icculus@9
  1716
        Uint8 *src, *dst;
icculus@9
  1717
icculus@9
  1718
        /* Set up the copy pointers */
icculus@9
  1719
        screenbpp = screen->format->BytesPerPixel;
icculus@9
  1720
        if ((screen->flags & SDL_SCREEN_SURFACE) ||
icculus@9
  1721
            FORMAT_EQUAL(screen->format, window->surface->format)) {
icculus@9
  1722
            src = SDL_cursor->save[0];
icculus@9
  1723
        } else {
icculus@9
  1724
            src = SDL_cursor->save[1];
icculus@9
  1725
        }
icculus@9
  1726
        dst = (Uint8 *) screen->pixels + area.y * screen->pitch +
icculus@9
  1727
            area.x * screenbpp;
icculus@9
  1728
icculus@9
  1729
        /* Perform the copy */
icculus@9
  1730
        w = area.w * screenbpp;
icculus@9
  1731
        h = area.h;
icculus@9
  1732
        while (h--) {
icculus@9
  1733
            SDL_memcpy(dst, src, w);
icculus@9
  1734
            src += w;
icculus@9
  1735
            dst += screen->pitch;
icculus@9
  1736
        }
icculus@9
  1737
icculus@9
  1738
        /* Perform pixel conversion on cursor background */
icculus@9
  1739
        if (src > SDL_cursor->save[1]) {
icculus@9
  1740
            SDL_ConvertCursorSave(screen, area.w, area.h);
icculus@9
  1741
        }
icculus@9
  1742
    }
icculus@9
  1743
}
icculus@9
  1744
icculus@9
  1745
void
icculus@9
  1746
SDL_EraseCursor(SDL_Surface * screen)
icculus@9
  1747
{
icculus@9
  1748
    /* Lock the screen if necessary */
icculus@9
  1749
    if (screen == NULL) {
icculus@9
  1750
        return;
icculus@9
  1751
    }
icculus@9
  1752
    if (SDL_MUSTLOCK(screen)) {
icculus@9
  1753
        if (SDL_LockSurface(screen) < 0) {
icculus@9
  1754
            return;
icculus@9
  1755
        }
icculus@9
  1756
    }
icculus@9
  1757
icculus@9
  1758
    SDL_EraseCursorNoLock(screen);
icculus@9
  1759
icculus@9
  1760
    /* Unlock the screen and update if necessary */
icculus@9
  1761
    if (SDL_MUSTLOCK(screen)) {
icculus@9
  1762
        SDL_UnlockSurface(screen);
icculus@9
  1763
    }
icculus@9
  1764
    if (screen->flags & SDL_SCREEN_SURFACE) {
icculus@9
  1765
        SDL_VideoDevice *_this = SDL_GetVideoDevice();
icculus@9
  1766
        SDL_Window *window;
icculus@9
  1767
        SDL_Rect area;
icculus@9
  1768
icculus@9
  1769
        window = SDL_GetWindowFromSurface(screen);
icculus@9
  1770
        if (!window) {
icculus@9
  1771
            return;
icculus@9
  1772
        }
icculus@9
  1773
icculus@9
  1774
        SDL_MouseRect(&area);
icculus@9
  1775
icculus@9
  1776
        if (_this->UpdateWindowSurface) {
icculus@9
  1777
            _this->UpdateWindowSurface(_this, window, 1, &area);
icculus@9
  1778
        }
icculus@9
  1779
    }
icculus@9
  1780
}
icculus@9
  1781
icculus@9
  1782
/* Reset the cursor on video mode change
icculus@9
  1783
   FIXME:  Keep track of all cursors, and reset them all.
icculus@9
  1784
 */
icculus@9
  1785
void
icculus@9
  1786
SDL_ResetCursor(void)
icculus@9
  1787
{
icculus@9
  1788
    int savelen;
icculus@9
  1789
icculus@9
  1790
    if (SDL_cursor) {
icculus@9
  1791
        savelen = SDL_cursor->area.w * 4 * SDL_cursor->area.h;
icculus@9
  1792
        SDL_cursor->area.x = 0;
icculus@9
  1793
        SDL_cursor->area.y = 0;
icculus@9
  1794
        SDL_memset(SDL_cursor->save[0], 0, savelen);
icculus@9
  1795
    }
icculus@9
  1796
}
icculus@9
  1797
#endif
icculus@9
  1798
icculus@9
  1799
struct private_yuvhwdata
icculus@9
  1800
{
icculus@9
  1801
    SDL_SW_YUVTexture *texture;
icculus@9
  1802
    SDL_Surface *display;
icculus@9
  1803
    Uint32 display_format;
icculus@9
  1804
};
icculus@9
  1805
icculus@9
  1806
SDL_Overlay *
icculus@9
  1807
SDL_CreateYUVOverlay(int w, int h, Uint32 format, SDL_Surface * display)
icculus@9
  1808
{
icculus@9
  1809
    SDL_Overlay *overlay;
icculus@9
  1810
    Uint32 texture_format;
icculus@9
  1811
    SDL_SW_YUVTexture *texture;
icculus@9
  1812
icculus@9
  1813
    if ((display->flags & SDL_OPENGL) == SDL_OPENGL) {
icculus@9
  1814
        SDL_SetError("YUV overlays are not supported in OpenGL mode");
icculus@9
  1815
        return NULL;
icculus@9
  1816
    }
icculus@9
  1817
icculus@9
  1818
    if (display != SDL_PublicSurface) {
icculus@9
  1819
        SDL_SetError("YUV display is only supported on the screen surface");
icculus@9
  1820
        return NULL;
icculus@9
  1821
    }
icculus@9
  1822
icculus@9
  1823
    switch (format) {
icculus@9
  1824
    case SDL_YV12_OVERLAY:
icculus@9
  1825
        texture_format = SDL_PIXELFORMAT_YV12;
icculus@9
  1826
        break;
icculus@9
  1827
    case SDL_IYUV_OVERLAY:
icculus@9
  1828
        texture_format = SDL_PIXELFORMAT_IYUV;
icculus@9
  1829
        break;
icculus@9
  1830
    case SDL_YUY2_OVERLAY:
icculus@9
  1831
        texture_format = SDL_PIXELFORMAT_YUY2;
icculus@9
  1832
        break;
icculus@9
  1833
    case SDL_UYVY_OVERLAY:
icculus@9
  1834
        texture_format = SDL_PIXELFORMAT_UYVY;
icculus@9
  1835
        break;
icculus@9
  1836
    case SDL_YVYU_OVERLAY:
icculus@9
  1837
        texture_format = SDL_PIXELFORMAT_YVYU;
icculus@9
  1838
        break;
icculus@9
  1839
    default:
icculus@9
  1840
        SDL_SetError("Unknown YUV format");
icculus@9
  1841
        return NULL;
icculus@9
  1842
    }
icculus@9
  1843
icculus@9
  1844
    overlay = (SDL_Overlay *) SDL_malloc(sizeof(*overlay));
icculus@9
  1845
    if (!overlay) {
icculus@9
  1846
        SDL_OutOfMemory();
icculus@9
  1847
        return NULL;
icculus@9
  1848
    }
icculus@9
  1849
    SDL_zerop(overlay);
icculus@9
  1850
icculus@9
  1851
    overlay->hwdata =
icculus@9
  1852
        (struct private_yuvhwdata *) SDL_malloc(sizeof(*overlay->hwdata));
icculus@9
  1853
    if (!overlay->hwdata) {
icculus@9
  1854
        SDL_free(overlay);
icculus@9
  1855
        SDL_OutOfMemory();
icculus@9
  1856
        return NULL;
icculus@9
  1857
    }
icculus@9
  1858
icculus@9
  1859
    texture = SDL_SW_CreateYUVTexture(texture_format, w, h);
icculus@9
  1860
    if (!texture) {
icculus@9
  1861
        SDL_free(overlay->hwdata);
icculus@9
  1862
        SDL_free(overlay);
icculus@9
  1863
        return NULL;
icculus@9
  1864
    }
icculus@9
  1865
    overlay->hwdata->texture = texture;
icculus@9
  1866
    overlay->hwdata->display = NULL;
icculus@9
  1867
    overlay->hwdata->display_format = SDL_PIXELFORMAT_UNKNOWN;
icculus@9
  1868
icculus@9
  1869
    overlay->format = format;
icculus@9
  1870
    overlay->w = w;
icculus@9
  1871
    overlay->h = h;
icculus@9
  1872
    if (format == SDL_YV12_OVERLAY || format == SDL_IYUV_OVERLAY) {
icculus@9
  1873
        overlay->planes = 3;
icculus@9
  1874
    } else {
icculus@9
  1875
        overlay->planes = 1;
icculus@9
  1876
    }
icculus@9
  1877
    overlay->pitches = texture->pitches;
icculus@9
  1878
    overlay->pixels = texture->planes;
icculus@9
  1879
icculus@9
  1880
    return overlay;
icculus@9
  1881
}
icculus@9
  1882
icculus@9
  1883
int
icculus@9
  1884
SDL_LockYUVOverlay(SDL_Overlay * overlay)
icculus@9
  1885
{
icculus@9
  1886
    SDL_Rect rect;
icculus@9
  1887
    void *pixels;
icculus@9
  1888
    int pitch;
icculus@9
  1889
icculus@9
  1890
    if (!overlay) {
icculus@9
  1891
        SDL_SetError("Passed a NULL overlay");
icculus@9
  1892
        return -1;
icculus@9
  1893
    }
icculus@9
  1894
icculus@9
  1895
    rect.x = 0;
icculus@9
  1896
    rect.y = 0;
icculus@9
  1897
    rect.w = overlay->w;
icculus@9
  1898
    rect.h = overlay->h;
icculus@9
  1899
icculus@9
  1900
    if (SDL_SW_LockYUVTexture(overlay->hwdata->texture, &rect, &pixels, &pitch) < 0) {
icculus@9
  1901
        return -1;
icculus@9
  1902
    }
icculus@9
  1903
icculus@9
  1904
    overlay->pixels[0] = (Uint8 *) pixels;
icculus@9
  1905
    overlay->pitches[0] = pitch;
icculus@9
  1906
    switch (overlay->format) {
icculus@9
  1907
    case SDL_YV12_OVERLAY:
icculus@9
  1908
    case SDL_IYUV_OVERLAY:
icculus@9
  1909
        overlay->pitches[1] = pitch / 2;
icculus@9
  1910
        overlay->pitches[2] = pitch / 2;
icculus@9
  1911
        overlay->pixels[1] =
icculus@9
  1912
            overlay->pixels[0] + overlay->pitches[0] * overlay->h;
icculus@9
  1913
        overlay->pixels[2] =
icculus@9
  1914
            overlay->pixels[1] + overlay->pitches[1] * overlay->h / 2;
icculus@9
  1915
        break;
icculus@9
  1916
    case SDL_YUY2_OVERLAY:
icculus@9
  1917
    case SDL_UYVY_OVERLAY:
icculus@9
  1918
    case SDL_YVYU_OVERLAY:
icculus@9
  1919
        break;
icculus@9
  1920
    }
icculus@9
  1921
    return 0;
icculus@9
  1922
}
icculus@9
  1923
icculus@9
  1924
void
icculus@9
  1925
SDL_UnlockYUVOverlay(SDL_Overlay * overlay)
icculus@9
  1926
{
icculus@9
  1927
    if (!overlay) {
icculus@9
  1928
        return;
icculus@9
  1929
    }
icculus@9
  1930
icculus@9
  1931
    SDL_SW_UnlockYUVTexture(overlay->hwdata->texture);
icculus@9
  1932
}
icculus@9
  1933
icculus@9
  1934
int
icculus@9
  1935
SDL_DisplayYUVOverlay(SDL_Overlay * overlay, SDL_Rect * dstrect)
icculus@9
  1936
{
icculus@9
  1937
    SDL_Surface *display;
icculus@9
  1938
    SDL_Rect src_rect;
icculus@9
  1939
    SDL_Rect dst_rect;
icculus@9
  1940
    void *pixels;
icculus@9
  1941
icculus@9
  1942
    if (!overlay || !dstrect) {
icculus@9
  1943
        SDL_SetError("Passed a NULL overlay or dstrect");
icculus@9
  1944
        return -1;
icculus@9
  1945
    }
icculus@9
  1946
icculus@9
  1947
    display = overlay->hwdata->display;
icculus@9
  1948
    if (display != SDL_VideoSurface) {
icculus@9
  1949
        overlay->hwdata->display = display = SDL_VideoSurface;
icculus@9
  1950
        overlay->hwdata->display_format = SDL_MasksToPixelFormatEnum(
icculus@9
  1951
                                                display->format->BitsPerPixel,
icculus@9
  1952
                                                display->format->Rmask,
icculus@9
  1953
                                                display->format->Gmask,
icculus@9
  1954
                                                display->format->Bmask,
icculus@9
  1955
                                                display->format->Amask);
icculus@9
  1956
    }
icculus@9
  1957
icculus@9
  1958
    src_rect.x = 0;
icculus@9
  1959
    src_rect.y = 0;
icculus@9
  1960
    src_rect.w = overlay->w;
icculus@9
  1961
    src_rect.h = overlay->h;
icculus@9
  1962
icculus@9
  1963
    if (!SDL_IntersectRect(&display->clip_rect, dstrect, &dst_rect)) {
icculus@9
  1964
        return 0;
icculus@9
  1965
    }
icculus@9
  1966
     
icculus@9
  1967
    pixels = (void *)((Uint8 *)display->pixels +
icculus@9
  1968
                        dst_rect.y * display->pitch +
icculus@9
  1969
                        dst_rect.x * display->format->BytesPerPixel);
icculus@9
  1970
icculus@9
  1971
    if (SDL_SW_CopyYUVToRGB(overlay->hwdata->texture, &src_rect,
icculus@9
  1972
                            overlay->hwdata->display_format,
icculus@9
  1973
                            dst_rect.w, dst_rect.h,
icculus@9
  1974
                            pixels, display->pitch) < 0) {
icculus@9
  1975
        return -1;
icculus@9
  1976
    }
icculus@9
  1977
    SDL_UpdateWindowSurface(SDL_VideoWindow);
icculus@9
  1978
    return 0;
icculus@9
  1979
}
icculus@9
  1980
icculus@9
  1981
void
icculus@9
  1982
SDL_FreeYUVOverlay(SDL_Overlay * overlay)
icculus@9
  1983
{
icculus@9
  1984
    if (!overlay) {
icculus@9
  1985
        return;
icculus@9
  1986
    }
icculus@9
  1987
    if (overlay->hwdata) {
icculus@9
  1988
        if (overlay->hwdata->texture) {
icculus@9
  1989
            SDL_SW_DestroyYUVTexture(overlay->hwdata->texture);
icculus@9
  1990
        }
icculus@9
  1991
        SDL_free(overlay->hwdata);
icculus@9
  1992
    }
icculus@9
  1993
    SDL_free(overlay);
icculus@9
  1994
}
icculus@9
  1995
icculus@9
  1996
void
icculus@9
  1997
SDL_GL_SwapBuffers(void)
icculus@9
  1998
{
icculus@9
  1999
    SDL_GL_SwapWindow(SDL_VideoWindow);
icculus@9
  2000
}
icculus@9
  2001
icculus@9
  2002
int
icculus@9
  2003
SDL_SetGamma(float red, float green, float blue)
icculus@9
  2004
{
icculus@9
  2005
    Uint16 red_ramp[256];
icculus@9
  2006
    Uint16 green_ramp[256];
icculus@9
  2007
    Uint16 blue_ramp[256];
icculus@9
  2008
icculus@9
  2009
    SDL_CalculateGammaRamp(red, red_ramp);
icculus@9
  2010
    if (green == red) {
icculus@9
  2011
        SDL_memcpy(green_ramp, red_ramp, sizeof(red_ramp));
icculus@9
  2012
    } else {
icculus@9
  2013
        SDL_CalculateGammaRamp(green, green_ramp);
icculus@9
  2014
    }
icculus@9
  2015
    if (blue == red) {
icculus@9
  2016
        SDL_memcpy(blue_ramp, red_ramp, sizeof(red_ramp));
icculus@9
  2017
    } else {
icculus@9
  2018
        SDL_CalculateGammaRamp(blue, blue_ramp);
icculus@9
  2019
    }
icculus@9
  2020
    return SDL_SetWindowGammaRamp(SDL_VideoWindow, red_ramp, green_ramp, blue_ramp);
icculus@9
  2021
}
icculus@9
  2022
icculus@9
  2023
int
icculus@9
  2024
SDL_SetGammaRamp(const Uint16 * red, const Uint16 * green, const Uint16 * blue)
icculus@9
  2025
{
icculus@9
  2026
    return SDL_SetWindowGammaRamp(SDL_VideoWindow, red, green, blue);
icculus@9
  2027
}
icculus@9
  2028
icculus@9
  2029
int
icculus@9
  2030
SDL_GetGammaRamp(Uint16 * red, Uint16 * green, Uint16 * blue)
icculus@9
  2031
{
icculus@9
  2032
    return SDL_GetWindowGammaRamp(SDL_VideoWindow, red, green, blue);
icculus@9
  2033
}
icculus@9
  2034
icculus@9
  2035
int
icculus@9
  2036
SDL_EnableKeyRepeat(int delay, int interval)
icculus@9
  2037
{
icculus@9
  2038
    return 0;
icculus@9
  2039
}
icculus@9
  2040
icculus@9
  2041
void
icculus@9
  2042
SDL_GetKeyRepeat(int *delay, int *interval)
icculus@9
  2043
{
icculus@9
  2044
    if (delay) {
icculus@9
  2045
        *delay = SDL_DEFAULT_REPEAT_DELAY;
icculus@9
  2046
    }
icculus@9
  2047
    if (interval) {
icculus@9
  2048
        *interval = SDL_DEFAULT_REPEAT_INTERVAL;
icculus@9
  2049
    }
icculus@9
  2050
}
icculus@9
  2051
icculus@9
  2052
int
icculus@9
  2053
SDL_EnableUNICODE(int enable)
icculus@9
  2054
{
icculus@9
  2055
    int previous = SDL_enabled_UNICODE;
icculus@9
  2056
icculus@9
  2057
    switch (enable) {
icculus@9
  2058
    case 1:
icculus@9
  2059
        SDL_enabled_UNICODE = 1;
icculus@9
  2060
        SDL_StartTextInput();
icculus@9
  2061
        break;
icculus@9
  2062
    case 0:
icculus@9
  2063
        SDL_enabled_UNICODE = 0;
icculus@9
  2064
        SDL_StopTextInput();
icculus@9
  2065
        break;
icculus@9
  2066
    }
icculus@9
  2067
    return previous;
icculus@9
  2068
}
icculus@9
  2069
icculus@9
  2070
static Uint32
icculus@9
  2071
SDL_SetTimerCallback(Uint32 interval, void* param)
icculus@9
  2072
{
icculus@9
  2073
    return ((SDL_OldTimerCallback)param)(interval);
icculus@9
  2074
}
icculus@9
  2075
icculus@9
  2076
int
icculus@9
  2077
SDL_SetTimer(Uint32 interval, SDL_OldTimerCallback callback)
icculus@9
  2078
{
icculus@9
  2079
    static SDL_TimerID compat_timer;
icculus@9
  2080
icculus@9
  2081
    if (compat_timer) {
icculus@9
  2082
        SDL_RemoveTimer(compat_timer);
icculus@9
  2083
        compat_timer = 0;
icculus@9
  2084
    }
icculus@9
  2085
icculus@9
  2086
    if (interval && callback) {
icculus@9
  2087
        compat_timer = SDL_AddTimer(interval, SDL_SetTimerCallback, callback);
icculus@9
  2088
        if (!compat_timer) {
icculus@9
  2089
            return -1;
icculus@9
  2090
        }
icculus@9
  2091
    }
icculus@9
  2092
    return 0;
icculus@9
  2093
}
icculus@9
  2094
icculus@9
  2095
int
icculus@9
  2096
SDL_putenv(const char *_var)
icculus@9
  2097
{
icculus@9
  2098
    char *ptr = NULL;
icculus@9
  2099
    char *var = SDL_strdup(_var);
icculus@9
  2100
    if (var == NULL) {
icculus@9
  2101
        return -1;  /* we don't set errno. */
icculus@9
  2102
    }
icculus@9
  2103
icculus@9
  2104
    ptr = SDL_strchr(var, '=');
icculus@9
  2105
    if (ptr == NULL) {
icculus@9
  2106
        SDL_free(var);
icculus@9
  2107
        return -1;
icculus@9
  2108
    }
icculus@9
  2109
icculus@9
  2110
    *ptr = '\0';  /* split the string into name and value. */
icculus@9
  2111
    SDL_setenv(var, ptr + 1, 1);
icculus@9
  2112
    SDL_free(var);
icculus@9
  2113
    return 0;
icculus@9
  2114
}
icculus@9
  2115
icculus@9
  2116
icculus@9
  2117
icculus@9
  2118
/* CD-ROM support is gone from SDL 2.0, so just have stubs that fail. */
icculus@9
  2119
icculus@9
  2120
typedef void *SDL12_CD;  /* close enough.  :) */
icculus@9
  2121
typedef int SDL12_CDstatus;  /* close enough.  :) */
icculus@9
  2122
icculus@9
  2123
static int
icculus@9
  2124
CDUnsupported(void)
icculus@9
  2125
{
icculus@9
  2126
    SDL_SetError("CD interface is unsupported");
icculus@9
  2127
    return -1;
icculus@9
  2128
}
icculus@9
  2129
icculus@9
  2130
int
icculus@9
  2131
SDL_CDNumDrives(void)
icculus@9
  2132
{
icculus@9
  2133
    return 0;  /* !!! FIXME: should return -1 without SDL_INIT_CDROM */
icculus@9
  2134
}
icculus@9
  2135
icculus@9
  2136
const char *SDL_CDName(int drive) { CDUnsupported(); return NULL; }
icculus@9
  2137
SDL12_CD * SDL_CDOpen(int drive) { CDUnsupported(); return NULL; }
icculus@9
  2138
SDL12_CDstatus SDL_CDStatus(SDL_CD *cdrom) { return CDUnsupported(); }
icculus@9
  2139
int SDL_CDPlayTracks(SDL12_CD *cdrom, int start_track, int start_frame, int ntracks, int nframes) { return CDUnsupported(); }
icculus@9
  2140
int SDL_CDPlay(SDL12_CD *cdrom, int start, int length) { return CDUnsupported(); }
icculus@9
  2141
int SDL_CDPause(SDL12_CD *cdrom) { return CDUnsupported(); }
icculus@9
  2142
int SDL_CDResume(SDL12_CD *cdrom) { return CDUnsupported(); }
icculus@9
  2143
int SDL_CDStop(SDL12_CD *cdrom) { return CDUnsupported(); }
icculus@9
  2144
int SDL_CDEject(SDL12_CD *cdrom) { return CDUnsupported(); }
icculus@9
  2145
void SDL_CDClose(SDL12_CD *cdrom) {}
icculus@9
  2146
icculus@9
  2147
/* !!! FIXME: Removed from 2.0; do nothing. We can't even report failure. */
icculus@9
  2148
void SDL_KillThread(SDL_Thread *thread) {}
icculus@9
  2149
icculus@9
  2150
/* Things that _should_ be binary compatible pass right through... */
icculus@9
  2151
#define SDL20_SYM(rc,fn,params,args,ret)
icculus@9
  2152
#define SDL20_SYM_PASSTHROUGH(rc,fn,params,args,ret) \
icculus@9
  2153
    rc SDL_##fn params { ret SDL20_##fn args; }
icculus@9
  2154
#include "SDL20_syms.h"
icculus@9
  2155
#undef SDL20_SYM_PASSTHROUGH
icculus@9
  2156
#undef SDL20_SYM
icculus@9
  2157
icculus@9
  2158
icculus@9
  2159
/* vi: set ts=4 sw=4 expandtab: */