term: xcursor cleanup

Show 'text' cursor when:

* we have no mouse tracking enabled
* forced selection has been enabled (shift being held down)
* We're *not* scrollback searching

In all other cases, show the 'left_ptr' cursor.
This commit is contained in:
Daniel Eklöf 2019-11-29 22:15:03 +01:00
parent 2c12549f93
commit f41788c185
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F

View file

@ -1433,13 +1433,20 @@ term_mouse_motion(struct terminal *term, int button, int row, int col,
void
term_xcursor_update(struct terminal *term)
{
const bool no_mouse_tracking = term->mouse_tracking == MOUSE_NONE;
const bool is_searching = term->is_searching;
const bool is_focused = term->wl->focused == term;
const char *new_cursor =
is_focused && selection_enabled(term) ? "text" : "left_ptr";
const bool forced_selection = is_focused && term->wl->kbd.shift;
LOG_DBG("setting xcursor to '%s' for term=%p", new_cursor, term);
term->xcursor = (no_mouse_tracking || forced_selection) && !is_searching
? "text" : "left_ptr";
LOG_DBG(
"setting xcursor to '%s' for term=%p "
"(is_focused=%d, tracking=%d, shift=%d, searching=%d)",
term->xcursor, term, is_focused, term->mouse_tracking,
term->wl->kbd.shift, is_searching);
term->xcursor = new_cursor;
wayl_cursor_set(term->wl, term);
}