Removed SDL_TEXTINPUTEVENT_TEXT_SIZE

This commit is contained in:
Sam Lantinga
2024-03-25 12:55:49 -07:00
parent fa236f169b
commit 6443c75eda
8 changed files with 14 additions and 37 deletions

View File

@@ -310,7 +310,7 @@ class SDL_BLooper : public BLooper
const int8 *keyUtf8;
ssize_t count;
if (msg->FindData("key-utf8", B_INT8_TYPE, (const void **)&keyUtf8, &count) == B_OK) {
char text[SDL_TEXTINPUTEVENT_TEXT_SIZE];
char text[64];
SDL_zeroa(text);
SDL_memcpy(text, keyUtf8, count);
SDL_SendKeyboardText(text);

View File

@@ -191,17 +191,7 @@ static DBusHandlerResult DBus_MessageFilter(DBusConnection *conn, DBusMessage *m
dbus->message_iter_init(msg, &iter);
dbus->message_iter_get_basic(&iter, &text);
if (text && *text) {
char buf[SDL_TEXTINPUTEVENT_TEXT_SIZE];
size_t text_bytes = SDL_strlen(text), i = 0;
while (i < text_bytes) {
size_t sz = SDL_utf8strlcpy(buf, text + i, sizeof(buf));
SDL_SendKeyboardText(buf);
i += sz;
}
}
SDL_SendKeyboardText(text);
return DBUS_HANDLER_RESULT_HANDLED;
}

View File

@@ -228,17 +228,7 @@ static DBusHandlerResult IBus_MessageHandler(DBusConnection *conn, DBusMessage *
dbus->message_iter_init(msg, &iter);
text = IBus_GetVariantText(conn, &iter, dbus);
if (text && *text) {
char buf[SDL_TEXTINPUTEVENT_TEXT_SIZE];
size_t text_bytes = SDL_strlen(text), i = 0;
while (i < text_bytes) {
size_t sz = SDL_utf8strlcpy(buf, text + i, sizeof(buf));
SDL_SendKeyboardText(buf);
i += sz;
}
}
SDL_SendKeyboardText(text);
return DBUS_HANDLER_RESULT_HANDLED;
}

View File

@@ -1184,6 +1184,10 @@ int SDL_SendKeyboardText(const char *text)
return 0;
}
if (!text || !*text) {
return 0;
}
/* Don't post text events for unprintable characters */
if (SDL_iscntrl((unsigned char)*text)) {
return 0;
@@ -1218,6 +1222,10 @@ int SDL_SendEditingText(const char *text, int start, int length)
return 0;
}
if (!text) {
return 0;
}
/* Post the event, if desired */
posted = 0;
if (SDL_EventEnabled(SDL_EVENT_TEXT_EDITING)) {

View File

@@ -2320,17 +2320,7 @@ static void text_input_commit_string(void *data,
struct zwp_text_input_v3 *zwp_text_input_v3,
const char *text)
{
if (text && *text) {
char buf[SDL_TEXTINPUTEVENT_TEXT_SIZE];
size_t text_bytes = SDL_strlen(text), i = 0;
while (i < text_bytes) {
size_t sz = SDL_utf8strlcpy(buf, text + i, sizeof(buf));
SDL_SendKeyboardText(buf);
i += sz;
}
}
SDL_SendKeyboardText(text);
}
static void text_input_delete_surrounding_text(void *data,

View File

@@ -838,7 +838,7 @@ void X11_HandleKeyEvent(SDL_VideoDevice *_this, SDL_WindowData *windowdata, SDL_
Display *display = videodata->display;
KeyCode keycode = xevent->xkey.keycode;
KeySym keysym = NoSymbol;
char text[SDL_TEXTINPUTEVENT_TEXT_SIZE];
char text[64];
Status status = 0;
SDL_bool handled_by_ime = SDL_FALSE;