ibus-m17n/ibus-m17n-fedora.patch

208 lines
6.7 KiB
Diff
Raw Normal View History

2010-10-14 03:30:14 +00:00
diff --git a/src/engine.c b/src/engine.c
index dbd00fc..1dbcf34 100644
--- a/src/engine.c
+++ b/src/engine.c
@@ -424,9 +424,9 @@ ibus_m17n_engine_commit_string (IBusM17NEngine *m17n,
ibus_m17n_engine_update_preedit (m17n);
}
-/* Note on AltGr handling: While currently we expect AltGr == mod5, it
- would be better to not expect the modifier always be assigned
- to particular modX. However, it needs some code like:
+/* Note on AltGr (Level3 Shift) handling: While currently we expect
+ AltGr == mod5, it would be better to not expect the modifier always
+ be assigned to particular modX. However, it needs some code like:
KeyCode altgr = XKeysymToKeycode (display, XK_ISO_Level3_Shift);
XModifierKeymap *mods = XGetModifierMapping (display);
@@ -448,20 +448,26 @@ ibus_m17n_key_event_to_symbol (guint keycode,
MSymbol mkeysym = Mnil;
guint mask = 0;
IBusKeymap *keymap;
- guint base_keyval;
if (keyval >= IBUS_Shift_L && keyval <= IBUS_Hyper_R) {
return Mnil;
}
- keymap = ibus_keymap_get ("us");
- base_keyval = ibus_keymap_lookup_keysym (keymap, keycode, 0);
- g_object_unref (keymap);
+ /* Here, keyval is already translated by IBUS_MOD5_MASK. Obtain
+ the untranslated keyval from the underlying keymap and
+ represent the translated keyval as the form "G-<untranslated
+ keyval>", which m17n-lib accepts. */
+ if (modifiers & IBUS_MOD5_MASK) {
+ keymap = ibus_keymap_get ("us");
+ keyval = ibus_keymap_lookup_keysym (keymap, keycode,
+ modifiers & ~IBUS_MOD5_MASK);
+ g_object_unref (keymap);
+ }
keysym = g_string_new ("");
- if (base_keyval >= IBUS_space && base_keyval <= IBUS_asciitilde) {
- gint c = (modifiers & IBUS_MOD5_MASK) ? base_keyval : keyval;
+ if (keyval >= IBUS_space && keyval <= IBUS_asciitilde) {
+ gint c = keyval;
if (keyval == IBUS_space && modifiers & IBUS_SHIFT_MASK)
mask |= IBUS_SHIFT_MASK;
diff --git a/src/m17nutil.c b/src/m17nutil.c
index ae0fe56..22b9fe1 100644
--- a/src/m17nutil.c
+++ b/src/m17nutil.c
@@ -7,37 +7,60 @@
static MConverter *utf8_converter = NULL;
-static const gchar *keymap[] = {
- "m17n:as:phonetic",
- "m17n:bn:inscript",
- "m17n:gu:inscript",
- "m17n:hi:inscript",
- "m17n:kn:kgp",
- "m17n:ks:kbd",
- "m17n:mai:inscript",
- "m17n:ml:inscript",
- "m17n:mr:inscript",
- "m17n:ne:rom",
- "m17n:or:inscript",
- "m17n:pa:inscript",
- "m17n:sa:harvard-kyoto",
- "m17n:sd:inscript",
- "m17n:si:wijesekera",
- "m17n:ta:tamil99",
- "m17n:te:inscript"
-};
-
-static const gchar *preedit_highlight[] = {
- "m17n:ja:anthy",
- "m17n:zh:cangjie",
- "m17n:zh:py-b5",
- "m17n:zh:py-gb",
- "m17n:zh:py",
- "m17n:zh:quick",
- "m17n:zh:tonepy-b5",
- "m17n:zh:tonepy-gb",
- "m17n:zh:tonepy",
- "m17n:zh:util",
+static const struct {
+ const gchar *name;
+ gint rank; /* engine rank (default 0) */
+ gboolean preedit_highlight; /* whether to highlight preedit (default 0) */
+} engine_config[] = {
+ /* Indic engines which represent languages. */
+ {"m17n:as:phonetic", 2, FALSE},
+ {"m17n:bn:inscript", 2, FALSE},
+ {"m17n:gu:inscript", 2, FALSE},
+ {"m17n:hi:inscript", 2, FALSE},
+ {"m17n:kn:kgp", 2, FALSE},
+ {"m17n:ks:kbd", 2, FALSE},
+ {"m17n:mai:inscript", 2, FALSE},
+ {"m17n:ml:inscript", 2, FALSE},
+ {"m17n:mr:inscript", 2, FALSE},
+ {"m17n:ne:rom", 2, FALSE},
+ {"m17n:or:inscript", 2, FALSE},
+ {"m17n:pa:inscript", 2, FALSE},
+ {"m17n:sa:harvard-kyoto", 2, FALSE},
+ {"m17n:sd:inscript", 2, FALSE},
+ {"m17n:si:wijesekera", 2, FALSE},
+ {"m17n:ta:tamil99", 2, FALSE},
+ {"m17n:te:inscript", 2, FALSE},
+ /* Other Indic engines should be selected by default:
+ https://bugzilla.redhat.com/show_bug.cgi?id=640896
+ */
+ {"m17n:as:*", 1, FALSE},
+ {"m17n:bn:*", 1, FALSE},
+ {"m17n:gu:*", 1, FALSE},
+ {"m17n:hi:*", 1, FALSE},
+ {"m17n:kn:*", 1, FALSE},
+ {"m17n:ks:*", 1, FALSE},
+ {"m17n:mai:*", 1, FALSE},
+ {"m17n:ml:*", 1, FALSE},
+ {"m17n:mr:*", 1, FALSE},
+ {"m17n:ne:*", 1, FALSE},
+ {"m17n:or:*", 1, FALSE},
+ {"m17n:pa:*", 1, FALSE},
+ {"m17n:sa:*", 1, FALSE},
+ {"m17n:sd:*", 1, FALSE},
+ {"m17n:si:*", 1, FALSE},
+ {"m17n:ta:*", 1, FALSE},
+ {"m17n:te:*", 1, FALSE},
+ /* Chinese and Japanese engines which require preedit decoration. */
+ {"m17n:ja:anthy", 0, TRUE},
+ {"m17n:zh:cangjie", 0, TRUE},
+ {"m17n:zh:py-b5", 0, TRUE},
+ {"m17n:zh:py-gb", 0, TRUE},
+ {"m17n:zh:py", 0, TRUE},
+ {"m17n:zh:quick", 0, TRUE},
+ {"m17n:zh:tonepy-b5", 0, TRUE},
+ {"m17n:zh:tonepy-gb", 0, TRUE},
+ {"m17n:zh:tonepy", 0, TRUE},
+ {"m17n:zh:util", 0, TRUE}
};
void
@@ -101,11 +124,16 @@ guint
ibus_m17n_parse_color (const gchar *hex)
{
guint color;
- if (hex && *hex == '#' &&
- ((color = strtoul (&hex[1], NULL, 16)) != ULONG_MAX ||
- errno != ERANGE))
- return color;
- return (guint)-1;
+
+ if (!hex || *hex != '#')
+ return (guint)-1;
+
+ errno = 0;
+ color = strtoul (&hex[1], NULL, 16);
+ if ((errno == ERANGE && color == ULONG_MAX)
+ || (errno != 0 && color == 0))
+ return (guint)-1;
+ return color;
}
static IBusEngineDesc *
@@ -141,10 +169,10 @@ ibus_m17n_engine_new (MSymbol lang,
/* set default rank to 0 */
engine->rank = 0;
- for (i = 0; i < G_N_ELEMENTS(keymap); i++) {
- if (strcmp (engine_name, keymap[i]) == 0) {
+ for (i = 0; i < G_N_ELEMENTS(engine_config); i++) {
+ if (g_pattern_match_simple (engine_config[i].name, engine_name)) {
/* set rank of default keymap to 1 */
- engine->rank = 1;
+ engine->rank = engine_config[i].rank;
break;
}
}
@@ -271,9 +299,9 @@ ibus_m17n_preedit_highlight (const gchar *engine_name)
{
gint i;
- for (i = 0; i < G_N_ELEMENTS(preedit_highlight); i++) {
- if (strcmp (engine_name, preedit_highlight[i]) == 0)
- return TRUE;
+ for (i = 0; i < G_N_ELEMENTS(engine_config); i++) {
+ if (g_pattern_match_simple (engine_config[i].name, engine_name))
+ return engine_config[i].preedit_highlight;
}
return FALSE;
}
diff --git a/src/setup.c b/src/setup.c
index 7442159..0fe6e1b 100644
--- a/src/setup.c
+++ b/src/setup.c
@@ -83,6 +83,7 @@ parse_value (MPlist *plist, gchar *text)
if (mplist_key (plist) == Minteger) {
long val;
+ errno = 0;
val = strtol (text, NULL, 10);
if ((errno == ERANGE && (val == LONG_MAX || val == LONG_MIN))
|| (errno != 0 && val == 0))