src/video/x11/SDL_x11events.c
changeset 3030 f13ad181f5b2
parent 3025 54fac87e1f34
child 3031 86918831452f
     1.1 --- a/src/video/x11/SDL_x11events.c	Mon Jan 12 08:23:47 2009 +0000
     1.2 +++ b/src/video/x11/SDL_x11events.c	Mon Jan 12 08:26:24 2009 +0000
     1.3 @@ -410,6 +410,33 @@
     1.4      }
     1.5  }
     1.6  
     1.7 +/* This is so wrong it hurts */
     1.8 +#define GNOME_SCREENSAVER_HACK
     1.9 +#ifdef GNOME_SCREENSAVER_HACK
    1.10 +#include <unistd.h>
    1.11 +static pid_t screensaver_inhibit_pid;
    1.12 +static void gnome_screensaver_disable()
    1.13 +{
    1.14 +    screensaver_inhibit_pid = fork();
    1.15 +    if (screensaver_inhibit_pid == 0) {
    1.16 +        //close(0);
    1.17 +        //close(1);
    1.18 +        //close(2);
    1.19 +        execl("/usr/bin/gnome-screensaver-command",
    1.20 +              "gnome-screensaver-command",
    1.21 +              "--inhibit",
    1.22 +              "--reason",
    1.23 +              "GNOME screensaver doesn't respect MIT-SCREEN-SAVER",
    1.24 +              NULL);
    1.25 +        exit(2);
    1.26 +    }
    1.27 +}
    1.28 +static void gnome_screensaver_enable()
    1.29 +{
    1.30 +    kill(screensaver_inhibit_pid, 15);
    1.31 +}
    1.32 +#endif
    1.33 +
    1.34  void
    1.35  X11_SuspendScreenSaver(_THIS)
    1.36  {
    1.37 @@ -418,20 +445,26 @@
    1.38      int dummy;
    1.39      int major_version, minor_version;
    1.40  
    1.41 -    if (!SDL_X11_HAVE_XSS) {
    1.42 -        return;
    1.43 -    }
    1.44 +    if (SDL_X11_HAVE_XSS) {
    1.45 +        /* XScreenSaverSuspend was introduced in MIT-SCREEN-SAVER 1.1 */
    1.46 +        if (!XScreenSaverQueryExtension(data->display, &dummy, &dummy) ||
    1.47 +            !XScreenSaverQueryVersion(data->display,
    1.48 +                                      &major_version, &minor_version) ||
    1.49 +            major_version < 1 || (major_version == 1 && minor_version < 1)) {
    1.50 +            return;
    1.51 +        }
    1.52  
    1.53 -    /* XScreenSaverSuspend was introduced in MIT-SCREEN-SAVER 1.1 */
    1.54 -    if (!XScreenSaverQueryExtension(data->display, &dummy, &dummy) ||
    1.55 -        !XScreenSaverQueryVersion(data->display,
    1.56 -                                  &major_version, &minor_version) ||
    1.57 -        major_version < 1 || (major_version == 1 && minor_version < 1)) {
    1.58 -        return;
    1.59 +        XScreenSaverSuspend(data->display, _this->suspend_screensaver);
    1.60 +        XResetScreenSaver(data->display);
    1.61      }
    1.62 +#endif
    1.63  
    1.64 -    XScreenSaverSuspend(data->display, _this->suspend_screensaver);
    1.65 -    XResetScreenSaver(data->display);
    1.66 +#ifdef GNOME_SCREENSAVER_HACK
    1.67 +    if (_this->suspend_screensaver) {
    1.68 +        gnome_screensaver_disable();
    1.69 +    } else {
    1.70 +        gnome_screensaver_enable();
    1.71 +    }
    1.72  #endif
    1.73  }
    1.74