Index: gtk/gtkimcontextsimple.c
===================================================================
--- gtk/gtkimcontextsimple.c	(revision 21787)
+++ gtk/gtkimcontextsimple.c	(working copy)
@@ -271,9 +271,9 @@
 }
 
 static gboolean
-check_compact_table (GtkIMContextSimple    *context_simple,
-	     const GtkComposeTableCompact *table,
-	     gint                   n_compose)
+check_compact_table_impl (GtkIMContextSimple           *context_simple,
+	                  const GtkComposeTableCompact *table,
+	                  gint                          n_compose)
 {
   gint row_stride;
   guint16 *seq_index;
@@ -287,9 +287,9 @@
     return FALSE;
   
   seq_index = bsearch (context_simple->compose_buffer,
-		 table->data, table->n_index_size,
-		 sizeof (guint16) *  table->n_index_stride, 
-		 compare_seq_index);
+		       table->data, table->n_index_size,
+		       sizeof (guint16) * table->n_index_stride, 
+		       compare_seq_index);
 
   if (!seq_index)
     return FALSE;
@@ -306,9 +306,9 @@
       if (seq_index[i+1] - seq_index[i] > 0)
         {
 	  seq = bsearch (context_simple->compose_buffer + 1,
-		 table->data + seq_index[i], (seq_index[i+1] - seq_index[i]) / row_stride,
-		 sizeof (guint16) *  row_stride, 
-		 compare_seq);
+		         table->data + seq_index[i], (seq_index[i+1] - seq_index[i]) / row_stride,
+		         sizeof (guint16) *  row_stride, 
+		         compare_seq);
 
 	  if (seq)
             {
@@ -340,6 +340,42 @@
   return FALSE;
 }
 
+static gboolean
+check_compact_table (GtkIMContextSimple           *context_simple,
+	             const GtkComposeTableCompact *table,
+	             gint                          n_compose)
+{
+  gint i;
+
+  /* Will never match, if the sequence in the compose buffer is longer
+   * than the sequences in the table.  Further, compare_seq (key, val)
+   * will overrun val if key is longer than val. */
+  if (n_compose > table->max_seq_len)
+    return FALSE;
+
+  if (check_compact_table_impl (context_simple, table, n_compose))
+    return TRUE;
+
+  if (n_compose == 3 &&
+      context_simple->compose_buffer[0] == GDK_Multi_key)
+    {
+       guint key;
+
+       key = context_simple->compose_buffer[1];
+       context_simple->compose_buffer[1] = context_simple->compose_buffer[2];
+       context_simple->compose_buffer[2] = key;
+  
+       if (check_compact_table_impl (context_simple, table, n_compose))
+         return TRUE;
+
+       key = context_simple->compose_buffer[1];
+       context_simple->compose_buffer[1] = context_simple->compose_buffer[2];
+       context_simple->compose_buffer[2] = key;
+    }
+
+  return FALSE;
+}
+  
 /* This function receives a sequence of Unicode characters and tries to
  * normalize it (NFC). We check for the case the the resulting string
  * has length 1 (single character).
