src/video/x11/SDL_x11video.c
author Alex Baines <alex@abaines.me.uk>
Fri, 28 Oct 2016 01:28:58 +0100
changeset 10562 b48d8a98e261
parent 10518 fe8023cff95a
child 10737 3406a0f8b041
permissions -rw-r--r--
Fix double events / no repeat flag on key events when built withoutibus/fcitx

Uses XkbSetDetectableKeyRepeat, and falls back to forcing @im=none if it's not
supported.
slouken@1950
     1
/*
slouken@5535
     2
  Simple DirectMedia Layer
slouken@9998
     3
  Copyright (C) 1997-2016 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
*/
icculus@8093
    21
#include "../../SDL_internal.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@7191
    35
#include "SDL_x11touch.h"
dimitris@6316
    36
#include "SDL_x11xinput2.h"
slouken@2710
    37
gabomdq@7659
    38
#if SDL_VIDEO_OPENGL_EGL
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()) {
icculus@7827
    96
        display = X11_XOpenDisplay(NULL);
slouken@1950
    97
        if (display != NULL) {
icculus@7827
    98
            X11_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) {
icculus@7827
   110
        X11_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
{
gabomdq@7679
   125
    SDL_VideoDevice *device = NULL;
icculus@6498
   126
    /* if we trigger an error in our error handler, don't try again. */
icculus@6498
   127
    if (!safety_net_triggered) {
icculus@6498
   128
        safety_net_triggered = SDL_TRUE;
gabomdq@7679
   129
        device = SDL_GetVideoDevice();
icculus@6498
   130
        if (device != NULL) {
icculus@6498
   131
            int i;
icculus@6498
   132
            for (i = 0; i < device->num_displays; i++) {
icculus@6498
   133
                SDL_VideoDisplay *display = &device->displays[i];
icculus@6498
   134
                if (SDL_memcmp(&display->current_mode, &display->desktop_mode,
icculus@6498
   135
                               sizeof (SDL_DisplayMode)) != 0) {
icculus@6498
   136
                    X11_SetDisplayMode(device, display, &display->desktop_mode);
icculus@6498
   137
                }
icculus@6498
   138
            }
icculus@6498
   139
        }
icculus@6498
   140
    }
icculus@6498
   141
icculus@6498
   142
    if (orig_x11_errhandler != NULL) {
icculus@6498
   143
        return orig_x11_errhandler(d, e);  /* probably terminate. */
icculus@6498
   144
    }
icculus@6498
   145
icculus@6498
   146
    return 0;
icculus@6498
   147
}
icculus@6498
   148
slouken@1950
   149
static SDL_VideoDevice *
slouken@1950
   150
X11_CreateDevice(int devindex)
slouken@1950
   151
{
slouken@1950
   152
    SDL_VideoDevice *device;
slouken@1950
   153
    SDL_VideoData *data;
slouken@1950
   154
    const char *display = NULL; /* Use the DISPLAY environment variable */
slouken@1950
   155
slouken@1950
   156
    if (!SDL_X11_LoadSymbols()) {
slouken@1950
   157
        return NULL;
slouken@1950
   158
    }
slouken@1950
   159
icculus@6817
   160
    /* Need for threading gl calls. This is also required for the proprietary
icculus@6817
   161
        nVidia driver to be threaded. */
icculus@7827
   162
    X11_XInitThreads();
mikesart@6569
   163
slouken@1950
   164
    /* Initialize all variables that we clean on shutdown */
slouken@1950
   165
    device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
bob@2323
   166
    if (!device) {
bob@2323
   167
        SDL_OutOfMemory();
bob@2323
   168
        return NULL;
slouken@1950
   169
    }
bob@2323
   170
    data = (struct SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData));
bob@2323
   171
    if (!data) {
icculus@7037
   172
        SDL_free(device);
slouken@1950
   173
        SDL_OutOfMemory();
slouken@1950
   174
        return NULL;
slouken@1950
   175
    }
slouken@1950
   176
    device->driverdata = data;
slouken@1950
   177
icculus@10018
   178
    data->global_mouse_changed = SDL_TRUE;
icculus@10018
   179
slouken@1950
   180
    /* FIXME: Do we need this?
icculus@7827
   181
       if ( (SDL_strncmp(X11_XDisplayName(display), ":", 1) == 0) ||
icculus@7827
   182
       (SDL_strncmp(X11_XDisplayName(display), "unix:", 5) == 0) ) {
slouken@1950
   183
       local_X11 = 1;
slouken@1950
   184
       } else {
slouken@1950
   185
       local_X11 = 0;
slouken@1950
   186
       }
slouken@1950
   187
     */
icculus@7827
   188
    data->display = X11_XOpenDisplay(display);
slouken@1950
   189
#if defined(__osf__) && defined(SDL_VIDEO_DRIVER_X11_DYNAMIC)
slouken@1950
   190
    /* On Tru64 if linking without -lX11, it fails and you get following message.
slouken@1950
   191
     * Xlib: connection to ":0.0" refused by server
slouken@1950
   192
     * Xlib: XDM authorization key matches an existing client!
slouken@1950
   193
     *
slouken@1950
   194
     * It succeeds if retrying 1 second later
slouken@1950
   195
     * or if running xhost +localhost on shell.
slouken@1950
   196
     */
slouken@1950
   197
    if (data->display == NULL) {
slouken@1950
   198
        SDL_Delay(1000);
icculus@7827
   199
        data->display = X11_XOpenDisplay(display);
slouken@1950
   200
    }
slouken@1950
   201
#endif
slouken@1950
   202
    if (data->display == NULL) {
slouken@6367
   203
        SDL_free(device->driverdata);
slouken@1950
   204
        SDL_free(device);
slouken@1950
   205
        SDL_SetError("Couldn't open X11 display");
slouken@1950
   206
        return NULL;
slouken@1950
   207
    }
slouken@1950
   208
#ifdef X11_DEBUG
icculus@7827
   209
    X11_XSynchronize(data->display, True);
slouken@1950
   210
#endif
slouken@1950
   211
icculus@6498
   212
    /* Hook up an X11 error handler to recover the desktop resolution. */
icculus@6498
   213
    safety_net_triggered = SDL_FALSE;
icculus@7827
   214
    orig_x11_errhandler = X11_XSetErrorHandler(X11_SafetyNetErrHandler);
icculus@6498
   215
slouken@1950
   216
    /* Set the function pointers */
slouken@1950
   217
    device->VideoInit = X11_VideoInit;
slouken@1950
   218
    device->VideoQuit = X11_VideoQuit;
slouken@1950
   219
    device->GetDisplayModes = X11_GetDisplayModes;
gabomdq@6331
   220
    device->GetDisplayBounds = X11_GetDisplayBounds;
icculus@10019
   221
    device->GetDisplayUsableBounds = X11_GetDisplayUsableBounds;
alfred@9814
   222
    device->GetDisplayDPI = X11_GetDisplayDPI;
slouken@1950
   223
    device->SetDisplayMode = X11_SetDisplayMode;
slouken@3025
   224
    device->SuspendScreenSaver = X11_SuspendScreenSaver;
slouken@1951
   225
    device->PumpEvents = X11_PumpEvents;
slouken@1950
   226
slouken@1950
   227
    device->CreateWindow = X11_CreateWindow;
slouken@1950
   228
    device->CreateWindowFrom = X11_CreateWindowFrom;
slouken@1950
   229
    device->SetWindowTitle = X11_SetWindowTitle;
slouken@2967
   230
    device->SetWindowIcon = X11_SetWindowIcon;
slouken@1950
   231
    device->SetWindowPosition = X11_SetWindowPosition;
slouken@1950
   232
    device->SetWindowSize = X11_SetWindowSize;
slouken@7617
   233
    device->SetWindowMinimumSize = X11_SetWindowMinimumSize;
slouken@7617
   234
    device->SetWindowMaximumSize = X11_SetWindowMaximumSize;
icculus@10024
   235
    device->GetWindowBordersSize = X11_GetWindowBordersSize;
icculus@10025
   236
    device->SetWindowOpacity = X11_SetWindowOpacity;
icculus@10027
   237
    device->SetWindowModalFor = X11_SetWindowModalFor;
icculus@10026
   238
    device->SetWindowInputFocus = X11_SetWindowInputFocus;
slouken@1950
   239
    device->ShowWindow = X11_ShowWindow;
slouken@1950
   240
    device->HideWindow = X11_HideWindow;
slouken@1950
   241
    device->RaiseWindow = X11_RaiseWindow;
slouken@1950
   242
    device->MaximizeWindow = X11_MaximizeWindow;
slouken@1950
   243
    device->MinimizeWindow = X11_MinimizeWindow;
slouken@1950
   244
    device->RestoreWindow = X11_RestoreWindow;
icculus@6422
   245
    device->SetWindowBordered = X11_SetWindowBordered;
icculus@10385
   246
    device->SetWindowResizable = X11_SetWindowResizable;
slouken@5302
   247
    device->SetWindowFullscreen = X11_SetWindowFullscreen;
slouken@5466
   248
    device->SetWindowGammaRamp = X11_SetWindowGammaRamp;
slouken@1950
   249
    device->SetWindowGrab = X11_SetWindowGrab;
slouken@1950
   250
    device->DestroyWindow = X11_DestroyWindow;
slouken@5182
   251
    device->CreateWindowFramebuffer = X11_CreateWindowFramebuffer;
slouken@5182
   252
    device->UpdateWindowFramebuffer = X11_UpdateWindowFramebuffer;
slouken@5182
   253
    device->DestroyWindowFramebuffer = X11_DestroyWindowFramebuffer;
slouken@1950
   254
    device->GetWindowWMInfo = X11_GetWindowWMInfo;
icculus@8935
   255
    device->SetWindowHitTest = X11_SetWindowHitTest;
slouken@5182
   256
eligottlieb@4782
   257
    device->shape_driver.CreateShaper = X11_CreateShaper;
eligottlieb@4782
   258
    device->shape_driver.SetWindowShape = X11_SetWindowShape;
eligottlieb@4782
   259
    device->shape_driver.ResizeWindowShape = X11_ResizeWindowShape;
slouken@5182
   260
slouken@5088
   261
#if SDL_VIDEO_OPENGL_GLX
slouken@6370
   262
    device->GL_LoadLibrary = X11_GL_LoadLibrary;
slouken@6370
   263
    device->GL_GetProcAddress = X11_GL_GetProcAddress;
slouken@6370
   264
    device->GL_UnloadLibrary = X11_GL_UnloadLibrary;
slouken@6370
   265
    device->GL_CreateContext = X11_GL_CreateContext;
slouken@6370
   266
    device->GL_MakeCurrent = X11_GL_MakeCurrent;
slouken@6370
   267
    device->GL_SetSwapInterval = X11_GL_SetSwapInterval;
slouken@6370
   268
    device->GL_GetSwapInterval = X11_GL_GetSwapInterval;
slouken@6370
   269
    device->GL_SwapWindow = X11_GL_SwapWindow;
slouken@6370
   270
    device->GL_DeleteContext = X11_GL_DeleteContext;
gabomdq@7659
   271
#elif SDL_VIDEO_OPENGL_EGL
slouken@6370
   272
    device->GL_LoadLibrary = X11_GLES_LoadLibrary;
slouken@6370
   273
    device->GL_GetProcAddress = X11_GLES_GetProcAddress;
slouken@6370
   274
    device->GL_UnloadLibrary = X11_GLES_UnloadLibrary;
slouken@6370
   275
    device->GL_CreateContext = X11_GLES_CreateContext;
slouken@6370
   276
    device->GL_MakeCurrent = X11_GLES_MakeCurrent;
slouken@6370
   277
    device->GL_SetSwapInterval = X11_GLES_SetSwapInterval;
slouken@6370
   278
    device->GL_GetSwapInterval = X11_GLES_GetSwapInterval;
slouken@6370
   279
    device->GL_SwapWindow = X11_GLES_SwapWindow;
slouken@6370
   280
    device->GL_DeleteContext = X11_GLES_DeleteContext;
slouken@3218
   281
#endif
slouken@1950
   282
slouken@4508
   283
    device->SetClipboardText = X11_SetClipboardText;
slouken@4508
   284
    device->GetClipboardText = X11_GetClipboardText;
slouken@4508
   285
    device->HasClipboardText = X11_HasClipboardText;
alex@8889
   286
    device->StartTextInput = X11_StartTextInput;
alex@8889
   287
    device->StopTextInput = X11_StopTextInput;
alex@8889
   288
    device->SetTextInputRect = X11_SetTextInputRect;
slouken@10442
   289
slouken@1950
   290
    device->free = X11_DeleteDevice;
slouken@1950
   291
slouken@1950
   292
    return device;
slouken@1950
   293
}
slouken@1950
   294
slouken@1950
   295
VideoBootStrap X11_bootstrap = {
slouken@1950
   296
    "x11", "SDL X11 video driver",
slouken@1950
   297
    X11_Available, X11_CreateDevice
slouken@1950
   298
};
slouken@1950
   299
slouken@4559
   300
static int (*handler) (Display *, XErrorEvent *) = NULL;
slouken@4559
   301
static int
slouken@4559
   302
X11_CheckWindowManagerErrorHandler(Display * d, XErrorEvent * e)
slouken@4559
   303
{
slouken@4559
   304
    if (e->error_code == BadWindow) {
slouken@4559
   305
        return (0);
slouken@4559
   306
    } else {
slouken@4559
   307
        return (handler(d, e));
slouken@4559
   308
    }
slouken@4559
   309
}
slouken@4508
   310
slouken@4518
   311
static void
slouken@4518
   312
X11_CheckWindowManager(_THIS)
slouken@4518
   313
{
slouken@4518
   314
    SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
slouken@4518
   315
    Display *display = data->display;
slouken@4518
   316
    Atom _NET_SUPPORTING_WM_CHECK;
slouken@4518
   317
    int status, real_format;
slouken@4518
   318
    Atom real_type;
slouken@8034
   319
    unsigned long items_read = 0, items_left = 0;
slouken@8034
   320
    unsigned char *propdata = NULL;
slouken@4518
   321
    Window wm_window = 0;
slouken@4518
   322
#ifdef DEBUG_WINDOW_MANAGER
slouken@4518
   323
    char *wm_name;
slouken@4518
   324
#endif
slouken@4518
   325
slouken@4559
   326
    /* Set up a handler to gracefully catch errors */
icculus@7827
   327
    X11_XSync(display, False);
icculus@7827
   328
    handler = X11_XSetErrorHandler(X11_CheckWindowManagerErrorHandler);
slouken@4559
   329
icculus@7827
   330
    _NET_SUPPORTING_WM_CHECK = X11_XInternAtom(display, "_NET_SUPPORTING_WM_CHECK", False);
icculus@7827
   331
    status = X11_XGetWindowProperty(display, DefaultRootWindow(display), _NET_SUPPORTING_WM_CHECK, 0L, 1L, False, XA_WINDOW, &real_type, &real_format, &items_read, &items_left, &propdata);
slouken@8034
   332
    if (status == Success) {
slouken@8034
   333
        if (items_read) {
slouken@8034
   334
            wm_window = ((Window*)propdata)[0];
slouken@8034
   335
        }
slouken@8034
   336
        if (propdata) {
slouken@8034
   337
            X11_XFree(propdata);
slouken@8034
   338
            propdata = NULL;
slouken@8034
   339
        }
slouken@4559
   340
    }
slouken@4559
   341
slouken@4559
   342
    if (wm_window) {
icculus@7827
   343
        status = X11_XGetWindowProperty(display, wm_window, _NET_SUPPORTING_WM_CHECK, 0L, 1L, False, XA_WINDOW, &real_type, &real_format, &items_read, &items_left, &propdata);
slouken@4559
   344
        if (status != Success || !items_read || wm_window != ((Window*)propdata)[0]) {
slouken@4559
   345
            wm_window = None;
slouken@4559
   346
        }
slouken@8034
   347
        if (status == Success && propdata) {
icculus@7827
   348
            X11_XFree(propdata);
slouken@8034
   349
            propdata = NULL;
slouken@4559
   350
        }
slouken@4559
   351
    }
slouken@4559
   352
slouken@4559
   353
    /* Reset the error handler, we're done checking */
icculus@7827
   354
    X11_XSync(display, False);
icculus@7827
   355
    X11_XSetErrorHandler(handler);
slouken@4518
   356
slouken@4518
   357
    if (!wm_window) {
slouken@4518
   358
#ifdef DEBUG_WINDOW_MANAGER
slouken@4518
   359
        printf("Couldn't get _NET_SUPPORTING_WM_CHECK property\n");
slouken@4518
   360
#endif
slouken@4518
   361
        return;
slouken@4518
   362
    }
slouken@4518
   363
    data->net_wm = SDL_TRUE;
slouken@4518
   364
slouken@4518
   365
#ifdef DEBUG_WINDOW_MANAGER
slouken@4518
   366
    wm_name = X11_GetWindowTitle(_this, wm_window);
slouken@4518
   367
    printf("Window manager: %s\n", wm_name);
slouken@4518
   368
    SDL_free(wm_name);
slouken@4518
   369
#endif
slouken@4518
   370
}
slouken@1950
   371
icculus@6774
   372
slouken@1950
   373
int
slouken@1950
   374
X11_VideoInit(_THIS)
slouken@1950
   375
{
slouken@1951
   376
    SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
slouken@1951
   377
slouken@1951
   378
    /* Get the window class name, usually the name of the application */
slouken@1951
   379
    data->classname = get_classname();
slouken@1951
   380
mail@6167
   381
    /* Get the process PID to be associated to the window */
mail@6167
   382
    data->pid = getpid();
mail@6167
   383
icculus@10023
   384
    /* I have no idea how random this actually is, or has to be. */
icculus@10023
   385
    data->window_group = (XID) (((size_t) data->pid) ^ ((size_t) _this));
icculus@10023
   386
slouken@1951
   387
    /* Look up some useful Atoms */
icculus@7827
   388
#define GET_ATOM(X) data->X = X11_XInternAtom(data->display, #X, False)
icculus@6637
   389
    GET_ATOM(WM_PROTOCOLS);
slouken@4518
   390
    GET_ATOM(WM_DELETE_WINDOW);
icculus@10029
   391
    GET_ATOM(WM_TAKE_FOCUS);
slouken@4518
   392
    GET_ATOM(_NET_WM_STATE);
slouken@4518
   393
    GET_ATOM(_NET_WM_STATE_HIDDEN);
slouken@6481
   394
    GET_ATOM(_NET_WM_STATE_FOCUSED);
slouken@4518
   395
    GET_ATOM(_NET_WM_STATE_MAXIMIZED_VERT);
slouken@4518
   396
    GET_ATOM(_NET_WM_STATE_MAXIMIZED_HORZ);
slouken@4518
   397
    GET_ATOM(_NET_WM_STATE_FULLSCREEN);
icculus@10021
   398
    GET_ATOM(_NET_WM_STATE_ABOVE);
icculus@10021
   399
    GET_ATOM(_NET_WM_STATE_SKIP_TASKBAR);
icculus@10021
   400
    GET_ATOM(_NET_WM_STATE_SKIP_PAGER);
icculus@6466
   401
    GET_ATOM(_NET_WM_ALLOWED_ACTIONS);
icculus@6466
   402
    GET_ATOM(_NET_WM_ACTION_FULLSCREEN);
slouken@4518
   403
    GET_ATOM(_NET_WM_NAME);
slouken@4518
   404
    GET_ATOM(_NET_WM_ICON_NAME);
slouken@4518
   405
    GET_ATOM(_NET_WM_ICON);
icculus@6638
   406
    GET_ATOM(_NET_WM_PING);
icculus@10025
   407
    GET_ATOM(_NET_WM_WINDOW_OPACITY);
icculus@10006
   408
    GET_ATOM(_NET_WM_USER_TIME);
slouken@6970
   409
    GET_ATOM(_NET_ACTIVE_WINDOW);
icculus@10102
   410
    GET_ATOM(_NET_FRAME_EXTENTS);
slouken@4518
   411
    GET_ATOM(UTF8_STRING);
slouken@7001
   412
    GET_ATOM(PRIMARY);
slouken@7001
   413
    GET_ATOM(XdndEnter);
slouken@7001
   414
    GET_ATOM(XdndPosition);
slouken@7001
   415
    GET_ATOM(XdndStatus);
slouken@7001
   416
    GET_ATOM(XdndTypeList);
slouken@7001
   417
    GET_ATOM(XdndActionCopy);
slouken@7001
   418
    GET_ATOM(XdndDrop);
slouken@7001
   419
    GET_ATOM(XdndFinished);
slouken@7001
   420
    GET_ATOM(XdndSelection);
icculus@9845
   421
    GET_ATOM(XKLAVIER_STATE);
slouken@4518
   422
slouken@4518
   423
    /* Detect the window manager */
slouken@4518
   424
    X11_CheckWindowManager(_this);
slouken@1951
   425
slouken@3521
   426
    if (X11_InitModes(_this) < 0) {
slouken@3521
   427
        return -1;
slouken@3521
   428
    }
slouken@1950
   429
dimitris@6316
   430
    X11_InitXinput2(_this);
slouken@6311
   431
bob@2295
   432
    if (X11_InitKeyboard(_this) != 0) {
bob@2295
   433
        return -1;
bob@2295
   434
    }
slouken@1950
   435
    X11_InitMouse(_this);
slouken@1950
   436
jim@4645
   437
    X11_InitTouch(_this);
icculus@6774
   438
icculus@6774
   439
#if SDL_USE_LIBDBUS
alex@8889
   440
    SDL_DBus_Init();
icculus@6774
   441
#endif
icculus@6774
   442
slouken@1950
   443
    return 0;
slouken@1950
   444
}
slouken@1950
   445
slouken@1950
   446
void
slouken@1950
   447
X11_VideoQuit(_THIS)
slouken@1950
   448
{
slouken@1951
   449
    SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
slouken@1951
   450
slouken@7719
   451
    SDL_free(data->classname);
slouken@1951
   452
#ifdef X_HAVE_UTF8_STRING
slouken@1951
   453
    if (data->im) {
icculus@7827
   454
        X11_XCloseIM(data->im);
slouken@1951
   455
    }
slouken@1951
   456
#endif
slouken@1951
   457
slouken@1950
   458
    X11_QuitModes(_this);
slouken@1950
   459
    X11_QuitKeyboard(_this);
slouken@1950
   460
    X11_QuitMouse(_this);
jim@4645
   461
    X11_QuitTouch(_this);
icculus@6774
   462
icculus@6774
   463
#if SDL_USE_LIBDBUS
alex@8889
   464
    SDL_DBus_Quit();
icculus@6774
   465
#endif
slouken@1950
   466
}
slouken@1950
   467
slouken@5466
   468
SDL_bool
slouken@5466
   469
X11_UseDirectColorVisuals(void)
slouken@5466
   470
{
slouken@5466
   471
    return SDL_getenv("SDL_VIDEO_X11_NODIRECTCOLOR") ? SDL_FALSE : SDL_TRUE;
slouken@5466
   472
}
slouken@5466
   473
slouken@5481
   474
#endif /* SDL_VIDEO_DRIVER_X11 */
slouken@5481
   475
slouken@1950
   476
/* vim: set ts=4 sw=4 expandtab: */