src/video/x11/SDL_x11events.c
author Sam Lantinga <slouken@libsdl.org>
Sun, 04 Jan 2009 18:29:20 +0000
changeset 2992 dbff5769d742
parent 2942 1e431c2631ee
child 2993 2fad80c77c17
permissions -rw-r--r--
The core pointer is comprised of merging the inputs of all mice.
If there are other mice, they should show up in the device list, and
we want to report events from those devices instead of the core events.
However, if XInput isn't supported or we can't find other mice in the
device list, we'll add the core pointer and interpret normal mouse events.
slouken@1951
     1
/*
slouken@1951
     2
    SDL - Simple DirectMedia Layer
slouken@2859
     3
    Copyright (C) 1997-2009 Sam Lantinga
slouken@1951
     4
slouken@1951
     5
    This library is free software; you can redistribute it and/or
slouken@1951
     6
    modify it under the terms of the GNU Lesser General Public
slouken@1951
     7
    License as published by the Free Software Foundation; either
slouken@1951
     8
    version 2.1 of the License, or (at your option) any later version.
slouken@1951
     9
slouken@1951
    10
    This library is distributed in the hope that it will be useful,
slouken@1951
    11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
slouken@1951
    12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
slouken@1951
    13
    Lesser General Public License for more details.
slouken@1951
    14
slouken@1951
    15
    You should have received a copy of the GNU Lesser General Public
slouken@1951
    16
    License along with this library; if not, write to the Free Software
slouken@1951
    17
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
slouken@1951
    18
slouken@1951
    19
    Sam Lantinga
slouken@1951
    20
    slouken@libsdl.org
slouken@1951
    21
*/
slouken@1951
    22
#include "SDL_config.h"
slouken@1951
    23
slouken@2046
    24
#include <sys/types.h>
slouken@2046
    25
#include <sys/time.h>
slouken@2046
    26
#include <unistd.h>
slouken@2046
    27
slouken@1951
    28
#include "SDL_syswm.h"
slouken@1951
    29
#include "SDL_x11video.h"
slouken@1951
    30
#include "../../events/SDL_events_c.h"
slouken@2940
    31
#include "../../events/SDL_mouse_c.h"
slouken@1951
    32
slouken@1951
    33
static void
slouken@1951
    34
