1 From 320f56d2a4a31026e5c8d3b60303af98bf885e1b Mon Sep 17 00:00:00 2001
2 From: "Jan Alexander Steffens (heftig)" <jan.steffens@gmail.com>
3 Date: Sun, 4 Sep 2022 00:51:07 +0200
4 Subject: [PATCH] interactive-wayland: Fix interface versioning
5
6 We need to request the lower version of the interface versions we
7 support and the server supports, not the higher version.
8
9 Using the higher version caused crashes due to unbound callbacks on
10 GNOME, which supports a higher version of `xdg_wm_base`.
11 ---
12 tools/interactive-wayland.c | 10 +++++-----
13 1 file changed, 5 insertions(+), 5 deletions(-)
14
15 diff --git a/tools/interactive-wayland.c b/tools/interactive-wayland.c
16 index d23432d4..890680f5 100644
17 --- a/tools/interactive-wayland.c
18 +++ b/tools/interactive-wayland.c
19 @@ -42,7 +42,7 @@
20 #include "xdg-shell-client-protocol.h"
21 #include <wayland-util.h>
22
23 -#define MAX(a, b) ((a) > (b) ? (a) : (b))
24 +#define MIN(a, b) ((a) < (b) ? (a) : (b))
25
26 struct interactive_dpy {
27 struct wl_display *dpy;
28 @@ -557,7 +557,7 @@ seat_create(struct interactive_dpy *inter, struct wl_registry *registry,
29 seat->global_name = name;
30 seat->inter = inter;
31 seat->wl_seat = wl_registry_bind(registry, name, &wl_seat_interface,
32 - MAX(version, 5));
33 + MIN(version, 5));
34 wl_seat_add_listener(seat->wl_seat, &seat_listener, seat);
35 ret = asprintf(&seat->name_str, "seat:%d",
36 wl_proxy_get_id((struct wl_proxy *) seat->wl_seat));
37 @@ -607,17 +607,17 @@ registry_global(void *data, struct wl_registry *registry, uint32_t name,
38 else if (strcmp(interface, "xdg_wm_base") == 0) {
39 inter->shell = wl_registry_bind(registry, name,
40 &xdg_wm_base_interface,
41 - MAX(version, 2));
42 + MIN(version, 2));
43 xdg_wm_base_add_listener(inter->shell, &shell_listener, inter);
44 }
45 else if (strcmp(interface, "wl_compositor") == 0) {
46 inter->compositor = wl_registry_bind(registry, name,
47 &wl_compositor_interface,
48 - MAX(version, 1));
49 + MIN(version, 1));
50 }
51 else if (strcmp(interface, "wl_shm") == 0) {
52 inter->shm = wl_registry_bind(registry, name, &wl_shm_interface,
53 - MAX(version, 1));
54 + MIN(version, 1));
55 }
56 }
57
|