From 6398dd5b75f3f3cb39c78956391898c6a25d4f18 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 26 Mar 2024 11:17:27 +0530 Subject: [PATCH] Move xdg confugure response into its own function --- glfw/wl_window.c | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/glfw/wl_window.c b/glfw/wl_window.c index 1e6bcc4f8..5bfc20690 100644 --- a/glfw/wl_window.c +++ b/glfw/wl_window.c @@ -693,21 +693,8 @@ static const struct xdg_toplevel_listener xdgToplevelListener = { xdgToplevelHandleClose }; -static void xdgSurfaceHandleConfigure(void* data, - struct xdg_surface* surface, - uint32_t serial) -{ - // The poorly documented pattern Wayland requires is: - // 1) ack the configure, - // 2) set the window geometry - // 3) attach a new buffer of the correct size to the surface - // 4) only then commit the surface. - // buffer is attached only by eglSwapBuffers, - // so we set a flag to not commit the surface till the next swapbuffers. Note that - // wl_egl_window_resize() does not actually resize the buffer until the next draw call - // or buffer state query. - _GLFWwindow* window = data; - xdg_surface_ack_configure(surface, serial); +static void +apply_xdg_configure_changes(_GLFWwindow *window) { if (window->wl.pending_state & PENDING_STATE_TOPLEVEL) { uint32_t new_states = window->wl.pending.toplevel_states; int width = window->wl.pending.width; @@ -755,6 +742,22 @@ static void xdgSurfaceHandleConfigure(void* data, window->wl.pending_state = 0; } +static void +xdgSurfaceHandleConfigure(void* data, struct xdg_surface* surface, uint32_t serial) { + // The poorly documented pattern Wayland requires is: + // 1) ack the configure, + // 2) set the window geometry + // 3) attach a new buffer of the correct size to the surface + // 4) only then commit the surface. + // buffer is attached only by eglSwapBuffers, + // so we set a flag to not commit the surface till the next swapbuffers. Note that + // wl_egl_window_resize() does not actually resize the buffer until the next draw call + // or buffer state query. + _GLFWwindow* window = data; + xdg_surface_ack_configure(surface, serial); + apply_xdg_configure_changes(window); +} + static const struct xdg_surface_listener xdgSurfaceListener = { xdgSurfaceHandleConfigure };