From e3cc0341b99026a0f7d7773a79347c88105deef2 Mon Sep 17 00:00:00 2001 From: Colin Kinloch Date: Sun, 29 Dec 2024 17:56:17 +0000 Subject: [PATCH] wayland: Fix improperly sized commits (#17309) * Revert "wayland: Ignore splash sized events during splash" This reverts commit 5ef24debe491666bc2dffe0f64d811862b90afb5. * wayland: Fix improperly sized commits * Set viewport on splash commit * Don't commit "set video mode" viewport update * Hide the libdecor frame before transitioning to fullscreen --- gfx/common/wayland_common.c | 11 ++++++++++- gfx/common/wayland_common.h | 4 ---- gfx/drivers_context/wayland_ctx.c | 11 ++--------- gfx/drivers_context/wayland_vk_ctx.c | 11 ++--------- 4 files changed, 14 insertions(+), 23 deletions(-) diff --git a/gfx/common/wayland_common.c b/gfx/common/wayland_common.c index e98eed58be8..4b826ee3d56 100644 --- a/gfx/common/wayland_common.c +++ b/gfx/common/wayland_common.c @@ -43,6 +43,10 @@ #define DEFAULT_WINDOWED_WIDTH 640 #define DEFAULT_WINDOWED_HEIGHT 480 +/* Icon is 16x15 scaled by 16 */ +#define SPLASH_WINDOW_WIDTH 240 +#define SPLASH_WINDOW_HEIGHT 256 + #ifndef MFD_CLOEXEC #define MFD_CLOEXEC 0x0001U #endif @@ -630,7 +634,12 @@ static bool wl_draw_splash_screen(gfx_ctx_wayland_data_t *wl) wl_surface_damage_buffer(wl->surface, 0, 0, wl->buffer_width, wl->buffer_height); + + if (wl->viewport) + wp_viewport_set_destination(wl->viewport, wl->width, wl->height); + wl_surface_commit(wl->surface); + return true; } @@ -902,12 +911,12 @@ bool gfx_ctx_wl_set_video_mode_common_size(gfx_ctx_wayland_data_t *wl, { /* Stretch old buffer to fill new size, commit/roundtrip to apply */ wp_viewport_set_destination(wl->viewport, wl->width, wl->height); - wl_surface_commit(wl->surface); } #ifdef HAVE_LIBDECOR_H if (wl->libdecor) { + wl->libdecor_frame_set_visibility(wl->libdecor_frame, !fullscreen); struct libdecor_state *state = wl->libdecor_state_new(wl->width, wl->height); wl->libdecor_frame_commit(wl->libdecor_frame, state, NULL); wl->libdecor_state_free(state); diff --git a/gfx/common/wayland_common.h b/gfx/common/wayland_common.h index b7fb3771ed5..41f32a9e2e4 100644 --- a/gfx/common/wayland_common.h +++ b/gfx/common/wayland_common.h @@ -21,10 +21,6 @@ #include "../../input/common/wayland_common.h" -/* Icon is 16x15 scaled by 16 */ -#define SPLASH_WINDOW_WIDTH 240 -#define SPLASH_WINDOW_HEIGHT 256 - #define WAYLAND_APP_ID "com.libretro.RetroArch" typedef struct toplevel_listener diff --git a/gfx/drivers_context/wayland_ctx.c b/gfx/drivers_context/wayland_ctx.c index 3e0eb46b364..2d70ae68b10 100644 --- a/gfx/drivers_context/wayland_ctx.c +++ b/gfx/drivers_context/wayland_ctx.c @@ -54,9 +54,7 @@ static void xdg_toplevel_handle_configure(void *data, int32_t width, int32_t height, struct wl_array *states) { gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data; - if (wl->ignore_configuration && - width == SPLASH_WINDOW_WIDTH && - height == SPLASH_WINDOW_HEIGHT) + if (wl->ignore_configuration) return; xdg_toplevel_handle_configure_common(wl, toplevel, width, height, states); #ifdef HAVE_EGL @@ -117,17 +115,12 @@ static bool gfx_ctx_wl_set_resize(void *data, unsigned width, unsigned height) } #ifdef HAVE_LIBDECOR_H -#include static void libdecor_frame_handle_configure(struct libdecor_frame *frame, struct libdecor_configuration *configuration, void *data) { gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data; - int width, height; - if (wl->ignore_configuration && - wl->libdecor_configuration_get_content_size(configuration, frame, &width, &height) && - width == SPLASH_WINDOW_WIDTH && - height == SPLASH_WINDOW_HEIGHT) + if (wl->ignore_configuration) return; libdecor_frame_handle_configure_common(frame, configuration, wl); diff --git a/gfx/drivers_context/wayland_vk_ctx.c b/gfx/drivers_context/wayland_vk_ctx.c index b1a3a66128e..5cfcdd8626f 100644 --- a/gfx/drivers_context/wayland_vk_ctx.c +++ b/gfx/drivers_context/wayland_vk_ctx.c @@ -46,9 +46,7 @@ static void xdg_toplevel_handle_configure(void *data, int32_t width, int32_t height, struct wl_array *states) { gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data; - if (wl->ignore_configuration && - width == SPLASH_WINDOW_WIDTH && - height == SPLASH_WINDOW_HEIGHT) + if (wl->ignore_configuration) return; xdg_toplevel_handle_configure_common(wl, toplevel, width, height, states); wl->configured = false; @@ -102,17 +100,12 @@ static bool gfx_ctx_wl_set_resize(void *data, unsigned width, unsigned height) } #ifdef HAVE_LIBDECOR_H -#include static void libdecor_frame_handle_configure(struct libdecor_frame *frame, struct libdecor_configuration *configuration, void *data) { gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data; - int width, height; - if (wl->ignore_configuration && - wl->libdecor_configuration_get_content_size(configuration, frame, &width, &height) && - width == SPLASH_WINDOW_WIDTH && - height == SPLASH_WINDOW_HEIGHT) + if (wl->ignore_configuration) return; libdecor_frame_handle_configure_common(frame, configuration, wl);