Skip to content

Commit 3e536ed

Browse files
zzagKontrabant
authored andcommitted
wayland: Add support for wl_fixes.ack_global_remove
The wl_fixes.ack_global_remove request signals the compositor that the client will not bind the removed global. It can be used by the compositor to decide when it is safe to actually destroy the corresponding global. If a global is destroyed too soon, some clients may get disconnected. See also https://gitlab.freedesktop.org/wayland/wayland/-/merge_requests/533 (cherry picked from commit 6eba2f2)
1 parent 29d07d3 commit 3e536ed

2 files changed

Lines changed: 1678 additions & 1525 deletions

File tree

src/video/wayland/SDL_waylandvideo.c

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,9 @@
110110
#define SDL_WL_DATA_DEVICE_VERSION 3
111111

112112
// wl_fixes was introduced in 1.24.0
113-
#if SDL_WAYLAND_CHECK_VERSION(1, 24, 0)
113+
#if SDL_WAYLAND_CHECK_VERSION(1, 26, 0)
114+
#define SDL_WL_FIXES_VERSION 2
115+
#elif SDL_WAYLAND_CHECK_VERSION(1, 24, 0)
114116
#define SDL_WL_FIXES_VERSION 1
115117
#endif
116118

@@ -506,7 +508,11 @@ static void wayland_preferred_check_handle_global(void *data, struct wl_registry
506508

507509
static void wayland_preferred_check_remove_global(void *data, struct wl_registry *registry, uint32_t id)
508510
{
509-
// No need to do anything here.
511+
SDL_WaylandPreferredData *d = (SDL_WaylandPreferredData *)data;
512+
513+
if (d->wl_fixes && wl_fixes_get_version(d->wl_fixes) >= WL_FIXES_ACK_GLOBAL_REMOVE_SINCE_VERSION) {
514+
wl_fixes_ack_global_remove(d->wl_fixes, registry, id);
515+
}
510516
}
511517

512518
static const struct wl_registry_listener preferred_registry_listener = {
@@ -1370,18 +1376,22 @@ static void handle_registry_remove_global(void *data, struct wl_registry *regist
13701376
}
13711377

13721378
d->output_count--;
1373-
return;
1379+
goto ack_remove;
13741380
}
13751381
}
13761382

13771383
SDL_WaylandSeat *seat, *temp;
1378-
wl_list_for_each_safe (seat, temp, &d->seat_list, link)
1379-
{
1384+
wl_list_for_each_safe (seat, temp, &d->seat_list, link) {
13801385
if (seat->registry_id == id) {
13811386
Wayland_SeatDestroy(seat, false);
1382-
return;
1387+
goto ack_remove;
13831388
}
13841389
}
1390+
1391+
ack_remove:
1392+
if (d->wl_fixes && wl_fixes_get_version(d->wl_fixes) >= WL_FIXES_ACK_GLOBAL_REMOVE_SINCE_VERSION) {
1393+
wl_fixes_ack_global_remove(d->wl_fixes, registry, id);
1394+
}
13851395
}
13861396

13871397
static const struct wl_registry_listener registry_listener = {

0 commit comments

Comments
 (0)