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.
This commit is contained in:
Alexander Orzechowski 2022-03-10 05:47:38 -05:00
parent d4b048735d
commit 322a80e76e
2 changed files with 7 additions and 4 deletions

5
glfw/wl_platform.h vendored
View File

@ -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; 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 // Wayland-specific per-window data
// //
@ -217,10 +220,10 @@ typedef struct _GLFWwindowWayland
unsigned int x, y; unsigned int x, y;
} axis_discrete_count; } axis_discrete_count;
uint32_t pending_state;
struct { struct {
int width, height; int width, height;
uint32_t toplevel_states; uint32_t toplevel_states;
bool set;
} current, pending; } current, pending;
} _GLFWwindowWayland; } _GLFWwindowWayland;

6
glfw/wl_window.c vendored
View File

@ -479,7 +479,7 @@ xdgToplevelHandleConfigure(void* data,
window->wl.pending.toplevel_states = new_states; window->wl.pending.toplevel_states = new_states;
window->wl.pending.width = width; window->wl.pending.width = width;
window->wl.pending.height = height; window->wl.pending.height = height;
window->wl.pending.set = true; window->wl.pending_state |= PENDING_STATE_TOPLEVEL;
} }
static void xdgToplevelHandleClose(void* data, static void xdgToplevelHandleClose(void* data,
@ -500,11 +500,10 @@ static void xdgSurfaceHandleConfigure(void* data,
{ {
_GLFWwindow* window = data; _GLFWwindow* window = data;
xdg_surface_ack_configure(surface, serial); 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; uint32_t new_states = window->wl.pending.toplevel_states;
int width = window->wl.pending.width; int width = window->wl.pending.width;
int height = window->wl.pending.height; int height = window->wl.pending.height;
window->wl.pending.set = false;
if (new_states != window->wl.current.toplevel_states || if (new_states != window->wl.current.toplevel_states ||
width != window->wl.current.width || width != window->wl.current.width ||
@ -524,6 +523,7 @@ static void xdgSurfaceHandleConfigure(void* data,
} }
} }
wl_surface_commit(window->wl.surface); wl_surface_commit(window->wl.surface);
window->wl.pending_state = 0;
} }
static const struct xdg_surface_listener xdgSurfaceListener = { static const struct xdg_surface_listener xdgSurfaceListener = {