X11_DispatchEvent(_THIS)
slouken@1951
    35
{
slouken@1951
    36
    SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
slouken@1951
    37
    SDL_WindowData *data;
slouken@1951
    38
    XEvent xevent;
slouken@1951
    39
    int i;
slouken@1951
    40
slouken@1951
    41
    SDL_zero(xevent);           /* valgrind fix. --ryan. */
slouken@1951
    42
    XNextEvent(videodata->display, &xevent);
slouken@1951
    43
bob@2325
    44
    /* filter events catchs XIM events and sends them to the correct
bob@2325
    45
       handler */
bob@2325
    46
    if (XFilterEvent(&xevent, None) == True) {
bob@2327
    47
#if 0
bob@2328
    48
        printf("Filtered event type = %d display = %d window = %d\n",
bob@2328
    49
               xevent.type, xevent.xany.display, xevent.xany.window);
bob@2325
    50
#endif
bob@2325
    51
        return;
bob@2325
    52
    }
bob@2325
    53
slouken@1951
    54
    /* Send a SDL_SYSWMEVENT if the application wants them */
slouken@1951
    55
    if (SDL_ProcessEvents[SDL_SYSWMEVENT] == SDL_ENABLE) {
slouken@1951
    56
        SDL_SysWMmsg wmmsg;
slouken@1951
    57
slouken@1951
    58
        SDL_VERSION(&wmmsg.version);
slouken@1951
    59
        wmmsg.subsystem = SDL_SYSWM_X11;
slouken@1951
    60
        wmmsg.event.xevent = xevent;
slouken@1951
    61
        SDL_SendSysWMEvent(&wmmsg);
slouken@1951
    62
    }
slouken@1951
    63
slouken@1951
    64
    data = NULL;
bob@2324
    65
    if (videodata && videodata->windowlist) {
bob@2324
    66
        for (i = 0; i < videodata->numwindows; ++i) {
bob@2324
    67
            if ((videodata->windowlist[i] != NULL) &&
bob@2324
    68
                (videodata->windowlist[i]->window == xevent.xany.window)) {
bob@2324
    69
                data = videodata->windowlist[i];
bob@2324
    70
                break;
bob@2324
    71
            }
slouken@1951
    72
        }
slouken@1951
    73
    }
slouken@1951
    74
    if (!data) {
slouken@1951
    75
        return;
slouken@1951
    76
    }
bob@2327
    77
#if 0
bob@2328
    78
    printf("type = %d display = %d window = %d\n",
bob@2328
    79
           xevent.type, xevent.xany.display, xevent.xany.window);
bob@2327
    80
#endif
slouken@1951
    81
    switch (xevent.type) {
slouken@1951
    82
slouken@1951
    83
        /* Gaining mouse coverage? */
slouken@1951
    84
    case EnterNotify:{
slouken@1951
    85
#ifdef DEBUG_XEVENTS
slouken@1951
    86
            printf("EnterNotify! (%d,%d)\n", xevent.xcrossing.x,
slouken@1951
    87
                   xevent.xcrossing.y);
slouken@1951
    88
            if (xevent.xcrossing.mode == NotifyGrab)
slouken@1951
    89
                printf("Mode: NotifyGrab\n");
slouken@1951
    90
            if (xevent.xcrossing.mode == NotifyUngrab)
slouken@1951
    91
                printf("Mode: NotifyUngrab\n");
slouken@1951
    92
#endif
slouken@1951
    93
            if ((xevent.xcrossing.mode != NotifyGrab) &&
slouken@1951
    94
                (xevent.xcrossing.mode != NotifyUngrab)) {
slouken@2940
    95
                /* FIXME: Should we reset data for all mice? */
slouken@2940
    96
#if 0
slouken@2940
    97
                SDL_SetMouseFocus(0, data->windowID);
slouken@2940
    98
                SDL_SendMouseMotion(0, 0, move->x, move->y, 0);
slouken@2940
    99
#endif
slouken@1951
   100
            }
slouken@1951
   101
        }
slouken@1951
   102
        break;
slouken@1951
   103
slouken@1951
   104
        /* Losing mouse coverage? */
slouken@1951
   105
    case LeaveNotify:{
slouken@1951
   106
#ifdef DEBUG_XEVENTS
slouken@1951
   107
            printf("LeaveNotify! (%d,%d)\n", xevent.xcrossing.x,
slouken@1951
   108
                   xevent.xcrossing.y);
slouken@1951
   109
            if (xevent.xcrossing.mode == NotifyGrab)
slouken@1951
   110
                printf("Mode: NotifyGrab\n");
slouken@1951
   111
            if (xevent.xcrossing.mode == NotifyUngrab)
slouken@1951
   112
                printf("Mode: NotifyUngrab\n");
slouken@1951
   113
#endif
slouken@1951
   114
            if ((xevent.xcrossing.mode != NotifyGrab) &&
slouken@1951
   115
                (xevent.xcrossing.mode != NotifyUngrab) &&
slouken@1951
   116
                (xevent.xcrossing.detail != NotifyInferior)) {
slouken@2940
   117
                /* FIXME: Should we reset data for all mice? */
slouken@2940
   118
#if 0
slouken@2940
   119
                SDL_SetMouseFocus(0, 0);
slouken@2940
   120
#endif
slouken@1951
   121
            }
slouken@1951
   122
        }
slouken@1951
   123
        break;
slouken@1951
   124
slouken@1951
   125
        /* Gaining input focus? */
slouken@1951
   126
    case FocusIn:{
slouken@1951
   127
#ifdef DEBUG_XEVENTS
slouken@1951
   128
            printf("FocusIn!\n");
slouken@1951
   129
#endif
slouken@1951
   130
            SDL_SetKeyboardFocus(videodata->keyboard, data->windowID);
slouken@1951
   131
#ifdef X_HAVE_UTF8_STRING
slouken@1951
   132
            if (data->ic) {
slouken@1951
   133
                XSetICFocus(data->ic);
slouken@1951
   134
            }
slouken@1951
   135
#endif
slouken@1951
   136
        }
slouken@1951
   137
        break;
slouken@1951
   138
slouken@1951
   139
        /* Losing input focus? */
slouken@1951
   140
    case FocusOut:{
slouken@1951
   141
#ifdef DEBUG_XEVENTS
slouken@1951
   142
            printf("FocusOut!\n");
slouken@1951
   143
#endif
slouken@1951
   144
            SDL_SetKeyboardFocus(videodata->keyboard, 0);
slouken@1951
   145
#ifdef X_HAVE_UTF8_STRING
slouken@1951
   146
            if (data->ic) {
slouken@1951
   147
                XUnsetICFocus(data->ic);
slouken@1951
   148
            }
slouken@1951
   149
#endif
slouken@1951
   150
        }
slouken@1951
   151
        break;
slouken@1951
   152
slouken@1951
   153
        /* Generated upon EnterWindow and FocusIn */
slouken@1951
   154
    case KeymapNotify:{
slouken@1951
   155
#ifdef DEBUG_XEVENTS
slouken@1951
   156
            printf("KeymapNotify!\n");
slouken@1951
   157
#endif
slouken@1951
   158
            /* FIXME:
slouken@1951
   159
               X11_SetKeyboardState(SDL_Display, xevent.xkeymap.key_vector);
slouken@1951
   160
             */
slouken@1951
   161
        }
slouken@1951
   162
        break;
slouken@1951
   163
slouken@2305
   164
        /* Has the keyboard layout changed? */
slouken@2305
   165
    case MappingNotify:{
slouken@2305
   166
#ifdef DEBUG_XEVENTS
slouken@2305
   167
            printf("MappingNotify!\n");
slouken@2305
   168
#endif
slouken@2306
   169
            X11_UpdateKeymap(_this);
slouken@2305
   170
        }
slouken@2305
   171
        break;
slouken@2305
   172
slouken@1951
   173
        /* Key press? */
slouken@1951
   174
    case KeyPress:{
slouken@1951
   175
            KeyCode keycode = xevent.xkey.keycode;
bob@2300
   176
            KeySym keysym = NoSymbol;
slouken@2306
   177
            char text[SDL_TEXTINPUTEVENT_TEXT_SIZE];
bob@2325
   178
            Status status = 0;
slouken@1951
   179
slouken@1951
   180
#ifdef DEBUG_XEVENTS
slouken@1951
   181
            printf("KeyPress (X11 keycode = 0x%X)\n", xevent.xkey.keycode);
slouken@1951
   182
#endif
bob@2299
   183
            SDL_SendKeyboardKey(videodata->keyboard, SDL_PRESSED,
slouken@2305
   184
                                videodata->key_layout[keycode]);
bob@2325
   185
#if 0
slouken@2305
   186
            if (videodata->key_layout[keycode] == SDLK_UNKNOWN) {
slouken@2305
   187
                int min_keycode, max_keycode;
slouken@2305
   188
                XDisplayKeycodes(videodata->display, &min_keycode,
slouken@2305
   189
                                 &max_keycode);
slouken@2305
   190
                keysym = XKeycodeToKeysym(videodata->display, keycode, 0);
bob@2299
   191
                fprintf(stderr,
slouken@2305
   192
                        "The key you just pressed is not recognized by SDL. To help get this fixed, please report this to the SDL mailing list <sdl@libsdl.org> X11 KeyCode %d (%d), X11 KeySym 0x%X (%s).\n",
slouken@2305
   193
                        keycode, keycode - min_keycode, keysym,
slouken@2305
   194
                        XKeysymToString(keysym));
bob@2299
   195
            }
bob@2295
   196
#endif
bob@2325
   197
            /* */
slouken@2305
   198
            SDL_zero(text);
bob@2325
   199
#ifdef X_HAVE_UTF8_STRING
bob@2325
   200
            if (data->ic) {
bob@2325
   201
                Xutf8LookupString(data->ic, &xevent.xkey, text, sizeof(text),
slouken@2738
   202
                                  &keysym, &status);
bob@2325
   203
            }
bob@2325
   204
#else
slouken@2306
   205
            XLookupString(&xevent.xkey, text, sizeof(text), &keysym, NULL);
bob@2325
   206
#endif
slouken@2305
   207
            if (*text) {
slouken@2305
   208
                printf("Sending text event %s\n", text);
bob@2300
   209
                SDL_SendKeyboardText(videodata->keyboard, text);
bob@2300
   210
            }
slouken@1951
   211
        }
slouken@1951
   212
        break;
slouken@1951
   213
slouken@1951
   214
        /* Key release? */
slouken@1951
   215
    case KeyRelease:{
slouken@1951
   216
            KeyCode keycode = xevent.xkey.keycode;
slouken@1951
   217
slouken@1951
   218
#ifdef DEBUG_XEVENTS
slouken@1951
   219
            printf("KeyRelease (X11 keycode = 0x%X)\n", xevent.xkey.keycode);
slouken@1951
   220
#endif
bob@2295
   221
            SDL_SendKeyboardKey(videodata->keyboard, SDL_RELEASED,
slouken@2305
   222
                                videodata->key_layout[keycode]);
slouken@1951
   223
        }
slouken@1951
   224
        break;
slouken@1951
   225
slouken@1951
   226
        /* Have we been iconified? */
slouken@1951
   227
    case UnmapNotify:{
slouken@1951
   228
#ifdef DEBUG_XEVENTS
slouken@1951
   229
            printf("UnmapNotify!\n");
slouken@1951
   230
#endif
slouken@1951
   231
            SDL_SendWindowEvent(data->windowID, SDL_WINDOWEVENT_HIDDEN, 0, 0);
slouken@1951
   232
            SDL_SendWindowEvent(data->windowID, SDL_WINDOWEVENT_MINIMIZED, 0,
slouken@1951
   233
                                0);
slouken@1951
   234
        }
slouken@1951
   235
        break;
slouken@1951
   236
slouken@1951
   237
        /* Have we been restored? */
slouken@1951
   238
    case MapNotify:{
slouken@1951
   239
#ifdef DEBUG_XEVENTS
slouken@1951
   240
            printf("MapNotify!\n");
slouken@1951
   241
#endif
slouken@1951
   242
            SDL_SendWindowEvent(data->windowID, SDL_WINDOWEVENT_SHOWN, 0, 0);
slouken@1951
   243
            SDL_SendWindowEvent(data->windowID, SDL_WINDOWEVENT_RESTORED, 0,
slouken@1951
   244
                                0);
slouken@1951
   245
        }
slouken@1951
   246
        break;
slouken@1951
   247
slouken@1951
   248
        /* Have we been resized or moved? */
slouken@1951
   249
    case ConfigureNotify:{
slouken@1951
   250
#ifdef DEBUG_XEVENTS
slouken@1951
   251
            printf("ConfigureNotify! (resize: %dx%d)\n",
slouken@1951
   252
                   xevent.xconfigure.width, xevent.xconfigure.height);
slouken@1951
   253
#endif
slouken@1951
   254
            SDL_SendWindowEvent(data->windowID, SDL_WINDOWEVENT_MOVED,
slouken@1951
   255
                                xevent.xconfigure.x, xevent.xconfigure.y);
slouken@1951
   256
            SDL_SendWindowEvent(data->windowID, SDL_WINDOWEVENT_RESIZED,
slouken@1951
   257
                                xevent.xconfigure.width,
slouken@1951
   258
                                xevent.xconfigure.height);
slouken@1951
   259
        }
slouken@1951
   260
        break;
slouken@1951
   261
slouken@1951
   262
        /* Have we been requested to quit (or another client message?) */
slouken@1951
   263
    case ClientMessage:{
slouken@1951
   264
            if ((xevent.xclient.format == 32) &&
slouken@1951
   265
                (xevent.xclient.data.l[0] == videodata->WM_DELETE_WINDOW)) {
slouken@1951
   266
slouken@1951
   267
                SDL_SendWindowEvent(data->windowID, SDL_WINDOWEVENT_CLOSE, 0,
slouken@1951
   268
                                    0);
slouken@1951
   269
            }
slouken@1951
   270
        }
slouken@1951
   271
        break;
slouken@1951
   272
slouken@1951
   273
        /* Do we need to refresh ourselves? */
slouken@1951
   274
    case Expose:{
slouken@1951
   275
#ifdef DEBUG_XEVENTS
slouken@1951
   276
            printf("Expose (count = %d)\n", xevent.xexpose.count);
slouken@1951
   277
#endif
slouken@1951
   278
            SDL_SendWindowEvent(data->windowID, SDL_WINDOWEVENT_EXPOSED, 0,
slouken@1951
   279
                                0);
slouken@1951
   280
        }
slouken@1951
   281
        break;
slouken@1951
   282
slouken@1951
   283
    default:{
slouken@2940
   284
#if SDL_VIDEO_DRIVER_X11_XINPUT
slouken@2942
   285
            for (i = 0; i < SDL_GetNumMice(); ++i) {
slouken@2942
   286
                SDL_Mouse *mouse;
slouken@2942
   287
                X11_MouseData *data;
slouken@2940
   288
slouken@2942
   289
                mouse = SDL_GetMouse(i);
slouken@2942
   290
                data = (X11_MouseData *) mouse->driverdata;
slouken@2942
   291
                if (!data) {
slouken@2992
   292
                    switch (xevent.type) {
slouken@2992
   293
                    case MotionNotify:
slouken@2992
   294
#ifdef DEBUG_MOTION
slouken@2992
   295
                        printf("X11 motion: %d,%d\n", xevent.xmotion.x, xevent.xmotion.y);
slouken@2992
   296
#endif
slouken@2992
   297
                        SDL_SendMouseMotion(0, 0, xevent.xmotion.x, xevent.xmotion.y, 0);
slouken@2992
   298
                        break;
slouken@2992
   299
slouken@2992
   300
                    case ButtonPress:
slouken@2992
   301
                        SDL_SendMouseButton(0, SDL_PRESSED, xevent.xbutton.button);
slouken@2992
   302
                        break;
slouken@2992
   303
slouken@2992
   304
                    case ButtonRelease:
slouken@2992
   305
                        SDL_SendMouseButton(0, SDL_RELEASED, xevent.xbutton.button);
slouken@2992
   306
                        break;
slouken@2992
   307
                    }
slouken@2942
   308
                    continue;
slouken@2942
   309
                }
slouken@2942
   310
slouken@2942
   311
                if (xevent.type == data->motion) {      /* MotionNotify */
slouken@2942
   312
                    XDeviceMotionEvent *move =
slouken@2942
   313
                        (XDeviceMotionEvent *) & xevent;
slouken@2942
   314
#ifdef DEBUG_MOTION
slouken@2942
   315
                    printf("X11 motion: %d,%d\n", move->x, move->y);
slouken@2942
   316
#endif
slouken@2942
   317
                    SDL_SendMouseMotion(move->deviceid, 0, move->x, move->y,
slouken@2942
   318
                                        move->axis_data[2]);
slouken@2942
   319
                    return;
slouken@2942
   320
                }
slouken@2942
   321
                if (xevent.type == data->button_pressed) {      /* ButtonPress */
slouken@2942
   322
                    XDeviceButtonPressedEvent *pressed =
slouken@2942
   323
                        (XDeviceButtonPressedEvent *) & xevent;
slouken@2942
   324
                    SDL_SendMouseButton(pressed->deviceid, SDL_PRESSED,
slouken@2942
   325
                                        pressed->button);
slouken@2942
   326
                    return;
slouken@2942
   327
                }
slouken@2942
   328
                if (xevent.type == data->button_released) {     /* ButtonRelease */
slouken@2942
   329
                    XDeviceButtonReleasedEvent *released =
slouken@2942
   330
                        (XDeviceButtonReleasedEvent *) & xevent;
slouken@2942
   331
                    SDL_SendMouseButton(released->deviceid, SDL_RELEASED,
slouken@2942
   332
                                        released->button);
slouken@2942
   333
                    return;
slouken@2942
   334
                }
slouken@2942
   335
                if (xevent.type == data->proximity_in) {
slouken@2942
   336
                    XProximityNotifyEvent *proximity =
slouken@2942
   337
                        (XProximityNotifyEvent *) & xevent;
slouken@2942
   338
                    SDL_SendProximity(proximity->deviceid, proximity->x,
slouken@2942
   339
                                      proximity->y, SDL_PROXIMITYIN);
slouken@2942
   340
                    return;
slouken@2942
   341
                }
slouken@2942
   342
                if (xevent.type == data->proximity_out) {
slouken@2942
   343
                    XProximityNotifyEvent *proximity =
slouken@2942
   344
                        (XProximityNotifyEvent *) & xevent;
slouken@2942
   345
                    SDL_SendProximity(proximity->deviceid, proximity->x,
slouken@2942
   346
                                      proximity->y, SDL_PROXIMITYOUT);
slouken@2942
   347
                    return;
slouken@2942
   348
                }
slouken@2940
   349
            }
slouken@2940
   350
#endif
slouken@1951
   351
#ifdef DEBUG_XEVENTS
slouken@2940
   352
            printf("Unhandled event %d\n", xevent.type);
slouken@1951
   353
#endif
slouken@1951
   354
        }
slouken@1951
   355
        break;
slouken@1951
   356
    }
slouken@1951
   357
}
slouken@1951
   358
