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