Skip to content

Commit ef4b748

Browse files
committed
wayland: Use wl_shm_release when available
1 parent 03fcbb4 commit ef4b748

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/video/wayland/SDL_waylandvideo.c

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474

7575
#define WAYLANDVID_DRIVER_NAME "wayland"
7676

77-
// Clamp certain core protocol versions on older versions of libwayland.
77+
// Clamp core protocol versions on older versions of libwayland.
7878
#if SDL_WAYLAND_CHECK_VERSION(1, 22, 0)
7979
#define SDL_WL_COMPOSITOR_VERSION 6
8080
#else
@@ -97,7 +97,13 @@
9797
#define SDL_WL_OUTPUT_VERSION 3
9898
#endif
9999

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

103109
// wl_fixes was introduced in 1.24.0
@@ -1281,7 +1287,7 @@ static void display_handle_global(void *data, struct wl_registry *registry, uint
12811287
d->shell.xdg = wl_registry_bind(d->registry, id, &xdg_wm_base_interface, SDL_min(version, 7));
12821288
xdg_wm_base_add_listener(d->shell.xdg, &shell_listener_xdg, NULL);
12831289
} else if (SDL_strcmp(interface, "wl_shm") == 0) {
1284-
d->shm = wl_registry_bind(registry, id, &wl_shm_interface, 1);
1290+
d->shm = wl_registry_bind(registry, id, &wl_shm_interface, SDL_min(SDL_WL_SHM_VERSION, version));
12851291
} else if (SDL_strcmp(interface, "zwp_relative_pointer_manager_v1") == 0) {
12861292
d->relative_pointer_manager = wl_registry_bind(d->registry, id, &zwp_relative_pointer_manager_v1_interface, 1);
12871293
} else if (SDL_strcmp(interface, "zwp_pointer_constraints_v1") == 0) {
@@ -1574,7 +1580,11 @@ static void Wayland_VideoCleanup(SDL_VideoDevice *_this)
15741580
}
15751581

15761582
if (data->shm) {
1577-
wl_shm_destroy(data->shm);
1583+
if (wl_shm_get_version(data->shm) >= WL_SHM_RELEASE_SINCE_VERSION) {
1584+
wl_shm_release(data->shm);
1585+
} else {
1586+
wl_shm_destroy(data->shm);
1587+
}
15781588
data->shm = NULL;
15791589
}
15801590

0 commit comments

Comments
 (0)