From 9284a03053ed9cbbd9d9d2f5de2ea437bd855107 Mon Sep 17 00:00:00 2001
From: Frank Praznik <[EMAIL REDACTED]>
Date: Sat, 23 Sep 2023 12:51:24 -0400
Subject: [PATCH] wayland: Remove some unnecessary helper functions
---
src/video/wayland/SDL_waylandevents.c | 29 -------------------------
src/video/wayland/SDL_waylandevents_c.h | 6 -----
src/video/wayland/SDL_waylandvideo.c | 16 ++++++++++----
3 files changed, 12 insertions(+), 39 deletions(-)
diff --git a/src/video/wayland/SDL_waylandevents.c b/src/video/wayland/SDL_waylandevents.c
index 498f69c5c3ca..0f7ff37ef794 100644
--- a/src/video/wayland/SDL_waylandevents.c
+++ b/src/video/wayland/SDL_waylandevents.c
@@ -2846,35 +2846,6 @@ void Wayland_display_destroy_input(SDL_VideoData *d)
d->input = NULL;
}
-/* !!! FIXME: just merge these into display_handle_global(). */
-void Wayland_display_add_relative_pointer_manager(SDL_VideoData *d, uint32_t id)
-{
- d->relative_pointer_manager =
- wl_registry_bind(d->registry, id,
- &zwp_relative_pointer_manager_v1_interface, 1);
-}
-
-void Wayland_display_destroy_relative_pointer_manager(SDL_VideoData *d)
-{
- if (d->relative_pointer_manager) {
- zwp_relative_pointer_manager_v1_destroy(d->relative_pointer_manager);
- }
-}
-
-void Wayland_display_add_pointer_constraints(SDL_VideoData *d, uint32_t id)
-{
- d->pointer_constraints =
- wl_registry_bind(d->registry, id,
- &zwp_pointer_constraints_v1_interface, 1);
-}
-
-void Wayland_display_destroy_pointer_constraints(SDL_VideoData *d)
-{
- if (d->pointer_constraints) {
- zwp_pointer_constraints_v1_destroy(d->pointer_constraints);
- }
-}
-
static void relative_pointer_handle_relative_motion(void *data,
struct zwp_relative_pointer_v1 *pointer,
uint32_t time_hi,
diff --git a/src/video/wayland/SDL_waylandevents_c.h b/src/video/wayland/SDL_waylandevents_c.h
index 0a5189324b90..5dd584084190 100644
--- a/src/video/wayland/SDL_waylandevents_c.h
+++ b/src/video/wayland/SDL_waylandevents_c.h
@@ -182,18 +182,12 @@ extern void Wayland_add_text_input_manager(SDL_VideoData *d, uint32_t id, uint32
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_add_pointer_constraints(SDL_VideoData *d, uint32_t id);
-extern void Wayland_display_destroy_pointer_constraints(SDL_VideoData *d);
-
extern int Wayland_input_lock_pointer(struct SDL_WaylandInput *input);
extern int Wayland_input_unlock_pointer(struct SDL_WaylandInput *input);
extern int Wayland_input_confine_pointer(struct SDL_WaylandInput *input, SDL_Window *window);
extern int Wayland_input_unconfine_pointer(struct SDL_WaylandInput *input, SDL_Window *window);
-extern void Wayland_display_add_relative_pointer_manager(SDL_VideoData *d, uint32_t id);
-extern void Wayland_display_destroy_relative_pointer_manager(SDL_VideoData *d);
-
extern int Wayland_input_grab_keyboard(SDL_Window *window, struct SDL_WaylandInput *input);
extern int Wayland_input_ungrab_keyboard(SDL_Window *window);
diff --git a/src/video/wayland/SDL_waylandvideo.c b/src/video/wayland/SDL_waylandvideo.c
index 4d1b3d10d3b5..2ba3bb7f3c61 100644
--- a/src/video/wayland/SDL_waylandvideo.c
+++ b/src/video/wayland/SDL_waylandvideo.c
@@ -55,6 +55,8 @@
#include "primary-selection-unstable-v1-client-protocol.h"
#include "fractional-scale-v1-client-protocol.h"
#include "input-timestamps-unstable-v1-client-protocol.h"
+#include "relative-pointer-unstable-v1-client-protocol.h"
+#include "pointer-constraints-unstable-v1-client-protocol.h"
#ifdef HAVE_LIBDECOR_H
#include <libdecor.h>
@@ -762,9 +764,9 @@ static void display_handle_global(void *data, struct wl_registry *registry, uint
} else if (SDL_strcmp(interface, "wl_shm") == 0) {
d->shm = wl_registry_bind(registry, id, &wl_shm_interface, 1);
} else if (SDL_strcmp(interface, "zwp_relative_pointer_manager_v1") == 0) {
- Wayland_display_add_relative_pointer_manager(d, id);
+ d->relative_pointer_manager = wl_registry_bind(d->registry, id, &zwp_relative_pointer_manager_v1_interface, 1);
} else if (SDL_strcmp(interface, "zwp_pointer_constraints_v1") == 0) {
- Wayland_display_add_pointer_constraints(d, id);
+ d->pointer_constraints = wl_registry_bind(d->registry, id, &zwp_pointer_constraints_v1_interface, 1);
} else if (SDL_strcmp(interface, "zwp_keyboard_shortcuts_inhibit_manager_v1") == 0) {
d->key_inhibitor_manager = wl_registry_bind(d->registry, id, &zwp_keyboard_shortcuts_inhibit_manager_v1_interface, 1);
} else if (SDL_strcmp(interface, "zwp_idle_inhibit_manager_v1") == 0) {
@@ -941,8 +943,14 @@ static void Wayland_VideoCleanup(SDL_VideoDevice *_this)
}
Wayland_display_destroy_input(data);
- Wayland_display_destroy_pointer_constraints(data);
- Wayland_display_destroy_relative_pointer_manager(data);
+
+ if (data->pointer_constraints) {
+ zwp_pointer_constraints_v1_destroy(data->pointer_constraints);
+ }
+
+ if (data->relative_pointer_manager) {
+ zwp_relative_pointer_manager_v1_destroy(data->relative_pointer_manager);
+ }
if (data->activation_manager) {
xdg_activation_v1_destroy(data->activation_manager);