diff options
author | Simon Ser <contact@emersion.fr> | 2020-03-11 11:54:48 +0100 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2020-03-11 11:54:48 +0100 |
commit | 42eb8c469c448cbe187ac79f51aa27477d7613df (patch) | |
tree | 5d9294bf5e6f49e3449a84460ba93336640eb3ca | |
parent | 7ed9b05325c2755763c7394b9f3ffcbed3b69711 (diff) |
Toggle IME with Hangul key
-rw-r--r-- | include/wlhangul.h | 1 | ||||
-rw-r--r-- | main.c | 14 |
2 files changed, 9 insertions, 6 deletions
diff --git a/include/wlhangul.h b/include/wlhangul.h index 3b610f0..0e9cf22 100644 --- a/include/wlhangul.h +++ b/include/wlhangul.h @@ -30,6 +30,7 @@ struct wlhangul_seat { struct xkb_state *xkb_state; bool active; + bool enabled; uint32_t serial; bool pending_activate, pending_deactivate; struct zwp_input_method_keyboard_grab_v2 *keyboard_grab; @@ -10,20 +10,22 @@ static bool handle_key_pressed(struct wlhangul_seat *seat, xkb_keycode_t xkb_key) { - bool handled; + bool handled = false; xkb_keysym_t sym = xkb_state_key_get_one_sym(seat->xkb_state, xkb_key); switch (sym) { - case XKB_KEY_Escape: - seat->state->running = false; + case XKB_KEY_Hangul: + seat->enabled = !seat->enabled; + if (!seat->enabled) { + hangul_ic_reset(seat->input_context); + } handled = true; break; case XKB_KEY_BackSpace: - handled = hangul_ic_backspace(seat->input_context); + handled = seat->enabled && hangul_ic_backspace(seat->input_context); break; - // TODO: XKB_KEY_Hangul default:; uint32_t ch = xkb_state_key_get_utf32(seat->xkb_state, xkb_key); - handled = hangul_ic_process(seat->input_context, ch); + handled = seat->enabled && hangul_ic_process(seat->input_context, ch); break; } |