|
74 | 74 |
|
75 | 75 | #define WAYLANDVID_DRIVER_NAME "wayland" |
76 | 76 |
|
77 | | -// Clamp certain core protocol versions on older versions of libwayland. |
| 77 | +// Clamp core protocol versions on older versions of libwayland. |
78 | 78 | #if SDL_WAYLAND_CHECK_VERSION(1, 22, 0) |
79 | 79 | #define SDL_WL_COMPOSITOR_VERSION 6 |
80 | 80 | #else |
|
97 | 97 | #define SDL_WL_OUTPUT_VERSION 3 |
98 | 98 | #endif |
99 | 99 |
|
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. |
101 | 107 | #define SDL_WL_DATA_DEVICE_VERSION 3 |
102 | 108 |
|
103 | 109 | // wl_fixes was introduced in 1.24.0 |
@@ -1281,7 +1287,7 @@ static void display_handle_global(void *data, struct wl_registry *registry, uint |
1281 | 1287 | d->shell.xdg = wl_registry_bind(d->registry, id, &xdg_wm_base_interface, SDL_min(version, 7)); |
1282 | 1288 | xdg_wm_base_add_listener(d->shell.xdg, &shell_listener_xdg, NULL); |
1283 | 1289 | } 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)); |
1285 | 1291 | } else if (SDL_strcmp(interface, "zwp_relative_pointer_manager_v1") == 0) { |
1286 | 1292 | d->relative_pointer_manager = wl_registry_bind(d->registry, id, &zwp_relative_pointer_manager_v1_interface, 1); |
1287 | 1293 | } else if (SDL_strcmp(interface, "zwp_pointer_constraints_v1") == 0) { |
@@ -1574,7 +1580,11 @@ static void Wayland_VideoCleanup(SDL_VideoDevice *_this) |
1574 | 1580 | } |
1575 | 1581 |
|
1576 | 1582 | 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 | + } |
1578 | 1588 | data->shm = NULL; |
1579 | 1589 | } |
1580 | 1590 |
|
|
0 commit comments