src/SDL_compat.c
author Sam Lantinga <slouken@libsdl.org>
Mon, 29 May 2006 05:08:33 +0000
branchSDL-1.3
changeset 1669 9857d21967bb
parent 1668 4da1ee79c9af
child 1670 eef792d31de8
permissions -rw-r--r--
The test programs compile again. The dummy video driver is partially functional now.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1667
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     1
/*
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     2
    SDL - Simple DirectMedia Layer
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     3
    Copyright (C) 1997-2006 Sam Lantinga
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     4
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     5
    This library is free software; you can redistribute it and/or
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     6
    modify it under the terms of the GNU Lesser General Public
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     7
    License as published by the Free Software Foundation; either
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     8
    version 2.1 of the License, or (at your option) any later version.
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     9
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    10
    This library is distributed in the hope that it will be useful,
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    13
    Lesser General Public License for more details.
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    14
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    15
    You should have received a copy of the GNU Lesser General Public
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    16
    License along with this library; if not, write to the Free Software
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    17
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    18
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    19
    Sam Lantinga
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    20
    slouken@libsdl.org
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    21
*/
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    22
#include "SDL_config.h"
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    23
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    24
/* This file contains functions for backwards compatibility with SDL 1.2 */
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    25
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    26
#include "SDL.h"
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    27
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    28
#include "video/SDL_sysvideo.h"
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    29
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    30
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    31
static SDL_WindowID window;
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    32
static char *wm_title;
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    33
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    34
char *
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
    35
SDL_AudioDriverName(char *namebuf, int maxlen)
1667
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    36
{
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
    37
    const char *name = SDL_GetCurrentAudioDriver();
1667
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    38
    if (name) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
    39
        SDL_strlcpy(namebuf, name, maxlen);
1667
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    40
        return namebuf;
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    41
    }
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    42
    return NULL;
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    43
}
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    44
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    45
char *
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
    46
SDL_VideoDriverName(char *namebuf, int maxlen)
1667
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    47
{
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
    48
    const char *name = SDL_GetCurrentVideoDriver();
1667
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    49
    if (name) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
    50
        SDL_strlcpy(namebuf, name, maxlen);
1667
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    51
        return namebuf;
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    52
    }
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    53
    return NULL;
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    54
}
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    55
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    56
int
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
    57
SDL_VideoModeOK(int width, int height, int bpp, Uint32 flags)
1667
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    58
{
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    59
    int i, actual_bpp = 0;
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    60
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
    61
    if (!SDL_GetVideoDevice()) {
1667
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    62
        return 0;
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    63
    }
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    64
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    65
    if (!(flags & SDL_FULLSCREEN)) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
    66
        return SDL_BITSPERPIXEL(SDL_GetDesktopDisplayMode()->format);
1667
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    67
    }
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    68
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
    69
    for (i = 0; i < SDL_GetNumDisplayModes(); ++i) {
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
    70
        const SDL_DisplayMode *mode = SDL_GetDisplayMode(i);
1667
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    71
        if (!mode->w || !mode->h || (width == mode->w && height == mode->h)) {
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    72
            if (!mode->format) {
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    73
                return bpp;
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    74
            }
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
    75
            if (SDL_BITSPERPIXEL(mode->format) >= bpp) {
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
    76
                actual_bpp = SDL_BITSPERPIXEL(mode->format);
1667
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    77
            }
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    78
        }
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    79
    }
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    80
    return actual_bpp;
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    81
}
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    82
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    83
SDL_Rect **
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
    84
