Skip to content

Commit fc7802b

Browse files
committed
wayland: Use wl_shm_release when available
1 parent 71a821d commit fc7802b

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/video/wayland/SDL_waylandvideo.c

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

99+
#if SDL_WAYLAND_CHECK_VERSION(1, 24, 0)
100+
#define SDL_WL_SHM_VERSION 2
101+
#else
102+
#define SDL_WL_SHM_VERSION 1
103+
#endif
104+
105+
99106
// The SDL wayland-client minimum is 1.18, which supports version 3.
100107
#define SDL_WL_DATA_DEVICE_VERSION 3
101108

@@ -1280,7 +1287,7 @@ static void display_handle_global(void *data, struct wl_registry *registry, uint
12801287
d->shell.xdg = wl_registry_bind(d->registry, id, &xdg_wm_base_interface, SDL_min(version, 7));
12811288
xdg_wm_base_add_listener(d->shell.xdg, &shell_listener_xdg, NULL);
12821289
} else if (SDL_strcmp(interface, "wl_shm") == 0) {
1283-
d->shm = wl_registry_bind(registry, id, &wl_shm_interface, 1);
1290+
d->shm = wl_registry_bind(registry, id, &wl_shm_interface, SDL_WL_SHM_VERSION);
12841291
} else if (SDL_strcmp(interface, "zwp_relative_pointer_manager_v1") == 0) {
12851292
d->relative_pointer_manager = wl_registry_bind(d->registry, id, &zwp_relative_pointer_manager_v1_interface, 1);
12861293
} else if (SDL_strcmp(interface, "zwp_pointer_constraints_v1") == 0) {
@@ -1570,7 +1577,11 @@ static void Wayland_VideoCleanup(SDL_VideoDevice *_this)
15701577
}
15711578

15721579
if (data->shm) {
1573-
wl_shm_destroy(data->shm);
1580+
if (wl_shm_get_version(data->shm) >= WL_SHM_RELEASE_SINCE_VERSION) {
1581+
wl_shm_release(data->shm);
1582+
} else {
1583+
wl_shm_destroy(data->shm);
1584+
}
15741585
data->shm = NULL;
15751586
}
15761587

0 commit comments

Comments
 (0)