src/video/x11/SDL_x11video.c
author Ryan C. Gordon <icculus@icculus.org>
Fri, 07 Dec 2012 23:26:28 -0500
changeset 6724 6c5ed0c4cc6d
parent 6638 3d221da309d3
child 6774 ad8522052ce6
permissions -rw-r--r--
X11 msgbox: try to protect the existing setlocale() state.
slouken@1950
     1
/*
slouken@5535
     2
  Simple DirectMedia Layer
slouken@6138
     3
  Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
slouken@1950
     4
slouken@5535
     5
  This software is provided 'as-is', without any express or implied
slouken@5535
     6
  warranty.  In no event will the authors be held liable for any damages
slouken@5535
     7
  arising from the use of this software.
slouken@1950
     8
slouken@5535
     9
  Permission is granted to anyone to use this software for any purpose,
slouken@5535
    10
  including commercial applications, and to alter it and redistribute it
slouken@5535
    11
  freely, subject to the following restrictions:
slouken@1950
    12
slouken@5535
    13
  1. The origin of this software must not be misrepresented; you must not
slouken@5535
    14
     claim that you wrote the original software. If you use this software
slouken@5535
    15
     in a product, an acknowledgment in the product documentation would be
slouken@5535
    16
     appreciated but is not required.
slouken@5535
    17
  2. Altered source versions must be plainly marked as such, and must not be
slouken@5535
    18
     misrepresented as being the original software.
slouken@5535
    19
  3. This notice may not be removed or altered from any source distribution.
slouken@1950
    20
*/
slouken@1950
    21
#include "SDL_config.h"
slouken@1950
    22
slouken@5481
    23
#if SDL_VIDEO_DRIVER_X11
slouken@5481
    24
slouken@4508
    25
#include <unistd.h> /* For getpid() and readlink() */
slouken@4508
    26
slouken@1950
    27
#include "SDL_video.h"
slouken@1950
    28
#include "SDL_mouse.h"
slouken@1950
    29
#include "../SDL_sysvideo.h"
slouken@1950
    30
#include "../SDL_pixels_c.h"
slouken@1950
    31
slouken@1950
    32
#include "SDL_x11video.h"
slouken@5182
    33
#include "SDL_x11framebuffer.h"
eligottlieb@4782
    34
#include "SDL_x11shape.h"
slouken@4923
    35
#include "SDL_x11touch.h" 
dimitris@6316
    36
#include "SDL_x11xinput2.h"
slouken@2710
    37
slouken@6188
    38
#if SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2
slouken@3218
    39
#include "SDL_x11opengles.h"
slouken@3218
    40
#endif
slouken@1950
    41
slouken@1950
    42
/* Initialization/Query functions */
slouken@1950
    43
static int X11_VideoInit(_THIS);
slouken@1950
    44
static void X11_VideoQuit(_THIS);
slouken@1950
    45
slouken@1951
    46
/* Find out what class name we should use */
slouken@1951
    47
static char *
slouken@1951
    48
get_classname()
slouken@1951
    49
{
slouken@1951
    50
    char *spot;
slouken@1951
    51
#if defined(__LINUX__) || defined(__FREEBSD__)
slouken@1951
    52
    char procfile[1024];
slouken@1951
    53
    char linkfile[1024];
slouken@1951
    54
    int linksize;
slouken@1951
    55
#endif
slouken@1951
    56
slouken@1951
    57
    /* First allow environment variable override */
slouken@1951
    58
    spot = SDL_getenv("SDL_VIDEO_X11_WMCLASS");
slouken@1951
    59
    if (spot) {
slouken@1951
    60
        return SDL_strdup(spot);
slouken@1951
    61
    }
slouken@1951
    62
slouken@1951
    63
    /* Next look at the application's executable name */
slouken@1951
    64
#if defined(__LINUX__) || defined(__FREEBSD__)
slouken@1951
    65
#if defined(__LINUX__)
slouken@1951
    66
    SDL_snprintf(procfile, SDL_arraysize(procfile), "/proc/%d/exe", getpid());
slouken@1951
    67
#elif defined(__FREEBSD__)
slouken@1951
    68
    SDL_snprintf(procfile, SDL_arraysize(procfile), "/proc/%d/file",
slouken@1951
    69
                 getpid());
slouken@1951
    70
#else
slouken@1951
    71
#error Where can we find the executable name?
slouken@1951
    72
#endif
slouken@1951
    73
    linksize = readlink(procfile, linkfile, sizeof(linkfile) - 1);
slouken@1951
    74
    if (linksize > 0) {
slouken@1951
    75
        linkfile[linksize] = '\0';
slouken@1951
    76
        spot = SDL_strrchr(linkfile, '/');
slouken@1951
    77
        if (spot) {
slouken@1951
    78
            return SDL_strdup(spot + 1);
slouken@1951
    79
        } else {
slouken@1951
    80
            return SDL_strdup(linkfile);
slouken@1951
    81
        }
slouken@1951
    82
    }
slouken@1951
    83
#endif /* __LINUX__ || __FREEBSD__ */
slouken@1951
    84
slouken@1951
    85
    /* Finally use the default we've used forever */
slouken@1951
    86
    return SDL_strdup("SDL_App");
slouken@1951
    87
}
slouken@1951
    88
