Inhibit the screensaver while the emulator is running on linux. Fixes issue 3279. Uses the xdg-screensaver method suggested in that issue.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6477 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Glenn Rice
2010-11-25 02:26:46 +00:00
parent 7fe6a0b451
commit fae12f43c2
6 changed files with 75 additions and 2 deletions

View File

@ -17,6 +17,14 @@
#include "X11Utils.h"
#if defined(HAVE_XDG_SCREENSAVER) && HAVE_XDG_SCREENSAVER
#include <unistd.h>
#include <spawn.h>
#include <sys/wait.h>
extern char **environ;
#endif
namespace X11Utils
{
@ -78,6 +86,7 @@ void EWMH_Fullscreen(Display *dpy, int action)
ERROR_LOG(VIDEO, "Failed to switch fullscreen/windowed mode.");
}
#if defined(HAVE_WX) && HAVE_WX
Window XWindowFromHandle(void *Handle)
{
@ -90,6 +99,39 @@ Display *XDisplayFromHandle(void *Handle)
}
#endif
#if defined(HAVE_XDG_SCREENSAVER) && HAVE_XDG_SCREENSAVER
void InhibitScreensaver(Display *dpy, Window win, bool suspend)
{
// Get X server window id
Atom actual_type;
int actual_format, status;
unsigned long nitems, bytes_after;
unsigned char *prop;
status = XGetWindowProperty(dpy, win, XInternAtom(dpy, "_NET_FRAME_WINDOW", True),
0, 125000, False, AnyPropertyType,
&actual_type, &actual_format, &nitems, &bytes_after, &prop);
char id[11];
snprintf(id, sizeof(id), "0x%lx", *(unsigned long *)prop & 0xffffffff);
// Call xdg-screensaver
char *argv[4] = {
(char *)"xdg-screensaver",
(char *)(suspend ? "suspend" : "resume"),
id,
NULL};
pid_t pid;
if (!posix_spawnp(&pid, "xdg-screensaver", NULL, NULL, argv, environ))
{
int status;
while (waitpid (pid, &status, 0) == -1);
DEBUG_LOG(VIDEO, "Started xdg-screensaver (PID = %d)", (int)pid);
}
}
#endif
#if defined(HAVE_XRANDR) && HAVE_XRANDR
XRRConfiguration::XRRConfiguration(Display *_dpy, Window _win)
: dpy(_dpy)
@ -125,7 +167,6 @@ XRRConfiguration::~XRRConfiguration()
}
}
void XRRConfiguration::Update()
{
if (!bValid)