Skip to content

Commit 44249f3

Browse files
committed
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.
1 parent f9440a0 commit 44249f3

File tree

7 files changed

+0
-61
lines changed

7 files changed

+0
-61
lines changed

src/events/SDL_keyboard.c

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -172,19 +172,6 @@ void SDL_RemoveKeyboard(SDL_KeyboardID keyboardID, bool send_event)
172172
}
173173
}
174174

175-
void SDL_SetKeyboardName(SDL_KeyboardID keyboardID, const char *name)
176-
{
177-
SDL_assert(keyboardID != 0);
178-
179-
const int keyboard_index = SDL_GetKeyboardIndex(keyboardID);
180-
181-
if (keyboard_index >= 0) {
182-
SDL_KeyboardInstance *instance = &SDL_keyboards[keyboard_index];
183-
SDL_free(instance->name);
184-
instance->name = SDL_strdup(name ? name : "");
185-
}
186-
}
187-
188175
bool SDL_HasKeyboard(void)
189176
{
190177
return (SDL_keyboard_count > 0);

src/events/SDL_keyboard_c.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,6 @@ extern void SDL_AddKeyboard(SDL_KeyboardID keyboardID, const char *name, bool se
4343
// A keyboard has been removed from the system
4444
extern void SDL_RemoveKeyboard(SDL_KeyboardID keyboardID, bool send_event);
4545

46-
// Set or update the name of a keyboard instance.
47-
extern void SDL_SetKeyboardName(SDL_KeyboardID keyboardID, const char *name);
48-
4946
// Set the mapping of scancode to key codes
5047
extern void SDL_SetKeymap(SDL_Keymap *keymap, bool send_event);
5148

src/events/SDL_mouse.c

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -413,19 +413,6 @@ void SDL_RemoveMouse(SDL_MouseID mouseID, bool send_event)
413413
}
414414
}
415415

416-
void SDL_SetMouseName(SDL_MouseID mouseID, const char *name)
417-
{
418-
SDL_assert(mouseID != 0);
419-
420-
const int mouse_index = SDL_GetMouseIndex(mouseID);
421-
422-
if (mouse_index >= 0) {
423-
SDL_MouseInstance *instance = &SDL_mice[mouse_index];
424-
SDL_free(instance->name);
425-
instance->name = SDL_strdup(name ? name : "");
426-
}
427-
}
428-
429416
bool SDL_HasMouse(void)
430417
{
431418
return (SDL_mouse_count > 0);

src/events/SDL_mouse_c.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,6 @@ extern void SDL_AddMouse(SDL_MouseID mouseID, const char *name, bool send_event)
169169
// A mouse has been removed from the system
170170
extern void SDL_RemoveMouse(SDL_MouseID mouseID, bool send_event);
171171

172-
// Set or update the name of a mouse instance.
173-
extern void SDL_SetMouseName(SDL_MouseID mouseID, const char *name);
174-
175172
// Get the mouse state structure
176173
extern SDL_Mouse *SDL_GetMouse(void);
177174

src/events/SDL_touch.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -205,16 +205,6 @@ int SDL_AddTouch(SDL_TouchID touchID, SDL_TouchDeviceType type, const char *name
205205
return index;
206206
}
207207

208-
// Set or update the name of a touch.
209-
void SDL_SetTouchName(SDL_TouchID id, const char *name)
210-
{
211-
SDL_Touch *touch = SDL_GetTouch(id);
212-
if (touch) {
213-
SDL_free(touch->name);
214-
touch->name = SDL_strdup(name ? name : "");
215-
}
216-
}
217-
218208
static bool SDL_AddFinger(SDL_Touch *touch, SDL_FingerID fingerid, float x, float y, float pressure)
219209
{
220210
SDL_Finger *finger;

src/events/SDL_touch_c.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,6 @@ extern bool SDL_TouchDevicesAvailable(void);
4242
// Add a touch, returning the index of the touch, or -1 if there was an error.
4343
extern int SDL_AddTouch(SDL_TouchID id, SDL_TouchDeviceType type, const char *name);
4444

45-
// Set or update the name of a touch.
46-
extern void SDL_SetTouchName(SDL_TouchID id, const char *name);
47-
4845
// Get the touch with a given id
4946
extern SDL_Touch *SDL_GetTouch(SDL_TouchID id);
5047

src/video/wayland/SDL_waylandevents.c

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2276,25 +2276,9 @@ static void seat_handle_capabilities(void *data, struct wl_seat *wl_seat, enum w
22762276
static void seat_handle_name(void *data, struct wl_seat *wl_seat, const char *name)
22772277
{
22782278
SDL_WaylandSeat *seat = (SDL_WaylandSeat *)data;
2279-
char name_fmt[256];
22802279

22812280
if (name && *name != '\0') {
22822281
seat->name = SDL_strdup(name);
2283-
2284-
if (seat->keyboard.wl_keyboard) {
2285-
SDL_snprintf(name_fmt, sizeof(name_fmt), "%s (%s)", WAYLAND_DEFAULT_KEYBOARD_NAME, seat->name);
2286-
SDL_SetKeyboardName(seat->keyboard.sdl_id, name_fmt);
2287-
}
2288-
2289-
if (seat->pointer.wl_pointer) {
2290-
SDL_snprintf(name_fmt, sizeof(name_fmt), "%s (%s)", WAYLAND_DEFAULT_POINTER_NAME, seat->name);
2291-
SDL_SetMouseName(seat->pointer.sdl_id, name_fmt);
2292-
}
2293-
2294-
if (seat->touch.wl_touch) {
2295-
SDL_snprintf(name_fmt, sizeof(name_fmt), "%s (%s)", WAYLAND_DEFAULT_TOUCH_NAME, seat->name);
2296-
SDL_SetTouchName((SDL_TouchID)(uintptr_t)seat->touch.wl_touch, name_fmt);
2297-
}
22982282
}
22992283
}
23002284

0 commit comments

Comments
 (0)