src/video/x11/SDL_x11wm.c
author Sam Lantinga <slouken@libsdl.org>
Mon, 29 May 2006 04:04:35 +0000
branchSDL-1.3
changeset 1668 4da1ee79c9af
parent 1662 782fd950bd46
permissions -rw-r--r--
more tweaking indent options
slouken@0
     1
/*
slouken@0
     2
    SDL - Simple DirectMedia Layer
slouken@1312
     3
    Copyright (C) 1997-2006 Sam Lantinga
slouken@0
     4
slouken@0
     5
    This library is free software; you can redistribute it and/or
slouken@1312
     6
    modify it under the terms of the GNU Lesser General Public
slouken@0
     7
    License as published by the Free Software Foundation; either
slouken@1312
     8
    version 2.1 of the License, or (at your option) any later version.
slouken@0
     9
slouken@0
    10
    This library is distributed in the hope that it will be useful,
slouken@0
    11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
slouken@0
    12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
slouken@1312
    13
    Lesser General Public License for more details.
slouken@0
    14
slouken@1312
    15
    You should have received a copy of the GNU Lesser General Public
slouken@1312
    16
    License along with this library; if not, write to the Free Software
slouken@1312
    17
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
slouken@0
    18
slouken@0
    19
    Sam Lantinga
slouken@252
    20
    slouken@libsdl.org
slouken@0
    21
*/
slouken@1402
    22
#include "SDL_config.h"
slouken@0
    23
slouken@0
    24
#include <X11/Xlib.h>
slouken@0
    25
#include <X11/Xutil.h>
slouken@0
    26
slouken@0
    27
#include "SDL_version.h"
slouken@0
    28
#include "SDL_timer.h"
slouken@0
    29
#include "SDL_video.h"
slouken@0
    30
#include "SDL_syswm.h"
slouken@1361
    31
#include "../SDL_pixels_c.h"
slouken@1361
    32
#include "../../events/SDL_events_c.h"
slouken@0
    33
#include "SDL_x11modes_c.h"
slouken@0
    34
#include "SDL_x11wm_c.h"
slouken@0
    35
slouken@1662
    36
static Uint8
slouken@1668
    37
reverse_byte(Uint8 x)
slouken@236
    38
{
slouken@1662
    39
    x = (x & 0xaa) >> 1 | (x & 0x55) << 1;
slouken@1662
    40
    x = (x & 0xcc) >> 2 | (x & 0x33) << 2;
slouken@1662
    41
    x = (x & 0xf0) >> 4 | (x & 0x0f) << 4;
slouken@1662
    42
    return x;
slouken@236
    43
}
slouken@0
    44
slouken@1662
    45
void
slouken@1668
    46
