From: Matthias Clasen Date: Thu, 29 Jul 2021 12:24:14 +0000 (-0400) Subject: imcontext: Tweak Compose sequence handling X-Git-Tag: archive/raspbian/4.4.1+ds1-2+rpi1^2~18^2~1^2~43^2~4 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=76d67b586c5dc2b19ee4072284fa4fb7f74b01f3;p=gtk4.git imcontext: Tweak Compose sequence handling When we don't have any matches for a Compose sequence anymore, beep, and keep the preedit as it was for the last match. Fixes: #4127 --- diff --git a/gtk/gtkimcontextsimple.c b/gtk/gtkimcontextsimple.c index f193eb48e3..71f9094aee 100644 --- a/gtk/gtkimcontextsimple.c +++ b/gtk/gtkimcontextsimple.c @@ -622,7 +622,7 @@ no_sequence_matches (GtkIMContextSimple *context_simple, guint keyval; context = GTK_IM_CONTEXT (context_simple); - + priv->in_compose_sequence = FALSE; /* No compose sequences found, check first if we have a partial @@ -1071,6 +1071,7 @@ gtk_im_context_simple_filter_keypress (GtkIMContext *context, else /* Then, check for compose sequences */ { gboolean success = FALSE; + int prefix = 0; GString *output; output = g_string_new (""); @@ -1109,6 +1110,16 @@ gtk_im_context_simple_filter_keypress (GtkIMContext *context, success = TRUE; break; } + else + { + int table_prefix; + + gtk_compose_table_get_prefix ((GtkComposeTable *)tmp_list->data, + priv->compose_buffer, n_compose, + &table_prefix); + + prefix = MAX (prefix, table_prefix); + } tmp_list = tmp_list->next; } @@ -1135,6 +1146,21 @@ gtk_im_context_simple_filter_keypress (GtkIMContext *context, return TRUE; } + + /* If we get here, no Compose sequence matched. + * Only beep if we were in a sequence before. + */ + if (prefix > 0) + { + for (i = prefix; i < n_compose; i++) + priv->compose_buffer[i] = 0; + + beep_surface (gdk_event_get_surface (event)); + + g_signal_emit_by_name (context_simple, "preedit-changed"); + + return TRUE; + } } /* The current compose_buffer doesn't match anything */