slouken@1950
    89
/* X11 driver bootstrap functions */
slouken@1950
    90
slouken@1950
    91
static int
slouken@1950
    92
X11_Available(void)
slouken@1950
    93
{
slouken@1950
    94
    Display *display = NULL;
slouken@1950
    95
    if (SDL_X11_LoadSymbols()) {
slouken@1950
    96
        display = XOpenDisplay(NULL);
slouken@1950
    97
        if (display != NULL) {
slouken@1950
    98
            XCloseDisplay(display);
slouken@1950
    99
        }
slouken@1950
   100
        SDL_X11_UnloadSymbols();
slouken@1950
   101
    }
slouken@1950
   102
    return (display != NULL);
slouken@1950
   103
}
slouken@1950
   104
slouken@1950
   105
static void
slouken@1950
   106
X11_DeleteDevice(SDL_VideoDevice * device)
slouken@1950
   107
{
slouken@1950
   108
    SDL_VideoData *data = (SDL_VideoData *) device->driverdata;
slouken@1950
   109
    if (data->display) {
slouken@1950
   110
        XCloseDisplay(data->display);
slouken@1950
   111
    }
bob@2324
   112
    SDL_free(data->windowlist);
slouken@1950
   113
    SDL_free(device->driverdata);
slouken@1950
   114
    SDL_free(device);
slouken@1950
   115
slouken@1950
   116
    SDL_X11_UnloadSymbols();
slouken@1950
   117
}
slouken@1950
   118
icculus@6498
   119
/* An error handler to reset the vidmode and then call the default handler. */
icculus@6498
   120
static SDL_bool safety_net_triggered = SDL_FALSE;
icculus@6498
   121
static int (*orig_x11_errhandler) (Display *, XErrorEvent *) = NULL;
icculus@6498
   122
static int
icculus@6498
   123
X11_SafetyNetErrHandler(Display * d, XErrorEvent * e)
icculus@6498
   124
{
icculus@6498
   125
    /* if we trigger an error in our error handler, don't try again. */
icculus@6498
   126
    if (!safety_net_triggered) {
icculus@6498
   127
        safety_net_triggered = SDL_TRUE;
icculus@6498
   128
        SDL_VideoDevice *device = SDL_GetVideoDevice();
icculus@6498
   129
        if (device != NULL) {
icculus@6498
   130
            int i;
icculus@6498
   131
            for (i = 0; i < device->num_displays; i++) {
icculus@6498
   132
                SDL_VideoDisplay *display = &device->displays[i];
icculus@6498
   133
                if (SDL_memcmp(&display->current_mode, &display->desktop_mode,
icculus@6498
   134
                               sizeof (SDL_DisplayMode)) != 0) {
icculus@6498
   135
                    X11_SetDisplayMode(device, display, &display->desktop_mode);
icculus@6498
   136
                }
icculus@6498
   137
            }
icculus@6498
   138
        }
icculus@6498
   139
    }
icculus@6498
   140
icculus@6498
   141
    if (orig_x11_errhandler != NULL) {
icculus@6498
   142
        return orig_x11_errhandler(d, e);  /* probably terminate. */
icculus@6498
   143
    }
icculus@6498
   144
icculus@6498
   145
    return 0;
icculus@6498
   146
}
icculus@6498
   147
slouken@1950
   148
static SDL_VideoDevice *
slouken@1950
   149
