[gtk/better-dead-keys: 2/5] imcontext: Improve dead key handling more
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/better-dead-keys: 2/5] imcontext: Improve dead key handling more
- Date: Mon, 22 Mar 2021 01:38:15 +0000 (UTC)
commit 5b38ef33ffe4aebf958a175728f119068ffbd444
Author: Matthias Clasen <mclasen redhat com>
Date: Sun Mar 21 18:51:57 2021 -0400
imcontext: Improve dead key handling more
For sequences like ``, we want to commit the first
deadkey and then continue preedit with the second.
The alternative is to do chained deadkeys, where
entering ~~a yields ̃̀̃̃a. But we don't do that, and
I think that would be more controversial.
gtk/gtkimcontextsimple.c | 35 ++++++++++++++++++++++++++++++++++-
1 file changed, 34 insertions(+), 1 deletion(-)
---
diff --git a/gtk/gtkimcontextsimple.c b/gtk/gtkimcontextsimple.c
index 3e19deb4d8..9c1024e0c3 100644
--- a/gtk/gtkimcontextsimple.c
+++ b/gtk/gtkimcontextsimple.c
@@ -565,7 +565,7 @@ no_sequence_matches (GtkIMContextSimple *context_simple,
{
keyval = gdk_key_event_get_keyval (event);
- if (n_compose == 2 && is_?ead_key (priv->compose_buffer[0]))
+ if (n_compose == 2 && is_dead_key (priv->compose_buffer[0]))
{
gboolean need_space;
GString *s;
@@ -922,6 +922,39 @@ gtk_im_context_simple_filter_keypress (GtkIMContext *context,
output = g_string_new ("");
+ if (n_compose == 2)
+ {
+ /* Special-case deadkey-deadkey sequences.
+ * We are not doing chained deadkeys, so we
+ * want to commit the first key, and contine
+ * preediting with second.
+ */
+ if (is_dead_key (priv->compose_buffer[0]) &&
+ is_dead_key (priv->compose_buffer[1]))
+ {
+ gunichar ch;
+ gboolean need_space;
+ guint next;
+
+ next = priv->compose_buffer[1];
+
+ ch = dead_key_to_unicode (priv->compose_buffer[0], &need_space);
+ if (ch)
+ {
+ if (need_space)
+ g_string_append_c (output, ' ');
+ g_string_append_unichar (output, ch);
+
+ gtk_im_context_simple_commit_string (context_simple, output->str);
+ g_string_set_size (output, 0);
+
+ priv->compose_buffer[0] = next;
+ priv->compose_buffer[1] = 0;
+ n_compose = 1;
+ }
+ }
+ }
+
G_LOCK (global_tables);
tmp_list = global_tables;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]