wayland: Support wayland compositors with wl_seat version < 5 (thanks, Nia!).

Fixes Bugzilla #5074.
This commit is contained in:
Ryan C. Gordon 2020-04-07 13:30:46 -04:00
parent 3cb62d5265
commit 024698779b
3 changed files with 13 additions and 8 deletions

View File

@ -42,7 +42,15 @@
#include "xdg-shell-client-protocol.h" #include "xdg-shell-client-protocol.h"
#include "xdg-shell-unstable-v6-client-protocol.h" #include "xdg-shell-unstable-v6-client-protocol.h"
#ifdef SDL_INPUT_LINUXEV
#include <linux/input.h> #include <linux/input.h>
#else
#define BTN_LEFT (0x110)
#define BTN_RIGHT (0x111)
#define BTN_MIDDLE (0x112)
#define BTN_SIDE (0x113)
#define BTN_EXTRA (0x114)
#endif
#include <sys/select.h> #include <sys/select.h>
#include <sys/mman.h> #include <sys/mman.h>
#include <poll.h> #include <poll.h>
@ -436,7 +444,7 @@ pointer_handle_axis(void *data, struct wl_pointer *pointer,
{ {
struct SDL_WaylandInput *input = data; struct SDL_WaylandInput *input = data;
if(wl_seat_interface.version >= 5) if(wl_seat_get_version(input->seat) >= 5)
pointer_handle_axis_common(input, SDL_FALSE, axis, value); pointer_handle_axis_common(input, SDL_FALSE, axis, value);
else else
pointer_handle_axis_common_v1(input, time, axis, value); pointer_handle_axis_common_v1(input, time, axis, value);
@ -997,7 +1005,7 @@ static const struct wl_data_device_listener data_device_listener = {
}; };
void void
Wayland_display_add_input(SDL_VideoData *d, uint32_t id) Wayland_display_add_input(SDL_VideoData *d, uint32_t id, uint32_t version)
{ {
struct SDL_WaylandInput *input; struct SDL_WaylandInput *input;
SDL_WaylandDataDevice *data_device = NULL; SDL_WaylandDataDevice *data_device = NULL;
@ -1007,10 +1015,7 @@ Wayland_display_add_input(SDL_VideoData *d, uint32_t id)
return; return;
input->display = d; input->display = d;
if (wl_seat_interface.version >= 5) input->seat = wl_registry_bind(d->registry, id, &wl_seat_interface, SDL_min(5, version));
input->seat = wl_registry_bind(d->registry, id, &wl_seat_interface, 5);
else
input->seat = wl_registry_bind(d->registry, id, &wl_seat_interface, 1);
input->sx_w = wl_fixed_from_int(0); input->sx_w = wl_fixed_from_int(0);
input->sy_w = wl_fixed_from_int(0); input->sy_w = wl_fixed_from_int(0);
d->input = input; d->input = input;

View File

@ -32,7 +32,7 @@ struct SDL_WaylandInput;
extern void Wayland_PumpEvents(_THIS); extern void Wayland_PumpEvents(_THIS);
extern void Wayland_display_add_input(SDL_VideoData *d, uint32_t id); extern void Wayland_display_add_input(SDL_VideoData *d, uint32_t id, uint32_t version);
extern void Wayland_display_destroy_input(SDL_VideoData *d); extern void Wayland_display_destroy_input(SDL_VideoData *d);
extern SDL_WaylandDataDevice* Wayland_get_data_device(struct SDL_WaylandInput *input); extern SDL_WaylandDataDevice* Wayland_get_data_device(struct SDL_WaylandInput *input);

View File

@ -364,7 +364,7 @@ display_handle_global(void *data, struct wl_registry *registry, uint32_t id,
} else if (strcmp(interface, "wl_output") == 0) { } else if (strcmp(interface, "wl_output") == 0) {
Wayland_add_display(d, id); Wayland_add_display(d, id);
} else if (strcmp(interface, "wl_seat") == 0) { } else if (strcmp(interface, "wl_seat") == 0) {
Wayland_display_add_input(d, id); Wayland_display_add_input(d, id, version);
} else if (strcmp(interface, "xdg_wm_base") == 0) { } else if (strcmp(interface, "xdg_wm_base") == 0) {
d->shell.xdg = wl_registry_bind(d->registry, id, &xdg_wm_base_interface, 1); d->shell.xdg = wl_registry_bind(d->registry, id, &xdg_wm_base_interface, 1);
xdg_wm_base_add_listener(d->shell.xdg, &shell_listener_xdg, NULL); xdg_wm_base_add_listener(d->shell.xdg, &shell_listener_xdg, NULL);