178a48b8889cccf1a09bac8b6d06c9decad16cfa
[mono.git] / bockbuild / mac-sdk / patches / gtk / bgo702841-fix-kana-eisu-keys.patch
1 From b93535cc5d60149edc3a45d5b7f31f62a80234bf Mon Sep 17 00:00:00 2001
2 From: Takuro Ashie <ashie@clear-code.com>
3 Date: Fri, 21 Jun 2013 21:29:14 +0900
4 Subject: [PATCH] Quartz: translate JIS Hiragana & Eisu keys.
5
6 Since UCKeyTranslate() converts these keys to Space key unexpectedly,
7 applications can't distinguish these keys by keysyms.
8 To solve it, this fix translates these keys by same way with function
9 keys & keypad keys.
10 ---
11  gdk/quartz/gdkkeys-quartz.c | 31 +++++++++++++++++++++++++++++++
12  1 file changed, 31 insertions(+)
13
14 diff --git a/gdk/quartz/gdkkeys-quartz.c b/gdk/quartz/gdkkeys-quartz.c
15 index a4df2cf..fb11c33 100644
16 --- a/gdk/quartz/gdkkeys-quartz.c
17 +++ b/gdk/quartz/gdkkeys-quartz.c
18 @@ -191,6 +191,29 @@ const static struct {
19    { 92, GDK_KEY_9, GDK_KEY_KP_9 }
20  };
21
22 +/* Keys only in JIS layout.
23 + * The rationale of these key codes is <HIToolbox/Events.h> in Carbon.
24 + */
25 +const static struct {
26 +  guint keycode;
27 +  guint keyval;
28 +} jis_keys[] = {
29 +#if 0
30 +  /* Although These keys are also defined in <HIToolbox/Events.h>, they can be
31 +   * translated by UCKeyTranslate correctly.
32 +   */
33 +  { 0x5D, GDK_KEY_yen },
34 +  { 0x5E, GDK_KEY_underscore },
35 +  { 0x5F, GDK_KEY_comma },
36 +#endif
37 +  /* These keys are unexpectedly translated to Space key by UCKeyTranslate,
38 +   * and there is no suitable ucs value for them to add to special_ucs_table.
39 +   * So we should translate them particularly.
40 +   */
41 +  { 0x66 /* 102 */, GDK_KEY_Eisu_toggle },
42 +  { 0x68 /* 104 */, GDK_KEY_Hiragana }
43 +};
44 +
45  /* These values aren't covered by gdk_unicode_to_keyval */
46  const static struct {
47    gunichar ucs_value;
48 @@ -498,6 +521,14 @@ maybe_update_keymap (void)
49           if (p[0] == known_numeric_keys[i].normal_keyval)
50              p[0] = known_numeric_keys[i].keypad_keyval;
51         }
52 +
53 +      for (i = 0; i < G_N_ELEMENTS (jis_keys); i++)
54 +       {
55 +         p = keyval_array + jis_keys[i].keycode * KEYVALS_PER_KEYCODE;
56 +
57 +          p[0] = jis_keys[i].keyval;
58 +          p[1] = p[2] = p[3] = 0;
59 +       }
60
61        if (current_layout)
62         g_signal_emit_by_name (default_keymap, "keys_changed");
63 --
64 1.7.12.4 (Apple Git-37)