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