X11_SetIcon(_THIS, SDL_Surface * icon, Uint8 * mask)
slouken@0
    47
{
slouken@1662
    48
    SDL_Surface *sicon;
slouken@1662
    49
    XWMHints *wmhints;
slouken@1662
    50
    XImage *icon_image;
slouken@1662
    51
    Pixmap icon_pixmap;
slouken@1662
    52
    Pixmap mask_pixmap;
slouken@1662
    53
    Window icon_window = None;
slouken@1662
    54
    GC gc;
slouken@1662
    55
    XGCValues GCvalues;
slouken@1662
    56
    int i, dbpp;
slouken@1662
    57
    SDL_Rect bounds;
slouken@1662
    58
    Uint8 *LSBmask;
slouken@1662
    59
    Visual *dvis;
slouken@1662
    60
    char *p;
slouken@1662
    61
    int masksize;
slouken@0
    62
slouken@1668
    63
    SDL_Lock_EventThread();
slouken@0
    64
slouken@1662
    65
    /* The icon must use the default visual, depth and colormap of the
slouken@1662
    66
       screen, so it might need a conversion */
slouken@1668
    67
    dvis = DefaultVisual(SDL_Display, SDL_Screen);
slouken@1668
    68
    dbpp = DefaultDepth(SDL_Display, SDL_Screen);
slouken@1662
    69
    for (i = 0; i < this->hidden->nvisuals; i++) {
slouken@1662
    70
        if (this->hidden->visuals[i].visual == dvis) {
slouken@1662
    71
            dbpp = this->hidden->visuals[i].bpp;
slouken@1662
    72
            break;
slouken@1662
    73
        }
slouken@1662
    74
    }
slouken@0
    75
slouken@1662
    76
    /* The Visual struct is supposed to be opaque but we cheat a little */
slouken@1668
    77
    sicon = SDL_CreateRGBSurface(SDL_SWSURFACE, icon->w, icon->h,
slouken@1668
    78
                                 dbpp,
slouken@1668
    79
                                 dvis->red_mask, dvis->green_mask,
slouken@1668
    80
                                 dvis->blue_mask, 0);
slouken@1662
    81
    if (sicon == NULL)
slouken@1662
    82
        goto done;
slouken@0
    83
slouken@1662
    84
    if (dbpp == 8) {
slouken@1662
    85
        /* Default visual is 8bit; we need to allocate colours from
slouken@1662
    86
           the default colormap */
slouken@1662
    87
        SDL_Color want[256], got[256];
slouken@1662
    88
        int nwant;
slouken@1662
    89
        Colormap dcmap;
slouken@1662
    90
        int missing;
slouken@1668
    91
        dcmap = DefaultColormap(SDL_Display, SDL_Screen);
slouken@1662
    92
        if (icon->format->palette) {
slouken@1662
    93
            /* The icon has a palette as well - we just have to
slouken@1662
    94
               find those colours */
slouken@1662
    95
            nwant = icon->format->palette->ncolors;
slouken@1668
    96
            SDL_memcpy(want, icon->format->palette->colors,
slouken@1668
    97
                       nwant * sizeof want[0]);
slouken@1662
    98
        } else {
slouken@1662
    99
            /* try the standard 6x6x6 cube for lack of better
slouken@1662
   100
               ideas */
slouken@1662
   101
            int r, g, b, i;
slouken@1662
   102
            for (r = i = 0; r < 256; r += 0x33)
slouken@1662
   103
                for (g = 0; g < 256; g += 0x33)
slouken@1662
   104
                    for (b = 0; b < 256; b += 0x33, i++) {
slouken@1662
   105
                        want[i].r = r;
slouken@1662
   106
                        want[i].g = g;
slouken@1662
   107
                        want[i].b = b;
slouken@1662
   108
                    }
slouken@1662
   109
            nwant = 216;
slouken@1662
   110
        }
slouken@1662
   111
        if (SDL_iconcolors) {
slouken@1662
   112
            /* free already allocated colours first */
slouken@1662
   113
            unsigned long freelist[512];
slouken@1662
   114
            int nfree = 0;
slouken@1662
   115
            for (i = 0; i < 256; i++) {
slouken@1662
   116
                while (SDL_iconcolors[i]) {
slouken@1662
   117
                    freelist[nfree++] = i;
slouken@1662
   118
                    SDL_iconcolors[i]--;
slouken@1662
   119
                }
slouken@1662
   120
            }
slouken@1668
   121
            XFreeColors(GFX_Display, dcmap, freelist, nfree, 0);
slouken@1662
   122
        }
slouken@1662
   123
        if (!SDL_iconcolors)
slouken@1668
   124
            SDL_iconcolors = SDL_malloc(256 * sizeof *SDL_iconcolors);
slouken@1668
   125
        SDL_memset(SDL_iconcolors, 0, 256 * sizeof *SDL_iconcolors);
slouken@236
   126
slouken@1662
   127
        /* try to allocate the colours */
slouken@1668
   128
        SDL_memset(got, 0, sizeof got);
slouken@1662
   129
        missing = 0;
slouken@1662
   130
        for (i = 0; i < nwant; i++) {
slouken@1662
   131
            XColor c;
slouken@1662
   132
            c.red = want[i].r << 8;
slouken@1662
   133
            c.green = want[i].g << 8;
slouken@1662
   134
            c.blue = want[i].b << 8;
slouken@1662
   135
            c.flags = DoRed | DoGreen | DoBlue;
slouken@1668
   136
            if (XAllocColor(GFX_Display, dcmap, &c)) {
slouken@1662
   137
                /* got the colour */
slouken@1662
   138
                SDL_iconcolors[c.pixel]++;
slouken@1662
   139
                got[c.pixel] = want[i];
slouken@1662
   140
            } else {
slouken@1662
   141
                missing = 1;
slouken@1662
   142
            }
slouken@1662
   143
        }
slouken@1662
   144
        if (missing) {
slouken@1662
   145
            /* Some colours were apparently missing, so we just
slouken@1662
   146
               allocate all the rest as well */
slouken@1662
   147
            XColor cols[256];
slouken@1662
   148
            for (i = 0; i < 256; i++)
slouken@1662
   149
                cols[i].pixel = i;
slouken@1668
   150
            XQueryColors(GFX_Display, dcmap, cols, 256);
slouken@1662
   151
            for (i = 0; i < 256; i++) {
slouken@1662
   152
                got[i].r = cols[i].red >> 8;
slouken@1662
   153
                got[i].g = cols[i].green >> 8;
slouken@1662
   154
                got[i].b = cols[i].blue >> 8;
slouken@1662
   155
                if (!SDL_iconcolors[i]) {
slouken@1668
   156
                    if (XAllocColor(GFX_Display, dcmap, cols + i)) {
slouken@1662
   157
                        SDL_iconcolors[i] = 1;
slouken@1662
   158
                    } else {
slouken@1662
   159
                        /* index not available */
slouken@1662
   160
                        got[i].r = 0;
slouken@1662
   161
                        got[i].g = 0;
slouken@1662
   162
                        got[i].b = 0;
slouken@1662
   163
                    }
slouken@1662
   164
                }
slouken@1662
   165
            }
slouken@1662
   166
        }
slouken@236
   167
slouken@1668
   168
        SDL_SetColors(sicon, got, 0, 256);
slouken@1662
   169
    }
slouken@0
   170
slouken@1662
   171
    bounds.x = 0;
slouken@1662
   172
    bounds.y = 0;
slouken@1662
   173
    bounds.w = icon->w;
slouken@1662
   174
    bounds.h = icon->h;
slouken@1668
   175
    if (SDL_LowerBlit(icon, &bounds, sicon, &bounds) < 0)
slouken@1662
   176
        goto done;
slouken@0
   177
slouken@1662
   178
    /* We need the mask as given, except in LSBfirst format instead of
slouken@1662
   179
       MSBfirst. Reverse the bits in each byte. */
slouken@1662
   180
    masksize = ((sicon->w + 7) >> 3) * sicon->h;
slouken@1668
   181
    LSBmask = SDL_malloc(masksize);
slouken@1662
   182
    if (LSBmask == NULL) {
slouken@1662
   183
        goto done;
slouken@1662
   184
    }
slouken@1668
   185
    SDL_memset(LSBmask, 0, masksize);
slouken@1662
   186
    for (i = 0; i < masksize; i++)
slouken@1668
   187
        LSBmask[i] = reverse_byte(mask[i]);
slouken@1668
   188
    mask_pixmap = XCreatePixmapFromBitmapData(SDL_Display, WMwindow,
slouken@1668
   189
                                              (char *) LSBmask,
slouken@1668
   190
                                              sicon->w, sicon->h, 1L, 0L, 1);
slouken@0
   191
slouken@1662
   192
    /* Transfer the image to an X11 pixmap */
slouken@1668
   193
    icon_image = XCreateImage(SDL_Display,
slouken@1668
   194
                              DefaultVisual(SDL_Display, SDL_Screen),
slouken@1668
   195
                              DefaultDepth(SDL_Display, SDL_Screen),
slouken@1668
   196
                              ZPixmap, 0, sicon->pixels,
slouken@1668
   197
                              sicon->w, sicon->h, 32, 0);
slouken@1662
   198
    icon_image->byte_order = (SDL_BYTEORDER == SDL_BIG_ENDIAN)
slouken@1662
   199
        ? MSBFirst : LSBFirst;
slouken@1668
   200
    icon_pixmap = XCreatePixmap(SDL_Display, SDL_Root, sicon->w, sicon->h,
slouken@1668
   201
                                DefaultDepth(SDL_Display, SDL_Screen));
slouken@1668
   202
    gc = XCreateGC(SDL_Display, icon_pixmap, 0, &GCvalues);
slouken@1668
   203
    XPutImage(SDL_Display, icon_pixmap, gc, icon_image,
slouken@1668
   204
              0, 0, 0, 0, sicon->w, sicon->h);
slouken@1668
   205
    XFreeGC(SDL_Display, gc);
slouken@1668
   206
    XDestroyImage(icon_image);
slouken@1668
   207
    SDL_free(LSBmask);
slouken@1662
   208
    sicon->pixels = NULL;
slouken@0
   209
slouken@1662
   210
    /* Some buggy window managers (some versions of Enlightenment, it
slouken@1662
   211
       seems) need an icon window *and* icon pixmap to work properly, while
slouken@1662
   212
       it screws up others. The default is only to use a pixmap. */
slouken@1668
   213
    p = SDL_getenv("SDL_VIDEO_X11_ICONWIN");
slouken@1662
   214
    if (p && *p) {
slouken@1668
   215
        icon_window = XCreateSimpleWindow(SDL_Display, SDL_Root,
slouken@1668
   216
                                          0, 0, sicon->w, sicon->h, 0,
slouken@1668
   217
                                          CopyFromParent, CopyFromParent);
slouken@1668
   218
        XSetWindowBackgroundPixmap(SDL_Display, icon_window, icon_pixmap);
slouken@1668
   219
        XClearWindow(SDL_Display, icon_window);
slouken@1662
   220
    }
slouken@0
   221
slouken@1662
   222
    /* Set the window icon to the icon pixmap (and icon window) */
slouken@1668
   223
    wmhints = XAllocWMHints();
slouken@1662
   224
    wmhints->flags = (IconPixmapHint | IconMaskHint);
slouken@1662
   225
    wmhints->icon_pixmap = icon_pixmap;
slouken@1662
   226
    wmhints->icon_mask = mask_pixmap;
slouken@1662
   227
    if (icon_window != None) {
slouken@1662
   228
        wmhints->flags |= IconWindowHint;
slouken@1662
   229
        wmhints->icon_window = icon_window;
slouken@1662
   230
    }
slouken@1668
   231
    XSetWMHints(SDL_Display, WMwindow, wmhints);
slouken@1668
   232
    XFree(wmhints);
slouken@1668
   233
    XSync(SDL_Display, False);
slouken@0
   234
slouken@0
   235
  done:
slouken@1668
   236
    SDL_Unlock_EventThread();
slouken@1668
   237
    SDL_FreeSurface(sicon);
slouken@0
   238
}
slouken@0
   239
