Skip to content

Commit

Permalink
[ibus] Send an empty TextEditing event when the text is cleared by pr…
Browse files Browse the repository at this point in the history
…essing backspace.
  • Loading branch information
baines committed Feb 1, 2015
1 parent 21d0cde commit 42d9cf6
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/core/linux/SDL_ibus.c
Expand Up @@ -156,20 +156,20 @@ IBus_MessageFilter(DBusConnection *conn, DBusMessage *msg, void *user_data)
dbus->message_iter_init(msg, &iter);
text = IBus_GetVariantText(conn, &iter, dbus);

if (text && *text) {
if (text) {
char buf[SDL_TEXTEDITINGEVENT_TEXT_SIZE];
size_t text_bytes = SDL_strlen(text), i = 0;
size_t cursor = 0;

while (i < text_bytes) {
do {
size_t sz = SDL_utf8strlcpy(buf, text+i, sizeof(buf));
size_t chars = IBus_utf8_strlen(buf);

SDL_SendEditingText(buf, cursor, chars);

i += sz;
cursor += chars;
}
} while (i < text_bytes);
}

SDL_IBus_UpdateTextRect(NULL);
Expand Down

0 comments on commit 42d9cf6

Please sign in to comment.