slouken@1951
   359
/* Ack!  XPending() actually performs a blocking read if no events available */
slouken@1951
   360
int
slouken@1951
   361
X11_Pending(Display * display)
slouken@1951
   362
{
slouken@1951
   363
    /* Flush the display connection and look to see if events are queued */
slouken@1951
   364
    XFlush(display);
slouken@1951
   365
    if (XEventsQueued(display, QueuedAlready)) {
slouken@1951
   366
        return (1);
slouken@1951
   367
    }
slouken@1951
   368
slouken@1951
   369
    /* More drastic measures are required -- see if X is ready to talk */
slouken@1951
   370
    {
slouken@1951
   371
        static struct timeval zero_time;        /* static == 0 */
slouken@1951
   372
        int x11_fd;
slouken@1951
   373
        fd_set fdset;
slouken@1951
   374
slouken@1951
   375
        x11_fd = ConnectionNumber(display);
slouken@1951
   376
        FD_ZERO(&fdset);
slouken@1951
   377
        FD_SET(x11_fd, &fdset);
slouken@1951
   378
        if (select(x11_fd + 1, &fdset, NULL, NULL, &zero_time) == 1) {
slouken@1951
   379
            return (XPending(display));
slouken@1951
   380
        }
slouken@1951
   381
    }
slouken@1951
   382
slouken@1951
   383
    /* Oh well, nothing is ready .. */
slouken@1951
   384
    return (0);
slouken@1951
   385
}
slouken@1951
   386
