imcontext: Treat keysyms as 32bit values
authorMatthias Clasen <mclasen@redhat.com>
Mon, 2 Aug 2021 23:15:16 +0000 (19:15 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Mon, 2 Aug 2021 23:16:18 +0000 (19:16 -0400)
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
gtk/gtkcomposetable.h
gtk/gtkimcontextsimple.c
testsuite/gtk/composetable.c

index 464bf1876aaece9362576d4e65d6ee66c86bb7b0..6495163d888d5447f60f7f0467492a7a0ee9f0bd 100644 (file)
@@ -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;
index 584849f74759fc4cc8300c4b8d31efe9c2659a72..d64071d19991af0552c492ecaae93d5675e70d8f 100644 (file)
@@ -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);
 
index cdba288c0b7067b346baa3905ca04abbfb14206e..4da14cbb9d26f257cace6c7b9351cd69f0a9968e 100644 (file)
@@ -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;
index dec41af467cf5df47b4cd9e4bb4017b6bde2394c..564416ceb8728e19b7e0488b6d43da3dbe722e81 100644 (file)
@@ -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;