Skip to content

Commit 37ab4fe

Browse files
committed
wayland: Use wl_fixes for registry destruction
1 parent 82336cb commit 37ab4fe

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

src/video/wayland/SDL_waylandvideo.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,13 @@
9696
#define SDL_WL_OUTPUT_VERSION 3
9797
#endif
9898

99+
// The SDL wayland-client minimum is 1.18, which supports version 3.
100+
#define SDL_WL_DATA_DEVICE_VERSION 3
101+
102+
#if SDL_WAYLAND_CHECK_VERSION(1, 24, 0)
103+
#define SDL_WL_FIXES_VERSION 1
104+
#endif
105+
99106
#ifdef SDL_USE_LIBDBUS
100107
#include "../../core/linux/SDL_dbus.h"
101108

@@ -457,6 +464,7 @@ static void Wayland_DeleteDevice(SDL_VideoDevice *device)
457464
typedef struct
458465
{
459466
bool has_fifo_v1;
467+
struct wl_fixes *wl_fixes;
460468
} SDL_WaylandPreferredData;
461469

462470
static void wayland_preferred_check_handle_global(void *data, struct wl_registry *registry, uint32_t id,
@@ -466,6 +474,10 @@ static void wayland_preferred_check_handle_global(void *data, struct wl_registry
466474

467475
if (SDL_strcmp(interface, "wp_fifo_manager_v1") == 0) {
468476
d->has_fifo_v1 = true;
477+
#ifdef SDL_WL_FIXES_VERSION
478+
} else if (SDL_strcmp(interface, "wl_fixes") == 0) {
479+
d->wl_fixes = wl_registry_bind(registry, id, &wl_fixes_interface, SDL_min(SDL_WL_FIXES_VERSION, version));
480+
#endif
469481
}
470482
}
471483

@@ -493,6 +505,12 @@ static bool Wayland_IsPreferred(struct wl_display *display)
493505

494506
WAYLAND_wl_display_roundtrip(display);
495507

508+
#ifdef WL_FIXES_INTERFACE
509+
if (preferred_data.wl_fixes) {
510+
wl_fixes_destroy_registry(preferred_data.wl_fixes, registry);
511+
wl_fixes_destroy(preferred_data.wl_fixes);
512+
}
513+
#endif
496514
wl_registry_destroy(registry);
497515

498516
if (!preferred_data.has_fifo_v1) {
@@ -1313,6 +1331,10 @@ static void display_handle_global(void *data, struct wl_registry *registry, uint
13131331
} else if (SDL_strcmp(interface, "wp_color_manager_v1") == 0) {
13141332
d->wp_color_manager_v1 = wl_registry_bind(d->registry, id, &wp_color_manager_v1_interface, 1);
13151333
Wayland_InitColorManager(d);
1334+
#ifdef SDL_WL_FIXES_VERSION
1335+
} else if (SDL_strcmp(interface, "wl_fixes") == 0) {
1336+
d->wl_fixes = wl_registry_bind(d->registry, id, &wl_fixes_interface, SDL_min(SDL_WL_FIXES_VERSION, version));
1337+
#endif
13161338
}
13171339
}
13181340

@@ -1628,6 +1650,13 @@ static void Wayland_VideoCleanup(SDL_VideoDevice *_this)
16281650
}
16291651

16301652
if (data->registry) {
1653+
#ifdef SDL_WL_FIXES_VERSION
1654+
if (data->wl_fixes) {
1655+
wl_fixes_destroy_registry(data->wl_fixes, data->registry);
1656+
wl_fixes_destroy(data->wl_fixes);
1657+
data->wl_fixes = NULL;
1658+
}
1659+
#endif
16311660
wl_registry_destroy(data->registry);
16321661
data->registry = NULL;
16331662
}

src/video/wayland/SDL_waylandvideo.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ struct SDL_VideoData
8484
struct frog_color_management_factory_v1 *frog_color_management_factory_v1;
8585
struct wp_color_manager_v1 *wp_color_manager_v1;
8686
struct zwp_tablet_manager_v2 *tablet_manager;
87+
struct wl_fixes *wl_fixes;
8788

8889
struct xkb_context *xkb_context;
8990

0 commit comments

Comments
 (0)