Ticket #68017: gtk3_gdkkeys.patch

File gtk3_gdkkeys.patch, 3.9 KB (added by rmottola (Riccardo), 7 months ago)

remove 32bit codepath broken on 10.6

  • gdk/quartz/gdkkeys-quartz.c

    old new  
    237237   * bad regression. This way, old unsupported layouts will just not work in
    238238   * 64-bit.
    239239   */
    240 #ifdef __LP64__
    241240  TISInputSourceRef new_layout = TISCopyCurrentKeyboardLayoutInputSource ();
    242241  CFDataRef layout_data_ref;
    243242
    244 #else
    245   KeyboardLayoutRef new_layout;
    246   KeyboardLayoutKind layout_kind;
    247 
    248   KLGetCurrentKeyboardLayout (&new_layout);
    249 #endif
    250 
    251243  g_free (keyval_array);
    252244  keyval_array = g_new0 (guint, NUM_KEYCODES * KEYVALS_PER_KEYCODE);
    253245
    254 #ifdef __LP64__
    255246  layout_data_ref = (CFDataRef) TISGetInputSourceProperty
    256247    (new_layout, kTISPropertyUnicodeKeyLayoutData);
    257248
     
    263254      g_error ("cannot get keyboard layout data");
    264255      return;
    265256    }
    266 #else
    267 
    268   /* Get the layout kind */
    269   KLGetKeyboardLayoutProperty (new_layout, kKLKind, (const void **)&layout_kind);
    270 
    271   /* 8-bit-only keyabord layout */
    272   if (layout_kind == kKLKCHRKind)
    273     {
    274       /* Get chr data */
    275       KLGetKeyboardLayoutProperty (new_layout, kKLKCHRData, (const void **)&chr_data);
    276 
    277       for (i = 0; i < NUM_KEYCODES; i++)
    278         {
    279           int j;
    280           UInt32 modifiers[] = {0, shiftKey, optionKey, shiftKey | optionKey};
    281 
    282           p = keyval_array + i * KEYVALS_PER_KEYCODE;
    283 
    284           for (j = 0; j < KEYVALS_PER_KEYCODE; j++)
    285             {
    286               UInt32 c, state = 0;
    287               UInt16 key_code;
    288               UniChar uc;
    289 
    290               key_code = modifiers[j] | i;
    291               c = KeyTranslate (chr_data, key_code, &state);
    292 
    293               if (state != 0)
    294                 {
    295                   UInt32 state2 = 0;
    296                   c = KeyTranslate (chr_data, key_code | 128, &state2);
    297                 }
    298 
    299               if (c != 0 && c != 0x10)
    300                 {
    301                   int k;
    302                   gboolean found = FALSE;
    303 
    304                   /* FIXME: some keyboard layouts (e.g. Russian) use a
    305                    * different 8-bit character set. We should check
    306                    * for this. Not a serious problem, because most
    307                    * (all?) of these layouts also have a uchr version.
    308                    */
    309                   uc = macroman2ucs (c);
    310 
    311                   for (k = 0; k < G_N_ELEMENTS (special_ucs_table); k++)
    312                     {
    313                       if (special_ucs_table[k].ucs_value == uc)
    314                         {
    315                           p[j] = special_ucs_table[k].keyval;
    316                           found = TRUE;
    317                           break;
    318                         }
    319                     }
    320 
    321                   /* Special-case shift-tab since GTK+ expects
    322                    * GDK_KEY_ISO_Left_Tab for that.
    323                    */
    324                   if (found && p[j] == GDK_KEY_Tab && modifiers[j] == shiftKey)
    325                     p[j] = GDK_KEY_ISO_Left_Tab;
    326 
    327                   if (!found)
    328                     p[j] = gdk_unicode_to_keyval (uc);
    329                 }
    330             }
    331 
    332           if (p[3] == p[2])
    333             p[3] = 0;
    334           if (p[2] == p[1])
    335             p[2] = 0;
    336           if (p[1] == p[0])
    337             p[1] = 0;
    338           if (p[0] == p[2] &&
    339               p[1] == p[3])
    340             p[2] = p[3] = 0;
    341         }
    342     }
    343   /* unicode keyboard layout */
    344   else if (layout_kind == kKLKCHRuchrKind || layout_kind == kKLuchrKind)
    345     {
    346       /* Get chr data */
    347       KLGetKeyboardLayoutProperty (new_layout, kKLuchrData, (const void **)&chr_data);
    348 #endif
    349257
    350258      for (i = 0; i < NUM_KEYCODES; i++)
    351259        {
     
    428336              p[1] == p[3])
    429337            p[2] = p[3] = 0;
    430338        }
    431 #ifndef __LP64__
    432     }
    433   else
    434     {
    435       g_error ("unknown type of keyboard layout (neither KCHR nor uchr)"
    436                " - not supported right now");
    437     }
    438 #endif
    439339
    440340  for (i = 0; i < G_N_ELEMENTS (modifier_keys); i++)
    441341    {