@@ -2032,6 +2032,13 @@ static void Wayland_create_data_device(SDL_VideoData *d)
2032
2032
return ;
2033
2033
}
2034
2034
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
+
2035
2042
data_device = SDL_calloc (1 , sizeof (* data_device ));
2036
2043
if (!data_device ) {
2037
2044
return ;
@@ -2060,6 +2067,13 @@ static void Wayland_create_primary_selection_device(SDL_VideoData *d)
2060
2067
return ;
2061
2068
}
2062
2069
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
+
2063
2077
primary_selection_device = SDL_calloc (1 , sizeof (* primary_selection_device ));
2064
2078
if (!primary_selection_device ) {
2065
2079
return ;
@@ -2089,6 +2103,13 @@ static void Wayland_create_text_input(SDL_VideoData *d)
2089
2103
return ;
2090
2104
}
2091
2105
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
+
2092
2113
text_input = SDL_calloc (1 , sizeof (* text_input ));
2093
2114
if (!text_input ) {
2094
2115
return ;
@@ -2467,6 +2488,23 @@ void Wayland_display_add_input(SDL_VideoData *d, uint32_t id, uint32_t version)
2467
2488
{
2468
2489
struct SDL_WaylandInput * input = d -> input ;
2469
2490
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
+
2470
2508
input -> seat = wl_registry_bind (d -> registry , id , & wl_seat_interface , SDL_min (SDL_WL_SEAT_VERSION , version ));
2471
2509
2472
2510
if (d -> data_device_manager ) {
@@ -2573,6 +2611,15 @@ void Wayland_display_destroy_input(SDL_VideoData *d)
2573
2611
WAYLAND_xkb_keymap_unref (input -> xkb .keymap );
2574
2612
}
2575
2613
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
+
2576
2623
SDL_free (input );
2577
2624
d -> input = NULL ;
2578
2625
}
0 commit comments