src/video/x11/SDL_x11events.c
changeset 3030 f13ad181f5b2
parent 3025 54fac87e1f34
child 3031 86918831452f
equal deleted inserted replaced
3029:89f8a72e1ee9 3030:f13ad181f5b2
   408     while (X11_Pending(data->display)) {
   408     while (X11_Pending(data->display)) {
   409         X11_DispatchEvent(_this);
   409         X11_DispatchEvent(_this);
   410     }
   410     }
   411 }
   411 }
   412 
   412 
       
   413 /* This is so wrong it hurts */
       
   414 #define GNOME_SCREENSAVER_HACK
       
   415 #ifdef GNOME_SCREENSAVER_HACK
       
   416 #include <unistd.h>
       
   417 static pid_t screensaver_inhibit_pid;
       
   418 static void gnome_screensaver_disable()
       
   419 {
       
   420     screensaver_inhibit_pid = fork();
       
   421     if (screensaver_inhibit_pid == 0) {
       
   422         //close(0);
       
   423         //close(1);
       
   424         //close(2);
       
   425         execl("/usr/bin/gnome-screensaver-command",
       
   426               "gnome-screensaver-command",
       
   427               "--inhibit",
       
   428               "--reason",
       
   429               "GNOME screensaver doesn't respect MIT-SCREEN-SAVER",
       
   430               NULL);
       
   431         exit(2);
       
   432     }
       
   433 }
       
   434 static void gnome_screensaver_enable()
       
   435 {
       
   436     kill(screensaver_inhibit_pid, 15);
       
   437 }
       
   438 #endif
       
   439 
   413 void
   440 void
   414 X11_SuspendScreenSaver(_THIS)
   441 X11_SuspendScreenSaver(_THIS)
   415 {
   442 {
   416 #if SDL_VIDEO_DRIVER_X11_SCRNSAVER
   443 #if SDL_VIDEO_DRIVER_X11_SCRNSAVER
   417     SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
   444     SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
   418     int dummy;
   445     int dummy;
   419     int major_version, minor_version;
   446     int major_version, minor_version;
   420 
   447 
   421     if (!SDL_X11_HAVE_XSS) {
   448     if (SDL_X11_HAVE_XSS) {
   422         return;
   449         /* XScreenSaverSuspend was introduced in MIT-SCREEN-SAVER 1.1 */
   423     }
   450         if (!XScreenSaverQueryExtension(data->display, &dummy, &dummy) ||
   424 
   451             !XScreenSaverQueryVersion(data->display,
   425     /* XScreenSaverSuspend was introduced in MIT-SCREEN-SAVER 1.1 */
   452                                       &major_version, &minor_version) ||
   426     if (!XScreenSaverQueryExtension(data->display, &dummy, &dummy) ||
   453             major_version < 1 || (major_version == 1 && minor_version < 1)) {
   427         !XScreenSaverQueryVersion(data->display,
   454             return;
   428                                   &major_version, &minor_version) ||
   455         }
   429         major_version < 1 || (major_version == 1 && minor_version < 1)) {
   456 
   430         return;
   457         XScreenSaverSuspend(data->display, _this->suspend_screensaver);
   431     }
   458         XResetScreenSaver(data->display);
   432 
   459     }
   433     XScreenSaverSuspend(data->display, _this->suspend_screensaver);
   460 #endif
   434     XResetScreenSaver(data->display);
   461 
       
   462 #ifdef GNOME_SCREENSAVER_HACK
       
   463     if (_this->suspend_screensaver) {
       
   464         gnome_screensaver_disable();
       
   465     } else {
       
   466         gnome_screensaver_enable();
       
   467     }
   435 #endif
   468 #endif
   436 }
   469 }
   437 
   470 
   438 /* vi: set ts=4 sw=4 expandtab: */
   471 /* vi: set ts=4 sw=4 expandtab: */