[gtk/gtk-3-24.win.updated] gtkimcontextime.c: Fix Korean input
- From: Chun-wei Fan <fanchunwei src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/gtk-3-24.win.updated] gtkimcontextime.c: Fix Korean input
- Date: Fri, 28 Sep 2018 11:07:35 +0000 (UTC)
commit 9332a4346e4935b5ee99e113f7c99b8a11c2f67a
Author: Chun-wei Fan <fanchunwei src gnome org>
Date: Tue Sep 25 16:50:36 2018 +0800
gtkimcontextime.c: Fix Korean input
Commit c255ba68 inadvertently introduced a regression that broke Korean
text input because the changes there resulted that only the last input
string that we have from ImmGetCompositionStringW() for each time the
commit signal is emitted is kept, and also as a result the final Korean
character that is input by hitting space is also lost as a result, as we
didn't check for whether we are done with preediting.
Fix these issues by doing the following when we receive the
WM_IME_COMPOSITION message with GCS_RESULTSTR from Windows:
-Append to the string to commit, rather than replacing that string, if
that string already has something in it (i.e. we did not receive the
WM_IME_ENDCOMPOSITION from Windows IME yet).
-Emit the commit signal immediately if we are already done with
preediting, without waiting for the WM_IME_ENDCOMPOSITION message.
Fixes issue #1350.
modules/input/gtkimcontextime.c | 40 +++++++++++++++++++++++++++++++++-------
1 file changed, 33 insertions(+), 7 deletions(-)
---
diff --git a/modules/input/gtkimcontextime.c b/modules/input/gtkimcontextime.c
index c6ce515129..b73d9f7c01 100644
--- a/modules/input/gtkimcontextime.c
+++ b/modules/input/gtkimcontextime.c
@@ -997,6 +997,18 @@ ERROR_OUT:
ImmReleaseContext (hwnd, himc);
}
+static void
+gtk_im_context_ime_commit_input_string (GtkIMContext *context)
+{
+ GtkIMContextIME *context_ime = GTK_IM_CONTEXT_IME (context);
+
+ if (context_ime->commit_string == NULL)
+ return;
+
+ g_signal_emit_by_name (context, "commit", context_ime->commit_string);
+ g_free (context_ime->commit_string);
+ context_ime->commit_string = NULL;
+}
static GdkFilterReturn
gtk_im_context_ime_message_filter (GdkXEvent *xevent,
@@ -1069,12 +1081,30 @@ gtk_im_context_ime_message_filter (GdkXEvent *xevent,
gpointer buf = g_alloca (len);
ImmGetCompositionStringW (himc, GCS_RESULTSTR, buf, len);
len /= 2;
- context_ime->commit_string = g_utf16_to_utf8 (buf, len, NULL, NULL, &error);
+ if (context_ime->commit_string == NULL)
+ context_ime->commit_string = g_utf16_to_utf8 (buf, len, NULL, NULL, &error);
+ else
+ {
+ gchar *tmp_commit_string = g_strdup (context_ime->commit_string);
+ gchar *utf8str = g_utf16_to_utf8 (buf, len, NULL, NULL, &error);
+
+ g_free (context_ime->commit_string);
+ context_ime->commit_string = g_strconcat (context_ime->commit_string, utf8str, NULL);
+ g_free (tmp_commit_string);
+ g_free (utf8str);
+ }
+
if (error)
{
g_warning ("%s", error->message);
g_error_free (error);
}
+
+ if (!context_ime->preediting)
+ {
+ gtk_im_context_ime_commit_input_string (context);
+ retval = TRUE;
+ }
}
if (context_ime->commit_string)
@@ -1083,6 +1113,7 @@ gtk_im_context_ime_message_filter (GdkXEvent *xevent,
if (context_ime->use_preedit)
retval = TRUE;
+
break;
}
@@ -1099,12 +1130,7 @@ gtk_im_context_ime_message_filter (GdkXEvent *xevent,
g_signal_emit_by_name (context, "preedit-changed");
g_signal_emit_by_name (context, "preedit-end");
- if (context_ime->commit_string)
- {
- g_signal_emit_by_name (context, "commit", context_ime->commit_string);
- g_free (context_ime->commit_string);
- context_ime->commit_string = NULL;
- }
+ gtk_im_context_ime_commit_input_string (context);
if (context_ime->use_preedit)
retval = TRUE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]