Merge branch 'obsd-master'

This commit is contained in:
Thomas Adam
2026-04-03 16:01:08 +01:00
8 changed files with 212 additions and 67 deletions

View File

@@ -604,7 +604,8 @@ server_client_check_mouse_in_pane(struct window_pane *wp, u_int px, u_int py,
struct options *wo = w->options;
struct window_pane *fwp;
int pane_status, sb, sb_pos, sb_w, sb_pad;
u_int line, sl_top, sl_bottom;
int pane_status_line, sl_top, sl_bottom;
int bdr_bottom, bdr_top, bdr_right;
sb = options_get_number(wo, "pane-scrollbars");
sb_pos = options_get_number(wo, "pane-scrollbars-position");
@@ -617,35 +618,38 @@ server_client_check_mouse_in_pane(struct window_pane *wp, u_int px, u_int py,
sb_w = 0;
sb_pad = 0;
}
if (pane_status == PANE_STATUS_TOP)
line = wp->yoff - 1;
pane_status_line = wp->yoff - 1;
else if (pane_status == PANE_STATUS_BOTTOM)
line = wp->yoff + wp->sy;
pane_status_line = wp->yoff + wp->sy;
else
pane_status_line = -1; /* not used */
/* Check if point is within the pane or scrollbar. */
if (((pane_status != PANE_STATUS_OFF &&
py != line && py != wp->yoff + wp->sy) ||
(int)py != pane_status_line && py != wp->yoff + wp->sy) ||
(wp->yoff == 0 && py < wp->sy) ||
(py >= wp->yoff && py < wp->yoff + wp->sy)) &&
((sb_pos == PANE_SCROLLBARS_RIGHT &&
px < wp->xoff + wp->sx + sb_pad + sb_w) ||
(int)px < (int)wp->xoff + (int)wp->sx + sb_pad + sb_w) ||
(sb_pos == PANE_SCROLLBARS_LEFT &&
px < wp->xoff + wp->sx - sb_pad - sb_w))) {
(int)px < (int)wp->xoff + (int)wp->sx - sb_pad - sb_w))) {
/* Check if in the scrollbar. */
if ((sb_pos == PANE_SCROLLBARS_RIGHT &&
(px >= wp->xoff + wp->sx + sb_pad &&
px < wp->xoff + wp->sx + sb_pad + sb_w)) ||
((int)px >= (int)wp->xoff + (int)wp->sx + sb_pad &&
(int)px < (int)wp->xoff + (int)wp->sx + sb_pad + sb_w)) ||
(sb_pos == PANE_SCROLLBARS_LEFT &&
(px >= wp->xoff - sb_pad - sb_w &&
px < wp->xoff - sb_pad))) {
((int)px >= (int)wp->xoff - sb_pad - sb_w &&
(int)px < (int)wp->xoff - sb_pad))) {
/* Check where inside the scrollbar. */
sl_top = wp->yoff + wp->sb_slider_y;
sl_bottom = (wp->yoff + wp->sb_slider_y +
wp->sb_slider_h - 1);
if (py < sl_top)
if ((int)py < sl_top)
return (KEYC_MOUSE_LOCATION_SCROLLBAR_UP);
else if (py >= sl_top &&
py <= sl_bottom) {
else if ((int)py >= sl_top &&
(int)py <= sl_bottom) {
*sl_mpos = (py - wp->sb_slider_y - wp->yoff);
return (KEYC_MOUSE_LOCATION_SCROLLBAR_SLIDER);
} else /* py > sl_bottom */
@@ -654,19 +658,30 @@ server_client_check_mouse_in_pane(struct window_pane *wp, u_int px, u_int py,
/* Must be inside the pane. */
return (KEYC_MOUSE_LOCATION_PANE);
}
} else if (~w->flags & WINDOW_ZOOMED) {
/* Try the pane borders if not zoomed. */
} else {
/* Try the pane borders. */
TAILQ_FOREACH(fwp, &w->panes, entry) {
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->xoff <= 1 + px &&
fwp->xoff + fwp->sx >= px))
break;
if ((w->flags & WINDOW_ZOOMED) &&
(~fwp->flags & PANE_ZOOMED))
continue;
bdr_top = fwp->yoff - 1;
bdr_bottom = fwp->yoff + (int)fwp->sy;
if (sb_pos == PANE_SCROLLBARS_LEFT)
bdr_right = fwp->xoff + (int)fwp->sx;
else
/* PANE_SCROLLBARS_RIGHT or none. */
bdr_right = fwp->xoff + (int)fwp->sx +
sb_pad + sb_w;
if ((int)py >= (int)fwp->yoff - 1 &&
py <= fwp->yoff + fwp->sy) {
if ((int)px == bdr_right)
break;
}
if ((int)px >= (int)fwp->xoff - 1 &&
px <= fwp->xoff + fwp->sx) {
if ((int)py == bdr_bottom || (int)py == bdr_top)
break;
}
}
if (fwp != NULL)
return (KEYC_MOUSE_LOCATION_BORDER);
@@ -683,7 +698,7 @@ server_client_check_mouse(struct client *c, struct key_event *event)
struct window *w = s->curw->window;
struct winlink *fwl;
struct window_pane *wp, *fwp;
u_int x, y, sx, sy, px, py, sl_mpos = 0;
u_int x, y, sx, sy, px, py, n, sl_mpos = 0;
u_int b, bn;
int ignore = 0;
key_code key;
@@ -821,8 +836,14 @@ have_event:
loc = KEYC_MOUSE_LOCATION_STATUS;
break;
case STYLE_RANGE_USER:
log_debug("mouse range: user");
loc = KEYC_MOUSE_LOCATION_STATUS;
break;
case STYLE_RANGE_CONTROL:
n = sr->argument; /* parsing keeps this < 10 */
log_debug("mouse range: control %u", n);
loc = KEYC_MOUSE_LOCATION_CONTROL0 + n;
break;
}
}
}
@@ -861,9 +882,15 @@ have_event:
if (loc == KEYC_MOUSE_LOCATION_PANE) {
log_debug("mouse %u,%u on pane %%%u", x, y,
wp->id);
} else if (loc == KEYC_MOUSE_LOCATION_BORDER)
} else if (loc == KEYC_MOUSE_LOCATION_BORDER) {
sr = window_pane_border_status_get_range(wp, px,
py);
if (sr != NULL) {
n = sr->argument;
loc = KEYC_MOUSE_LOCATION_CONTROL0 + n;
}
log_debug("mouse on pane %%%u border", wp->id);
else if (loc == KEYC_MOUSE_LOCATION_SCROLLBAR_UP ||
} else if (loc == KEYC_MOUSE_LOCATION_SCROLLBAR_UP ||
loc == KEYC_MOUSE_LOCATION_SCROLLBAR_SLIDER ||
loc == KEYC_MOUSE_LOCATION_SCROLLBAR_DOWN) {
log_debug("mouse on pane %%%u scrollbar",