slouken@1662
   240
void
slouken@1668
   241
X11_SetCaptionNoLock(_THIS, const char *title, const char *icon)
slouken@0
   242
{
slouken@1662
   243
    XTextProperty titleprop, iconprop;
slouken@1662
   244
    Status status;
slouken@1558
   245
slouken@1558
   246
#ifdef X_HAVE_UTF8_STRING
slouken@1662
   247
    Atom _NET_WM_NAME;
slouken@1662
   248
    Atom _NET_WM_ICON_NAME;
slouken@1558
   249
slouken@1662
   250
    /* Look up some useful Atoms */
slouken@1662
   251
    if (SDL_X11_HAVE_UTF8) {
slouken@1668
   252
        _NET_WM_NAME = XInternAtom(SDL_Display, "_NET_WM_NAME", False);
slouken@1662
   253
        _NET_WM_ICON_NAME =
slouken@1668
   254
            XInternAtom(SDL_Display, "_NET_WM_ICON_NAME", False);
slouken@1662
   255
    }
slouken@1558
   256
#endif
slouken@0
   257
slouken@1662
   258
    if (title != NULL) {
slouken@1668
   259
        char *title_latin1 = SDL_iconv_utf8_latin1((char *) title);
slouken@1662
   260
        if (!title_latin1) {
slouken@1668
   261
            SDL_OutOfMemory();
slouken@1662
   262
            return;
slouken@1662
   263
        }
slouken@1668
   264
        status = XStringListToTextProperty(&title_latin1, 1, &titleprop);
slouken@1668
   265
        SDL_free(title_latin1);
slouken@1662
   266
        if (status) {
slouken@1668
   267
            XSetTextProperty(SDL_Display, WMwindow, &titleprop, XA_WM_NAME);
slouken@1668
   268
            XFree(titleprop.value);
slouken@1662
   269
        }
slouken@913
   270
#ifdef X_HAVE_UTF8_STRING
slouken@1662
   271
        if (SDL_X11_HAVE_UTF8) {
slouken@1668
   272
            status = Xutf8TextListToTextProperty(SDL_Display,
slouken@1668
   273
                                                 (char **) &title, 1,
slouken@1668
   274
                                                 XUTF8StringStyle,
slouken@1668
   275
                                                 &titleprop);
slouken@1662
   276
            if (status == Success) {
slouken@1668
   277
                XSetTextProperty(SDL_Display, WMwindow, &titleprop,
slouken@1668
   278
                                 _NET_WM_NAME);
slouken@1668
   279
                XFree(titleprop.value);
slouken@1662
   280
            }
slouken@1662
   281
        }
slouken@913
   282
#endif
slouken@1662
   283
    }
slouken@1662
   284
    if (icon != NULL) {
slouken@1668
   285
        char *icon_latin1 = SDL_iconv_utf8_latin1((char *) icon);
slouken@1662
   286
        if (!icon_latin1) {
slouken@1668
   287
            SDL_OutOfMemory();
slouken@1662
   288
            return;
slouken@1662
   289
        }
slouken@1668
   290
        status = XStringListToTextProperty(&icon_latin1, 1, &iconprop);
slouken@1668
   291
        SDL_free(icon_latin1);
slouken@1662
   292
        if (status) {
slouken@1668
   293
            XSetTextProperty(SDL_Display, WMwindow, &iconprop,
slouken@1668
   294
                             XA_WM_ICON_NAME);
slouken@1668
   295
            XFree(iconprop.value);
slouken@1662
   296
        }
slouken@913
   297
#ifdef X_HAVE_UTF8_STRING
slouken@1662
   298
        if (SDL_X11_HAVE_UTF8) {
slouken@1668
   299
            status = Xutf8TextListToTextProperty(SDL_Display,
slouken@1668
   300
                                                 (char **) &icon, 1,
slouken@1668
   301
                                                 XUTF8StringStyle, &iconprop);
slouken@1662
   302
            if (status == Success) {
slouken@1668
   303
                XSetTextProperty(SDL_Display, WMwindow, &iconprop,
slouken@1668
   304
                                 _NET_WM_ICON_NAME);
slouken@1668
   305
                XFree(iconprop.value);
slouken@1662
   306
            }
slouken@1662
   307
        }
slouken@913
   308
#endif
slouken@1662
   309
    }
slouken@1668
   310
    XSync(SDL_Display, False);
slouken@1659
   311
}
slouken@0
   312
