src/video/x11/SDL_x11events.c
author Sam Lantinga <slouken@libsdl.org>
Mon, 25 Aug 2008 06:33:00 +0000
changeset 2710 44e49d3fa6cf
parent 2328 91e601d9df8b
child 2738 79c1bd651f04
permissions -rw-r--r--
Final merge of Google Summer of Code 2008 work...

Many-mouse and tablet support
by Szymon Wilczek, mentored by Ryan C. Gordon

Everything concerning the project is noted on the wiki:
http://wilku.ravenlord.ws/doku.php?id=start
slouken@1951
     1
/*
slouken@1951
     2
    SDL - Simple DirectMedia Layer
slouken@1951
     3
    Copyright (C) 1997-2006 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@1951
    31
slouken@2710
    32
extern int motion;              /* the motion event id defined by an XInput function */
slouken@2710
    33
extern int button_pressed;      /* the button_pressed event id defined by an XInput function */
slouken@2710
    34
extern int button_released;     /* the button_released event id defined by an XInput function */
slouken@2710
    35
extern int proximity_in;        /* the proximity in event defined by an XInput function */
slouken@2710
    36
extern int proximity_out;       /* the proximity out event defined by an XInput function */
slouken@2710
    37
slouken@1951
    38
static void
slouken@1951
    39
