From 03fcbb4e46f321c5103ba6057219fb8022d40c45 Mon Sep 17 00:00:00 2001
From: Frank Praznik <[EMAIL REDACTED]>
Date: Wed, 28 May 2025 12:37:59 -0400
Subject: [PATCH] wayland/events: Names will always be sent before devices and
capabilities
Wayland previously didn't specify that the seat name preceded the capabilities, but it is now specified that the name event must always come first. Remove the 'SDL_Set<device>Name()' functions that were only added to accommodate the case of compositors sending the name after the seat capabilities, as this clarification means that they are no longer needed.
---
src/events/SDL_keyboard.c | 13 -------------
src/events/SDL_keyboard_c.h | 3 ---
src/events/SDL_mouse.c | 13 -------------
src/events/SDL_mouse_c.h | 3 ---
src/events/SDL_touch.c | 10 ----------
src/events/SDL_touch_c.h | 3 ---
src/video/wayland/SDL_waylandevents.c | 16 ----------------
7 files changed, 61 deletions(-)
diff --git a/src/events/SDL_keyboard.c b/src/events/SDL_keyboard.c
index fc06f07258d43..e281f5daaa7fe 100644
--- a/src/events/SDL_keyboard.c
+++ b/src/events/SDL_keyboard.c
@@ -172,19 +172,6 @@ void SDL_RemoveKeyboard(SDL_KeyboardID keyboardID, bool send_event)
}
}
-void SDL_SetKeyboardName(SDL_KeyboardID keyboardID, const char *name)
-{
- SDL_assert(keyboardID != 0);
-
- const int keyboard_index = SDL_GetKeyboardIndex(keyboardID);
-
- if (keyboard_index >= 0) {
- SDL_KeyboardInstance *instance = &SDL_keyboards[keyboard_index];
- SDL_free(instance->name);
- instance->name = SDL_strdup(name ? name : "");
- }
-}
-
bool SDL_HasKeyboard(void)
{
return (SDL_keyboard_count > 0);
diff --git a/src/events/SDL_keyboard_c.h b/src/events/SDL_keyboard_c.h
index 9a6589ddb2060..ddfb5c5747176 100644
--- a/src/events/SDL_keyboard_c.h
+++ b/src/events/SDL_keyboard_c.h
@@ -43,9 +43,6 @@ extern void SDL_AddKeyboard(SDL_KeyboardID keyboardID, const char *name, bool se
// A keyboard has been removed from the system
extern void SDL_RemoveKeyboard(SDL_KeyboardID keyboardID, bool send_event);
-// Set or update the name of a keyboard instance.
-extern void SDL_SetKeyboardName(SDL_KeyboardID keyboardID, const char *name);
-
// Set the mapping of scancode to key codes
extern void SDL_SetKeymap(SDL_Keymap *keymap, bool send_event);
diff --git a/src/events/SDL_mouse.c b/src/events/SDL_mouse.c
index 5838d47cf8e89..54611bf36d153 100644
--- a/src/events/SDL_mouse.c
+++ b/src/events/SDL_mouse.c
@@ -413,19 +413,6 @@ void SDL_RemoveMouse(SDL_MouseID mouseID, bool send_event)
}
}
-void SDL_SetMouseName(SDL_MouseID mouseID, const char *name)
-{
- SDL_assert(mouseID != 0);
-
- const int mouse_index = SDL_GetMouseIndex(mouseID);
-
- if (mouse_index >= 0) {
- SDL_MouseInstance *instance = &SDL_mice[mouse_index];
- SDL_free(instance->name);
- instance->name = SDL_strdup(name ? name : "");
- }
-}
-
bool SDL_HasMouse(void)
{
return (SDL_mouse_count > 0);
diff --git a/src/events/SDL_mouse_c.h b/src/events/SDL_mouse_c.h
index 0bc913b94e16e..c25974ba8278e 100644
--- a/src/events/SDL_mouse_c.h
+++ b/src/events/SDL_mouse_c.h
@@ -169,9 +169,6 @@ extern void SDL_AddMouse(SDL_MouseID mouseID, const char *name, bool send_event)
// A mouse has been removed from the system
extern void SDL_RemoveMouse(SDL_MouseID mouseID, bool send_event);
-// Set or update the name of a mouse instance.
-extern void SDL_SetMouseName(SDL_MouseID mouseID, const char *name);
-
// Get the mouse state structure
extern SDL_Mouse *SDL_GetMouse(void);
diff --git a/src/events/SDL_touch.c b/src/events/SDL_touch.c
index bf3cc02354f1f..e825117c82a7e 100644
--- a/src/events/SDL_touch.c
+++ b/src/events/SDL_touch.c
@@ -205,16 +205,6 @@ int SDL_AddTouch(SDL_TouchID touchID, SDL_TouchDeviceType type, const char *name
return index;
}
-// Set or update the name of a touch.
-void SDL_SetTouchName(SDL_TouchID id, const char *name)
-{
- SDL_Touch *touch = SDL_GetTouch(id);
- if (touch) {
- SDL_free(touch->name);
- touch->name = SDL_strdup(name ? name : "");
- }
-}
-
static bool SDL_AddFinger(SDL_Touch *touch, SDL_FingerID fingerid, float x, float y, float pressure)
{
SDL_Finger *finger;
diff --git a/src/events/SDL_touch_c.h b/src/events/SDL_touch_c.h
index e46ba68197ee2..db2d64b85f004 100644
--- a/src/events/SDL_touch_c.h
+++ b/src/events/SDL_touch_c.h
@@ -42,9 +42,6 @@ extern bool SDL_TouchDevicesAvailable(void);
// Add a touch, returning the index of the touch, or -1 if there was an error.
extern int SDL_AddTouch(SDL_TouchID id, SDL_TouchDeviceType type, const char *name);
-// Set or update the name of a touch.
-extern void SDL_SetTouchName(SDL_TouchID id, const char *name);
-
// Get the touch with a given id
extern SDL_Touch *SDL_GetTouch(SDL_TouchID id);
diff --git a/src/video/wayland/SDL_waylandevents.c b/src/video/wayland/SDL_waylandevents.c
index 2710928c81006..5f640321ebcef 100644
--- a/src/video/wayland/SDL_waylandevents.c
+++ b/src/video/wayland/SDL_waylandevents.c
@@ -2352,25 +2352,9 @@ static void seat_handle_capabilities(void *data, struct wl_seat *wl_seat, enum w
static void seat_handle_name(void *data, struct wl_seat *wl_seat, const char *name)
{
SDL_WaylandSeat *seat = (SDL_WaylandSeat *)data;
- char name_fmt[256];
if (name && *name != '\0') {
seat->name = SDL_strdup(name);
-
- if (seat->keyboard.wl_keyboard) {
- SDL_snprintf(name_fmt, sizeof(name_fmt), "%s (%s)", WAYLAND_DEFAULT_KEYBOARD_NAME, seat->name);
- SDL_SetKeyboardName(seat->keyboard.sdl_id, name_fmt);
- }
-
- if (seat->pointer.wl_pointer) {
- SDL_snprintf(name_fmt, sizeof(name_fmt), "%s (%s)", WAYLAND_DEFAULT_POINTER_NAME, seat->name);
- SDL_SetMouseName(seat->pointer.sdl_id, name_fmt);
- }
-
- if (seat->touch.wl_touch) {
- SDL_snprintf(name_fmt, sizeof(name_fmt), "%s (%s)", WAYLAND_DEFAULT_TOUCH_NAME, seat->name);
- SDL_SetTouchName((SDL_TouchID)(uintptr_t)seat->touch.wl_touch, name_fmt);
- }
}
}