X11_CreateDevice(int devindex)
slouken@1950
   150
{
slouken@1950
   151
    SDL_VideoDevice *device;
slouken@1950
   152
    SDL_VideoData *data;
slouken@1950
   153
    const char *display = NULL; /* Use the DISPLAY environment variable */
slouken@1950
   154
slouken@1950
   155
    if (!SDL_X11_LoadSymbols()) {
slouken@1950
   156
        return NULL;
slouken@1950
   157
    }
slouken@1950
   158
mikesart@6569
   159
    // Need for threading gl calls. This is also required for the proprietary nVidia
mikesart@6569
   160
	//  driver to be threaded.
mikesart@6569
   161
    XInitThreads();
mikesart@6569
   162
slouken@1950
   163
    /* Initialize all variables that we clean on shutdown */
slouken@1950
   164
    device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
bob@2323
   165
    if (!device) {
bob@2323
   166
        SDL_OutOfMemory();
bob@2323
   167
        return NULL;
slouken@1950
   168
    }
bob@2323
   169
    data = (struct SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData));
bob@2323
   170
    if (!data) {
slouken@1950
   171
        SDL_OutOfMemory();
bob@2323
   172
        SDL_free(device);
slouken@1950
   173
        return NULL;
slouken@1950
   174
    }
slouken@1950
   175
    device->driverdata = data;
slouken@1950
   176
slouken@1950
   177
    /* FIXME: Do we need this?
slouken@1950
   178
       if ( (SDL_strncmp(XDisplayName(display), ":", 1) == 0) ||
slouken@1950
   179
       (SDL_strncmp(XDisplayName(display), "unix:", 5) == 0) ) {
slouken@1950
   180
       local_X11 = 1;
slouken@1950
   181
       } else {
slouken@1950
   182
       local_X11 = 0;
slouken@1950
   183
       }
slouken@1950
   184
     */
slouken@1950
   185
    data->display = XOpenDisplay(display);
slouken@1950
   186
#if defined(__osf__) && defined(SDL_VIDEO_DRIVER_X11_DYNAMIC)
slouken@1950
   187
    /* On Tru64 if linking without -lX11, it fails and you get following message.
slouken@1950
   188
     * Xlib: connection to ":0.0" refused by server
slouken@1950
   189
     * Xlib: XDM authorization key matches an existing client!
slouken@1950
   190
     *
slouken@1950
   191
     * It succeeds if retrying 1 second later
slouken@1950
   192
     * or if running xhost +localhost on shell.
slouken@1950
   193
     */
slouken@1950
   194
    if (data->display == NULL) {
slouken@1950
   195
        SDL_Delay(1000);
slouken@1950
   196
        data->display = XOpenDisplay(display);
slouken@1950
   197
    }
slouken@1950
   198
#endif
slouken@1950
   199
    if (data->display == NULL) {
slouken@6367
   200
        SDL_free(device->driverdata);
slouken@1950
   201
        SDL_free(device);
slouken@1950
   202
        SDL_SetError("Couldn't open X11 display");
slouken@1950
   203
        return NULL;
slouken@1950
   204
    }
slouken@1950
   205
#ifdef X11_DEBUG
slouken@1950
   206
    XSynchronize(data->display, True);
slouken@1950
   207
#endif
slouken@1950
   208
icculus@6498
   209
    /* Hook up an X11 error handler to recover the desktop resolution. */
icculus@6498
   210
    safety_net_triggered = SDL_FALSE;
icculus@6498
   211
    orig_x11_errhandler = XSetErrorHandler(X11_SafetyNetErrHandler);
icculus@6498
   212
slouken@1950
   213
    /* Set the function pointers */
slouken@1950
   214
    device->VideoInit = X11_VideoInit;
slouken@1950
   215
    device->VideoQuit = X11_VideoQuit;
slouken@1950
   216
    device->GetDisplayModes = X11_GetDisplayModes;
gabomdq@6331
   217
    device->GetDisplayBounds = X11_GetDisplayBounds;
slouken@1950
   218
    device->SetDisplayMode = X11_SetDisplayMode;
slouken@3025
   219
    device->SuspendScreenSaver = X11_SuspendScreenSaver;
slouken@1951
   220
    device->PumpEvents = X11_PumpEvents;
slouken@1950
   221
slouken@1950
   222
    device->CreateWindow = X11_CreateWindow;
slouken@1950
   223
    device->CreateWindowFrom = X11_CreateWindowFrom;
slouken@1950
   224
    device->SetWindowTitle = X11_SetWindowTitle;
slouken@2967
   225
    device->SetWindowIcon = X11_SetWindowIcon;
slouken@1950
   226
    device->SetWindowPosition = X11_SetWindowPosition;
