Commit b085c18251bc0298b1a78a621025978702ca07f7

rohlem 2022-07-04T16:38:05

make SDL_SetTextInputRect take a pointer to const The documentation doesn't state that the argument is ever modified, and no implementation does so currently. This is a non-breaking change to guarantee as much to callers.

diff --git a/include/SDL_keyboard.h b/include/SDL_keyboard.h
index b19a293..b80a7dc 100644
--- a/include/SDL_keyboard.h
+++ b/include/SDL_keyboard.h
@@ -303,7 +303,7 @@ extern DECLSPEC SDL_bool SDLCALL SDL_IsTextInputShown(void);
  *
  * \sa SDL_StartTextInput
  */
-extern DECLSPEC void SDLCALL SDL_SetTextInputRect(SDL_Rect *rect);
+extern DECLSPEC void SDLCALL SDL_SetTextInputRect(const SDL_Rect *rect);
 
 /**
  * Check whether the platform has screen keyboard support.
diff --git a/src/core/linux/SDL_fcitx.c b/src/core/linux/SDL_fcitx.c
index c7a7359..f653279 100644
--- a/src/core/linux/SDL_fcitx.c
+++ b/src/core/linux/SDL_fcitx.c
@@ -424,7 +424,7 @@ SDL_Fcitx_ProcessKeyEvent(Uint32 keysym, Uint32 keycode, Uint8 state)
 }
 
 void
-SDL_Fcitx_UpdateTextRect(SDL_Rect *rect)
+SDL_Fcitx_UpdateTextRect(const SDL_Rect *rect)
 {
     SDL_Window *focused_win = NULL;
     SDL_SysWMinfo info;
diff --git a/src/core/linux/SDL_fcitx.h b/src/core/linux/SDL_fcitx.h
index c3cea52..567ddce 100644
--- a/src/core/linux/SDL_fcitx.h
+++ b/src/core/linux/SDL_fcitx.h
@@ -32,7 +32,7 @@ extern void SDL_Fcitx_Quit(void);
 extern void SDL_Fcitx_SetFocus(SDL_bool focused);
 extern void SDL_Fcitx_Reset(void);
 extern SDL_bool SDL_Fcitx_ProcessKeyEvent(Uint32 keysym, Uint32 keycode, Uint8 state);
-extern void SDL_Fcitx_UpdateTextRect(SDL_Rect *rect);
+extern void SDL_Fcitx_UpdateTextRect(const SDL_Rect *rect);
 extern void SDL_Fcitx_PumpEvents(void);
 
 #endif /* SDL_fcitx_h_ */
diff --git a/src/core/linux/SDL_ibus.c b/src/core/linux/SDL_ibus.c
index dc0b928..8b74f57 100644
--- a/src/core/linux/SDL_ibus.c
+++ b/src/core/linux/SDL_ibus.c
@@ -639,7 +639,7 @@ SDL_IBus_ProcessKeyEvent(Uint32 keysym, Uint32 keycode, Uint8 state)
 }
 
 void
