From bbc36448fb2df1766499346f3268a247063d3366 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Mon, 2 Aug 2021 19:15:16 -0400 Subject: [PATCH] imcontext: Treat keysyms as 32bit values Our compose table format is still limited to 16bit values for keysyms, but what we see in key events can be 32bit values, and we treat them as such now. Fixes: #4149 --- gtk/gtkcomposetable.c | 22 +++++++++++----------- gtk/gtkcomposetable.h | 6 +++--- gtk/gtkimcontextsimple.c | 14 +++++++------- testsuite/gtk/composetable.c | 6 +++--- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/gtk/gtkcomposetable.c b/gtk/gtkcomposetable.c index 464bf1876a..6495163d88 100644 --- a/gtk/gtkcomposetable.c +++ b/gtk/gtkcomposetable.c @@ -493,7 +493,7 @@ parser_remove_duplicates (GtkComposeParser *parser) g_hash_table_iter_init (&iter, parser->sequences); while (g_hash_table_iter_next (&iter, (gpointer *)&sequence, (gpointer *)&value)) { - static guint16 keysyms[MAX_COMPOSE_LEN + 1]; + static guint keysyms[MAX_COMPOSE_LEN + 1]; int i; int n_compose = 0; gboolean remove_sequence = FALSE; @@ -515,8 +515,8 @@ parser_remove_duplicates (GtkComposeParser *parser) for (i = 0; i < MAX_COMPOSE_LEN + 1; i++) { - gunichar codepoint = sequence[i]; - keysyms[i] = (guint16) codepoint; + guint codepoint = sequence[i]; + keysyms[i] = codepoint; if (codepoint == 0) break; @@ -1217,7 +1217,7 @@ static int compare_seq (const void *key, const void *value) { int i = 0; - const guint16 *keysyms = key; + const guint *keysyms = key; const guint16 *seq = value; while (keysyms[i]) @@ -1236,7 +1236,7 @@ compare_seq (const void *key, const void *value) static int compare_seq_index (const void *key, const void *value) { - const guint16 *keysyms = key; + const guint *keysyms = key; const guint16 *seq = value; if (keysyms[0] < seq[0]) @@ -1262,7 +1262,7 @@ compare_seq_index (const void *key, const void *value) */ gboolean gtk_compose_table_check (const GtkComposeTable *table, - const guint16 *compose_buffer, + const guint *compose_buffer, int n_compose, gboolean *compose_finish, gboolean *compose_match, @@ -1356,7 +1356,7 @@ gtk_compose_table_check (const GtkComposeTable *table, void gtk_compose_table_get_prefix (const GtkComposeTable *table, - const guint16 *compose_buffer, + const guint *compose_buffer, int n_compose, int *prefix) { @@ -1381,7 +1381,7 @@ gtk_compose_table_get_prefix (const GtkComposeTable *table, for (k = 0; k < MIN (len, n_compose) - 1; k++) { - if (compose_buffer[k + 1] != (gunichar) table->data[j + k]) + if (compose_buffer[k + 1] != table->data[j + k]) break; } p = MAX (p, k + 1); @@ -1463,9 +1463,9 @@ gtk_compose_table_foreach (const GtkComposeTable *table, ((k) >= GDK_KEY_dead_grave && (k) <= GDK_KEY_dead_greek) gboolean -gtk_check_algorithmically (const guint16 *compose_buffer, - int n_compose, - GString *output) +gtk_check_algorithmically (const guint *compose_buffer, + int n_compose, + GString *output) { int i; diff --git a/gtk/gtkcomposetable.h b/gtk/gtkcomposetable.h index 584849f747..d64071d199 100644 --- a/gtk/gtkcomposetable.h +++ b/gtk/gtkcomposetable.h @@ -74,18 +74,18 @@ void gtk_compose_table_foreach (const GtkComposeTable *table, gpointer data); gboolean gtk_compose_table_check (const GtkComposeTable *table, - const guint16 *compose_buffer, + const guint *compose_buffer, int n_compose, gboolean *compose_finish, gboolean *compose_match, GString *output); void gtk_compose_table_get_prefix (const GtkComposeTable *table, - const guint16 *compose_buffer, + const guint *compose_buffer, int n_compose, int *prefix); -gboolean gtk_check_algorithmically (const guint16 *compose_buffer, +gboolean gtk_check_algorithmically (const guint *compose_buffer, int n_compose, GString *output); diff --git a/gtk/gtkimcontextsimple.c b/gtk/gtkimcontextsimple.c index cdba288c0b..4da14cbb9d 100644 --- a/gtk/gtkimcontextsimple.c +++ b/gtk/gtkimcontextsimple.c @@ -79,7 +79,7 @@ struct _GtkIMContextSimplePrivate { - guint16 *compose_buffer; + guint *compose_buffer; int compose_buffer_len; GString *tentative_match; int tentative_match_len; @@ -118,7 +118,7 @@ init_builtin_table (void) G_LOCK_DEFINE_STATIC (global_tables); static GSList *global_tables; -static const guint16 gtk_compose_ignore[] = { +static const guint gtk_compose_ignore[] = { 0, /* Yes, XKB will send us key press events with NoSymbol :( */ GDK_KEY_Overlay1_Enable, GDK_KEY_Overlay2_Enable, @@ -384,7 +384,7 @@ gtk_im_context_simple_init (GtkIMContextSimple *context_simple) priv = context_simple->priv = gtk_im_context_simple_get_instance_private (context_simple); priv->compose_buffer_len = builtin_compose_table.max_seq_len + 1; - priv->compose_buffer = g_new0 (guint16, priv->compose_buffer_len); + priv->compose_buffer = g_new0 (guint, priv->compose_buffer_len); priv->tentative_match = g_string_new (""); priv->tentative_match_len = 0; } @@ -635,12 +635,12 @@ no_sequence_matches (GtkIMContextSimple *context_simple, { int len = priv->tentative_match_len; int i; - guint16 *compose_buffer; + guint *compose_buffer; char *str; - compose_buffer = alloca (sizeof (guint16) * priv->compose_buffer_len); + compose_buffer = alloca (sizeof (guint) * priv->compose_buffer_len); - memcpy (compose_buffer, priv->compose_buffer, sizeof (guint16) * priv->compose_buffer_len); + memcpy (compose_buffer, priv->compose_buffer, sizeof (guint) * priv->compose_buffer_len); str = g_strdup (priv->tentative_match->str); gtk_im_context_simple_commit_string (context_simple, str); @@ -1015,7 +1015,7 @@ gtk_im_context_simple_filter_keypress (GtkIMContext *context, if (n_compose + 1 == priv->compose_buffer_len) { priv->compose_buffer_len += 1; - priv->compose_buffer = g_renew (guint16, priv->compose_buffer, priv->compose_buffer_len); + priv->compose_buffer = g_renew (guint, priv->compose_buffer, priv->compose_buffer_len); } priv->compose_buffer[n_compose++] = keyval; diff --git a/testsuite/gtk/composetable.c b/testsuite/gtk/composetable.c index dec41af467..564416ceb8 100644 --- a/testsuite/gtk/composetable.c +++ b/testsuite/gtk/composetable.c @@ -171,7 +171,7 @@ compose_table_match (void) { GtkComposeTable *table; char *file; - guint16 buffer[8] = { 0, }; + guint buffer[8] = { 0, }; gboolean finish, match, ret; GString *output; @@ -240,7 +240,7 @@ static void compose_table_match_builtin (void) { const GtkComposeTable *table = &builtin_compose_table; - guint16 buffer[8] = { 0, }; + guint buffer[8] = { 0, }; gboolean finish, match, ret; GString *s; @@ -308,7 +308,7 @@ compose_table_match_builtin (void) static void match_algorithmic (void) { - guint16 buffer[8] = { 0, }; + guint buffer[8] = { 0, }; gboolean ret; GString *output;