slouken@1951
   387
void
slouken@1951
   388
X11_PumpEvents(_THIS)
slouken@1951
   389
{
slouken@1951
   390
    SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
slouken@1951
   391
slouken@1951
   392
    /* Keep processing pending events */
slouken@1951
   393
    while (X11_Pending(data->display)) {
slouken@1951
   394
        X11_DispatchEvent(_this);
slouken@1951
   395
    }
slouken@1951
   396
}
slouken@1951
   397
slouken@1951
   398
void
slouken@1951
   399
X11_SaveScreenSaver(Display * display, int *saved_timeout, BOOL * dpms)
slouken@1951
   400
{
slouken@1951
   401
    int timeout, interval, prefer_blank, allow_exp;
slouken@1951
   402
    XGetScreenSaver(display, &timeout, &interval, &prefer_blank, &allow_exp);
slouken@1951
   403
    *saved_timeout = timeout;
slouken@1951
   404
slouken@1951
   405
#if SDL_VIDEO_DRIVER_X11_DPMS
slouken@1951
   406
    if (SDL_X11_HAVE_DPMS) {
slouken@1951
   407
        int dummy;
slouken@1951
   408
        if (DPMSQueryExtension(display, &dummy, &dummy)) {
slouken@1951
   409
            CARD16 state;
slouken@1951
   410
            DPMSInfo(display, &state, dpms);
slouken@1951
   411
        }
slouken@1951
   412
    }
slouken@1951
   413
#else
slouken@1951
   414
    *dpms = 0;
slouken@1951
   415
#endif /* SDL_VIDEO_DRIVER_X11_DPMS */
slouken@1951
   416
}
slouken@1951
   417
