From 322a80e76ec610080472cf301f34c2fe1d1678ff Mon Sep 17 00:00:00 2001 From: Alexander Orzechowski Date: Thu, 10 Mar 2022 05:47:38 -0500 Subject: [PATCH] wayland: track configures through a bit field This will let us add more stuff later. Also, it's a better spot to put the bit field outside of the {current, pending} struct as the bit field doesn't make any sense if it's part of the `current` values. --- glfw/wl_platform.h | 5 ++++- glfw/wl_window.c | 6 +++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/glfw/wl_platform.h b/glfw/wl_platform.h index 1aca8eacd..66f214428 100644 --- a/glfw/wl_platform.h +++ b/glfw/wl_platform.h @@ -127,6 +127,9 @@ typedef enum WaylandWindowState { static const WaylandWindowState TOPLEVEL_STATE_DOCKED = TOPLEVEL_STATE_MAXIMIZED | TOPLEVEL_STATE_FULLSCREEN | TOPLEVEL_STATE_TILED_TOP | TOPLEVEL_STATE_TILED_LEFT | TOPLEVEL_STATE_TILED_RIGHT | TOPLEVEL_STATE_TILED_BOTTOM; +enum WaylandWindowPendingState { + PENDING_STATE_TOPLEVEL = 1, +}; // Wayland-specific per-window data // @@ -217,10 +220,10 @@ typedef struct _GLFWwindowWayland unsigned int x, y; } axis_discrete_count; + uint32_t pending_state; struct { int width, height; uint32_t toplevel_states; - bool set; } current, pending; } _GLFWwindowWayland; diff --git a/glfw/wl_window.c b/glfw/wl_window.c index 18327e782..a7b80064b 100644 --- a/glfw/wl_window.c +++ b/glfw/wl_window.c @@ -479,7 +479,7 @@ xdgToplevelHandleConfigure(void* data, window->wl.pending.toplevel_states = new_states; window->wl.pending.width = width; window->wl.pending.height = height; - window->wl.pending.set = true; + window->wl.pending_state |= PENDING_STATE_TOPLEVEL; } static void xdgToplevelHandleClose(void* data, @@ -500,11 +500,10 @@ static void xdgSurfaceHandleConfigure(void* data, { _GLFWwindow* window = data; xdg_surface_ack_configure(surface, serial); - if (window->wl.pending.set) { + if (window->wl.pending_state & PENDING_STATE_TOPLEVEL) { uint32_t new_states = window->wl.pending.toplevel_states; int width = window->wl.pending.width; int height = window->wl.pending.height; - window->wl.pending.set = false; if (new_states != window->wl.current.toplevel_states || width != window->wl.current.width || @@ -524,6 +523,7 @@ static void xdgSurfaceHandleConfigure(void* data, } } wl_surface_commit(window->wl.surface); + window->wl.pending_state = 0; } static const struct xdg_surface_listener xdgSurfaceListener = {