X11_DispatchEvent(_THIS)
slouken@1951
    40
{
slouken@1951
    41
    SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
slouken@1951
    42
    SDL_WindowData *data;
slouken@1951
    43
    XEvent xevent;
slouken@1951
    44
    int i;
slouken@1951
    45
slouken@1951
    46
    SDL_zero(xevent);           /* valgrind fix. --ryan. */
slouken@1951
    47
    XNextEvent(videodata->display, &xevent);
slouken@1951
    48
bob@2325
    49
    /* filter events catchs XIM events and sends them to the correct
bob@2325
    50
       handler */
bob@2325
    51
    if (XFilterEvent(&xevent, None) == True) {
bob@2327
    52
#if 0
bob@2328
    53
        printf("Filtered event type = %d display = %d window = %d\n",
bob@2328
    54
               xevent.type, xevent.xany.display, xevent.xany.window);
bob@2325
    55
#endif
bob@2325
    56
        return;
bob@2325
    57
    }
bob@2325
    58
slouken@1951
    59
    /* Send a SDL_SYSWMEVENT if the application wants them */
slouken@1951
    60
    if (SDL_ProcessEvents[SDL_SYSWMEVENT] == SDL_ENABLE) {
slouken@1951
    61
        SDL_SysWMmsg wmmsg;
slouken@1951
    62
slouken@1951
    63
        SDL_VERSION(&wmmsg.version);
slouken@1951
    64
        wmmsg.subsystem = SDL_SYSWM_X11;
slouken@1951
    65
        wmmsg.event.xevent = xevent;
slouken@1951
    66
        SDL_SendSysWMEvent(&wmmsg);
slouken@1951
    67
    }
slouken@1951
    68
slouken@1951
    69
    data = NULL;
bob@2324
    70
    if (videodata && videodata->windowlist) {
bob@2324
    71
        for (i = 0; i < videodata->numwindows; ++i) {
bob@2324
    72
            if ((videodata->windowlist[i] != NULL) &&
bob@2324
    73
                (videodata->windowlist[i]->window == xevent.xany.window)) {
bob@2324
    74
                data = videodata->windowlist[i];
bob@2324
    75
                break;
bob@2324
    76
            }
slouken@1951
    77
        }
slouken@1951
    78
    }
slouken@1951
    79
    if (!data) {
slouken@1951
    80
        return;
slouken@1951
    81
    }
bob@2327
    82
#if 0
bob@2328
    83
    printf("type = %d display = %d window = %d\n",
bob@2328
    84
           xevent.type, xevent.xany.display, xevent.xany.window);
bob@2327
    85
#endif
slouken@1951
    86
    switch (xevent.type) {
slouken@1951
    87
slouken@1951
    88
        /* Gaining mouse coverage? */
slouken@1951
    89
    case EnterNotify:{
slouken@1951
    90
#ifdef DEBUG_XEVENTS
slouken@1951
    91
            printf("EnterNotify! (%d,%d)\n", xevent.xcrossing.x,
slouken@1951
    92
                   xevent.xcrossing.y);
slouken@1951
    93
            if (xevent.xcrossing.mode == NotifyGrab)
slouken@1951
    94
                printf("Mode: NotifyGrab\n");
slouken@1951
    95
            if (xevent.xcrossing.mode == NotifyUngrab)
slouken@1951
    96
                printf("Mode: NotifyUngrab\n");
slouken@1951
    97
#endif
slouken@1951
    98
            if ((xevent.xcrossing.mode != NotifyGrab) &&
slouken@1951
    99
                (xevent.xcrossing.mode != NotifyUngrab)) {
slouken@2710
   100
                XDeviceMotionEvent *move = (XDeviceMotionEvent *) & xevent;
slouken@2710
   101
                SDL_SetMouseFocus(move->deviceid, data->windowID);
slouken@2710
   102
                SDL_SendMouseMotion(move->deviceid, 0, move->x,
slouken@2710
   103
                                    move->y, move->axis_data[2]);
slouken@1951
   104
            }
slouken@1951
   105
        }
slouken@1951
   106
        break;
slouken@1951
   107
slouken@1951
   108
        /* Losing mouse coverage? */
slouken@1951
   109
    case LeaveNotify:{
slouken@1951
   110
#ifdef DEBUG_XEVENTS
slouken@1951
   111
            printf("LeaveNotify! (%d,%d)\n", xevent.xcrossing.x,
slouken@1951
   112
                   xevent.xcrossing.y);
slouken@1951
   113
            if (xevent.xcrossing.mode == NotifyGrab)
slouken@1951
   114
                printf("Mode: NotifyGrab\n");
slouken@1951
   115
            if (xevent.xcrossing.mode == NotifyUngrab)
slouken@1951
   116
                printf("Mode: NotifyUngrab\n");
slouken@1951
   117
#endif
slouken@1951
   118
            if ((xevent.xcrossing.mode != NotifyGrab) &&
slouken@1951
   119
                (xevent.xcrossing.mode != NotifyUngrab) &&
slouken@1951
   120
                (xevent.xcrossing.detail != NotifyInferior)) {
slouken@2710
   121
                XDeviceMotionEvent *move = (XDeviceMotionEvent *) & xevent;
slouken@2710
   122
                SDL_SetMouseFocus(move->deviceid, 0);
slouken@1951
   123
            }
slouken@1951
   124
        }
slouken@1951
   125
        break;
slouken@1951
   126
slouken@1951
   127
        /* Gaining input focus? */
slouken@1951
   128
    case FocusIn:{
slouken@1951
   129
#ifdef DEBUG_XEVENTS
slouken@1951
   130
            printf("FocusIn!\n");
slouken@1951
   131
#endif
slouken@1951
   132
            SDL_SetKeyboardFocus(videodata->keyboard, data->windowID);
slouken@1951
   133
#ifdef X_HAVE_UTF8_STRING
slouken@1951
   134
            if (data->ic) {
slouken@1951
   135
                XSetICFocus(data->ic);
slouken@1951
   136
            }
slouken@1951
   137
#endif
slouken@1951
   138
        }
slouken@1951
   139
        break;
slouken@1951
   140
slouken@1951
   141
        /* Losing input focus? */
slouken@1951
   142
    case FocusOut:{
slouken@1951
   143
#ifdef DEBUG_XEVENTS
slouken@1951
   144
            printf("FocusOut!\n");
slouken@1951
   145
#endif
slouken@1951
   146
            SDL_SetKeyboardFocus(videodata->keyboard, 0);
slouken@1951
   147
#ifdef X_HAVE_UTF8_STRING
slouken@1951
   148
            if (data->ic) {
slouken@1951
   149
                XUnsetICFocus(data->ic);
slouken@1951
   150
            }
slouken@1951
   151
#endif
slouken@1951
   152
        }
slouken@1951
   153
        break;
slouken@1951
   154
slouken@1951
   155
        /* Generated upon EnterWindow and FocusIn */
slouken@1951
   156
    case KeymapNotify:{
slouken@1951
   157
#ifdef DEBUG_XEVENTS
slouken@1951
   158
            printf("KeymapNotify!\n");
slouken@1951
   159
#endif
slouken@1951
   160
            /* FIXME:
slouken@1951
   161
               X11_SetKeyboardState(SDL_Display, xevent.xkeymap.key_vector);
slouken@1951
   162
             */
slouken@1951
   163
        }
slouken@1951
   164
        break;
slouken@1951
   165
slouken@2305
   166
        /* Has the keyboard layout changed? */
slouken@2305
   167
    case MappingNotify:{
slouken@2305
   168
#ifdef DEBUG_XEVENTS
slouken@2305
   169
            printf("MappingNotify!\n");
slouken@2305
   170
#endif
slouken@2306
   171
            X11_UpdateKeymap(_this);
slouken@2305
   172
        }
slouken@2305
   173
        break;
slouken@2305
   174
slouken@1951
   175
        /* Key press? */
slouken@1951
   176
    case KeyPress:{
slouken@1951
   177
            KeyCode keycode = xevent.xkey.keycode;
bob@2300
   178
            KeySym keysym = NoSymbol;
slouken@2306
   179
            char text[SDL_TEXTINPUTEVENT_TEXT_SIZE];
bob@2325
   180
            Status status = 0;
slouken@1951
   181
slouken@1951
   182
#ifdef DEBUG_XEVENTS
slouken@1951
   183
            printf("KeyPress (X11 keycode = 0x%X)\n", xevent.xkey.keycode);
slouken@1951
   184
#endif
bob@2299
   185
            SDL_SendKeyboardKey(videodata->keyboard, SDL_PRESSED,
slouken@2305
   186
                                videodata->key_layout[keycode]);
bob@2325
   187
#if 0
slouken@2305
   188
            if (videodata->key_layout[keycode] == SDLK_UNKNOWN) {
slouken@2305
   189
                int min_keycode, max_keycode;
slouken@2305
   190
                XDisplayKeycodes(videodata->display, &min_keycode,
slouken@2305
   191
                                 &max_keycode);
slouken@2305
   192
                keysym = XKeycodeToKeysym(videodata->display, keycode, 0);
bob@2299
   193
                fprintf(stderr,
slouken@2305
   194
                        "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
   195
                        keycode, keycode - min_keycode, keysym,
slouken@2305
   196
                        XKeysymToString(keysym));
bob@2299
   197
            }
bob@2295
   198
#endif
bob@2325
   199
            /* */
slouken@2305
   200
            SDL_zero(text);
bob@2325
   201
#ifdef X_HAVE_UTF8_STRING
bob@2325
   202
            if (data->ic) {
bob@2325
   203
                Xutf8LookupString(data->ic, &xevent.xkey, text, sizeof(text),
bob@2325
   204
                                  &keysym, status);
bob@2325
   205
            }
bob@2325
   206
#else
slouken@2306
   207
            XLookupString(&xevent.xkey, text, sizeof(text), &keysym, NULL);
bob@2325
   208
#endif
slouken@2305
   209
            if (*text) {
slouken@2305
   210
                printf("Sending text event %s\n", text);
bob@2300
   211
                SDL_SendKeyboardText(videodata->keyboard, text);
bob@2300
   212
            }
slouken@1951
   213
        }
slouken@1951
   214
        break;
slouken@1951
   215
slouken@1951
   216
        /* Key release? */
slouken@1951
   217
    case KeyRelease:{
slouken@1951
   218
            KeyCode keycode = xevent.xkey.keycode;
slouken@1951
   219
slouken@1951
   220
#ifdef DEBUG_XEVENTS
slouken@1951
   221
            printf("KeyRelease (X11 keycode = 0x%X)\n", xevent.xkey.keycode);
slouken@1951
   222
#endif
bob@2295
   223
            SDL_SendKeyboardKey(videodata->keyboard, SDL_RELEASED,
slouken@2305
   224
                                videodata->key_layout[keycode]);
slouken@1951
   225
        }
slouken@1951
   226
        break;
slouken@1951
   227
slouken@1951
   228
        /* Have we been iconified? */
slouken@1951
   229
    case UnmapNotify:{
slouken@1951
   230
#ifdef DEBUG_XEVENTS
slouken@1951
   231
            printf("UnmapNotify!\n");
slouken@1951
   232
#endif
slouken@1951
   233
            SDL_SendWindowEvent(data->windowID, SDL_WINDOWEVENT_HIDDEN, 0, 0);
slouken@1951
   234
            SDL_SendWindowEvent(data->windowID, SDL_WINDOWEVENT_MINIMIZED, 0,
slouken@1951
   235
                                0);
slouken@1951
   236
        }
slouken@1951
   237
        break;
slouken@1951
   238
slouken@1951
   239
        /* Have we been restored? */
slouken@1951
   240
    case MapNotify:{
slouken@1951
   241
#ifdef DEBUG_XEVENTS
slouken@1951
   242
            printf("MapNotify!\n");
slouken@1951
   243
#endif
slouken@1951
   244
            SDL_SendWindowEvent(data->windowID, SDL_WINDOWEVENT_SHOWN, 0, 0);
slouken@1951
   245
            SDL_SendWindowEvent(data->windowID, SDL_WINDOWEVENT_RESTORED, 0,
slouken@1951
   246
                                0);
slouken@1951
   247
        }
slouken@1951
   248
        break;
slouken@1951
   249
slouken@1951
   250
        /* Have we been resized or moved? */
slouken@1951
   251
    case ConfigureNotify:{
slouken@1951
   252
#ifdef DEBUG_XEVENTS
slouken@1951
   253
            printf("ConfigureNotify! (resize: %dx%d)\n",
slouken@1951
   254
                   xevent.xconfigure.width, xevent.xconfigure.height);
slouken@1951
   255
#endif
slouken@1951
   256
            SDL_SendWindowEvent(data->windowID, SDL_WINDOWEVENT_MOVED,
slouken@1951
   257
                                xevent.xconfigure.x, xevent.xconfigure.y);
slouken@1951
   258
            SDL_SendWindowEvent(data->windowID, SDL_WINDOWEVENT_RESIZED,
slouken@1951
   259
                                xevent.xconfigure.width,
slouken@1951
   260
                                xevent.xconfigure.height);
slouken@1951
   261
        }
slouken@1951
   262
        break;
slouken@1951
   263
slouken@1951
   264
        /* Have we been requested to quit (or another client message?) */
slouken@1951
   265
    case ClientMessage:{
slouken@1951
   266
            if ((xevent.xclient.format == 32) &&
slouken@1951
   267
                (xevent.xclient.data.l[0] == videodata->WM_DELETE_WINDOW)) {
slouken@1951
   268
slouken@1951
   269
                SDL_SendWindowEvent(data->windowID, SDL_WINDOWEVENT_CLOSE, 0,
slouken@1951
   270
                                    0);
slouken@1951
   271
            }
slouken@1951
   272
        }
slouken@1951
   273
        break;
slouken@1951
   274
slouken@1951
   275
        /* Do we need to refresh ourselves? */
slouken@1951
   276
    case Expose:{
slouken@1951
   277
#ifdef DEBUG_XEVENTS
slouken@1951
   278
            printf("Expose (count = %d)\n", xevent.xexpose.count);
slouken@1951
   279
#endif
slouken@1951
   280
            SDL_SendWindowEvent(data->windowID, SDL_WINDOWEVENT_EXPOSED, 0,
slouken@1951
   281
                                0);
slouken@1951
   282
        }
slouken@1951
   283
        break;
slouken@1951
   284
slouken@1951
   285
    default:{
slouken@2710
   286
            if (xevent.type == motion) {        /* MotionNotify */
slouken@2710
   287
#ifdef DEBUG_MOTION
slouken@2710
   288
                printf("X11 motion: %d,%d\n", xevent.xmotion.x,
slouken@2710
   289
                       xevent.xmotion.y);
slouken@2710
   290
#endif
slouken@2710
   291
                XWindowAttributes attrib;
slouken@2710
   292
                XGetWindowAttributes(videodata->display,
slouken@2710
   293
                                     ((XAnyEvent *) & xevent)->window,
slouken@2710
   294
                                     &attrib);
slouken@2710
   295
                SDL_UpdateCoordinates(attrib.width, attrib.height);
slouken@2710
   296
                XDeviceMotionEvent *move = (XDeviceMotionEvent *) & xevent;
slouken@2710
   297
                SDL_SendMouseMotion(move->deviceid, 0, move->x,
slouken@2710
   298
                                    move->y, move->axis_data[2]);
slouken@2710
   299
            } else if (xevent.type == button_pressed) { /* ButtonPress */
slouken@2710
   300
                XDeviceButtonPressedEvent *pressed =
slouken@2710
   301
                    (XDeviceButtonPressedEvent *) & xevent;
slouken@2710
   302
                SDL_SendMouseButton(pressed->deviceid, SDL_PRESSED,
slouken@2710
   303
                                    pressed->button);
slouken@2710
   304
            } else if (xevent.type == button_released) {        /* ButtonRelease */
slouken@2710
   305
                XDeviceButtonReleasedEvent *released =
slouken@2710
   306
                    (XDeviceButtonReleasedEvent *) & xevent;
slouken@2710
   307
                SDL_SendMouseButton(released->deviceid, SDL_RELEASED,
slouken@2710
   308
                                    released->button);
slouken@2710
   309
            } else if (xevent.type == proximity_in) {
slouken@2710
   310
                XProximityNotifyEvent *proximity =
slouken@2710
   311
                    (XProximityNotifyEvent *) & xevent;
slouken@2710
   312
                SDL_SendProximity(proximity->deviceid, proximity->x,
slouken@2710
   313
                                  proximity->y, SDL_PROXIMITYIN);
slouken@2710
   314
            } else if (xevent.type == proximity_out) {
slouken@2710
   315
                XProximityNotifyEvent *proximity =
slouken@2710
   316
                    (XProximityNotifyEvent *) & xevent;
slouken@2710
   317
                SDL_SendProximity(proximity->deviceid, proximity->x,
slouken@2710
   318
                                  proximity->y, SDL_PROXIMITYOUT);
slouken@2710
   319
            }
slouken@1951
   320
#ifdef DEBUG_XEVENTS
slouken@2710
   321
            else {
slouken@2710
   322
                printf("Unhandled event %d\n", xevent.type);
slouken@2710
   323
            }
slouken@1951
   324
#endif
slouken@1951
   325
        }
slouken@1951
   326
        break;
slouken@1951
   327
    }
slouken@1951
   328
}
slouken@1951
   329
