Standardize x11_suspend_screensaver

This commit is contained in:
libretroadmin 2023-06-20 11:37:29 +02:00
parent 5971f24237
commit 08ba0b53c6
8 changed files with 29 additions and 79 deletions

View File

@ -242,15 +242,20 @@ static void xdg_screensaver_inhibit(Window wnd)
}
}
void x11_suspend_screensaver(Window wnd, bool enable)
bool x11_suspend_screensaver(void *data, bool enable)
{
Window wnd;
if (video_driver_display_type_get() != RARCH_DISPLAY_X11)
return false;
wnd = video_driver_window_get();
#ifdef HAVE_DBUS
if (dbus_suspend_screensaver(enable))
return;
return true;
#endif
if (enable)
if (xdg_screensaver_available)
xdg_screensaver_inhibit(wnd);
return true;
}
#ifdef HAVE_XF86VM

View File

@ -30,7 +30,7 @@ extern unsigned g_x11_screen;
void x11_show_mouse(Display *dpy, Window win, bool state);
void x11_set_net_wm_fullscreen(Display *dpy, Window win);
void x11_suspend_screensaver(Window win, bool enable);
void x11_suspend_screensaver(void *data, bool enable);
void x11_move_window(Display *dpy, Window win,
int x, int y, unsigned width, unsigned height);
@ -49,6 +49,8 @@ bool x11_enter_fullscreen(Display *dpy, unsigned width, unsigned height);
void x11_exit_fullscreen(Display *dpy);
#endif
void x11_suspend_screensaver(void *data, bool state);
void x11_check_window(void *data, bool *quit,
bool *resize, unsigned *width, unsigned *height);

View File

