From f41788c185d9fb5335fe1f3f191900db5e0792eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Fri, 29 Nov 2019 22:15:03 +0100 Subject: [PATCH] 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. --- terminal.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/terminal.c b/terminal.c index 22d19652..2b933fe6 100644 --- a/terminal.c +++ b/terminal.c @@ -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); }