-SDL_IBus_UpdateTextRect(SDL_Rect *rect)
+SDL_IBus_UpdateTextRect(const SDL_Rect *rect)
 {
     SDL_Window *focused_win;
     SDL_SysWMinfo info;
diff --git a/src/core/linux/SDL_ibus.h b/src/core/linux/SDL_ibus.h
index 71d1f2d..d7071ec 100644
--- a/src/core/linux/SDL_ibus.h
+++ b/src/core/linux/SDL_ibus.h
@@ -45,7 +45,7 @@ extern SDL_bool SDL_IBus_ProcessKeyEvent(Uint32 keysym, Uint32 keycode, Uint8 st
 
 /* Update the position of IBus' candidate list. If rect is NULL then this will 
    just reposition it relative to the focused window's new position. */
-extern void SDL_IBus_UpdateTextRect(SDL_Rect *window_relative_rect);
+extern void SDL_IBus_UpdateTextRect(const SDL_Rect *window_relative_rect);
 
 /* Checks DBus for new IBus events, and calls SDL_SendKeyboardText / 
    SDL_SendEditingText for each event it finds */
diff --git a/src/core/linux/SDL_ime.c b/src/core/linux/SDL_ime.c
index 9c0cb80..50b5ebf 100644
--- a/src/core/linux/SDL_ime.c
+++ b/src/core/linux/SDL_ime.c
@@ -28,7 +28,7 @@ typedef void (*_SDL_IME_Quit)(void);
 typedef void (*_SDL_IME_SetFocus)(SDL_bool);
 typedef void (*_SDL_IME_Reset)(void);
 typedef SDL_bool (*_SDL_IME_ProcessKeyEvent)(Uint32, Uint32, Uint8 state);
-typedef void (*_SDL_IME_UpdateTextRect)(SDL_Rect *);
+typedef void (*_SDL_IME_UpdateTextRect)(const SDL_Rect *);
 typedef void (*_SDL_IME_PumpEvents)(void);
 
 static _SDL_IME_Init SDL_IME_Init_Real = NULL;
@@ -136,7 +136,7 @@ SDL_IME_ProcessKeyEvent(Uint32 keysym, Uint32 keycode, Uint8 state)
 }
 
 void
-SDL_IME_UpdateTextRect(SDL_Rect *rect)
+SDL_IME_UpdateTextRect(const SDL_Rect *rect)
 {
     if (SDL_IME_UpdateTextRect_Real)
         SDL_IME_UpdateTextRect_Real(rect);
diff --git a/src/core/linux/SDL_ime.h b/src/core/linux/SDL_ime.h
index cc5b105..23417f6 100644
--- a/src/core/linux/SDL_ime.h
+++ b/src/core/linux/SDL_ime.h
@@ -32,7 +32,7 @@ extern void SDL_IME_Quit(void);
 extern void SDL_IME_SetFocus(SDL_bool focused);
 extern void SDL_IME_Reset(void);
 extern SDL_bool SDL_IME_ProcessKeyEvent(Uint32 keysym, Uint32 keycode, Uint8 state);
-extern void SDL_IME_UpdateTextRect(SDL_Rect *rect);
+extern void SDL_IME_UpdateTextRect(const SDL_Rect *rect);
 extern void SDL_IME_PumpEvents(void);
 
 #endif /* SDL_ime_h_ */
diff --git a/src/dynapi/SDL_dynapi_procs.h b/src/dynapi/SDL_dynapi_procs.h
index 4c61f19..2d6e1e8 100644
--- a/src/dynapi/SDL_dynapi_procs.h
+++ b/src/dynapi/SDL_dynapi_procs.h
@@ -260,7 +260,7 @@ SDL_DYNAPI_PROC(SDL_Keycode,SDL_GetKeyFromName,(const char *a),(a),return)
 SDL_DYNAPI_PROC(void,SDL_StartTextInput,(void),(),)
 SDL_DYNAPI_PROC(SDL_bool,SDL_IsTextInputActive,(void),(),return)
 SDL_DYNAPI_PROC(void,SDL_StopTextInput,(void),(),)
-SDL_DYNAPI_PROC(void,SDL_SetTextInputRect,(SDL_Rect *a),(a),)
+SDL_DYNAPI_PROC(void,SDL_SetTextInputRect,(const SDL_Rect *a),(a),)
 SDL_DYNAPI_PROC(SDL_bool,SDL_HasScreenKeyboardSupport,(void),(),return)
 SDL_DYNAPI_PROC(SDL_bool,SDL_IsScreenKeyboardShown,(SDL_Window *a),(a),return)
 SDL_DYNAPI_PROC(void*,SDL_LoadObject,(const char *a),(a),return)
diff --git a/src/video/SDL_sysvideo.h b/src/video/SDL_sysvideo.h
index b1876b2..9e2bfb9 100644
--- a/src/video/SDL_sysvideo.h
+++ b/src/video/SDL_sysvideo.h
@@ -307,7 +307,7 @@ struct SDL_VideoDevice
     /* Text input */
     void (*StartTextInput) (_THIS);
     void (*StopTextInput) (_THIS);
-    void (*SetTextInputRect) (_THIS, SDL_Rect *rect);
+    void (*SetTextInputRect) (_THIS, const SDL_Rect *rect);
     void (*ClearComposition) (_THIS);
     SDL_bool (*IsTextInputShown) (_THIS);
 
diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c
index cda7655..1e520b2 100644
--- a/src/video/SDL_video.c
+++ b/src/video/SDL_video.c
@@ -4259,7 +4259,7 @@ SDL_StopTextInput(void)
 }
 
 void
-SDL_SetTextInputRect(SDL_Rect *rect)
+SDL_SetTextInputRect(const SDL_Rect *rect)
 {
     if (_this && _this->SetTextInputRect) {
         _this->SetTextInputRect(_this, rect);
diff --git a/src/video/android/SDL_androidkeyboard.c b/src/video/android/SDL_androidkeyboard.c
index 9bb0255..7098d2e 100644
--- a/src/video/android/SDL_androidkeyboard.c
+++ b/src/video/android/SDL_androidkeyboard.c
@@ -374,7 +374,7 @@ Android_StopTextInput(_THIS)
 }
 
 void
-Android_SetTextInputRect(_THIS, SDL_Rect *rect)
+Android_SetTextInputRect(_THIS, const SDL_Rect *rect)
 {
     SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;
 
diff --git a/src/video/android/SDL_androidkeyboard.h b/src/video/android/SDL_androidkeyboard.h
index 01da8ab..381c210 100644
--- a/src/video/android/SDL_androidkeyboard.h
+++ b/src/video/android/SDL_androidkeyboard.h
@@ -31,6 +31,6 @@ extern SDL_bool Android_IsScreenKeyboardShown(_THIS, SDL_Window * window);
 
 extern void Android_StartTextInput(_THIS);
 extern void Android_StopTextInput(_THIS);
-extern void Android_SetTextInputRect(_THIS, SDL_Rect *rect);
+extern void Android_SetTextInputRect(_THIS, const SDL_Rect *rect);
 
 /* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/video/cocoa/SDL_cocoakeyboard.h b/src/video/cocoa/SDL_cocoakeyboard.h
index 9ff2aff..e3b8460 100644
--- a/src/video/cocoa/SDL_cocoakeyboard.h
+++ b/src/video/cocoa/SDL_cocoakeyboard.h
@@ -29,7 +29,7 @@ extern void Cocoa_QuitKeyboard(_THIS);
 
 extern void Cocoa_StartTextInput(_THIS);
 extern void Cocoa_StopTextInput(_THIS);
-extern void Cocoa_SetTextInputRect(_THIS, SDL_Rect *rect);
+extern void Cocoa_SetTextInputRect(_THIS, const SDL_Rect *rect);
 
 extern void Cocoa_SetWindowKeyboardGrab(_THIS, SDL_Window * window, SDL_bool grabbed);
 
diff --git a/src/video/cocoa/SDL_cocoakeyboard.m b/src/video/cocoa/SDL_cocoakeyboard.m
index 6e2250d..fd96ea3 100644
--- a/src/video/cocoa/SDL_cocoakeyboard.m
+++ b/src/video/cocoa/SDL_cocoakeyboard.m
@@ -40,12 +40,12 @@
     SDL_Rect  _inputRect;
 }
 - (void)doCommandBySelector:(SEL)myselector;
-- (void)setInputRect:(SDL_Rect *)rect;
+- (void)setInputRect:(const SDL_Rect *)rect;
 @end
 
 @implementation SDLTranslatorResponder
 
-- (void)setInputRect:(SDL_Rect *)rect
+- (void)setInputRect:(const SDL_Rect *)rect
 {
     _inputRect = *rect;
 }
@@ -514,7 +514,7 @@ Cocoa_StopTextInput(_THIS)
 }}
 
 void
-Cocoa_SetTextInputRect(_THIS, SDL_Rect *rect)
+Cocoa_SetTextInputRect(_THIS, const SDL_Rect *rect)
 {
     SDL_VideoData *data = (__bridge SDL_VideoData *) _this->driverdata;
 
diff --git a/src/video/uikit/SDL_uikitviewcontroller.h b/src/video/uikit/SDL_uikitviewcontroller.h
index cff5445..2e64a52 100644
--- a/src/video/uikit/SDL_uikitviewcontroller.h
+++ b/src/video/uikit/SDL_uikitviewcontroller.h
@@ -87,5 +87,5 @@ SDL_bool UIKit_HasScreenKeyboardSupport(_THIS);
 void UIKit_ShowScreenKeyboard(_THIS, SDL_Window *window);
 void UIKit_HideScreenKeyboard(_THIS, SDL_Window *window);
 SDL_bool UIKit_IsScreenKeyboardShown(_THIS, SDL_Window *window);
-void UIKit_SetTextInputRect(_THIS, SDL_Rect *rect);
+void UIKit_SetTextInputRect(_THIS, const SDL_Rect *rect);
 #endif
diff --git a/src/video/uikit/SDL_uikitviewcontroller.m b/src/video/uikit/SDL_uikitviewcontroller.m
index 23a504c..d0dd863 100644
--- a/src/video/uikit/SDL_uikitviewcontroller.m
+++ b/src/video/uikit/SDL_uikitviewcontroller.m
@@ -547,7 +547,7 @@ UIKit_IsScreenKeyboardShown(_THIS, SDL_Window *window)
 }
 
 void
-UIKit_SetTextInputRect(_THIS, SDL_Rect *rect)
+UIKit_SetTextInputRect(_THIS, const SDL_Rect *rect)
 {
     if (!rect) {
         SDL_InvalidParamError("rect");
diff --git a/src/video/wayland/SDL_waylandkeyboard.c b/src/video/wayland/SDL_waylandkeyboard.c
index 8f293a5..8fcf678 100644
--- a/src/video/wayland/SDL_waylandkeyboard.c
+++ b/src/video/wayland/SDL_waylandkeyboard.c
@@ -108,7 +108,7 @@ Wayland_StopTextInput(_THIS)
 }
 
 void
-Wayland_SetTextInputRect(_THIS, SDL_Rect *rect)
+Wayland_SetTextInputRect(_THIS, const SDL_Rect *rect)
 {
     SDL_VideoData *driverdata = _this->driverdata;
 
diff --git a/src/video/wayland/SDL_waylandkeyboard.h b/src/video/wayland/SDL_waylandkeyboard.h
index 604e0f3..5909a24 100644
--- a/src/video/wayland/SDL_waylandkeyboard.h
+++ b/src/video/wayland/SDL_waylandkeyboard.h
@@ -34,7 +34,7 @@ extern int Wayland_InitKeyboard(_THIS);
 extern void Wayland_QuitKeyboard(_THIS);
 extern void Wayland_StartTextInput(_THIS);
 extern void Wayland_StopTextInput(_THIS);
-extern void Wayland_SetTextInputRect(_THIS, SDL_Rect *rect);
+extern void Wayland_SetTextInputRect(_THIS, const SDL_Rect *rect);
 extern SDL_bool Wayland_HasScreenKeyboardSupport(_THIS);
 
 #endif /* SDL_waylandkeyboard_h_ */
diff --git a/src/video/windows/SDL_windowskeyboard.c b/src/video/windows/SDL_windowskeyboard.c
index e447a4a..ac17fdf 100644
--- a/src/video/windows/SDL_windowskeyboard.c
+++ b/src/video/windows/SDL_windowskeyboard.c
@@ -235,7 +235,7 @@ WIN_StopTextInput(_THIS)
 }
 
 void
-WIN_SetTextInputRect(_THIS, SDL_Rect *rect)
+WIN_SetTextInputRect(_THIS, const SDL_Rect *rect)
 {
     SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;
     HIMC himc = 0;
diff --git a/src/video/windows/SDL_windowskeyboard.h b/src/video/windows/SDL_windowskeyboard.h
index 97382c7..57c4ffa 100644
--- a/src/video/windows/SDL_windowskeyboard.h
+++ b/src/video/windows/SDL_windowskeyboard.h
@@ -31,7 +31,7 @@ extern void WIN_ResetDeadKeys(void);
 
 extern void WIN_StartTextInput(_THIS);
 extern void WIN_StopTextInput(_THIS);
-extern void WIN_SetTextInputRect(_THIS, SDL_Rect *rect);
+extern void WIN_SetTextInputRect(_THIS, const SDL_Rect *rect);
 extern void WIN_ClearComposition(_THIS);
 extern SDL_bool WIN_IsTextInputShown(_THIS);
 
diff --git a/src/video/x11/SDL_x11keyboard.c b/src/video/x11/SDL_x11keyboard.c
index 9d9f3f9..6da6c7d 100644
--- a/src/video/x11/SDL_x11keyboard.c
+++ b/src/video/x11/SDL_x11keyboard.c
@@ -526,7 +526,7 @@ X11_StopTextInput(_THIS)
 }
 
 void
-X11_SetTextInputRect(_THIS, SDL_Rect *rect)
+X11_SetTextInputRect(_THIS, const SDL_Rect *rect)
 {
     if (!rect) {
         SDL_InvalidParamError("rect");
diff --git a/src/video/x11/SDL_x11keyboard.h b/src/video/x11/SDL_x11keyboard.h
index dacaf7e..9e20ae1 100644
--- a/src/video/x11/SDL_x11keyboard.h
+++ b/src/video/x11/SDL_x11keyboard.h
@@ -28,7 +28,7 @@ extern void X11_UpdateKeymap(_THIS);
 extern void X11_QuitKeyboard(_THIS);
 extern void X11_StartTextInput(_THIS);
 extern void X11_StopTextInput(_THIS);
-extern void X11_SetTextInputRect(_THIS, SDL_Rect *rect);
+extern void X11_SetTextInputRect(_THIS, const SDL_Rect *rect);
 extern KeySym X11_KeyCodeToSym(_THIS, KeyCode, unsigned char group);
 
 #endif /* SDL_x11keyboard_h_ */