@ -539,19 +539,7 @@ static bool sdl2_gfx_focus(void *data)
return (SDL_GetWindowFlags(vid->window) & flags) == flags;
}
static bool sdl2_gfx_suppress_screensaver(void *data, bool enable)
{
if (video_driver_display_type_get() == RARCH_DISPLAY_X11)
{
#ifdef HAVE_X11
x11_suspend_screensaver(video_driver_window_get(), enable);
#endif
return true;
}
return false;
}
static bool sdl2_gfx_suspend_screensaver(void *data, bool enable) { return false; }
/* TODO/FIXME - implement */
static bool sdl2_gfx_has_windowed(void *data) { return true; }
@ -726,7 +714,11 @@ video_driver_t video_sdl2 = {
sdl2_gfx_set_nonblock_state,
sdl2_gfx_alive,
sdl2_gfx_focus,
sdl2_gfx_suppress_screensaver,
#ifdef HAVE_X11
x11_suspend_screensaver,
#else
sdl2_gfx_suspend_screensaver,
#endif
sdl2_gfx_has_windowed,
sdl2_gfx_set_shader,
sdl2_gfx_free,

View File

@ -432,19 +432,7 @@ 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)
{
#ifdef HAVE_X11
if (video_driver_display_type_get() == RARCH_DISPLAY_X11)
{
x11_suspend_screensaver(video_driver_window_get(), enable);
return true;
}
#endif
return false;
}
static bool sdl_gfx_suspend_screensaver(void *data, bool enable) { return false; }
/* TODO/FIXME - implement */
static bool sdl_gfx_has_windowed(void *data) { return true; }
@ -576,7 +564,11 @@ video_driver_t video_sdl = {
sdl_gfx_set_nonblock_state,
sdl_gfx_alive,
sdl_gfx_focus,
sdl_gfx_suppress_screensaver,
#ifdef HAVE_X11
x11_suspend_screensaver,
#else
sdl_gfx_suspend_screensaver,
#endif
sdl_gfx_has_windowed,
sdl_gfx_set_shader,
sdl_gfx_free,

View File

@ -1064,15 +1064,6 @@ static bool xv_frame(void *data, const void *frame, unsigned width,
return true;
}
static bool xv_suppress_screensaver(void *data, bool enable)
{
if (video_driver_display_type_get() != RARCH_DISPLAY_X11)
return false;
x11_suspend_screensaver(video_driver_window_get(), enable);
return true;
}
static bool xv_has_windowed(void *data) { return true; }
static void xv_free(void *data)
@ -1182,7 +1173,7 @@ video_driver_t video_xvideo = {
xv_set_nonblock_state,
x11_alive,
x11_has_focus_internal,
xv_suppress_screensaver,
x11_suspend_screensaver,
xv_has_windowed,
xv_set_shader,
xv_free,

View File

@ -293,9 +293,8 @@ static void gfx_ctx_x_swap_interval(void *data, int interval)
static void gfx_ctx_x_swap_buffers(void *data)
{
gfx_ctx_x_data_t *x = (gfx_ctx_x_data_t*)data;
#if defined(HAVE_OPENGL) || defined(HAVE_OPENGL1) || defined(HAVE_OPENGL_CORE)
gfx_ctx_x_data_t *x = (gfx_ctx_x_data_t*)data;
if (x->is_double)
glXSwapBuffers(g_x11_dpy, x->glx_win);
#endif
@ -313,7 +312,8 @@ static bool gfx_ctx_x_set_resize(void *data,
* X11 loses focus on monitor/resolution swap and exits fullscreen.
* Set window on top again to maintain both fullscreen and resolution.
*/
if (x->is_fullscreen) {
if (x->is_fullscreen)
{
XMapRaised(g_x11_dpy, g_x11_win);
RARCH_LOG("[GLX]: Resized fullscreen resolution to %dx%d.\n", width, height);
}
@ -966,18 +966,6 @@ static void gfx_ctx_x_input_driver(void *data,
*input_data = x_input;
}
static bool gfx_ctx_x_suppress_screensaver(void *data, bool enable)
{
(void)data;
if (video_driver_display_type_get() != RARCH_DISPLAY_X11)
return false;
x11_suspend_screensaver(video_driver_window_get(), enable);
return true;
}
static gfx_ctx_proc_t gfx_ctx_x_get_proc_address(const char *symbol)
{
switch (x_api)
@ -1186,7 +1174,7 @@ const gfx_ctx_driver_t gfx_ctx_x = {
x11_check_window,
gfx_ctx_x_set_resize,
x11_has_focus,
gfx_ctx_x_suppress_screensaver,
x11_suspend_screensaver,
true, /* has_windowed */
gfx_ctx_x_swap_buffers,
gfx_ctx_x_input_driver,

View File

@ -508,16 +508,6 @@ static void gfx_ctx_x_vk_input_driver(void *data,
*input_data = x_input;
}
static bool gfx_ctx_x_vk_suppress_screensaver(void *data, bool enable)
{
if (video_driver_display_type_get() != RARCH_DISPLAY_X11)
return false;
x11_suspend_screensaver(video_driver_window_get(), enable);
return true;
}
static enum gfx_ctx_api gfx_ctx_x_vk_get_api(void *data)
{
return GFX_CTX_VULKAN_API;
@ -575,7 +565,7 @@ const gfx_ctx_driver_t gfx_ctx_vk_x = {
gfx_ctx_x_vk_check_window,
gfx_ctx_x_vk_set_resize,
x11_has_focus,
gfx_ctx_x_vk_suppress_screensaver,
x11_suspend_screensaver,
true, /* has_windowed */
gfx_ctx_x_vk_swap_buffers,
gfx_ctx_x_vk_input_driver,

View File

@ -483,16 +483,6 @@ static void gfx_ctx_xegl_input_driver(void *data,
*input_data = xinput;
}
static bool gfx_ctx_xegl_suppress_screensaver(void *data, bool enable)
{
if (video_driver_display_type_get() != RARCH_DISPLAY_X11)
return false;
x11_suspend_screensaver(video_driver_window_get(), enable);
return true;
}
static enum gfx_ctx_api gfx_ctx_xegl_get_api(void *data) { return xegl_api; }
static bool gfx_ctx_xegl_bind_api(void *video_driver,
@ -621,7 +611,7 @@ const gfx_ctx_driver_t gfx_ctx_x_egl =
x11_check_window,
NULL, /* set_resize */
x11_has_focus,
gfx_ctx_xegl_suppress_screensaver,
x11_suspend_screensaver,
true, /* has_windowed */
gfx_ctx_xegl_swap_buffers,
gfx_ctx_xegl_input_driver,