[ibus] Send an empty TextEditing event when the text is cleared by pressing backspace.
authorAlex Baines <alex@abaines.me.uk>
Sun, 01 Feb 2015 21:08:54 +0000
changeset 9645 b1e7169d1dcb
parent 9644 2bd2c601df72
child 9646 9d4917e2d909
[ibus] Send an empty TextEditing event when the text is cleared by pressing backspace.
src/core/linux/SDL_ibus.c
--- a/src/core/linux/SDL_ibus.c	Tue May 26 20:55:03 2015 -0400
+++ b/src/core/linux/SDL_ibus.c	Sun Feb 01 21:08:54 2015 +0000
@@ -156,12 +156,12 @@
         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);
                 
@@ -169,7 +169,7 @@
 
                 i += sz;
                 cursor += chars;
-            }
+            } while (i < text_bytes);
         }
         
         SDL_IBus_UpdateTextRect(NULL);