Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fallback to screensaver inhibit via D-Bus on Wayland (rebase) #15856

Merged
merged 1 commit into from
Nov 1, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -282,6 +286,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 @@ -659,6 +670,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 @@ -878,7 +892,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