SDL_ListModes(SDL_PixelFormat * format, Uint32 flags)
1667
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    85
{
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    86
    int i, nmodes;
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    87
    SDL_Rect **modes;
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    88
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
    89
    if (!SDL_GetVideoDevice()) {
1667
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    90
        return NULL;
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    91
    }
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    92
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    93
    if (!(flags & SDL_FULLSCREEN)) {
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    94
        return (SDL_Rect **) (-1);
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    95
    }
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    96
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    97
    /* Memory leak, but this is a compatibility function, who cares? */
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    98
    nmodes = 0;
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
    99
    for (i = 0; i < SDL_GetNumDisplayModes(); ++i) {
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
   100
        const SDL_DisplayMode *mode = SDL_GetDisplayMode(i);
1667
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   101
        if (!mode->w || !mode->h) {
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   102
            return (SDL_Rect **) (-1);
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   103
        }
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
   104
        if (SDL_BITSPERPIXEL(mode->format) != format->BitsPerPixel) {
1667
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   105
            continue;
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   106
        }
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   107
        if (nmodes > 0 && modes[nmodes - 1]->w == mode->w
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   108
            && modes[nmodes - 1]->h == mode->h) {
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   109
            continue;
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   110
        }
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   111
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
   112
        modes = SDL_realloc(modes, (nmodes + 2) * sizeof(*modes));
1667
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   113
        if (!modes) {
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   114
            return NULL;
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   115
        }
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
   116
        modes[nmodes] = (SDL_Rect *) SDL_malloc(sizeof(SDL_Rect));
1667
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   117
        if (!modes[nmodes]) {
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   118
            return NULL;
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   119
        }
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   120
        modes[nmodes]->x = 0;
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   121
        modes[nmodes]->y = 0;
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   122
        modes[nmodes]->w = mode->w;
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   123
        modes[nmodes]->h = mode->h;
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   124
        ++nmodes;
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   125
    }
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   126
    if (modes) {
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   127
        modes[nmodes] = NULL;
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   128
    }
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   129
    return modes;
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   130
}
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   131
1669
9857d21967bb The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents: 1668
diff changeset
   132
static int (*orig_eventfilter) (const SDL_Event * event);
9857d21967bb The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents: 1668
diff changeset
   133
9857d21967bb The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents: 1668
diff changeset
   134
static int
9857d21967bb The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents: 1668
diff changeset
   135