slouken@1950
   227
    device->SetWindowSize = X11_SetWindowSize;
slouken@1950
   228
    device->ShowWindow = X11_ShowWindow;
slouken@1950
   229
    device->HideWindow = X11_HideWindow;
slouken@1950
   230
    device->RaiseWindow = X11_RaiseWindow;
slouken@1950
   231
    device->MaximizeWindow = X11_MaximizeWindow;
slouken@1950
   232
    device->MinimizeWindow = X11_MinimizeWindow;
slouken@1950
   233
    device->RestoreWindow = X11_RestoreWindow;
icculus@6422
   234
    device->SetWindowBordered = X11_SetWindowBordered;
slouken@5302
   235
    device->SetWindowFullscreen = X11_SetWindowFullscreen;
slouken@5466
   236
    device->SetWindowGammaRamp = X11_SetWindowGammaRamp;
slouken@1950
   237
    device->SetWindowGrab = X11_SetWindowGrab;
slouken@1950
   238
    device->DestroyWindow = X11_DestroyWindow;
slouken@5182
   239
    device->CreateWindowFramebuffer = X11_CreateWindowFramebuffer;
slouken@5182
   240
    device->UpdateWindowFramebuffer = X11_UpdateWindowFramebuffer;
slouken@5182
   241
    device->DestroyWindowFramebuffer = X11_DestroyWindowFramebuffer;
slouken@1950
   242
    device->GetWindowWMInfo = X11_GetWindowWMInfo;
slouken@5182
   243
eligottlieb@4782
   244
    device->shape_driver.CreateShaper = X11_CreateShaper;
eligottlieb@4782
   245
    device->shape_driver.SetWindowShape = X11_SetWindowShape;
eligottlieb@4782
   246
    device->shape_driver.ResizeWindowShape = X11_ResizeWindowShape;
slouken@5182
   247
slouken@5088
   248
#if SDL_VIDEO_OPENGL_GLX
slouken@6370
   249
    device->GL_LoadLibrary = X11_GL_LoadLibrary;
slouken@6370
   250
    device->GL_GetProcAddress = X11_GL_GetProcAddress;
slouken@6370
   251
    device->GL_UnloadLibrary = X11_GL_UnloadLibrary;
slouken@6370
   252
    device->GL_CreateContext = X11_GL_CreateContext;
slouken@6370
   253
    device->GL_MakeCurrent = X11_GL_MakeCurrent;
slouken@6370
   254
    device->GL_SetSwapInterval = X11_GL_SetSwapInterval;
slouken@6370
   255
    device->GL_GetSwapInterval = X11_GL_GetSwapInterval;
slouken@6370
   256
    device->GL_SwapWindow = X11_GL_SwapWindow;
slouken@6370
   257
    device->GL_DeleteContext = X11_GL_DeleteContext;
slouken@6370
   258
#elif SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2
slouken@6370
   259
    device->GL_LoadLibrary = X11_GLES_LoadLibrary;
slouken@6370
   260
    device->GL_GetProcAddress = X11_GLES_GetProcAddress;
slouken@6370
   261
    device->GL_UnloadLibrary = X11_GLES_UnloadLibrary;
slouken@6370
   262
    device->GL_CreateContext = X11_GLES_CreateContext;
slouken@6370
   263
    device->GL_MakeCurrent = X11_GLES_MakeCurrent;
slouken@6370
   264
    device->GL_SetSwapInterval = X11_GLES_SetSwapInterval;
slouken@6370
   265
    device->GL_GetSwapInterval = X11_GLES_GetSwapInterval;
slouken@6370
   266
    device->GL_SwapWindow = X11_GLES_SwapWindow;
slouken@6370
   267
    device->GL_DeleteContext = X11_GLES_DeleteContext;
slouken@3218
   268
#endif
slouken@1950
   269
slouken@4508
   270
    device->SetClipboardText = X11_SetClipboardText;
slouken@4508
   271
    device->GetClipboardText = X11_GetClipboardText;
slouken@4508
   272
    device->HasClipboardText = X11_HasClipboardText;
slouken@4508
   273
slouken@1950
   274
    device->free = X11_DeleteDevice;
slouken@1950
   275
slouken@1950
   276
    return device;
slouken@1950
   277
}
slouken@1950
   278
slouken@1950
   279
VideoBootStrap X11_bootstrap = {
slouken@1950
   280
    "x11", "SDL X11 video driver",
slouken@1950
   281
    X11_Available, X11_CreateDevice
slouken@1950
   282
};
slouken@1950
   283
