From 6f281cebfb5db24c10a2cd0a10e2175fe9f6b514 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Thu, 2 Jan 2020 19:35:32 +0100 Subject: [PATCH] term: add term_visual_focus_{in,out} These functions should be called when the terminal gets or loses visual focus. Note that this isn't necessarily the same as having keyboard focus. --- terminal.c | 25 +++++++++++++++++-------- terminal.h | 2 ++ 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/terminal.c b/terminal.c index 4e1dd201..fe69890d 100644 --- a/terminal.c +++ b/terminal.c @@ -1392,27 +1392,36 @@ term_restore_cursor(struct terminal *term) } void -term_kbd_focus_in(struct terminal *term) +term_visual_focus_in(struct terminal *term) { + term->visual_focus = true; if (term->cursor_blink.active) cursor_blink_start_timer(term); + cursor_refresh(term); +} - if (term->focus_events) - term_to_slave(term, "\033[I", 3); +void +term_visual_focus_out(struct terminal *term) +{ + term->visual_focus = false; + if (term->cursor_blink.active) + cursor_blink_stop_timer(term); cursor_refresh(term); } +void +term_kbd_focus_in(struct terminal *term) +{ + if (term->focus_events) + term_to_slave(term, "\033[I", 3); +} + void term_kbd_focus_out(struct terminal *term) { - if (term->cursor_blink.active) - cursor_blink_stop_timer(term); - if (term->focus_events) term_to_slave(term, "\033[O", 3); - - cursor_refresh(term); } static int diff --git a/terminal.h b/terminal.h index 301ebad1..16323bfb 100644 --- a/terminal.h +++ b/terminal.h @@ -378,6 +378,8 @@ void term_arm_blink_timer(struct terminal *term); void term_restore_cursor(struct terminal *term); +void term_visual_focus_in(struct terminal *term); +void term_visual_focus_out(struct terminal *term); void term_kbd_focus_in(struct terminal *term); void term_kbd_focus_out(struct terminal *term); void term_mouse_down(struct terminal *term, int button, int row, int col);