diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2021-03-23 12:03:07 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2021-03-25 08:36:07 +0000 |
| commit | e8ffb05bc7fb3b996752f345b77af4b757f69776 (patch) | |
| tree | 1cf3f61f1b6f22d7a10d42cf333a550a2927469f /terminal.c | |
| parent | Merge branch 'clear-linebreak-flag-when-printing' (diff) | |
ime: move preedit state from terminal struct to the seat struct
This ensures different seat’s don’t step on each others IME pre-edit
state.
It also removes most dependencies on having a valid term pointer for
many IME operations.
We’re still not all the way, since we support disabling IME with a
private mode, which is per terminal, not seat.
Thus, we still require the seat to have keyboard focus on one of our
windows.
Closes #324. But note that *rendering* of multiple seat’s IME pre-edit
strings is still broken.
Diffstat (limited to 'terminal.c')
| -rw-r--r-- | terminal.c | 40 |
1 files changed, 20 insertions, 20 deletions
@@ -1182,9 +1182,7 @@ term_init(const struct config *conf, struct fdm *fdm, struct reaper *reaper, .foot_exe = xstrdup(foot_exe), .cwd = xstrdup(cwd), #if defined(FOOT_IME_ENABLED) && FOOT_IME_ENABLED - .ime = { - .enabled = true, - }, + .ime_enabled = true, #endif }; @@ -2405,10 +2403,8 @@ term_kbd_focus_out(struct terminal *term) return; #if defined(FOOT_IME_ENABLED) && FOOT_IME_ENABLED - if (term->ime.preedit.cells != NULL) { - term_ime_reset(term); + if (term_ime_reset(term)) render_refresh(term); - } #endif term->kbd_focus = false; @@ -3039,7 +3035,7 @@ bool term_ime_is_enabled(const struct terminal *term) { #if defined(FOOT_IME_ENABLED) && FOOT_IME_ENABLED - return term->ime.enabled; + return term->ime_enabled; #else return false; #endif @@ -3049,13 +3045,12 @@ void term_ime_enable(struct terminal *term) { #if defined(FOOT_IME_ENABLED) && FOOT_IME_ENABLED - if (term->ime.enabled) + if (term->ime_enabled) return; LOG_DBG("IME enabled"); - term->ime.enabled = true; - term_ime_reset(term); + term->ime_enabled = true; /* IME is per seat - enable on all seat currently focusing us */ tll_foreach(term->wl->seats, it) { @@ -3069,13 +3064,12 @@ void term_ime_disable(struct terminal *term) { #if defined(FOOT_IME_ENABLED) && FOOT_IME_ENABLED - if (!term->ime.enabled) + if (!term->ime_enabled) return; LOG_DBG("IME disabled"); - term->ime.enabled = false; - term_ime_reset(term); + term->ime_enabled = false; /* IME is per seat - disable on all seat currently focusing us */ tll_foreach(term->wl->seats, it) { @@ -3085,18 +3079,24 @@ term_ime_disable(struct terminal *term) #endif } -void +bool term_ime_reset(struct terminal *term) { + bool at_least_one_seat_was_reset = false; + #if defined(FOOT_IME_ENABLED) && FOOT_IME_ENABLED - if (term->ime.preedit.cells != NULL) { - free(term->ime.preedit.text); - free(term->ime.preedit.cells); - term->ime.preedit.text = NULL; - term->ime.preedit.cells = NULL; - term->ime.preedit.count = 0; + tll_foreach(term->wl->seats, it) { + struct seat *seat = &it->item; + + if (seat->kbd_focus != term) + continue; + + ime_reset_preedit(seat); + at_least_one_seat_was_reset = true; } #endif + + return at_least_one_seat_was_reset; } void |
