aboutsummaryrefslogtreecommitdiff
path: root/input.c
diff options
context:
space:
mode:
Diffstat (limited to 'input.c')
-rw-r--r--input.c46
1 files changed, 31 insertions, 15 deletions
diff --git a/input.c b/input.c
index 442cd322..67661eee 100644
--- a/input.c
+++ b/input.c
@@ -1023,13 +1023,19 @@ wl_pointer_enter(void *data, struct wl_pointer *wl_pointer,
int y = wl_fixed_to_int(surface_y) * term->scale;
switch ((term->active_surface = term_surface_kind(term, surface))) {
- case TERM_SURF_GRID:
- seat->mouse.col = x / term->cell_width;
- seat->mouse.row = y / term->cell_height;
+ case TERM_SURF_GRID: {
+ int col = (x - term->margins.left) / term->cell_width;
+ int row = (y - term->margins.top) / term->cell_height;
+
+ seat->mouse.col = col >= 0 && col < term->cols ? col : -1;
+ seat->mouse.row = row >= 0 && row < term->rows ? row : -1;
+
term_xcursor_update(term);
break;
+ }
case TERM_SURF_SEARCH:
+ case TERM_SURF_SCROLLBACK_INDICATOR:
case TERM_SURF_TITLE:
render_xcursor_set(seat, term, XCURSOR_LEFT_PTR);
break;
@@ -1107,6 +1113,7 @@ wl_pointer_leave(void *data, struct wl_pointer *wl_pointer,
case TERM_SURF_NONE:
case TERM_SURF_GRID:
case TERM_SURF_SEARCH:
+ case TERM_SURF_SCROLLBACK_INDICATOR:
case TERM_SURF_TITLE:
case TERM_SURF_BORDER_LEFT:
case TERM_SURF_BORDER_RIGHT:
@@ -1141,6 +1148,7 @@ wl_pointer_motion(void *data, struct wl_pointer *wl_pointer,
switch (term->active_surface) {
case TERM_SURF_NONE:
case TERM_SURF_SEARCH:
+ case TERM_SURF_SCROLLBACK_INDICATOR:
case TERM_SURF_BUTTON_MINIMIZE:
case TERM_SURF_BUTTON_MAXIMIZE:
case TERM_SURF_BUTTON_CLOSE:
@@ -1165,26 +1173,31 @@ wl_pointer_motion(void *data, struct wl_pointer *wl_pointer,
break;
case TERM_SURF_GRID: {
+ term_xcursor_update(term);
+
int col = (x - term->margins.left) / term->cell_width;
int row = (y - term->margins.top) / term->cell_height;
- if (col < 0 || row < 0 || col >= term->cols || row >= term->rows)
- return;
+ int old_col = seat->mouse.col;
+ int old_row = seat->mouse.row;
+
+ seat->mouse.col = col >= 0 && col < term->cols ? col : -1;
+ seat->mouse.row = row >= 0 && row < term->rows ? row : -1;
- bool update_selection = seat->mouse.button == BTN_LEFT;
+ if (seat->mouse.col < 0 || seat->mouse.row < 0)
+ break;
+
+ bool update_selection = seat->mouse.button == BTN_LEFT || seat->mouse.button == BTN_RIGHT;
bool update_selection_early = term->selection.end.row == -1;
if (update_selection && update_selection_early)
- selection_update(term, col, row);
+ selection_update(term, seat->mouse.col, seat->mouse.row);
- if (col == seat->mouse.col && row == seat->mouse.row)
+ if (old_col == seat->mouse.col && old_row == seat->mouse.row)
break;
- seat->mouse.col = col;
- seat->mouse.row = row;
-
if (update_selection && !update_selection_early)
- selection_update(term, col, row);
+ selection_update(term, seat->mouse.col, seat->mouse.row);
if (!term_mouse_grabbed(term, seat)) {
term_mouse_motion(
@@ -1347,6 +1360,7 @@ wl_pointer_button(void *data, struct wl_pointer *wl_pointer,
break;
case TERM_SURF_SEARCH:
+ case TERM_SURF_SCROLLBACK_INDICATOR:
break;
case TERM_SURF_GRID: {
@@ -1360,9 +1374,11 @@ wl_pointer_button(void *data, struct wl_pointer *wl_pointer,
if (selection_enabled(term, seat)) {
switch (seat->mouse.count) {
case 1:
- selection_start(
- term, seat->mouse.col, seat->mouse.row,
- seat->kbd.ctrl ? SELECTION_BLOCK : SELECTION_NORMAL);
+ if (seat->mouse.col >= 0 && seat->mouse.row >= 0) {
+ selection_start(
+ term, seat->mouse.col, seat->mouse.row,
+ seat->kbd.ctrl ? SELECTION_BLOCK : SELECTION_NORMAL);
+ }
break;
case 2: