From eb1ea2d80dd71c2799a961ca636722b74eb32286 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Thu, 2 Jan 2020 16:06:35 +0100 Subject: term: add visually focused attribute to terminal struct --- terminal.h | 1 + 1 file changed, 1 insertion(+) (limited to 'terminal.h') diff --git a/terminal.h b/terminal.h index a1c01942..e4eafe77 100644 --- a/terminal.h +++ b/terminal.h @@ -276,6 +276,7 @@ struct terminal { struct wayland *wl; struct wl_window *window; + bool visual_focus; struct { int scrollback_lines; -- cgit v1.3 From e9325b958f6fb6416f77a1f0d9f8b049f6a6a46b Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Thu, 2 Jan 2020 19:29:42 +0100 Subject: term: rename term_focus_{in,out} -> term_kbd_focus_{in,out} --- input.c | 4 ++-- terminal.c | 4 ++-- terminal.h | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'terminal.h') diff --git a/input.c b/input.c index ebbcac74..9df9c5dc 100644 --- a/input.c +++ b/input.c @@ -90,7 +90,7 @@ keyboard_enter(void *data, struct wl_keyboard *wl_keyboard, uint32_t serial, wayl->kbd_focus = wayl_terminal_from_surface(wayl, surface); assert(wayl->kbd_focus != NULL); - term_focus_in(wayl->kbd_focus); + term_kbd_focus_in(wayl->kbd_focus); term_xcursor_update(wayl->kbd_focus); } @@ -157,7 +157,7 @@ keyboard_leave(void *data, struct wl_keyboard *wl_keyboard, uint32_t serial, * keyboard_leave() (and keyboard_key()) without first having * received a keyboard_enter() */ - term_focus_out(old_focused); + term_kbd_focus_out(old_focused); term_xcursor_update(old_focused); } else { LOG_WARN( diff --git a/terminal.c b/terminal.c index a9ed686f..4e1dd201 100644 --- a/terminal.c +++ b/terminal.c @@ -1392,7 +1392,7 @@ term_restore_cursor(struct terminal *term) } void -term_focus_in(struct terminal *term) +term_kbd_focus_in(struct terminal *term) { if (term->cursor_blink.active) cursor_blink_start_timer(term); @@ -1404,7 +1404,7 @@ term_focus_in(struct terminal *term) } void -term_focus_out(struct terminal *term) +term_kbd_focus_out(struct terminal *term) { if (term->cursor_blink.active) cursor_blink_stop_timer(term); diff --git a/terminal.h b/terminal.h index e4eafe77..301ebad1 100644 --- a/terminal.h +++ b/terminal.h @@ -378,8 +378,8 @@ void term_arm_blink_timer(struct terminal *term); void term_restore_cursor(struct terminal *term); -void term_focus_in(struct terminal *term); -void term_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); void term_mouse_up(struct terminal *term, int button, int row, int col); void term_mouse_motion(struct terminal *term, int button, int row, int col); -- cgit v1.3 From 6f281cebfb5db24c10a2cd0a10e2175fe9f6b514 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Thu, 2 Jan 2020 19:35:32 +0100 Subject: 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(-) (limited to 'terminal.h') 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); - - if (term->focus_events) - term_to_slave(term, "\033[I", 3); - cursor_refresh(term); } void -term_kbd_focus_out(struct terminal *term) +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[O", 3); + term_to_slave(term, "\033[I", 3); +} - cursor_refresh(term); +void +term_kbd_focus_out(struct terminal *term) +{ + if (term->focus_events) + term_to_slave(term, "\033[O", 3); } 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); -- cgit v1.3