Implement suspend_screensaver callback

This commit is contained in:
twinaphex 2015-01-18 22:32:14 +01:00
parent c95668f2d5
commit c4310ec813
33 changed files with 292 additions and 13 deletions

View File

@ -270,6 +270,14 @@ static bool apple_gfx_ctx_has_focus(void *data)
#endif
}
static bool apple_gfx_ctx_suppress_screensaver(void *data, bool enable)
{
(void)data;
(void)enable;
return false;
}
static bool apple_gfx_ctx_has_windowed(void *data)
{
(void)data;
@ -371,6 +379,7 @@ const gfx_ctx_driver_t gfx_ctx_apple = {
apple_gfx_ctx_check_window,
apple_gfx_ctx_set_resize,
apple_gfx_ctx_has_focus,
apple_gfx_ctx_suppress_screensaver,
apple_gfx_ctx_has_windowed,
apple_gfx_ctx_swap_buffers,
apple_gfx_ctx_input_driver,

View File

@ -25,10 +25,6 @@
#include "audio/audio_monitor.h"
#include "gfx/gfx_common.h"
#ifdef HAVE_X11
#include "gfx/drivers_context/x11_common.h"
#endif
#ifdef HAVE_MENU
#include "menu/menu.h"
#endif
@ -574,13 +570,8 @@ static void init_video_input(void)
driver.video->set_rotation(driver.video_data,
(g_settings.video.rotation + g_extern.system.rotation) % 4);
#ifdef HAVE_X11
if (driver.display_type == RARCH_DISPLAY_X11)
{
RARCH_LOG("Suspending screensaver (X11).\n");
x11_suspend_screensaver(driver.video_window);
}
#endif
if (driver.video->suppress_screensaver)
driver.video->suppress_screensaver(driver.video_data, true);
if (!driver.input)
{

View File

@ -1347,6 +1347,14 @@ static bool exynos_gfx_focus(void *data)
return true; /* drm device always has focus */
}
static bool exynos_gfx_suppress_screensaver(void *data, bool enable)
{
(void)data;
(void)enable;
return false;
}
static bool exynos_gfx_has_windowed(void *data)
{
(void)data;
@ -1508,6 +1516,7 @@ video_driver_t video_exynos = {
exynos_gfx_set_nonblock_state,
exynos_gfx_alive,
exynos_gfx_focus,
exynos_gfx_suppress_screensaver,
exynos_gfx_has_windowed,
exynos_gfx_set_shader,
exynos_gfx_free,

View File

@ -2453,6 +2453,15 @@ static bool gl_focus(void *data)
return gl->ctx_driver->has_focus(gl);
}
static bool gl_suppress_screensaver(void *data, bool enable)
{
gl_t *gl = (gl_t*)data;
if (gl && gl->ctx_driver)
return gl->ctx_driver->suppress_screensaver(gl, enable);
return false;
}
static bool gl_has_windowed(void *data)
{
gl_t *gl = (gl_t*)data;
@ -3121,6 +3130,7 @@ video_driver_t video_gl = {
gl_set_nonblock_state,
gl_alive,
gl_focus,
gl_suppress_screensaver,
gl_has_windowed,
gl_set_shader,

View File

@ -1047,6 +1047,14 @@ static bool gx_focus(void *data)
return true;
}
static bool gx_suppress_screensaver(void *data, bool enable)
{
(void)data;
(void)enable;
return false;
}
static bool gx_has_windowed(void *data)
{
(void)data;
@ -1330,6 +1338,7 @@ video_driver_t video_gx = {
gx_set_nonblock_state,
gx_alive,
gx_focus,
gx_suppress_screensaver,
gx_has_windowed,
gx_set_shader,
gx_free,

View File

@ -58,6 +58,13 @@ static bool null_gfx_focus(void *data)
return true;
}
static bool null_gfx_suppress_screensaver(void *data, bool enable)
{
(void)data;
(void)enable;
return false;
}
static bool null_gfx_has_windowed(void *data)
{
(void)data;
@ -114,6 +121,7 @@ video_driver_t video_null = {
null_gfx_set_nonblock_state,
null_gfx_alive,
null_gfx_focus,
null_gfx_suppress_screensaver,
null_gfx_has_windowed,
null_gfx_set_shader,
null_gfx_free,

View File

@ -881,6 +881,14 @@ static void omap_gfx_viewport_info(void *data, struct rarch_viewport *vp) {
vp->height = vp->full_height = vid->height;
}
static bool omap_gfx_suppress_screensaver(void *data, bool enable)
{
(void)data;
(void)enable;
return false;
}
static bool omap_gfx_has_windowed(void *data)
{
(void)data;
@ -926,6 +934,7 @@ video_driver_t video_omap = {
omap_gfx_set_nonblock_state,
omap_gfx_alive,
omap_gfx_focus,
omap_gfx_suppress_screensaver,
omap_gfx_has_windowed,
omap_gfx_set_shader,
omap_gfx_free,

View File

@ -595,6 +595,13 @@ static bool psp_focus(void *data)
return true;
}
static bool psp_suppress_screensaver(void *data)
{
(void)data;
(void)enable;
return false;
}
static bool psp_has_windowed(void *data)
{
(void)data;
@ -874,6 +881,7 @@ video_driver_t video_psp1 = {
psp_set_nonblock_state,
psp_alive,
psp_focus,
psp_suppress_screensaver,
psp_has_windowed,
psp_set_shader,
psp_free,

View File

@ -536,6 +536,22 @@ static bool sdl2_gfx_focus(void *data)
return (SDL_GetWindowFlags(vid->window) & flags) == flags;
}
static bool sdl2_gfx_suppress_screensaver(void *data, bool enable)
{
(void)data;
(void)enable;
if (driver.display_type == RARCH_DISPLAY_X11)
{
#ifdef HAVE_X11
x11_suspend_screensaver(driver.video_window);
#endif
return true;
}
return false;
}
static bool sdl2_gfx_has_windowed(void *data)
{
(void)data;
@ -732,6 +748,7 @@ video_driver_t video_sdl2 = {
sdl2_gfx_set_nonblock_state,
sdl2_gfx_alive,
sdl2_gfx_focus,
sdl2_gfx_suppress_screensaver,
sdl2_gfx_has_windowed,
sdl2_gfx_set_shader,
sdl2_gfx_free,

View File

@ -389,6 +389,22 @@ static bool sdl_gfx_focus(void *data)
return (SDL_GetAppState() & (SDL_APPINPUTFOCUS | SDL_APPACTIVE)) == (SDL_APPINPUTFOCUS | SDL_APPACTIVE);
}
static bool sdl_gfx_suppress_screensaver(void *data, bool enable)
{
(void)data;
(void)enable;
#ifdef HAVE_X11
if (driver.display_type == RARCH_DISPLAY_X11)
{
x11_suspend_screensaver(driver.video_window);
return true;
}
#endif
return false;
}
static bool sdl_gfx_has_windowed(void *data)
{
(void)data;
@ -532,6 +548,7 @@ video_driver_t video_sdl = {
sdl_gfx_set_nonblock_state,
sdl_gfx_alive,
sdl_gfx_focus,
sdl_gfx_suppress_screensaver,
sdl_gfx_has_windowed,
sdl_gfx_set_shader,
sdl_gfx_free,

View File

@ -420,6 +420,14 @@ static bool vg_focus(void *data)
return false;
}
static bool vg_suppress_screensaver(void *data, bool enable)
{
vg_t *vg = (vg_t*)data;
if (vg && vg->driver)
return vg->driver->suppress_screensaver(vg);
return false;
}
static bool vg_has_windowed(void *data)
{
vg_t *vg = (vg_t*)data;
@ -472,6 +480,7 @@ video_driver_t video_vg = {
vg_set_nonblock_state,
vg_alive,
vg_focus,
vg_suppress_screensaver,
vg_has_windowed,
vg_set_shader,
vg_free,

View File

@ -257,6 +257,13 @@ static bool xenon360_gfx_focus(void *data)
return true;
}
static bool xenon360_gfx_suppress_screensaver(void *data, bool enable)
{
(void)data;
(void)enable;
return false;
}
static bool xenon360_gfx_has_windowed(void *data)
{
(void)data;
@ -312,6 +319,7 @@ video_driver_t video_xenon360 = {
xenon360_gfx_set_nonblock_state,
xenon360_gfx_alive,
xenon360_gfx_focus,
xenon360_gfx_suppress_screensaver,
xenon360_gfx_has_windowed,
xenon360_gfx_set_shader,
xenon360_gfx_free,

View File

@ -826,6 +826,20 @@ static bool xv_focus(void *data)
return xv->focus;
}
static bool xv_suppress_screensaver(void *data, bool enable)
{
(void)data;
(void)enable;
if (driver.display_type == RARCH_DISPLAY_X11)
{
x11_suspend_screensaver(driver.video_window);
return true;
}
return false;
}
static bool xv_has_windowed(void *data)
{
(void)data;
@ -907,6 +921,7 @@ video_driver_t video_xvideo = {
xv_set_nonblock_state,
xv_alive,
xv_focus,
xv_suppress_screensaver,
xv_has_windowed,
xv_set_shader,
xv_free,

View File

@ -341,6 +341,13 @@ static bool android_gfx_ctx_has_focus(void *data)
return true;
}
static bool android_gfx_ctx_suppress_screensaver(void *data, bool enable)
{
(void)data;
(void)enable;
return false;
}
static bool android_gfx_ctx_has_windowed(void *data)
{
(void)data;
@ -381,6 +388,7 @@ const gfx_ctx_driver_t gfx_ctx_android = {
android_gfx_ctx_check_window,
android_gfx_ctx_set_resize,
android_gfx_ctx_has_focus,
android_gfx_ctx_suppress_screensaver,
android_gfx_ctx_has_windowed,
android_gfx_ctx_swap_buffers,
android_gfx_ctx_input_driver,

View File

@ -417,6 +417,13 @@ static bool gfx_ctx_qnx_has_focus(void *data)
return true;
}
static bool gfx_ctx_qnx_suppress_screensaver(void *data, bool enable)
{
(void)data;
(void)enable;
return false;
}
static bool gfx_ctx_qnx_has_windowed(void *data)
{
(void)data;
@ -450,6 +457,7 @@ const gfx_ctx_driver_t gfx_ctx_bbqnx = {
gfx_ctx_qnx_check_window,
gfx_ctx_qnx_set_resize,
gfx_ctx_qnx_has_focus,
gfx_ctx_qnx_suppress_screensaver,
gfx_ctx_qnx_has_windowed,
gfx_ctx_qnx_swap_buffers,
gfx_ctx_qnx_input_driver,

View File

@ -321,6 +321,14 @@ static bool gfx_ctx_d3d_has_focus(void *data)
return GetFocus() == d3d->hWnd;
}
static bool gfx_ctx_d3d_suppress_screensaver(void *data, bool enable)
{
(void)data;
(void)enable;
return false;
}
static bool gfx_ctx_d3d_has_windowed(void *data)
{
(void)data;
@ -497,6 +505,7 @@ const gfx_ctx_driver_t gfx_ctx_d3d = {
gfx_ctx_d3d_check_window,
d3d_resize,
gfx_ctx_d3d_has_focus,
gfx_ctx_d3d_suppress_screensaver,
gfx_ctx_d3d_has_windowed,
gfx_ctx_d3d_swap_buffers,
gfx_ctx_d3d_input_driver,

View File

@ -881,6 +881,13 @@ static bool gfx_ctx_drm_egl_has_focus(void *data)
return true;
}
static bool gfx_ctx_drm_egl_suppress_screensaver(void *data, bool enable)
{
(void)data;
(void)enable;
return false;
}
static bool gfx_ctx_drm_egl_has_windowed(void *data)
{
(void)data;
@ -956,6 +963,7 @@ const gfx_ctx_driver_t gfx_ctx_drm_egl = {
gfx_ctx_drm_egl_check_window,
gfx_ctx_drm_egl_set_resize,
gfx_ctx_drm_egl_has_focus,
gfx_ctx_drm_egl_suppress_screensaver,
gfx_ctx_drm_egl_has_windowed,
gfx_ctx_drm_egl_swap_buffers,
gfx_ctx_drm_egl_input_driver,

View File

@ -257,6 +257,14 @@ static bool gfx_ctx_emscripten_has_focus(void *data)
return g_inited;
}
static bool gfx_ctx_emscripten_suppress_screensaver(void *data, bool enable)
{
(void)data;
(void)enable;
return false;
}
static bool gfx_ctx_emscripten_has_windowed(void *data)
{
(void)data;
@ -306,6 +314,7 @@ const gfx_ctx_driver_t gfx_ctx_emscripten = {
gfx_ctx_emscripten_check_window,
gfx_ctx_emscripten_set_resize,
gfx_ctx_emscripten_has_focus,
gfx_ctx_emscripten_suppress_screensaver,
gfx_ctx_emscripten_has_windowed,
gfx_ctx_emscripten_swap_buffers,
gfx_ctx_emscripten_input_driver,

View File

@ -92,6 +92,13 @@ static bool gfx_ctx_null_has_focus(void *data)
return true;
}
static bool gfx_ctx_null_suppress_screensaver(void *data, bool enable)
{
(void)data;
(void)enable;
return false;
}
static bool gfx_ctx_null_has_windowed(void *data)
{
(void)data;
@ -139,6 +146,7 @@ const gfx_ctx_driver_t gfx_ctx_null = {
gfx_ctx_null_check_window,
gfx_ctx_null_set_resize,
gfx_ctx_null_has_focus,
gfx_ctx_null_suppress_screensaver,
gfx_ctx_null_has_windowed,
gfx_ctx_null_swap_buffers,
gfx_ctx_null_input_driver,

View File

@ -666,6 +666,16 @@ static bool gfx_ctx_glx_has_focus(void *data)
return (win == glx->g_win && glx->g_has_focus) || glx->g_true_full;
}
static bool gfx_ctx_glx_suppress_screensaver(void *data, bool enable)
{
if (driver.display_type != RARCH_DISPLAY_X11)
return false;
x11_suspend_screensaver(driver.video_window);
return true;
}
static bool gfx_ctx_glx_has_windowed(void *data)
{
(void)data;
@ -729,6 +739,7 @@ const gfx_ctx_driver_t gfx_ctx_glx = {
gfx_ctx_glx_check_window,
gfx_ctx_glx_set_resize,
gfx_ctx_glx_has_focus,
gfx_ctx_glx_suppress_screensaver,
gfx_ctx_glx_has_windowed,
gfx_ctx_glx_swap_buffers,
gfx_ctx_glx_input_driver,

View File

@ -299,6 +299,13 @@ static bool gfx_ctx_mali_fbdev_has_focus(void *data)
return true;
}
static bool gfx_ctx_mali_fbdev_suppress_screensaver(void *data, bool enable)
{
(void)data;
(void)enable;
return false;
}
static bool gfx_ctx_mali_fbdev_has_windowed(void *data)
{
(void)data;
@ -317,6 +324,7 @@ const gfx_ctx_driver_t gfx_ctx_mali_fbdev = {
gfx_ctx_mali_fbdev_check_window,
gfx_ctx_mali_fbdev_set_resize,
gfx_ctx_mali_fbdev_has_focus,
gfx_ctx_mali_fbdev_suppress_screensaver,
gfx_ctx_mali_fbdev_has_windowed,
gfx_ctx_mali_fbdev_swap_buffers,
gfx_ctx_mali_fbdev_input_driver,

View File

@ -183,6 +183,13 @@ static bool gfx_ctx_ps3_has_focus(void *data)
return true;
}
static bool gfx_ctx_ps3_suppress_screensaver(void *data, bool enable)
{
(void)data;
(void)enable;
return false;
}
static bool gfx_ctx_ps3_has_windowed(void *data)
{
(void)data;
@ -378,6 +385,7 @@ const gfx_ctx_driver_t gfx_ctx_ps3 = {
gfx_ctx_ps3_check_window,
gfx_ctx_ps3_set_resize,
gfx_ctx_ps3_has_focus,
gfx_ctx_ps3_suppress_screensaver,
gfx_ctx_ps3_has_windowed,
gfx_ctx_ps3_swap_buffers,
gfx_ctx_ps3_input_driver,

View File

@ -372,6 +372,13 @@ static bool sdl_ctx_has_focus(void *data)
#endif
}
static bool sdl_ctx_suppress_screensaver(void *data, bool enable)
{
(void)data;
(void)enable;
return false;
}
static bool sdl_ctx_has_windowed(void *data)
{
(void)data;
@ -420,6 +427,7 @@ const gfx_ctx_driver_t gfx_ctx_sdl_gl =
sdl_ctx_check_window,
sdl_ctx_set_resize,
sdl_ctx_has_focus,
sdl_ctx_suppress_screensaver,
sdl_ctx_has_windowed,
sdl_ctx_swap_buffers,
sdl_ctx_input_driver,

View File

@ -425,6 +425,13 @@ static bool gfx_ctx_vc_has_focus(void *data)
return g_inited;
}
static bool gfx_ctx_vc_suppress_screensaver(void *data, bool enable)
{
(void)data;
(void)enable;
return false;
}
static bool gfx_ctx_vc_has_windowed(void *data)
{
(void)data;
@ -595,6 +602,7 @@ const gfx_ctx_driver_t gfx_ctx_videocore = {
gfx_ctx_vc_check_window,
gfx_ctx_vc_set_resize,
gfx_ctx_vc_has_focus,
gfx_ctx_vc_suppress_screensaver,
gfx_ctx_vc_has_windowed,
gfx_ctx_vc_swap_buffers,
gfx_ctx_vc_input_driver,

View File

@ -284,6 +284,13 @@ static bool gfx_ctx_vivante_has_focus(void *data)
return true;
}
static bool gfx_ctx_vivante_suppress_screensaver(void *data, bool enable)
{
(void)data;
(void)enable;
return false;
}
static bool gfx_ctx_vivante_has_windowed(void *data)
{
(void)data;
@ -302,6 +309,7 @@ const gfx_ctx_driver_t gfx_ctx_vivante_fbdev = {
gfx_ctx_vivante_check_window,
gfx_ctx_vivante_set_resize,
gfx_ctx_vivante_has_focus,
gfx_ctx_vivante_suppress_screensaver,
gfx_ctx_vivante_has_windowed,
gfx_ctx_vivante_swap_buffers,
gfx_ctx_vivante_input_driver,

View File

@ -665,6 +665,13 @@ static bool gfx_ctx_wl_has_focus(void *data)
return true;
}
static bool gfx_ctx_wl_suppress_screensaver(void *data, bool enable)
{
(void)data;
(void)enable;
return true;
}
static bool gfx_ctx_wl_has_windowed(void *data)
{
(void)data;
@ -879,6 +886,7 @@ const gfx_ctx_driver_t gfx_ctx_wayland = {
gfx_ctx_wl_check_window,
gfx_ctx_wl_set_resize,
gfx_ctx_wl_has_focus,
gfx_ctx_wl_suppress_screensaver,
gfx_ctx_wl_has_windowed,
gfx_ctx_wl_swap_buffers,
gfx_ctx_wl_input_driver,

View File

@ -624,6 +624,14 @@ static bool gfx_ctx_wgl_has_focus(void *data)
return GetFocus() == g_hwnd;
}
static bool gfx_ctx_wgl_suppress_screensaver(void *data, bool enable)
{
(void)data;
(void)enable;
return false;
}
static bool gfx_ctx_wgl_has_windowed(void *data)
{
(void)data;
@ -673,6 +681,7 @@ const gfx_ctx_driver_t gfx_ctx_wgl = {
gfx_ctx_wgl_check_window,
gfx_ctx_wgl_set_resize,
gfx_ctx_wgl_has_focus,
gfx_ctx_wgl_suppress_screensaver,
gfx_ctx_wgl_has_windowed,
gfx_ctx_wgl_swap_buffers,
gfx_ctx_wgl_input_driver,

View File

@ -126,6 +126,8 @@ void x11_suspend_screensaver(Window wnd)
int ret;
char cmd[64];
RARCH_LOG("Suspending screensaver (X11).\n");
snprintf(cmd, sizeof(cmd), "xdg-screensaver suspend %d", (int)wnd);
ret = system(cmd);

View File

@ -717,6 +717,19 @@ static bool gfx_ctx_xegl_has_focus(void *data)
return (win == g_win && g_has_focus) || g_true_full;
}
static bool gfx_ctx_xegl_suppress_screensaver(void *data, bool enable)
{
(void)data;
(void)enable;
if (driver.display_type != RARCH_DISPLAY_X11)
return false;
x11_suspend_screensaver(driver.video_window);
return true;
}
static bool gfx_ctx_xegl_has_windowed(void *data)
{
(void)data;
@ -792,6 +805,7 @@ const gfx_ctx_driver_t gfx_ctx_x_egl = {
gfx_ctx_xegl_check_window,
gfx_ctx_xegl_set_resize,
gfx_ctx_xegl_has_focus,
gfx_ctx_xegl_suppress_screensaver,
gfx_ctx_xegl_has_windowed,
gfx_ctx_xegl_swap_buffers,
gfx_ctx_xegl_input_driver,

View File

@ -92,6 +92,9 @@ typedef struct gfx_ctx_driver
/* Checks if window has input focus. */
bool (*has_focus)(void*);
/* Should the screensaver be suppressed? */
bool (*suppress_screensaver)(void *data, bool enable);
/* Checks if context driver has windowed support. */
bool (*has_windowed)(void*);
@ -123,7 +126,7 @@ typedef struct gfx_ctx_driver
/* Shows or hides mouse. Can be NULL if context doesn't
* have a concept of mouse pointer. */
void (*show_mouse)(void*, bool state);
void (*show_mouse)(void *data, bool state);
/* Human readable string. */
const char *ident;

View File

@ -132,7 +132,10 @@ typedef struct video_driver
/* Does the window have focus? */
bool (*focus)(void *data);
/* Does the graphics conext support windowed mode? */
/* Should the screensaver be suppressed? */
bool (*suppress_screensaver)(void *data, bool enable);
/* Does the graphics context support windowed mode? */
bool (*has_windowed)(void *data);
/* Sets shader. Might not be implemented. Will be moved to

View File

@ -306,6 +306,7 @@ static void thread_loop(void *data)
bool alive = false;
bool focus = false;
bool has_windowed = true;
bool suppress_screensaver = true;
struct rarch_viewport vp = {0};
slock_lock(thr->frame.lock);
@ -328,6 +329,9 @@ static void thread_loop(void *data)
if (thr->driver && thr->driver->has_windowed)
has_windowed = ret && thr->driver->has_windowed(thr->driver_data);
if (thr->driver && thr->driver->suppress_screensaver)
suppress_screensaver = ret && thr->driver->suppress_screensaver(thr->driver_data, true);
if (thr->driver && thr->driver->viewport_info)
thr->driver->viewport_info(thr->driver_data, &vp);
@ -335,6 +339,7 @@ static void thread_loop(void *data)
thr->alive = alive;
thr->focus = focus;
thr->has_windowed = has_windowed;
thr->suppress_screensaver = suppress_screensaver;
thr->frame.updated = false;
thr->vp = vp;
scond_signal(thr->cond_cmd);
@ -391,6 +396,18 @@ static bool thread_focus(void *data)
return ret;
}
static bool thread_suppress_screensaver(void *data, bool enable)
{
bool ret;
thread_video_t *thr = (thread_video_t*)data;
slock_lock(thr->lock);
ret = thr->suppress_screensaver;
slock_unlock(thr->lock);
return ret;
}
static bool thread_has_windowed(void *data)
{
bool ret;
@ -520,6 +537,7 @@ static bool thread_init(thread_video_t *thr, const video_info_t *info,
thr->alive = true;
thr->focus = true;
thr->has_windowed = true;
thr->suppress_screensaver = true;
max_size = info->input_scale * RARCH_SCALE_BASE;
max_size *= max_size;
@ -874,6 +892,7 @@ static const video_driver_t video_thread = {
thread_set_nonblock_state,
thread_alive,
thread_focus,
thread_suppress_screensaver,
thread_has_windowed,
thread_set_shader,
thread_free,

View File

@ -91,6 +91,7 @@ typedef struct thread_video
bool alive;
bool focus;
bool suppress_screensaver;
bool has_windowed;
bool nonblock;