@@ -2032,6 +2032,13 @@ static void Wayland_create_data_device(SDL_VideoData *d)
20322032 return ;
20332033 }
20342034
2035+ #ifdef SDL_VIDEO_DRIVER_WAYLAND_WEBOS
2036+ if (d -> input -> data_device ) {
2037+ /* Shouldn't be called at all on webOS, but just in case */
2038+ return ;
2039+ }
2040+ #endif
2041+
20352042 data_device = SDL_calloc (1 , sizeof (* data_device ));
20362043 if (!data_device ) {
20372044 return ;
@@ -2060,6 +2067,13 @@ static void Wayland_create_primary_selection_device(SDL_VideoData *d)
20602067 return ;
20612068 }
20622069
2070+ #ifdef SDL_VIDEO_DRIVER_WAYLAND_WEBOS
2071+ if (d -> input -> primary_selection_device ) {
2072+ /* Shouldn't be called at all on webOS, but just in case */
2073+ return ;
2074+ }
2075+ #endif
2076+
20632077 primary_selection_device = SDL_calloc (1 , sizeof (* primary_selection_device ));
20642078 if (!primary_selection_device ) {
20652079 return ;
@@ -2089,6 +2103,13 @@ static void Wayland_create_text_input(SDL_VideoData *d)
20892103 return ;
20902104 }
20912105
2106+ #ifdef SDL_VIDEO_DRIVER_WAYLAND_WEBOS
2107+ if (d -> input -> text_input ) {
2108+ /* Shouldn't be called at all on webOS, but just in case */
2109+ return ;
2110+ }
2111+ #endif
2112+
20922113 text_input = SDL_calloc (1 , sizeof (* text_input ));
20932114 if (!text_input ) {
20942115 return ;
@@ -2467,6 +2488,23 @@ void Wayland_display_add_input(SDL_VideoData *d, uint32_t id, uint32_t version)
24672488{
24682489 struct SDL_WaylandInput * input = d -> input ;
24692490
2491+ #ifdef SDL_VIDEO_DRIVER_WAYLAND_WEBOS
2492+ if (input -> seat ) {
2493+ struct SDL_WaylandInput * tail ;
2494+ /* Find the tail if the input has seat */
2495+ while (input -> next ) {
2496+ input = input -> next ;
2497+ }
2498+ tail = input ;
2499+ input = SDL_calloc (1 , sizeof (struct SDL_WaylandInput ));
2500+ if (!input ) {
2501+ return ;
2502+ }
2503+ input -> display = d ;
2504+ tail -> next = input ;
2505+ }
2506+ #endif
2507+
24702508 input -> seat = wl_registry_bind (d -> registry , id , & wl_seat_interface , SDL_min (SDL_WL_SEAT_VERSION , version ));
24712509
24722510 if (d -> data_device_manager ) {
@@ -2573,6 +2611,15 @@ void Wayland_display_destroy_input(SDL_VideoData *d)
25732611 WAYLAND_xkb_keymap_unref (input -> xkb .keymap );
25742612 }
25752613
2614+ #ifdef SDL_VIDEO_DRIVER_WAYLAND_WEBOS
2615+ /* Use recursive call to free up linked list */
2616+ /* Extremely evil but prevents goto usages and large changes */
2617+ if (input -> next ) {
2618+ d -> input = input -> next ;
2619+ Wayland_display_destroy_input (d );
2620+ }
2621+ #endif
2622+
25762623 SDL_free (input );
25772624 d -> input = NULL ;
25782625}
0 commit comments