sdl2-compat: Updated for latest SDL3 changes as of 9332de9f258c3c9238c6f85d71e00d70c5f2a661

From d5209de480c2600ad2977749b73fab2424486c93 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Fri, 28 Jun 2024 17:44:49 -0700
Subject: [PATCH] Updated for latest SDL3 changes as of
 9332de9f258c3c9238c6f85d71e00d70c5f2a661

---
 src/sdl2_compat.c          | 27 +++++++++++++++++++++++++--
 src/sdl3_include_wrapper.h | 16 +++++++++++++---
 src/sdl3_syms.h            |  2 +-
 3 files changed, 39 insertions(+), 6 deletions(-)

diff --git a/src/sdl2_compat.c b/src/sdl2_compat.c
index 4840793..099b186 100644
--- a/src/sdl2_compat.c
+++ b/src/sdl2_compat.c
@@ -433,8 +433,8 @@ static struct {
     const char *old_hint;
     const char *new_hint;
 } renamed_hints[] = {
-    { "SDL_AUDIODRIVER", "SDL_AUDIO_DRIVER" },
     { "SDL_ALLOW_TOPMOST", "SDL_WINDOW_ALLOW_TOPMOST" },
+    { "SDL_AUDIODRIVER", "SDL_AUDIO_DRIVER" },
     { "SDL_DIRECTINPUT_ENABLED", "SDL_JOYSTICK_DIRECTINPUT" },
     { "SDL_GDK_TEXTINPUT_DEFAULT", "SDL_GDK_TEXTINPUT_DEFAULT_TEXT" },
     { "SDL_JOYSTICK_GAMECUBE_RUMBLE_BRAKE", "SDL_JOYSTICK_HIDAPI_GAMECUBE_RUMBLE_BRAKE" },
@@ -4926,6 +4926,29 @@ SDL_InitSubSystem(Uint32 flags)
 {
     int ret;
 
+    /* Update IME UI hint */
+    if (flags & SDL_INIT_VIDEO) {
+        const char *old_hint;
+        const char *hint;
+
+#if defined(SDL_PLATFORM_WIN32)
+        old_hint = SDL_GetHint("SDL_IME_SHOW_UI");
+        if (old_hint && *old_hint == '1') {
+            hint = "candidates";
+        } else {
+            hint = "0";
+        }
+#else
+        old_hint = SDL_GetHint("SDL_IME_INTERNAL_EDITING");
+        if (old_hint && *old_hint == '1') {
+            hint = "1";
+        } else {
+            hint = "candidates";
+        }
+#endif
+        SDL_SetHint(SDL_HINT_IME_NATIVE_UI, hint);
+    }
+
     ret = SDL3_InitSubSystem(flags);
     if (flags & SDL_INIT_VIDEO) {
         /* default SDL2 GL attributes */
@@ -6906,7 +6929,7 @@ SDL_SetTextInputRect(const SDL_Rect *rect)
         int i;
 
         for ( i = 0; windows[i]; ++i ) {
-            SDL3_SetTextInputRect(windows[i], rect);
+            SDL3_SetTextInputArea(windows[i], rect, 0);
         }
         SDL_free( windows );
     }
diff --git a/src/sdl3_include_wrapper.h b/src/sdl3_include_wrapper.h
index a755fa3..b3e6070 100644
--- a/src/sdl3_include_wrapper.h
+++ b/src/sdl3_include_wrapper.h
@@ -469,6 +469,7 @@
 #define SDL_GetSystemRAM IGNORE_THIS_VERSION_OF_SDL_GetSystemRAM
 #define SDL_GetSystemTheme IGNORE_THIS_VERSION_OF_SDL_GetSystemTheme
 #define SDL_GetTLS IGNORE_THIS_VERSION_OF_SDL_GetTLS
+#define SDL_GetTextInputArea IGNORE_THIS_VERSION_OF_SDL_GetTextInputArea
 #define SDL_GetTextureAlphaMod IGNORE_THIS_VERSION_OF_SDL_GetTextureAlphaMod
 #define SDL_GetTextureAlphaModFloat IGNORE_THIS_VERSION_OF_SDL_GetTextureAlphaModFloat
 #define SDL_GetTextureBlendMode IGNORE_THIS_VERSION_OF_SDL_GetTextureBlendMode
@@ -777,7 +778,7 @@
 #define SDL_SetSurfacePalette IGNORE_THIS_VERSION_OF_SDL_SetSurfacePalette
 #define SDL_SetSurfaceRLE IGNORE_THIS_VERSION_OF_SDL_SetSurfaceRLE
 #define SDL_SetTLS IGNORE_THIS_VERSION_OF_SDL_SetTLS
-#define SDL_SetTextInputRect IGNORE_THIS_VERSION_OF_SDL_SetTextInputRect
+#define SDL_SetTextInputArea IGNORE_THIS_VERSION_OF_SDL_SetTextInputArea
 #define SDL_SetTextureAlphaMod IGNORE_THIS_VERSION_OF_SDL_SetTextureAlphaMod
 #define SDL_SetTextureAlphaModFloat IGNORE_THIS_VERSION_OF_SDL_SetTextureAlphaModFloat
 #define SDL_SetTextureBlendMode IGNORE_THIS_VERSION_OF_SDL_SetTextureBlendMode
@@ -820,6 +821,7 @@
 #define SDL_SignalCondition IGNORE_THIS_VERSION_OF_SDL_SignalCondition
 #define SDL_SoftStretch IGNORE_THIS_VERSION_OF_SDL_SoftStretch
 #define SDL_StartTextInput IGNORE_THIS_VERSION_OF_SDL_StartTextInput
+#define SDL_StepUTF8 IGNORE_THIS_VERSION_OF_SDL_StepUTF8
 #define SDL_StopHapticEffect IGNORE_THIS_VERSION_OF_SDL_StopHapticEffect
 #define SDL_StopHapticEffects IGNORE_THIS_VERSION_OF_SDL_StopHapticEffects
 #define SDL_StopHapticRumble IGNORE_THIS_VERSION_OF_SDL_StopHapticRumble
@@ -2834,6 +2836,10 @@
 #undef SDL_GetTLS
 #endif
 
+#ifdef SDL_GetTextInputArea
+#undef SDL_GetTextInputArea
+#endif
+
 #ifdef SDL_GetTextureAlphaMod
 #undef SDL_GetTextureAlphaMod
 #endif
@@ -4066,8 +4072,8 @@
 #undef SDL_SetTLS
 #endif
 
-#ifdef SDL_SetTextInputRect
-#undef SDL_SetTextInputRect
+#ifdef SDL_SetTextInputArea
+#undef SDL_SetTextInputArea
 #endif
 
 #ifdef SDL_SetTextureAlphaMod
@@ -4238,6 +4244,10 @@
 #undef SDL_StartTextInput
 #endif
 
+#ifdef SDL_StepUTF8
+#undef SDL_StepUTF8
+#endif
+
 #ifdef SDL_StopHapticEffect
 #undef SDL_StopHapticEffect
 #endif
diff --git a/src/sdl3_syms.h b/src/sdl3_syms.h
index a6d54ae..744a574 100644
--- a/src/sdl3_syms.h
+++ b/src/sdl3_syms.h
@@ -226,7 +226,7 @@ SDL3_SYM(SDL_Keycode,GetKeyFromName,(const char *a),(a),return)
 SDL3_SYM(int,StartTextInput,(SDL_Window *a),(a),return)
 SDL3_SYM(SDL_bool,TextInputActive,(SDL_Window *a),(a),return)
 SDL3_SYM(int,StopTextInput,(SDL_Window *a),(a),return)
-SDL3_SYM(int,SetTextInputRect,(SDL_Window *a, const SDL_Rect *b),(a,b),return)
+SDL3_SYM(int,SetTextInputArea,(SDL_Window *a, const SDL_Rect *b, int c),(a,b,c),return)
 SDL3_SYM_PASSTHROUGH(SDL_bool,HasScreenKeyboardSupport,(void),(),return)
 SDL3_SYM_RENAMED(SDL_bool,IsScreenKeyboardShown,ScreenKeyboardShown,(SDL_Window *a),(a),return)
 SDL3_SYM_PASSTHROUGH(void*,LoadObject,(const char *a),(a),return)