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.
This commit is contained in:
Daniel Eklöf 2020-07-31 17:09:06 +02:00
parent b00dfcf7b6
commit d4ee9be4d7
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
11 changed files with 57 additions and 16 deletions

View file

@ -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";
@ -2206,19 +2207,23 @@ term_mouse_motion(struct terminal *term, int button, int row, int col,
}
}
void
term_xcursor_update_for_seat(struct terminal *term, struct seat *seat)
{
const char *xcursor
= seat->pointer.hidden ? XCURSOR_HIDDEN
: term->is_searching ? XCURSOR_LEFT_PTR
: selection_enabled(term, seat) ? XCURSOR_TEXT
: XCURSOR_LEFT_PTR;
render_xcursor_set(seat, term, xcursor);
}
void
term_xcursor_update(struct terminal *term)
{
tll_foreach(term->wl->seats, it) {
struct seat *seat = &it->item;
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);
}
tll_foreach(term->wl->seats, it)
term_xcursor_update_for_seat(term, &it->item);
}
void