slouken@1951
   418
void
slouken@1951
   419
X11_DisableScreenSaver(Display * display)
slouken@1951
   420
{
slouken@1951
   421
    int timeout, interval, prefer_blank, allow_exp;
slouken@1951
   422
    XGetScreenSaver(display, &timeout, &interval, &prefer_blank, &allow_exp);
slouken@1951
   423
    timeout = 0;
slouken@1951
   424
    XSetScreenSaver(display, timeout, interval, prefer_blank, allow_exp);
slouken@1951
   425
slouken@1951
   426
#if SDL_VIDEO_DRIVER_X11_DPMS
slouken@1951
   427
    if (SDL_X11_HAVE_DPMS) {
slouken@1951
   428
        int dummy;
slouken@1951
   429
        if (DPMSQueryExtension(display, &dummy, &dummy)) {
slouken@1951
   430
            DPMSDisable(display);
slouken@1951
   431
        }
slouken@1951
   432
    }
slouken@1951
   433
#endif /* SDL_VIDEO_DRIVER_X11_DPMS */
slouken@1951
   434
}
slouken@1951
   435
slouken@1951
   436
void
slouken@1951
   437
X11_RestoreScreenSaver(Display * display, int saved_timeout, BOOL dpms)
slouken@1951
   438
{
slouken@1951
   439
    int timeout, interval, prefer_blank, allow_exp;
slouken@1951
   440
    XGetScreenSaver(display, &timeout, &interval, &prefer_blank, &allow_exp);
slouken@1951
   441
    timeout = saved_timeout;
slouken@1951
   442
    XSetScreenSaver(display, timeout, interval, prefer_blank, allow_exp);
slouken@1951
   443
slouken@1951
   444
#if SDL_VIDEO_DRIVER_X11_DPMS
slouken@1951
   445
    if (SDL_X11_HAVE_DPMS) {
slouken@1951
   446
        int dummy;
slouken@1951
   447
        if (DPMSQueryExtension(display, &dummy, &dummy)) {
slouken@1951
   448
            if (dpms) {
slouken@1951
   449
                DPMSEnable(display);
slouken@1951
   450
            }
slouken@1951
   451
        }
slouken@1951
   452
    }
slouken@1951
   453
#endif /* SDL_VIDEO_DRIVER_X11_DPMS */
slouken@1951
   454
}
slouken@1951
   455
slouken@1951
   456
/* vi: set ts=4 sw=4 expandtab: */