slouken@1951
   330
/* Ack!  XPending() actually performs a blocking read if no events available */
slouken@1951
   331
int
slouken@1951
   332
X11_Pending(Display * display)
slouken@1951
   333
{
slouken@1951
   334
    /* Flush the display connection and look to see if events are queued */
slouken@1951
   335
    XFlush(display);
slouken@1951
   336
    if (XEventsQueued(display, QueuedAlready)) {
slouken@1951
   337
        return (1);
slouken@1951
   338
    }
slouken@1951
   339
slouken@1951
   340
    /* More drastic measures are required -- see if X is ready to talk */
slouken@1951
   341
    {
slouken@1951
   342
        static struct timeval zero_time;        /* static == 0 */
slouken@1951
   343
        int x11_fd;
slouken@1951
   344
        fd_set fdset;
slouken@1951
   345
slouken@1951
   346
        x11_fd = ConnectionNumber(display);
slouken@1951
   347
        FD_ZERO(&fdset);
slouken@1951
   348
        FD_SET(x11_fd, &fdset);
slouken@1951
   349
        if (select(x11_fd + 1, &fdset, NULL, NULL, &zero_time) == 1) {
slouken@1951
   350
            return (XPending(display));
slouken@1951
   351
        }
slouken@1951
   352
    }
slouken@1951
   353
slouken@1951
   354
    /* Oh well, nothing is ready .. */
slouken@1951
   355
    return (0);
slouken@1951
   356
}
slouken@1951
   357
