From d4ee9be4d767ff4927c9e322bdbf958841dc091d Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Fri, 31 Jul 2020 17:09:06 +0200 Subject: config: add 'hide-when-typing' When enabled, the mouse cursor is hidden when the user types in the terminal. It is un-hidden when the user moves the mouse, or when the window loses keyboard focus. --- terminal.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'terminal.c') diff --git a/terminal.c b/terminal.c index 85dde554..ae4f3ee5 100644 --- a/terminal.c +++ b/terminal.c @@ -36,6 +36,7 @@ #define PTMX_TIMING 0 +const char *const XCURSOR_HIDDEN = "hidden"; const char *const XCURSOR_LEFT_PTR = "left_ptr"; const char *const XCURSOR_TEXT = "text"; //const char *const XCURSOR_HAND2 = "hand2"; @@ -2207,18 +2208,22 @@ term_mouse_motion(struct terminal *term, int button, int row, int col, } void -term_xcursor_update(struct terminal *term) +term_xcursor_update_for_seat(struct terminal *term, struct seat *seat) { - tll_foreach(term->wl->seats, it) { - struct seat *seat = &it->item; + const char *xcursor + = seat->pointer.hidden ? XCURSOR_HIDDEN + : term->is_searching ? XCURSOR_LEFT_PTR + : selection_enabled(term, seat) ? XCURSOR_TEXT + : XCURSOR_LEFT_PTR; - const char *xcursor - = term->is_searching ? XCURSOR_LEFT_PTR : /* TODO: something different? */ - selection_enabled(term, seat) ? XCURSOR_TEXT : - XCURSOR_LEFT_PTR; + render_xcursor_set(seat, term, xcursor); +} - render_xcursor_set(seat, term, xcursor); - } +void +term_xcursor_update(struct terminal *term) +{ + tll_foreach(term->wl->seats, it) + term_xcursor_update_for_seat(term, &it->item); } void -- cgit v1.3