diff --git a/gfx/gfx_common.c b/gfx/gfx_common.c index a5afc929b4..0b2604fcd1 100644 --- a/gfx/gfx_common.c +++ b/gfx/gfx_common.c @@ -111,37 +111,19 @@ bool gfx_window_title(char *buf, size_t size) return ret; } -#ifdef IS_LINUX -void suspend_screensaver(Window wnd) { - char wid[20]; - snprintf(wid, 20, "%d", (int) wnd); - wid[19] = '\0'; - char* args[4]; - args[0] = "xdg-screensaver"; - args[1] = "suspend"; - args[2] = wid; - args[3] = NULL; +#ifdef HAVE_X11 +void gfx_suspend_screensaver(Window wnd) +{ + char cmd[64]; + snprintf(cmd, sizeof(cmd), "xdg-screensaver suspend %d", (int)wnd); - int cpid = fork(); - if (cpid < 0) { - RARCH_WARN("Could not suspend screen saver: %s\n", strerror(errno)); - return; - } + int ret = system(cmd); - if (!cpid) { - execvp(args[0], args); - exit(errno); - } - - int err = 0; - waitpid(cpid, &err, 0); - if (err) { - RARCH_WARN("Could not suspend screen saver: %s\n", strerror(err)); - } + if (ret != 0) + RARCH_WARN("Could not suspend screen saver.\n"); } #endif - #if defined(_WIN32) && !defined(_XBOX) #include #include "../dynamic.h" diff --git a/gfx/gfx_common.h b/gfx/gfx_common.h index 5d2c2040f8..9a21f8ade9 100644 --- a/gfx/gfx_common.h +++ b/gfx/gfx_common.h @@ -19,12 +19,16 @@ #include #include "../boolean.h" +#ifdef HAVE_CONFIG_H +#include "../config.h" +#endif + bool gfx_window_title(char *buf, size_t size); void gfx_window_title_reset(void); -#ifdef IS_LINUX +#ifdef HAVE_X11 #include -void suspend_screensaver(Window wnd); +void gfx_suspend_screensaver(Window wnd); #endif #ifdef _WIN32 diff --git a/gfx/sdl_gfx.c b/gfx/sdl_gfx.c index a7916f2329..d0919d11c0 100644 --- a/gfx/sdl_gfx.c +++ b/gfx/sdl_gfx.c @@ -247,18 +247,19 @@ static void sdl_render_msg_32(sdl_video_t *vid, SDL_Surface *buffer, const char #endif } -#ifdef IS_LINUX -static Window sdl_get_window_id() { - SDL_SysWMinfo sys_info; - SDL_VERSION(&sys_info.version); +#ifdef HAVE_X11 +static Window sdl_get_window_id(void) +{ + SDL_SysWMinfo sys_info; + SDL_VERSION(&sys_info.version); - if(SDL_GetWMInfo(&sys_info) <= 0) { - RARCH_WARN("%s", SDL_GetError()); - return -1; - } + if (SDL_GetWMInfo(&sys_info) <= 0) + { + RARCH_WARN("%s\n", SDL_GetError()); + return -1; + } - Window wid = sys_info.info.x11.window; - return wid; + return sys_info.info.x11.window; } #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->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(); - if (wid > 0) { - suspend_screensaver(wid); - } + if (wid > 0) + gfx_suspend_screensaver(wid); #endif if (!vid->screen && !g_settings.video.force_16bit && !video->rgb32) diff --git a/gfx/xvideo.c b/gfx/xvideo.c index 8241b5473c..31d35d8595 100644 --- a/gfx/xvideo.c +++ b/gfx/xvideo.c @@ -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->focus = true; - suspend_screensaver(xv->window); + gfx_suspend_screensaver(xv->window); xinput = input_x.init(); if (xinput) diff --git a/input/null.c b/input/null.c index 4b228b4ad0..07818f4b1c 100644 --- a/input/null.c +++ b/input/null.c @@ -51,7 +51,9 @@ static void null_input_free(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 = { null_input_init,