Skip to content

Commit 6eba2f2

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
1 parent d330686 commit 6eba2f2

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
@@ -112,7 +112,9 @@
112112
#define SDL_WL_DATA_DEVICE_VERSION 3
113113

114114
// wl_fixes was introduced in 1.24.0
115-
#if SDL_WAYLAND_CHECK_VERSION(1, 24, 0)
115+
#if SDL_WAYLAND_CHECK_VERSION(1, 26, 0)
116+
#define SDL_WL_FIXES_VERSION 2
117+
#elif SDL_WAYLAND_CHECK_VERSION(1, 24, 0)
116118
#define SDL_WL_FIXES_VERSION 1
117119
#endif
118120

@@ -561,7 +563,11 @@ static void wayland_preferred_check_handle_global(void *data, struct wl_registry
561563

562564
static void wayland_preferred_check_remove_global(void *data, struct wl_registry *registry, uint32_t id)
563565
{
564-
// No need to do anything here.
566+
SDL_WaylandPreferredData *d = (SDL_WaylandPreferredData *)data;
567+
568+
if (d->wl_fixes && wl_fixes_get_version(d->wl_fixes) >= WL_FIXES_ACK_GLOBAL_REMOVE_SINCE_VERSION) {
569+
wl_fixes_ack_global_remove(d->wl_fixes, registry, id);
570+
}
565571
}
566572

567573
static const struct wl_registry_listener preferred_registry_listener = {
@@ -1537,18 +1543,22 @@ static void handle_registry_remove_global(void *data, struct wl_registry *regist
15371543
}
15381544

15391545
d->output_count--;
1540-
return;
1546+
goto ack_remove;
15411547
}
15421548
}
15431549

15441550
SDL_WaylandSeat *seat, *temp;
1545-
wl_list_for_each_safe (seat, temp, &d->seat_list, link)
1546-
{
1551+
wl_list_for_each_safe (seat, temp, &d->seat_list, link) {
15471552
if (seat->registry_id == id) {
15481553
Wayland_SeatDestroy(seat, false);
1549-
return;
1554+
goto ack_remove;
15501555
}
15511556
}
1557+
1558+
ack_remove:
1559+
if (d->wl_fixes && wl_fixes_get_version(d->wl_fixes) >= WL_FIXES_ACK_GLOBAL_REMOVE_SINCE_VERSION) {
1560+
wl_fixes_ack_global_remove(d->wl_fixes, registry, id);
1561+
}
15521562
}
15531563

15541564
static const struct wl_registry_listener registry_listener = {

0 commit comments

Comments
 (0)