From 320f56d2a4a31026e5c8d3b60303af98bf885e1b Mon Sep 17 00:00:00 2001 From: "Jan Alexander Steffens (heftig)" Date: Sun, 4 Sep 2022 00:51:07 +0200 Subject: [PATCH] interactive-wayland: Fix interface versioning We need to request the lower version of the interface versions we support and the server supports, not the higher version. Using the higher version caused crashes due to unbound callbacks on GNOME, which supports a higher version of `xdg_wm_base`. --- tools/interactive-wayland.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/interactive-wayland.c b/tools/interactive-wayland.c index d23432d..890680f 100644 --- a/tools/interactive-wayland.c +++ b/tools/interactive-wayland.c @@ -42,7 +42,7 @@ #include "xdg-shell-client-protocol.h" #include -#define MAX(a, b) ((a) > (b) ? (a) : (b)) +#define MIN(a, b) ((a) < (b) ? (a) : (b)) struct interactive_dpy { struct wl_display *dpy; @@ -557,7 +557,7 @@ seat_create(struct interactive_dpy *inter, struct wl_registry *registry, seat->global_name = name; seat->inter = inter; seat->wl_seat = wl_registry_bind(registry, name, &wl_seat_interface, - MAX(version, 5)); + MIN(version, 5)); wl_seat_add_listener(seat->wl_seat, &seat_listener, seat); ret = asprintf(&seat->name_str, "seat:%d", wl_proxy_get_id((struct wl_proxy *) seat->wl_seat)); @@ -607,17 +607,17 @@ registry_global(void *data, struct wl_registry *registry, uint32_t name, else if (strcmp(interface, "xdg_wm_base") == 0) { inter->shell = wl_registry_bind(registry, name, &xdg_wm_base_interface, - MAX(version, 2)); + MIN(version, 2)); xdg_wm_base_add_listener(inter->shell, &shell_listener, inter); } else if (strcmp(interface, "wl_compositor") == 0) { inter->compositor = wl_registry_bind(registry, name, &wl_compositor_interface, - MAX(version, 1)); + MIN(version, 1)); } else if (strcmp(interface, "wl_shm") == 0) { inter->shm = wl_registry_bind(registry, name, &wl_shm_interface, - MAX(version, 1)); + MIN(version, 1)); } }