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