diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2020-08-07 17:51:34 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2020-08-07 17:51:34 +0000 |
| commit | 158722b642dd1267e85f70c68f520b3a30a74877 (patch) | |
| tree | a1dadbdd91a34e9d9491fb7fcf90ad017d1752d1 | |
| parent | Merge branch 'syslog' into master (diff) | |
input: fix col/row calculation when cursor is in the top or left margin
This fixes an issue where the col/row were incorrectly set to 0
instead of -1, when the mouse cursor was inside the grid margins.
This resulted in e.g. the mouse cursor having the wrong shape, and
foot incorrectly handling mouse events as if they were inside the
grid.
| -rw-r--r-- | CHANGELOG.md | 1 | ||||
| -rw-r--r-- | input.c | 12 |
2 files changed, 9 insertions, 4 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 62aa0906..b9edbf1b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -54,6 +54,7 @@ * Incorrect multi-column character spacer insertion when reflowing text. * Compilation errors in 32-bit builds. +* Mouse cursor style of top and left margins. ### Security @@ -1048,8 +1048,12 @@ wl_pointer_enter(void *data, struct wl_pointer *wl_pointer, switch ((term->active_surface = term_surface_kind(term, surface))) { case TERM_SURF_GRID: { - int col = (x - term->margins.left) / term->cell_width; - int row = (y - term->margins.top) / term->cell_height; + int col = x >= term->margins.left + ? (x - term->margins.left) / term->cell_width + : -1; + int row = y >= term->margins.top + ? (y - term->margins.top) / term->cell_height + : -1; seat->mouse.col = col >= 0 && col < term->cols ? col : -1; seat->mouse.row = row >= 0 && row < term->rows ? row : -1; @@ -1202,8 +1206,8 @@ wl_pointer_motion(void *data, struct wl_pointer *wl_pointer, case TERM_SURF_GRID: { term_xcursor_update_for_seat(term, seat); - int col = (x - term->margins.left) / term->cell_width; - int row = (y - term->margins.top) / term->cell_height; + int col = x >= term->margins.left ? (x - term->margins.left) / term->cell_width : -1; + int row = y >= term->margins.top ? (y - term->margins.top) / term->cell_height : -1; int old_col = seat->mouse.col; int old_row = seat->mouse.row; |