slouken@4559
   284
static int (*handler) (Display *, XErrorEvent *) = NULL;
slouken@4559
   285
static int
slouken@4559
   286
X11_CheckWindowManagerErrorHandler(Display * d, XErrorEvent * e)
slouken@4559
   287
{
slouken@4559
   288
    if (e->error_code == BadWindow) {
slouken@4559
   289
        return (0);
slouken@4559
   290
    } else {
slouken@4559
   291
        return (handler(d, e));
slouken@4559
   292
    }
slouken@4559
   293
}
slouken@4508
   294
slouken@4518
   295
static void
slouken@4518
   296
X11_CheckWindowManager(_THIS)
slouken@4518
   297
{
slouken@4518
   298
    SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
slouken@4518
   299
    Display *display = data->display;
slouken@4518
   300
    Atom _NET_SUPPORTING_WM_CHECK;
slouken@4518
   301
    int status, real_format;
slouken@4518
   302
    Atom real_type;
slouken@4518
   303
    unsigned long items_read, items_left;
slouken@4518
   304
    unsigned char *propdata;
slouken@4518
   305
    Window wm_window = 0;
slouken@4518
   306
#ifdef DEBUG_WINDOW_MANAGER
slouken@4518
   307
    char *wm_name;
slouken@4518
   308
#endif
slouken@4518
   309
slouken@4559
   310
    /* Set up a handler to gracefully catch errors */
slouken@4559
   311
    XSync(display, False);
slouken@4559
   312
    handler = XSetErrorHandler(X11_CheckWindowManagerErrorHandler);
slouken@4559
   313
slouken@4518
   314
    _NET_SUPPORTING_WM_CHECK = XInternAtom(display, "_NET_SUPPORTING_WM_CHECK", False);
slouken@4518
   315
    status = XGetWindowProperty(display, DefaultRootWindow(display), _NET_SUPPORTING_WM_CHECK, 0L, 1L, False, XA_WINDOW, &real_type, &real_format, &items_read, &items_left, &propdata);
slouken@4518
   316
    if (status == Success && items_read) {
slouken@4518
   317
        wm_window = ((Window*)propdata)[0];
slouken@4518
   318
    }
slouken@4559
   319
    if (propdata) {
slouken@4559
   320
        XFree(propdata);
slouken@4559
   321
    }
slouken@4559
   322
slouken@4559
   323
    if (wm_window) {
slouken@4559
   324
        status = XGetWindowProperty(display, wm_window, _NET_SUPPORTING_WM_CHECK, 0L, 1L, False, XA_WINDOW, &real_type, &real_format, &items_read, &items_left, &propdata);
slouken@4559
   325
        if (status != Success || !items_read || wm_window != ((Window*)propdata)[0]) {
slouken@4559
   326
            wm_window = None;
slouken@4559
   327
        }
slouken@4559
   328
        if (propdata) {
slouken@4559
   329
            XFree(propdata);
slouken@4559
   330
        }
slouken@4559
   331
    }
slouken@4559
   332
slouken@4559
   333
    /* Reset the error handler, we're done checking */
slouken@4559
   334
    XSync(display, False);
slouken@4559
   335
    XSetErrorHandler(handler);
slouken@4518
   336
slouken@4518
   337
    if (!wm_window) {
slouken@4518
   338
#ifdef DEBUG_WINDOW_MANAGER
slouken@4518
   339
        printf("Couldn't get _NET_SUPPORTING_WM_CHECK property\n");
slouken@4518
   340
#endif
slouken@4518
   341
        return;
slouken@4518
   342
    }
slouken@4518
   343
    data->net_wm = SDL_TRUE;
slouken@4518
   344
slouken@4518
   345
#ifdef DEBUG_WINDOW_MANAGER
slouken@4518
   346
    wm_name = X11_GetWindowTitle(_this, wm_window);
slouken@4518
   347
    printf("Window manager: %s\n", wm_name);
slouken@4518
   348
    SDL_free(wm_name);
slouken@4518
   349
#endif
slouken@4518
   350
}
slouken@1950
   351
slouken@1950
   352
int
slouken@1950
   353