slouken@1951
   358
void
slouken@1951
   359
X11_PumpEvents(_THIS)
slouken@1951
   360
{
slouken@1951
   361
    SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
slouken@1951
   362
slouken@1951
   363
    /* Keep processing pending events */
slouken@1951
   364
    while (X11_Pending(data->display)) {
slouken@1951
   365
        X11_DispatchEvent(_this);
slouken@1951
   366
    }
slouken@1951
   367
}
slouken@1951
   368
slouken@1951
   369
void
slouken@1951
   370
X11_SaveScreenSaver(Display * display, int *saved_timeout, BOOL * dpms)
slouken@1951
   371
{
slouken@1951
   372
    int timeout, interval, prefer_blank, allow_exp;
slouken@1951
   373
    XGetScreenSaver(display, &timeout, &interval, &prefer_blank, &allow_exp);
slouken@1951
   374
    *saved_timeout = timeout;
slouken@1951
   375
slouken@1951
   376
#if SDL_VIDEO_DRIVER_X11_DPMS
slouken@1951
   377
    if (SDL_X11_HAVE_DPMS) {
slouken@1951
   378
        int dummy;
slouken@1951
   379
        if (DPMSQueryExtension(display, &dummy, &dummy)) {
slouken@1951
   380
            CARD16 state;
slouken@1951
   381
            DPMSInfo(display, &state, dpms);
slouken@1951
   382
        }
slouken@1951
   383
    }
slouken@1951
   384
#else
slouken@1951
   385
    *dpms = 0;
slouken@1951
   386
#endif /* SDL_VIDEO_DRIVER_X11_DPMS */
slouken@1951
   387
}
slouken@1951
   388