SDL_CompatEventFilter(const SDL_Event * event)
9857d21967bb The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents: 1668
diff changeset
   136
{
9857d21967bb The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents: 1668
diff changeset
   137
    SDL_Event fake;
9857d21967bb The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents: 1668
diff changeset
   138
9857d21967bb The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents: 1668
diff changeset
   139
    switch (event->type) {
9857d21967bb The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents: 1668
diff changeset
   140
    case SDL_WINDOWEVENT:
9857d21967bb The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents: 1668
diff changeset
   141
        switch (event->window.event) {
9857d21967bb The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents: 1668
diff changeset
   142
        case SDL_WINDOWEVENT_RESIZED:
9857d21967bb The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents: 1668
diff changeset
   143
            fake.type = SDL_VIDEORESIZE;
9857d21967bb The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents: 1668
diff changeset
   144
            fake.resize.w = event->window.data1;
9857d21967bb The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents: 1668
diff changeset
   145
            fake.resize.h = event->window.data2;
9857d21967bb The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents: 1668
diff changeset
   146
            SDL_PushEvent(&fake);
9857d21967bb The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents: 1668
diff changeset
   147
            break;
9857d21967bb The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents: 1668
diff changeset
   148
        case SDL_WINDOWEVENT_MINIMIZED:
9857d21967bb The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents: 1668
diff changeset
   149
            fake.type = SDL_ACTIVEEVENT;
9857d21967bb The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents: 1668
diff changeset
   150
            fake.active.gain = 0;
9857d21967bb The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents: 1668
diff changeset
   151
            fake.active.state = SDL_APPACTIVE;
9857d21967bb The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents: 1668
diff changeset
   152
            SDL_PushEvent(&fake);
9857d21967bb The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents: 1668
diff changeset
   153
            break;
9857d21967bb The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents: 1668
diff changeset
   154
        case SDL_WINDOWEVENT_RESTORED:
9857d21967bb The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents: 1668
diff changeset
   155
            fake.type = SDL_ACTIVEEVENT;
9857d21967bb The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents: 1668
diff changeset
   156
            fake.active.gain = 1;
9857d21967bb The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents: 1668
diff changeset
   157
            fake.active.state = SDL_APPACTIVE;
9857d21967bb The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents: 1668
diff changeset
   158
            SDL_PushEvent(&fake);
9857d21967bb The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents: 1668
diff changeset
   159
            break;
9857d21967bb The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents: 1668
diff changeset
   160
        case SDL_WINDOWEVENT_ENTER:
9857d21967bb The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents: 1668
diff changeset
   161
            fake.type = SDL_ACTIVEEVENT;
9857d21967bb The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents: 1668
diff changeset
   162
            fake.active.gain = 1;
9857d21967bb The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents: 1668
diff changeset
   163
            fake.active.state = SDL_APPMOUSEFOCUS;
9857d21967bb The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents: 1668
diff changeset
   164
            SDL_PushEvent(&fake);
9857d21967bb The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents: 1668
diff changeset
   165
            break;
9857d21967bb The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents: 1668
diff changeset
   166
        case SDL_WINDOWEVENT_LEAVE:
9857d21967bb The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents: 1668
diff changeset
   167
            fake.type = SDL_ACTIVEEVENT;
9857d21967bb The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents: 1668
diff changeset
   168
            fake.active.gain = 0;
9857d21967bb The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents: 1668
diff changeset
   169
            fake.active.state = SDL_APPMOUSEFOCUS;
9857d21967bb The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents: 1668
diff changeset
   170
            SDL_PushEvent(&fake);
9857d21967bb The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents: 1668
diff changeset
   171
            break;
9857d21967bb The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents: 1668
diff changeset
   172
        case SDL_WINDOWEVENT_FOCUS_GAINED:
9857d21967bb The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents: 1668
diff changeset
   173
            fake.type = SDL_ACTIVEEVENT;
9857d21967bb The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents: 1668
diff changeset
   174
            fake.active.gain = 1;
9857d21967bb The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents: 1668
diff changeset
   175
            fake.active.state = SDL_APPINPUTFOCUS;
9857d21967bb The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents: 1668
diff changeset
   176
            SDL_PushEvent(&fake);
9857d21967bb The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents: 1668
diff changeset
   177
            break;
9857d21967bb The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents: 1668
diff changeset
   178
        case SDL_WINDOWEVENT_FOCUS_LOST:
9857d21967bb The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents: 1668
diff changeset
   179
            fake.type = SDL_ACTIVEEVENT;
9857d21967bb The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents: 1668
diff changeset
   180
            fake.active.gain = 1;
9857d21967bb The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents: 1668
diff changeset
   181
            fake.active.state = SDL_APPINPUTFOCUS;
9857d21967bb The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents: 1668
diff changeset
   182
            SDL_PushEvent(&fake);
9857d21967bb The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents: 1668
diff changeset
   183
            break;
9857d21967bb The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents: 1668
diff changeset
   184
        }
9857d21967bb The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents: 1668
diff changeset
   185
    }
9857d21967bb The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents: 1668
diff changeset
   186
    return orig_eventfilter(event);
9857d21967bb The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents: 1668
diff changeset
   187
}
9857d21967bb The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents: 1668
diff changeset
   188
1667
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   189
SDL_Surface *
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
   190
SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags)
1667
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   191
{
1669
9857d21967bb The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents: 1668
diff changeset
   192
    int (*filter) (const SDL_Event * event);
9857d21967bb The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents: 1668
diff changeset
   193
    const SDL_DisplayMode *desktop_mode;
1667
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   194
    SDL_DisplayMode mode;
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   195
    int i;
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   196
    Uint32 window_flags;
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   197
    Uint32 desktop_format;
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   198
    Uint32 desired_format;
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   199
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
   200
    if (!SDL_GetVideoDevice()) {
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
   201
        if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE) < 0) {
1667
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   202
            return NULL;
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   203
        }
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   204
    }
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   205
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   206
    /* Destroy existing window */
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
   207
    SDL_DestroyWindow(window);
1667
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   208
1669
9857d21967bb The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents: 1668
diff changeset
   209
    /* Set up the event filter */
9857d21967bb The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents: 1668
diff changeset
   210
    filter = SDL_GetEventFilter();
9857d21967bb The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents: 1668
diff changeset
   211
    if (filter != SDL_CompatEventFilter) {
9857d21967bb The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents: 1668
diff changeset
   212
        orig_eventfilter = filter;
9857d21967bb The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents: 1668
diff changeset
   213
    }
