Add mouse detection on top & left borders of floating panes.

This commit is contained in:
Michael Grant
2025-10-23 23:25:48 +01:00
parent baf642b7d2
commit b315a6c3d1
2 changed files with 47 additions and 12 deletions

View File

@@ -592,6 +592,7 @@ server_client_check_mouse_in_pane(struct window_pane *wp, u_int px, u_int py,
struct window_pane *fwp; struct window_pane *fwp;
int pane_status, sb, sb_pos, sb_w, sb_pad; int pane_status, sb, sb_pos, sb_w, sb_pad;
u_int line, sl_top, sl_bottom; u_int line, sl_top, sl_bottom;
u_int bdr_bottom, bdr_top, bdr_left, bdr_right;
sb = options_get_number(wo, "pane-scrollbars"); sb = options_get_number(wo, "pane-scrollbars");
sb_pos = options_get_number(wo, "pane-scrollbars-position"); sb_pos = options_get_number(wo, "pane-scrollbars-position");
@@ -643,16 +644,40 @@ server_client_check_mouse_in_pane(struct window_pane *wp, u_int px, u_int py,
} else if (~w->flags & WINDOW_ZOOMED) { } else if (~w->flags & WINDOW_ZOOMED) {
/* Try the pane borders if not zoomed. */ /* Try the pane borders if not zoomed. */
TAILQ_FOREACH(fwp, &w->panes, entry) { TAILQ_FOREACH(fwp, &w->panes, entry) {
if ((((sb_pos == PANE_SCROLLBARS_RIGHT && if (sb_pos == PANE_SCROLLBARS_LEFT)
fwp->xoff + fwp->sx + sb_pad + sb_w == px) || bdr_right = fwp->xoff + fwp->sx;
(sb_pos == PANE_SCROLLBARS_LEFT && else
fwp->xoff + fwp->sx == px)) && /* PANE_SCROLLBARS_RIGHT or none. */
fwp->yoff <= 1 + py && bdr_right = fwp->xoff + fwp->sx + sb_pad + sb_w;
fwp->yoff + fwp->sy >= py) || if (py >= fwp->yoff - 1 && py <= fwp->yoff + fwp->sy) {
if (px == bdr_right)
break;
if (wp->layout_cell == NULL) {
/* Floating pane, check if left border. */
bdr_left = fwp->xoff - 1;
if (px == bdr_left)
break;
}
}
if (px >= fwp->xoff - 1 && px <= fwp->xoff + fwp->sx) {
bdr_bottom = fwp->yoff + fwp->sy;
if (py == bdr_bottom)
break;
if (wp->layout_cell == NULL) {
/* Floating pane, check if top border. */
bdr_top = fwp->yoff - 1;
if (py == bdr_top)
break;
}
}
/*
if ((((sb_pos == PANE_SCROLLBARS_RIGHT && fwp->xoff + fwp->sx + sb_pad + sb_w == px) ||
(sb_pos == PANE_SCROLLBARS_LEFT && fwp->xoff + fwp->sx == px)) &&
fwp->yoff <= 1 + py && fwp->yoff + fwp->sy >= py) ||
(fwp->yoff + fwp->sy == py && (fwp->yoff + fwp->sy == py &&
fwp->xoff <= 1 + px && fwp->xoff <= 1 + px && fwp->xoff + fwp->sx >= px))
fwp->xoff + fwp->sx >= px))
break; break;
*/
} }
if (fwp != NULL) if (fwp != NULL)
return (BORDER); return (BORDER);

View File

@@ -604,10 +604,20 @@ window_get_active_at(struct window *w, u_int x, u_int y)
if (!window_pane_visible(wp)) if (!window_pane_visible(wp))
continue; continue;
window_pane_full_size_offset(wp, &xoff, &yoff, &sx, &sy); window_pane_full_size_offset(wp, &xoff, &yoff, &sx, &sy);
if (x < xoff || x > xoff + sx) if (wp->layout_cell != NULL) {
continue; /* Tiled, select up to including bottom or
if (y < yoff || y > yoff + sy) right border. */
continue; if (x < xoff || x > xoff + sx)
continue;
if (y < yoff || y > yoff + sy)
continue;
} else {
/* Floating, include top or or left border. */
if (x < xoff - 1 || x > xoff + sx)
continue;
if (y < yoff - 1 || y > yoff + sy)
continue;
}
return (wp); return (wp);
} }
return (NULL); return (NULL);