slouken@1951
   389
void
slouken@1951
   390
X11_DisableScreenSaver(Display * display)
slouken@1951
   391
{
slouken@1951
   392
    int timeout, interval, prefer_blank, allow_exp;
slouken@1951
   393
    XGetScreenSaver(display, &timeout, &interval, &prefer_blank, &allow_exp);
slouken@1951
   394
    timeout = 0;
slouken@1951
   395
    XSetScreenSaver(display, timeout, interval, prefer_blank, allow_exp);
slouken@1951
   396
slouken@1951
   397
#if SDL_VIDEO_DRIVER_X11_DPMS
slouken@1951
   398
    if (SDL_X11_HAVE_DPMS) {
slouken@1951
   399
        int dummy;
slouken@1951
   400
        if (DPMSQueryExtension(display, &dummy, &dummy)) {
slouken@1951
   401
            DPMSDisable(display);
slouken@1951
   402
        }
slouken@1951
   403
    }
slouken@1951
   404
#endif /* SDL_VIDEO_DRIVER_X11_DPMS */
slouken@1951
   405
}
slouken@1951
   406
slouken@1951
   407
void
slouken@1951
   408
X11_RestoreScreenSaver(Display * display, int saved_timeout, BOOL dpms)
slouken@1951
   409
{
slouken@1951
   410
    int timeout, interval, prefer_blank, allow_exp;
slouken@1951
   411
    XGetScreenSaver(display, &timeout, &interval, &prefer_blank, &allow_exp);
slouken@1951
   412
    timeout = saved_timeout;
slouken@1951
   413
    XSetScreenSaver(display, timeout, interval, prefer_blank, allow_exp);
slouken@1951
   414
slouken@1951
   415
#if SDL_VIDEO_DRIVER_X11_DPMS
slouken@1951
   416
    if (SDL_X11_HAVE_DPMS) {
slouken@1951
   417
        int dummy;
slouken@1951
   418
        if (DPMSQueryExtension(display, &dummy, &dummy)) {
slouken@1951
   419
            if (dpms) {
slouken@1951
   420
                DPMSEnable(display);
slouken@1951
   421
            }
slouken@1951
   422
        }
slouken@1951
   423
    }
slouken@1951
   424
#endif /* SDL_VIDEO_DRIVER_X11_DPMS */
slouken@1951
   425
}
slouken@1951
   426
slouken@1951
   427
/* vi: set ts=4 sw=4 expandtab: */