9857d21967bb The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents: 1668
diff changeset
   214
    SDL_SetEventFilter(SDL_CompatEventFilter);
9857d21967bb The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents: 1668
diff changeset
   215
1667
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   216
    /* Create a new window */
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   217
    window_flags = SDL_WINDOW_SHOWN;
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   218
    if (flags & SDL_FULLSCREEN) {
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   219
        window_flags |= SDL_WINDOW_FULLSCREEN;
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   220
    }
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   221
    if (flags & SDL_OPENGL) {
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   222
        window_flags |= SDL_WINDOW_OPENGL;
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   223
    }
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   224
    if (flags & SDL_RESIZABLE) {
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   225
        window_flags |= SDL_WINDOW_RESIZABLE;
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   226
    }
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   227
    if (flags & SDL_NOFRAME) {
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   228
        window_flags |= SDL_WINDOW_BORDERLESS;
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   229
    }
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
   230
    window = SDL_CreateWindow(wm_title, 0, 0, width, height, window_flags);
1667
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   231
    if (!window) {
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   232
        return NULL;
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   233
    }
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   234
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   235
    /* Set up the desired display mode */
1669
9857d21967bb The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents: 1668
diff changeset
   236
    desktop_mode = SDL_GetDesktopDisplayMode();
9857d21967bb The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents: 1668
diff changeset
   237
    desktop_format = desktop_mode->format;
9857d21967bb The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents: 1668
diff changeset
   238
    if (desktop_format && ((flags & SDL_ANYFORMAT)
9857d21967bb The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents: 1668
diff changeset
   239
                           || (bpp == SDL_BITSPERPIXEL(desktop_format)))) {
1667
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   240
        desired_format = desktop_format;
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   241
    } else {
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   242
        switch (bpp) {
1669
9857d21967bb The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents: 1668
diff changeset
   243
        case 0:
9857d21967bb The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents: 1668
diff changeset
   244
            if (desktop_format) {
9857d21967bb The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents: 1668
diff changeset
   245
                desired_format = desktop_format;
9857d21967bb The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents: 1668
diff changeset
   246
            } else {
9857d21967bb The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents: 1668
diff changeset
   247
                desired_format = SDL_PixelFormat_RGB888;
9857d21967bb The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents: 1668
diff changeset
   248
            }
9857d21967bb The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents: 1668
diff changeset
   249
            break;
1667
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   250
        case 8:
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   251
            desired_format = SDL_PixelFormat_Index8;
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   252
            break;
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   253
        case 15:
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   254
            desired_format = SDL_PixelFormat_RGB555;
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   255
            break;
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   256
        case 16:
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   257
            desired_format = SDL_PixelFormat_RGB565;
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   258
            break;
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   259
        case 24:
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   260
            desired_format = SDL_PixelFormat_RGB24;
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   261
            break;
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   262
        case 32:
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   263
            desired_format = SDL_PixelFormat_RGB888;
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   264
            break;
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   265
        default:
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
   266
            SDL_SetError("Unsupported bpp in SDL_SetVideoMode()");
1667
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   267
            return NULL;
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   268
        }
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   269
    }
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   270
    mode.format = desired_format;
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   271
    mode.w = width;
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   272
    mode.h = height;
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   273
    mode.refresh_rate = 0;
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   274
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   275
    /* Set the desired display mode */
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   276
    if (flags & SDL_FULLSCREEN) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
   277
        if (!SDL_GetClosestDisplayMode(&mode, &mode)) {
1667
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   278
            return NULL;
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   279
        }
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   280
    } else {
1669
9857d21967bb The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents: 1668
diff changeset
   281
        if (desktop_format) {
9857d21967bb The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents: 1668
diff changeset
   282
            mode.format = desktop_format;
9857d21967bb The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents: 1668
diff changeset
   283
        }
9857d21967bb The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents: 1668
diff changeset
   284
        if (desktop_mode->w && desktop_mode->h) {
9857d21967bb The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents: 1668
diff changeset
   285
            mode.w = desktop_mode->w;
9857d21967bb The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents: 1668
diff changeset
   286
            mode.h = desktop_mode->h;
9857d21967bb The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents: 1668
diff changeset
   287
        }
9857d21967bb The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents: 1668
diff changeset
   288
        mode.refresh_rate = desktop_mode->refresh_rate;
1667
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   289
    }
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
   290
    if (SDL_SetDisplayMode(&mode) < 0) {
1667
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   291
        return NULL;
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   292
    }
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   293
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   294
    /* Create the display surface */
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
   295
    return SDL_CreateWindowSurface(window, desired_format, flags);
