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
This commit is contained in:
Matthias Clasen 2021-07-29 08:24:14 -04:00
parent 914edb1472
commit 76d67b586c

View File

@ -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 */