From 3f19ee4d921e69e90073d00846fa2a5a37d691af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Tue, 2 Mar 2021 09:01:40 +0100 Subject: [PATCH] =?UTF-8?q?ime:=20don=E2=80=99t=20commit=20IME=20changes?= =?UTF-8?q?=20when=20we=20don=E2=80=99t=20have=20IME=20focus?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes log spamming in Sway: 00:54:07.780 [DEBUG] [wlr] [types/wlr_text_input_v3.c:181] Text input commit received without focus 00:54:07.780 [INFO] [sway/input/text_input.c:127] Inactive text input tried to commit an update Closes #384 --- ime.c | 11 +++++++++++ wayland.h | 1 + 2 files changed, 12 insertions(+) diff --git a/ime.c b/ime.c index ad283455..ec38be18 100644 --- a/ime.c +++ b/ime.c @@ -26,6 +26,7 @@ enter(void *data, struct zwp_text_input_v3 *zwp_text_input_v3, /* The main grid is the *only* input-receiving surface we have */ xassert(seat->kbd_focus != NULL); + seat->ime.focused = true; ime_enable(seat); } @@ -41,6 +42,7 @@ leave(void *data, struct zwp_text_input_v3 *zwp_text_input_v3, term_ime_reset(term); ime_disable(seat); + seat->ime.focused = false; } static void @@ -334,6 +336,9 @@ ime_send_cursor_rect(struct seat *seat, struct terminal *term) if (unlikely(seat->wayl->text_input_manager == NULL)) return; + if (!seat->ime.focused) + return; + if (!term->ime.enabled) return; @@ -367,6 +372,9 @@ ime_enable(struct seat *seat) struct terminal *term = seat->kbd_focus; xassert(term != NULL); + if (!seat->ime.focused) + return; + if (!term->ime.enabled) return; @@ -397,6 +405,9 @@ ime_disable(struct seat *seat) if (unlikely(seat->wayl->text_input_manager == NULL)) return; + if (!seat->ime.focused) + return; + ime_reset(seat); zwp_text_input_v3_disable(seat->wl_text_input); diff --git a/wayland.h b/wayland.h index 7aecaee0..34314414 100644 --- a/wayland.h +++ b/wayland.h @@ -271,6 +271,7 @@ struct seat { } pending; } surrounding; + bool focused; uint32_t serial; } ime; #endif