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.
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
+
100
108
#ifdef SDL_USE_LIBDBUS
101
109
#include "../../core/linux/SDL_dbus.h"
102
110
@@ -458,6 +466,7 @@ static void Wayland_DeleteDevice(SDL_VideoDevice *device)
458
466
typedef struct
459
467
{
460
468
bool has_fifo_v1 ;
469
+ struct wl_fixes * wl_fixes ;
461
470
} SDL_WaylandPreferredData ;
462
471
463
472
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
468
477
if (SDL_strcmp (interface , "wp_fifo_manager_v1" ) == 0 ) {
469
478
d -> has_fifo_v1 = true;
470
479
}
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
471
485
}
472
486
473
487
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)
494
508
495
509
WAYLAND_wl_display_roundtrip (display );
496
510
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
+ }
497
515
wl_registry_destroy (registry );
498
516
499
517
if (!preferred_data .has_fifo_v1 ) {
@@ -1317,6 +1335,11 @@ static void display_handle_global(void *data, struct wl_registry *registry, uint
1317
1335
} else if (SDL_strcmp (interface , "wp_pointer_warp_v1" ) == 0 ) {
1318
1336
d -> wp_pointer_warp_v1 = wl_registry_bind (d -> registry , id , & wp_pointer_warp_v1_interface , 1 );
1319
1337
}
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
1320
1343
}
1321
1344
1322
1345
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)
1636
1659
}
1637
1660
1638
1661
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
+ }
1639
1667
wl_registry_destroy (data -> registry );
1640
1668
data -> registry = NULL ;
1641
1669
}
0 commit comments