mirror of
https://github.com/libretro/RetroArch.git
synced 2025-01-31 22:14:06 +00:00
Cleanup screensaver code.
This commit is contained in:
parent
ff9820af68
commit
e13b2e1cb5
@ -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 <windows.h>
|
||||
#include "../dynamic.h"
|
||||
|
@ -19,12 +19,16 @@
|
||||
#include <stddef.h>
|
||||
#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 <X11/Xlib.h>
|
||||
void suspend_screensaver(Window wnd);
|
||||
void gfx_suspend_screensaver(Window wnd);
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user