diff --git a/src/engine.c b/src/engine.c index 5c5f56f..06501bb 100644 --- a/src/engine.c +++ b/src/engine.c @@ -53,9 +53,10 @@ static void ibus_m17n_engine_page_up (IBusEngine *engine); static void ibus_m17n_engine_page_down (IBusEngine *engine); static void ibus_m17n_engine_cursor_up (IBusEngine *engine); static void ibus_m17n_engine_cursor_down (IBusEngine *engine); -static void ibus_m17n_property_activate (IBusEngine *engine, +static void ibus_m17n_engine_property_activate + (IBusEngine *engine, const gchar *prop_name, - gint prop_state); + guint prop_state); static void ibus_m17n_engine_property_show (IBusEngine *engine, const gchar *prop_name); @@ -126,6 +127,7 @@ ibus_m17n_engine_class_init (IBusM17NEngineClass *klass) engine_class->cursor_up = ibus_m17n_engine_cursor_up; engine_class->cursor_down = ibus_m17n_engine_cursor_down; + // engine_class->property_activate = ibus_m17n_engine_property_activate; } static void @@ -277,47 +279,67 @@ MSymbol ibus_m17n_key_event_to_symbol (guint keyval, guint modifiers) { - GString *key; - MSymbol mkey = Mnil; + GString *keysym; + MSymbol mkeysym = Mnil; guint mask = 0; + if (keyval >= IBUS_Shift_L && keyval <= IBUS_Hyper_R) { + return Mnil; + } + + keysym = g_string_new (""); + if (keyval >= IBUS_space && keyval <= IBUS_asciitilde) { + gint c = keyval; if (keyval == IBUS_space && modifiers & IBUS_SHIFT_MASK) mask |= IBUS_SHIFT_MASK; if (modifiers & IBUS_CONTROL_MASK) { - if (keyval >= IBUS_a && keyval <= IBUS_z) - keyval += IBUS_A - IBUS_a; + if (c >= IBUS_a && c <= IBUS_z) + c += IBUS_A - IBUS_a; mask |= IBUS_CONTROL_MASK; } + + g_string_append_c (keysym, c); } - else if (keyval >= IBUS_Shift_L && keyval <= IBUS_Hyper_R) { - return Mnil; + else { + mask |= modifiers & (IBUS_CONTROL_MASK | IBUS_SHIFT_MASK); + g_string_append (keysym, ibus_keyval_name (keyval)); + if (keysym->len == 0) { + g_string_free (keysym, TRUE); + return Mnil; + } } - mask |= modifiers & (IBUS_MOD1_MASK | IBUS_META_MASK); + mask |= modifiers & (IBUS_MOD1_MASK | + IBUS_META_MASK | + IBUS_SUPER_MASK | + IBUS_HYPER_MASK); - key = g_string_new (""); + if (mask & IBUS_HYPER_MASK) { + g_string_prepend (keysym, "H-"); + } + if (mask & IBUS_SUPER_MASK) { + g_string_prepend (keysym, "s-"); + } if (mask & IBUS_MOD1_MASK) { - g_string_append (key, "A-"); + g_string_prepend (keysym, "A-"); } if (mask & IBUS_META_MASK) { - g_string_append (key, "M-"); + g_string_prepend (keysym, "M-"); } if (mask & IBUS_CONTROL_MASK) { - g_string_append (key, "C-"); + g_string_prepend (keysym, "C-"); } if (mask & IBUS_SHIFT_MASK) { - g_string_append (key, "S-"); + g_string_prepend (keysym, "S-"); } - g_string_append (key, ibus_keyval_name (keyval)); - - mkey = msymbol (key->str); - g_string_free (key, TRUE); + mkeysym = msymbol (keysym->str); + g_string_free (keysym, TRUE); - return mkey; + return mkeysym; } static gboolean @@ -457,6 +479,15 @@ ibus_m17n_engine_cursor_down (IBusEngine *engine) } static void +ibus_m17n_engine_property_activate (IBusEngine *engine, + const gchar *prop_name, + guint prop_state) +{ + g_debug ("prop_name=%s, prop_state=%d", prop_name, prop_state); + parent_class->property_activate (engine, prop_name, prop_state); +} + +static void ibus_m17n_engine_update_lookup_table (IBusM17NEngine *m17n) { ibus_lookup_table_clear (m17n->table);