X11_VideoInit(_THIS)
slouken@1950
   354
{
slouken@1951
   355
    SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
slouken@1951
   356
slouken@1951
   357
    /* Get the window class name, usually the name of the application */
slouken@1951
   358
    data->classname = get_classname();
slouken@1951
   359
mail@6167
   360
    /* Get the process PID to be associated to the window */
mail@6167
   361
    data->pid = getpid();
mail@6167
   362
slouken@1951
   363
    /* Open a connection to the X input manager */
slouken@1951
   364
#ifdef X_HAVE_UTF8_STRING
slouken@1951
   365
    if (SDL_X11_HAVE_UTF8) {
slouken@1951
   366
        data->im =
slouken@1951
   367
            XOpenIM(data->display, NULL, data->classname, data->classname);
slouken@1951
   368
    }
slouken@1951
   369
#endif
slouken@1951
   370
slouken@1951
   371
    /* Look up some useful Atoms */
slouken@4518
   372
#define GET_ATOM(X) data->X = XInternAtom(data->display, #X, False)
icculus@6637
   373
    GET_ATOM(WM_PROTOCOLS);
slouken@4518
   374
    GET_ATOM(WM_DELETE_WINDOW);
slouken@4518
   375
    GET_ATOM(_NET_WM_STATE);
slouken@4518
   376
    GET_ATOM(_NET_WM_STATE_HIDDEN);
slouken@6481
   377
    GET_ATOM(_NET_WM_STATE_FOCUSED);
slouken@4518
   378
    GET_ATOM(_NET_WM_STATE_MAXIMIZED_VERT);
slouken@4518
   379
    GET_ATOM(_NET_WM_STATE_MAXIMIZED_HORZ);
slouken@4518
   380
    GET_ATOM(_NET_WM_STATE_FULLSCREEN);
icculus@6466
   381
    GET_ATOM(_NET_WM_ALLOWED_ACTIONS);
icculus@6466
   382
    GET_ATOM(_NET_WM_ACTION_FULLSCREEN);
slouken@4518
   383
    GET_ATOM(_NET_WM_NAME);
slouken@4518
   384
    GET_ATOM(_NET_WM_ICON_NAME);
slouken@4518
   385
    GET_ATOM(_NET_WM_ICON);
icculus@6638
   386
    GET_ATOM(_NET_WM_PING);
slouken@4518
   387
    GET_ATOM(UTF8_STRING);
slouken@4518
   388
slouken@4518
   389
    /* Detect the window manager */
slouken@4518
   390
    X11_CheckWindowManager(_this);
slouken@1951
   391
slouken@3521
   392
    if (X11_InitModes(_this) < 0) {
slouken@3521
   393
        return -1;
slouken@3521
   394
    }
slouken@1950
   395
dimitris@6316
   396
    X11_InitXinput2(_this);
slouken@6311
   397
bob@2295
   398
    if (X11_InitKeyboard(_this) != 0) {
bob@2295
   399
        return -1;
bob@2295
   400
    }
slouken@1950
   401
    X11_InitMouse(_this);
slouken@1950
   402
jim@4645
   403
    X11_InitTouch(_this);
slouken@1950
   404
    return 0;
slouken@1950
   405
}
slouken@1950
   406
slouken@1950
   407
void
slouken@1950
   408
X11_VideoQuit(_THIS)
slouken@1950
   409
{
slouken@1951
   410
    SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
slouken@1951
   411
slouken@1951
   412
    if (data->classname) {
slouken@1951
   413
        SDL_free(data->classname);
slouken@1951
   414
    }
slouken@1951
   415
#ifdef X_HAVE_UTF8_STRING
slouken@1951
   416
    if (data->im) {
slouken@1951
   417
        XCloseIM(data->im);
slouken@1951
   418
    }
slouken@1951
   419
#endif
slouken@1951
   420
slouken@1950
   421
    X11_QuitModes(_this);
slouken@1950
   422
    X11_QuitKeyboard(_this);
slouken@1950
   423
    X11_QuitMouse(_this);
jim@4645
   424
    X11_QuitTouch(_this);
slouken@1950
   425
}
slouken@1950
   426
slouken@5466
   427
SDL_bool
slouken@5466
   428
X11_UseDirectColorVisuals(void)
slouken@5466
   429
{
slouken@5466
   430
    return SDL_getenv("SDL_VIDEO_X11_NODIRECTCOLOR") ? SDL_FALSE : SDL_TRUE;
slouken@5466
   431
}
slouken@5466
   432
slouken@5481
   433
#endif /* SDL_VIDEO_DRIVER_X11 */
slouken@5481
   434
slouken@1950
   435
/* vim: set ts=4 sw=4 expandtab: */