Skip to content

Commit 45fa9db

Browse files
committed
wayland: Use wl_fixes for registry destruction
1 parent b9ab8cf commit 45fa9db

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

src/video/wayland/SDL_waylandvideo.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,14 @@
9797
#define SDL_WL_OUTPUT_VERSION 3
9898
#endif
9999

100+
// The SDL wayland-client minimum is 1.18, which supports version 3.
101+
#define SDL_WL_DATA_DEVICE_VERSION 3
102+
103+
// wl_fixes was introduced in 1.24.0
104+
#if SDL_WAYLAND_CHECK_VERSION(1, 24, 0)
105+
#define SDL_WL_FIXES_VERSION 1
106+
#endif
107+
100108
#ifdef SDL_USE_LIBDBUS
101109
#include "../../core/linux/SDL_dbus.h"
102110

@@ -458,6 +466,7 @@ static void Wayland_DeleteDevice(SDL_VideoDevice *device)
458466
typedef struct
459467
{
460468
bool has_fifo_v1;
469+
struct wl_fixes *wl_fixes;
461470
} SDL_WaylandPreferredData;
462471

463472
static void wayland_preferred_check_handle_global(void *data, struct wl_registry *registry, uint32_t id,
@@ -468,6 +477,11 @@ static void wayland_preferred_check_handle_global(void *data, struct wl_registry
468477
if (SDL_strcmp(interface, "wp_fifo_manager_v1") == 0) {
469478
d->has_fifo_v1 = true;
470479
}
480+
#ifdef SDL_WL_FIXES_VERSION
481+
else if (SDL_strcmp(interface, "wl_fixes") == 0) {
482+
d->wl_fixes = wl_registry_bind(registry, id, &wl_fixes_interface, SDL_min(SDL_WL_FIXES_VERSION, version));
483+
}
484+
#endif
471485
}
472486

473487
static void wayland_preferred_check_remove_global(void *data, struct wl_registry *registry, uint32_t id)
@@ -494,6 +508,10 @@ static bool Wayland_IsPreferred(struct wl_display *display)
494508

495509
WAYLAND_wl_display_roundtrip(display);
496510

511+
if (preferred_data.wl_fixes) {
512+
wl_fixes_destroy_registry(preferred_data.wl_fixes, registry);
513+
wl_fixes_destroy(preferred_data.wl_fixes);
514+
}
497515
wl_registry_destroy(registry);
498516

499517
if (!preferred_data.has_fifo_v1) {
@@ -1317,6 +1335,11 @@ static void display_handle_global(void *data, struct wl_registry *registry, uint
13171335
} else if (SDL_strcmp(interface, "wp_pointer_warp_v1") == 0) {
13181336
d->wp_pointer_warp_v1 = wl_registry_bind(d->registry, id, &wp_pointer_warp_v1_interface, 1);
13191337
}
1338+
#ifdef SDL_WL_FIXES_VERSION
1339+
else if (SDL_strcmp(interface, "wl_fixes") == 0) {
1340+
d->wl_fixes = wl_registry_bind(d->registry, id, &wl_fixes_interface, SDL_min(SDL_WL_FIXES_VERSION, version));
1341+
}
1342+
#endif
13201343
}
13211344

13221345
static void display_remove_global(void *data, struct wl_registry *registry, uint32_t id)
@@ -1636,6 +1659,11 @@ static void Wayland_VideoCleanup(SDL_VideoDevice *_this)
16361659
}
16371660

16381661
if (data->registry) {
1662+
if (data->wl_fixes) {
1663+
wl_fixes_destroy_registry(data->wl_fixes, data->registry);
1664+
wl_fixes_destroy(data->wl_fixes);
1665+
data->wl_fixes = NULL;
1666+
}
16391667
wl_registry_destroy(data->registry);
16401668
data->registry = NULL;
16411669
}

src/video/wayland/SDL_waylandvideo.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ struct SDL_VideoData
8585
struct frog_color_management_factory_v1 *frog_color_management_factory_v1;
8686
struct wp_color_manager_v1 *wp_color_manager_v1;
8787
struct zwp_tablet_manager_v2 *tablet_manager;
88+
struct wl_fixes *wl_fixes;
8889

8990
struct xkb_context *xkb_context;
9091

0 commit comments

Comments
 (0)