RetroArch icon indicating copy to clipboard operation
RetroArch copied to clipboard

(WIP) wayland: add support for XDG_TOPLEVEL_STATE_SUSPENDED

Open Sunderland93 opened this issue 2 years ago • 12 comments

This adds support for suspended toplevel state introduced in https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/201

Currently I'm not sure how to properly plug this event to RetroArch's window, so WIP for now

@ColinKinloch

Sunderland93 avatar Sep 03 '23 08:09 Sunderland93

Hmm, after compiling with this PR and run on KDE Plasma Wayland I got this error:

listener function for opcode 2 of xdg_toplevel is NULL

but on Sway it works fine

Sunderland93 avatar Sep 03 '23 17:09 Sunderland93

Ah, yes, that is because you've upped xdg_toplevel support to version 6. Which means you also need to implement version 4 and 5. Each adds one event to the xdg_toplevel listener so it shouldn't be too complex. Version 4: xdg_toplevel::configure_bounds Version 5: xdg_toplevel::wm_capabilities

Empty functions may be fine.

ColinKinloch avatar Sep 03 '23 18:09 ColinKinloch

Should I make a separate PR for this?

Sunderland93 avatar Sep 03 '23 18:09 Sunderland93

My gut says no. If the implementation of either event handler ends up complex then split it off.

ColinKinloch avatar Sep 03 '23 18:09 ColinKinloch

Done

Sunderland93 avatar Sep 03 '23 19:09 Sunderland93

@ColinKinloch should I also adapt libdecor part to this? https://gitlab.freedesktop.org/libdecor/libdecor/-/merge_requests/126

Sunderland93 avatar Sep 04 '23 14:09 Sunderland93

Looks like the latest release of libdecor was 0.1.1 10 months ago, whereas suspend support was merged last month. If you can hide it behind an #ifdef or something? I guess just make sure adding suspend support doesn't break libdecor.

ColinKinloch avatar Sep 04 '23 14:09 ColinKinloch

Also, does RetroArch already have an interface to interrupt window rendering (render loop) that could be bound to the suspended state?

Sunderland93 avatar Sep 04 '23 15:09 Sunderland93

I have a pretty poor understanding of the RetroArch code base outside of the Wayland code to be honest. It's could be you should implement it in gfx/drivers_context/wayland_ctx.c and gfx/drivers_context/wayland_vk_ctx.c or maybe runloop.c.

ColinKinloch avatar Sep 04 '23 15:09 ColinKinloch

I've had another look at this. Here are my thoughts:

Now that libdecor 0.2.x is stable you should add support for that.

I'm still not exactly sure where implement suspend in retroarch. I guess the goal is to avoid rendering frames when the surface is suspended so that the game loop, audio etc are still processed. Adding if (wl->suspended) return; at the start of gfx_ctx_wl_swap_buffers is a rudimentary option I've used while investigating this.

Logging when the surface suspends and resumes in xdg_toplevel_handle_configure_common shows that the suspend event doesn't arrive until the surface is resumed. It seems that once the surface is off screen retroarch stalls indefinitely at vkQueuePresentKHR so part of the solution may involve adding a timeout to that.

ColinKinloch avatar Jan 21 '24 15:01 ColinKinloch

Hello. I am unable to continue working on this PR at this time, so you can take it over if you'd like

Sunderland93 avatar Feb 01 '24 14:02 Sunderland93

Hi there @Sunderland93 and @ColinKinloch , sorry for the neglect with this PR.

Are you guys still willing to finalize this and get it incorporated, or has another PR superseded it? I'm still interested in getting this across the finish line. Thanks.

LibretroAdmin avatar Sep 11 '24 01:09 LibretroAdmin