slouken@1662
   313
void
slouken@1668
   314
X11_SetCaption(_THIS, const char *title, const char *icon)
slouken@1659
   315
{
slouken@1668
   316
    SDL_Lock_EventThread();
slouken@1668
   317
    X11_SetCaptionNoLock(this, title, icon);
slouken@1668
   318
    SDL_Unlock_EventThread();
slouken@0
   319
}
slouken@0
   320
slouken@0
   321
/* Iconify the window */
slouken@1662
   322
int
slouken@1668
   323
X11_IconifyWindow(_THIS)
slouken@0
   324
{
slouken@1662
   325
    int result;
slouken@0
   326
slouken@1668
   327
    SDL_Lock_EventThread();
slouken@1668
   328
    result = XIconifyWindow(SDL_Display, WMwindow, SDL_Screen);
slouken@1668
   329
    XSync(SDL_Display, False);
slouken@1668
   330
    SDL_Unlock_EventThread();
slouken@1662
   331
    return (result);
slouken@0
   332
}
slouken@0
   333
slouken@1662
   334
SDL_GrabMode
slouken@1668
   335
X11_GrabInputNoLock(_THIS, SDL_GrabMode mode)
slouken@0
   336
{
slouken@1662
   337
    int result;
slouken@0
   338
slouken@1662
   339
    if (SDL_VideoSurface == NULL) {
slouken@1662
   340
        return (SDL_GRAB_OFF);
slouken@1662
   341
    }
slouken@1662
   342
    if (!SDL_Window) {
slouken@1662
   343
        return (mode);          /* Will be set later on mode switch */
slouken@1662
   344
    }
slouken@1662
   345
    if (mode == SDL_GRAB_OFF) {
slouken@1668
   346
        XUngrabPointer(SDL_Display, CurrentTime);
slouken@1668
   347
        XUngrabKeyboard(SDL_Display, CurrentTime);
slouken@1662
   348
    } else {
slouken@1662
   349
        if (SDL_VideoSurface->flags & SDL_FULLSCREEN) {
slouken@1662
   350
            /* Unbind the mouse from the fullscreen window */
slouken@1668
   351
            XUngrabPointer(SDL_Display, CurrentTime);
slouken@1662
   352
        }
slouken@1662
   353
        /* Try to grab the mouse */
slouken@1662
   354
#if 0                           /* We'll wait here until we actually grab, otherwise behavior undefined */
slouken@1662
   355
        for (numtries = 0; numtries < 10; ++numtries) {
slouken@98
   356
#else
slouken@1662
   357
        for (;;) {
slouken@98
   358
#endif
slouken@1668
   359
            result = XGrabPointer(SDL_Display, SDL_Window, True, 0,
slouken@1668
   360
                                  GrabModeAsync, GrabModeAsync,
slouken@1668
   361
                                  SDL_Window, None, CurrentTime);
slouken@1662
   362
            if (result == GrabSuccess) {
slouken@1662
   363
                break;
slouken@1662
   364
            }
slouken@1668
   365
            SDL_Delay(100);
slouken@1662
   366
        }
slouken@1662
   367
        if (result != GrabSuccess) {
slouken@1662
   368
            /* Uh, oh, what do we do here? */ ;
slouken@1662
   369
        }
slouken@1662
   370
        /* Now grab the keyboard */
slouken@1668
   371
        XGrabKeyboard(SDL_Display, WMwindow, True,
slouken@1668
   372
                      GrabModeAsync, GrabModeAsync, CurrentTime);
slouken@0
   373
slouken@1662
   374
        /* Raise the window if we grab the mouse */
slouken@1662
   375
        if (!(SDL_VideoSurface->flags & SDL_FULLSCREEN))
slouken@1668
   376
            XRaiseWindow(SDL_Display, WMwindow);
slouken@98
   377
slouken@1662
   378
        /* Make sure we register input focus */
slouken@1668
   379
        SDL_PrivateAppActive(1, SDL_APPINPUTFOCUS);
slouken@1662
   380
    }
slouken@1668
   381
    XSync(SDL_Display, False);
slouken@0
   382
slouken@1662
   383
    return (mode);
slouken@0
   384
}
slouken@0
   385
slouken@1662
   386
SDL_GrabMode
slouken@1668
   387
X11_GrabInput(_THIS, SDL_GrabMode mode)
slouken@0
   388
{
slouken@1668
   389
    SDL_Lock_EventThread();
slouken@1668
   390
    mode = X11_GrabInputNoLock(this, mode);
slouken@1668
   391
    SDL_Unlock_EventThread();
slouken@0
   392
slouken@1662
   393
    return (mode);
slouken@0
   394
}
slouken@0
   395
slouken@0
   396
/* If 'info' is the right version, this function fills it and returns 1.
slouken@0
   397
   Otherwise, in case of a version mismatch, it returns -1.
slouken@0
   398
*/
slouken@1662
   399
static void
slouken@1668
   400
lock_display(void)
slouken@0
   401
{
slouken@1668
   402
    SDL_Lock_EventThread();
slouken@0
   403
}
slouken@1662
   404
static void
slouken@1668
   405
unlock_display(void)
slouken@0
   406
{
slouken@1662
   407
    /* Make sure any X11 transactions are completed */
slouken@1662
   408
    SDL_VideoDevice *this = current_video;
slouken@1668
   409
    XSync(SDL_Display, False);
slouken@1668
   410
    SDL_Unlock_EventThread();
slouken@0
   411
}
slouken@1662
   412
slouken@1662
   413
int
slouken@1668
   414
X11_GetWMInfo(_THIS, SDL_SysWMinfo * info)
slouken@0
   415
{
slouken@1662
   416
    if (info->version.major <= SDL_MAJOR_VERSION) {
slouken@1662
   417
        info->subsystem = SDL_SYSWM_X11;
slouken@1662
   418
        info->info.x11.display = SDL_Display;
slouken@1662
   419
        info->info.x11.window = SDL_Window;
slouken@1668
   420
        if (SDL_VERSIONNUM(info->version.major,
slouken@1668
   421
                           info->version.minor,
slouken@1668
   422
                           info->version.patch) >= 1002) {
slouken@1662
   423
            info->info.x11.fswindow = FSwindow;
slouken@1662
   424
            info->info.x11.wmwindow = WMwindow;
slouken@1662
   425
        }
slouken@1662
   426
        info->info.x11.lock_func = lock_display;
slouken@1662
   427
        info->info.x11.unlock_func = unlock_display;
slouken@1662
   428
        return (1);
slouken@1662
   429
    } else {
slouken@1668
   430
        SDL_SetError("Application not compiled with SDL %d.%d\n",
slouken@1668
   431
                     SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
slouken@1662
   432
        return (-1);
slouken@1662
   433
    }
slouken@0
   434
}
slouken@1662
   435
slouken@1662
   436
/* vi: set ts=4 sw=4 expandtab: */