terminal: Make seat xcursor update focus aware

When term_xcursor_update_for_seat() was called on e.g. keyboard focus
loss, it'd update the curret xcursor to 'text' even if it was e.g. on
top of the window title, or resize areas. This makes the function a bit
more focus aware, and will not be so eager to set the text xcursor.
This commit is contained in:
Jonas Ådahl 2021-11-19 15:02:48 +01:00
parent d70a21355c
commit 5c2557b421
3 changed files with 38 additions and 9 deletions

View file

@ -1372,7 +1372,7 @@ is_bottom_right(const struct terminal *term, int x, int y)
(term->active_surface == TERM_SURF_BORDER_BOTTOM && x > term->width + 1 * csd_border_size * term->scale - 10 * term->scale))); (term->active_surface == TERM_SURF_BORDER_BOTTOM && x > term->width + 1 * csd_border_size * term->scale - 10 * term->scale)));
} }
static const char * const char *
xcursor_for_csd_border(struct terminal *term, int x, int y) xcursor_for_csd_border(struct terminal *term, int x, int y)
{ {
if (is_top_left(term, x, y)) return XCURSOR_TOP_LEFT_CORNER; if (is_top_left(term, x, y)) return XCURSOR_TOP_LEFT_CORNER;

View file

@ -26,3 +26,5 @@ extern const struct wl_keyboard_listener keyboard_listener;
extern const struct wl_pointer_listener pointer_listener; extern const struct wl_pointer_listener pointer_listener;
void input_repeat(struct seat *seat, uint32_t key); void input_repeat(struct seat *seat, uint32_t key);
const char * xcursor_for_csd_border(struct terminal *term, int x, int y);

View file

@ -3015,14 +3015,41 @@ term_mouse_motion(struct terminal *term, int button, int row, int col,
void void
term_xcursor_update_for_seat(struct terminal *term, struct seat *seat) term_xcursor_update_for_seat(struct terminal *term, struct seat *seat)
{ {
const char *xcursor const char *xcursor;
= seat->pointer.hidden ? XCURSOR_HIDDEN
: term->is_searching ? XCURSOR_LEFT_PTR switch (term->active_surface) {
: (seat->mouse.col >= 0 && case TERM_SURF_GRID: {
seat->mouse.row >= 0 && xcursor = seat->pointer.hidden ? XCURSOR_HIDDEN
term_mouse_grabbed(term, seat)) ? XCURSOR_TEXT : term->is_searching ? XCURSOR_LEFT_PTR
: term->is_searching ? XCURSOR_TEXT : (seat->mouse.col >= 0 &&
: XCURSOR_LEFT_PTR; seat->mouse.row >= 0 &&
term_mouse_grabbed(term, seat)) ? XCURSOR_TEXT
: term->is_searching ? XCURSOR_TEXT
: XCURSOR_LEFT_PTR;
break;
}
case TERM_SURF_SEARCH:
case TERM_SURF_SCROLLBACK_INDICATOR:
case TERM_SURF_RENDER_TIMER:
case TERM_SURF_JUMP_LABEL:
case TERM_SURF_TITLE:
case TERM_SURF_BUTTON_MINIMIZE:
case TERM_SURF_BUTTON_MAXIMIZE:
case TERM_SURF_BUTTON_CLOSE:
xcursor = XCURSOR_LEFT_PTR;
break;
case TERM_SURF_BORDER_LEFT:
case TERM_SURF_BORDER_RIGHT:
case TERM_SURF_BORDER_TOP:
case TERM_SURF_BORDER_BOTTOM:
xcursor = xcursor_for_csd_border(term, seat->mouse.x, seat->mouse.y);
break;
case TERM_SURF_NONE:
default:
return;
}
render_xcursor_set(seat, term, xcursor); render_xcursor_set(seat, term, xcursor);
} }