Skip to content

Commit

Permalink
Fallback to screensaver inhibit via D-Bus on Wayland (libretro#15856)
Browse files Browse the repository at this point in the history
Some Wayland compositors (e.g. Phoc) don't implement Wayland's Idle
protocol. They instead rely on things like Gnome Screensaver.
  • Loading branch information
zoltanvb authored and Sunderland93 committed Dec 26, 2024
1 parent ccb691b commit 54d30a3
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions gfx/common/wayland_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
#include "../../frontend/frontend_driver.h"
#include "../../verbosity.h"

#ifdef HAVE_DBUS
#include "dbus_common.h"
#endif

#define SPLASH_SHM_NAME "retroarch-wayland-vk-splash"

#define APP_ID "org.libretro.RetroArch"
Expand Down Expand Up @@ -286,6 +290,13 @@ void gfx_ctx_wl_destroy_resources_common(gfx_ctx_wayland_data_t *wl)
zxdg_decoration_manager_v1_destroy(wl->deco_manager);
if (wl->idle_inhibit_manager)
zwp_idle_inhibit_manager_v1_destroy(wl->idle_inhibit_manager);
else
{
#ifdef HAVE_DBUS
dbus_screensaver_uninhibit();
dbus_close_connection();
#endif
}
if (wl->pointer_constraints)
zwp_pointer_constraints_v1_destroy(wl->pointer_constraints);
if (wl->relative_pointer_manager)
Expand Down Expand Up @@ -663,6 +674,9 @@ bool gfx_ctx_wl_init_common(
if (!wl->idle_inhibit_manager)
{
RARCH_LOG("[Wayland]: Compositor doesn't support zwp_idle_inhibit_manager_v1 protocol\n");
#ifdef HAVE_DBUS
dbus_ensure_connection();
#endif
}

if (!wl->deco_manager)
Expand Down Expand Up @@ -882,7 +896,13 @@ bool gfx_ctx_wl_suppress_screensaver(void *data, bool state)
gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data;

if (!wl->idle_inhibit_manager)
#ifdef HAVE_DBUS
/* Some Wayland compositors (e.g. Phoc) don't implement Wayland's Idle protocol.
* They instead rely on things like Gnome Screensaver. */
return dbus_suspend_screensaver(state);
#else
return false;
#endif
if (state != (!!wl->idle_inhibitor))
{
if (state)
Expand Down

0 comments on commit 54d30a3

Please sign in to comment.