1667
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   296
}
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   297
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   298
SDL_Surface *
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
   299
SDL_GetVideoSurface(void)
1667
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   300
{
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
   301
    SDL_VideoDevice *_this = SDL_GetVideoDevice();
1667
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   302
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   303
    return SDL_VideoSurface;
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   304
}
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   305
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   306
void
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
   307
SDL_WM_SetCaption(const char *title, const char *icon)
1667
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   308
{
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   309
    if (wm_title) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
   310
        SDL_free(wm_title);
1667
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   311
    } else {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
   312
        wm_title = SDL_strdup(title);
1667
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   313
    }
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
   314
    SDL_SetWindowTitle(window, wm_title);
1667
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   315
}
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   316
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   317
void
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
   318
SDL_WM_GetCaption(char **title, char **icon)
1667
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   319
{
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   320
    if (title) {
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   321
        *title = wm_title;
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   322
    }
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   323
    if (icon) {
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   324
        *icon = "";
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   325
    }
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   326
}
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   327
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   328
void
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
   329
SDL_WM_SetIcon(SDL_Surface * icon, Uint8 * mask)
1667
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   330
{
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   331
    /* FIXME */
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   332
}
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   333
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   334
int
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
   335
SDL_WM_IconifyWindow(void)
1667
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   336
{
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
   337
    SDL_MinimizeWindow(window);
1667
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   338
}
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   339
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   340
int
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
   341
SDL_WM_ToggleFullScreen(SDL_Surface * surface)
1667
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   342
{
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   343
    return 0;
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   344
}
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   345
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   346
SDL_GrabMode
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
   347
SDL_WM_GrabInput(SDL_GrabMode mode)
1667
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   348
{
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   349
    if (mode != SDL_GRAB_QUERY) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
   350
        SDL_SetWindowGrab(window, mode);
1667
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   351
    }
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
   352
    return (SDL_GrabMode) SDL_GetWindowGrab(window);
1667
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   353
}
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   354
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   355
Uint8
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
   356
SDL_GetAppState(void)
1667
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   357
{
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   358
    Uint8 state = 0;
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   359
    Uint32 flags = 0;
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   360
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
   361
    flags = SDL_GetWindowFlags(window);
1667
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   362
    if ((flags & SDL_WINDOW_SHOWN) && !(flags & SDL_WINDOW_MINIMIZED)) {
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   363
        state |= SDL_APPACTIVE;
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   364
    }
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   365
    if (flags & SDL_WINDOW_KEYBOARD_FOCUS) {
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   366
        state |= SDL_APPINPUTFOCUS;
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   367
    }
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   368
    if (flags & SDL_WINDOW_MOUSE_FOCUS) {
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   369
        state |= SDL_APPMOUSEFOCUS;
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   370
    }
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   371
    return state;
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   372
}
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   373
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   374
const SDL_version *
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
   375
SDL_Linked_Version(void)
1667
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   376
{
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   377
    static SDL_version version;
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
   378
    SDL_VERSION(&version);
1667
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   379
    return &version;
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   380
}
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   381
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   382
int
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
   383
SDL_SetPalette(SDL_Surface * surface, int flags, SDL_Color * colors,
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
   384
               int firstcolor, int ncolors)
1667
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   385
{
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
   386
    SDL_SetColors(surface, colors, firstcolor, ncolors);
1667
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   387
}
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   388
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   389
int
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
   390
SDL_GetWMInfo(SDL_SysWMinfo * info)
1667
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   391
{
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
   392
    return SDL_GetWindowWMInfo(window, info);
1667
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   393
}
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   394
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   395
/* vi: set ts=4 sw=4 expandtab: */