The padding is in windows coordinates not pixels, so you need to convert for Android.

Default is now 10 window coordinates (slightly more than 15 pixels).
This commit is contained in:
DominusExult 2026-02-14 14:03:35 +01:00
parent d6ddc84e56
commit ac90fa0879
3 changed files with 12 additions and 9 deletions

View file

@ -1389,14 +1389,18 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
* method (soft keyboard)
*/
static int getPanPadding() {
/* The hint is in window coordinates. Convert to pixels by
* multiplying by density. */
int defaultPadding = 10;
try {
String hint = nativeGetHint("SDL_IME_PAN_PADDING");
if (hint != null) {
return Integer.parseInt(hint);
defaultPadding = Integer.parseInt(hint);
}
} catch (NumberFormatException ignored) {
}
return 15;
float density = getContext().getResources().getDisplayMetrics().density;
return (int)(defaultPadding * density);
}
public int input_type;

View file

@ -1227,8 +1227,10 @@ extern "C" {
* to ensure there is extra breathing room between the text input area and
* the top of the keyboard when panning the view.
*
* The variable can be set to a number representing the padding in pixels.
* The default value is "15".
* The variable can be set to a number representing the padding in window
* coordinates.
*
* The default value is "10".
*
* This hint can be set anytime.
*

View file

@ -642,12 +642,9 @@ static void SDLCALL SDL_HideHomeIndicatorHintChanged(void *userdata, const char
#endif
if (self.keyboardHeight && self.textInputRect.h) {
/* Get the pan padding from the hint (in pixels). The text input rect
* and view bounds are in UIKit points, so divide by the scale factor
* to keep the visual gap consistent across platforms.*/
/// Get the pan padding from the hint (in window coordinates).
const char *hint = SDL_GetHint(SDL_HINT_IME_PAN_PADDING);
int panPadding = (hint && *hint) ? SDL_atoi(hint) : 15;
int padding = (int)(panPadding / self.view.contentScaleFactor);
int padding = (hint && *hint) ? SDL_atoi(hint) : 10;
int rectbottom = (int)(self.textInputRect.y + self.textInputRect.h + padding);
int keybottom = (int)(self.view.bounds.size.height - self.keyboardHeight);
if (keybottom < rectbottom) {