wayland: Clamp wl_seat version on older versions of libwayland

Clamp the wl_seat max version to 5 if being built against a version of libwayland below 1.21.0, or containers that bundle newer versions of SDL with older versions of libwayland can break if the compositor advertises support for a protocol version above 5.
main
Frank Praznik 2022-11-13 16:56:04 -05:00 committed by Cameron Gutman
parent 674989261d
commit eef4d3c86a
1 changed files with 8 additions and 1 deletions

View File

@ -64,6 +64,13 @@
#include <xkbcommon/xkbcommon-compose.h>
#include "../../events/imKStoUCS.h"
/* Clamp the wl_seat version on older versions of libwayland. */
#if SDL_WAYLAND_CHECK_VERSION(1, 21, 0)
#define SDL_WL_SEAT_VERSION 8
#else
#define SDL_WL_SEAT_VERSION 5
#endif
/* Weston uses a ratio of 10 units per scroll tick */
#define WAYLAND_WHEEL_AXIS_UNIT 10
@ -2384,7 +2391,7 @@ Wayland_display_add_input(SDL_VideoData *d, uint32_t id, uint32_t version)
return;
input->display = d;
input->seat = wl_registry_bind(d->registry, id, &wl_seat_interface, SDL_min(8, version));
input->seat = wl_registry_bind(d->registry, id, &wl_seat_interface, SDL_min(SDL_WL_SEAT_VERSION, version));
input->sx_w = wl_fixed_from_int(0);
input->sy_w = wl_fixed_from_int(0);
input->xkb.current_group = ~0;