Cleanup screensaver code.

This commit is contained in:
Themaister 2012-07-27 15:47:56 +02:00
parent ff9820af68
commit e13b2e1cb5
5 changed files with 32 additions and 44 deletions

View File

@ -111,37 +111,19 @@ bool gfx_window_title(char *buf, size_t size)
return ret; return ret;
} }
#ifdef IS_LINUX #ifdef HAVE_X11
void suspend_screensaver(Window wnd) { void gfx_suspend_screensaver(Window wnd)
char wid[20]; {
snprintf(wid, 20, "%d", (int) wnd); char cmd[64];
wid[19] = '\0'; snprintf(cmd, sizeof(cmd), "xdg-screensaver suspend %d", (int)wnd);
char* args[4];
args[0] = "xdg-screensaver";
args[1] = "suspend";
args[2] = wid;
args[3] = NULL;
int cpid = fork(); int ret = system(cmd);
if (cpid < 0) {
RARCH_WARN("Could not suspend screen saver: %s\n", strerror(errno));
return;
}
if (!cpid) { if (ret != 0)
execvp(args[0], args); RARCH_WARN("Could not suspend screen saver.\n");
exit(errno);
}
int err = 0;
waitpid(cpid, &err, 0);
if (err) {
RARCH_WARN("Could not suspend screen saver: %s\n", strerror(err));
}
} }
#endif #endif
#if defined(_WIN32) && !defined(_XBOX) #if defined(_WIN32) && !defined(_XBOX)
#include <windows.h> #include <windows.h>
#include "../dynamic.h" #include "../dynamic.h"

View File

@ -19,12 +19,16 @@
#include <stddef.h> #include <stddef.h>
#include "../boolean.h" #include "../boolean.h"
#ifdef HAVE_CONFIG_H
#include "../config.h"
#endif
bool gfx_window_title(char *buf, size_t size); bool gfx_window_title(char *buf, size_t size);
void gfx_window_title_reset(void); void gfx_window_title_reset(void);
#ifdef IS_LINUX #ifdef HAVE_X11
#include <X11/Xlib.h> #include <X11/Xlib.h>
void suspend_screensaver(Window wnd); void gfx_suspend_screensaver(Window wnd);
#endif #endif
#ifdef _WIN32 #ifdef _WIN32

View File

@ -247,18 +247,19 @@ static void sdl_render_msg_32(sdl_video_t *vid, SDL_Surface *buffer, const char
#endif #endif
} }
#ifdef IS_LINUX #ifdef HAVE_X11
static Window sdl_get_window_id() { static Window sdl_get_window_id(void)
SDL_SysWMinfo sys_info; {
SDL_VERSION(&sys_info.version); SDL_SysWMinfo sys_info;
SDL_VERSION(&sys_info.version);
if(SDL_GetWMInfo(&sys_info) <= 0) { if (SDL_GetWMInfo(&sys_info) <= 0)
RARCH_WARN("%s", SDL_GetError()); {
return -1; RARCH_WARN("%s\n", SDL_GetError());
} return -1;
}
Window wid = sys_info.info.x11.window; return sys_info.info.x11.window;
return wid;
} }
#endif #endif
@ -289,11 +290,10 @@ static void *sdl_gfx_init(const video_info_t *video, const input_driver_t **inpu
vid->render32 = video->rgb32 && !g_settings.video.force_16bit; vid->render32 = video->rgb32 && !g_settings.video.force_16bit;
vid->screen = SDL_SetVideoMode(video->width, video->height, vid->render32 ? 32 : 15, SDL_HWSURFACE | SDL_HWACCEL | SDL_DOUBLEBUF | (video->fullscreen ? SDL_FULLSCREEN : 0)); vid->screen = SDL_SetVideoMode(video->width, video->height, vid->render32 ? 32 : 15, SDL_HWSURFACE | SDL_HWACCEL | SDL_DOUBLEBUF | (video->fullscreen ? SDL_FULLSCREEN : 0));
#ifdef IS_LINUX #ifdef HAVE_X11
int wid = sdl_get_window_id(); int wid = sdl_get_window_id();
if (wid > 0) { if (wid > 0)
suspend_screensaver(wid); gfx_suspend_screensaver(wid);
}
#endif #endif
if (!vid->screen && !g_settings.video.force_16bit && !video->rgb32) if (!vid->screen && !g_settings.video.force_16bit && !video->rgb32)

View File

@ -527,7 +527,7 @@ static void *xv_init(const video_info_t *video, const input_driver_t **input, vo
xv_set_nonblock_state(xv, !video->vsync); xv_set_nonblock_state(xv, !video->vsync);
xv->focus = true; xv->focus = true;
suspend_screensaver(xv->window); gfx_suspend_screensaver(xv->window);
xinput = input_x.init(); xinput = input_x.init();
if (xinput) if (xinput)

View File

@ -51,7 +51,9 @@ static void null_input_free(void *data)
(void)data; (void)data;
} }
static void null_set_default_keybind_lut(void) { } #ifdef RARCH_CONSOLE
static void null_set_default_keybind_lut(void) {}
#endif
const input_driver_t input_null = { const input_driver_t input_null = {
null_input_init, null_input_init,