Korean input method depends on the key position on the keyboard, not the key
value. So we need to change the keyval to some generic value which can
represent the position on the keyboard. I choose the US qwerty layout as the
generic value. Before passing the keyval to libhangul, we change the keyval
as if the keyboard is US qwerty keyboard. Then, libhangul can handle the
keyval as the right position.
This will fix the problem with non-qwerty keyboard users.
static GString *hangul_keyboard = NULL;
static HanjaKeyList hanja_keys;
static int lookup_table_orientation = 0;
static GString *hangul_keyboard = NULL;
static HanjaKeyList hanja_keys;
static int lookup_table_orientation = 0;
+static IBusKeymap *keymap = NULL;
GType
ibus_hangul_engine_get_type (void)
GType
ibus_hangul_engine_get_type (void)
hanja_key_list_append(&hanja_keys, IBUS_Hangul_Hanja, 0);
hanja_key_list_append(&hanja_keys, IBUS_F9, 0);
}
hanja_key_list_append(&hanja_keys, IBUS_Hangul_Hanja, 0);
hanja_key_list_append(&hanja_keys, IBUS_F9, 0);
}
+
+ keymap = ibus_keymap_get("us");
}
void
ibus_hangul_exit (void)
{
}
void
ibus_hangul_exit (void)
{
+ if (keymap != NULL) {
+ g_object_unref(keymap);
+ keymap = NULL;
+ }
+
hanja_key_list_fini(&hanja_keys);
hanja_table_delete (hanja_table);
hanja_key_list_fini(&hanja_keys);
hanja_table_delete (hanja_table);
if (keyval == IBUS_BackSpace) {
retval = hangul_ic_backspace (hangul->context);
} else {
if (keyval == IBUS_BackSpace) {
retval = hangul_ic_backspace (hangul->context);
} else {
+ // We need to normalize the keyval to US qwerty keylayout,
+ // because the korean input method is depend on the position of
+ // each key, not the character. We make the keyval from keycode
+ // as if the keyboard is US qwerty layout. Then we can assume the
+ // keyval represent the position of the each key.
+ if (keymap != NULL)
+ keyval = ibus_keymap_lookup_keysym(keymap, keycode, modifiers);
+
// ignore capslock
if (modifiers & IBUS_LOCK_MASK) {
if (keyval >= 'A' && keyval <= 'z') {
// ignore capslock
if (modifiers & IBUS_LOCK_MASK) {
if (keyval >= 'A' && keyval <= 'z') {