From 8c72e9434e1b7a24ee19b2bcb414957088ec040e Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Sat, 11 Jul 2020 09:04:46 +0200 Subject: term: cache kbd-focused state, just like we cache visual focus state There's one difference however, when we receive a kbd unfocus call, *all* seats must have us unfocused before we actually change the state. --- terminal.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'terminal.c') diff --git a/terminal.c b/terminal.c index 1e7ddabe..64d4d643 100644 --- a/terminal.c +++ b/terminal.c @@ -1967,13 +1967,16 @@ term_has_kbd_focus(struct terminal *term) return false; } +#endif void term_kbd_focus_in(struct terminal *term) { - if (term_has_kbd_focus(term)) + if (term->kbd_focus) return; + term->kbd_focus = true; + if (term->focus_events) term_to_slave(term, "\033[I", 3); } @@ -1981,9 +1984,15 @@ term_kbd_focus_in(struct terminal *term) void term_kbd_focus_out(struct terminal *term) { - if (term_has_kbd_focus(term)) + if (!term->kbd_focus) return; + tll_foreach(term->wl->seats, it) + if (it->item.kbd_focus == term) + return; + + term->kbd_focus = false; + if (term->focus_events) term_to_slave(term, "\033[O", 3); } -- cgit v1.3