Add some new mouse ranges called "control0" to "control9", will be used

for controls on floating panes, from Dane Jensen, with some bits from
Michael Grant.
This commit is contained in:
nicm
2026-04-03 10:13:20 +00:00
parent 0917cd7010
commit 6b056eb53f
8 changed files with 212 additions and 67 deletions

View File

@@ -589,16 +589,24 @@ struct window_pane *
window_get_active_at(struct window *w, u_int x, u_int y)
{
struct window_pane *wp;
u_int xoff, yoff, sx, sy;
int pane_status, xoff, yoff;
u_int sx, sy;
pane_status = options_get_number(w->options, "pane-border-status");
TAILQ_FOREACH(wp, &w->panes, entry) {
if (!window_pane_visible(wp))
continue;
window_pane_full_size_offset(wp, &xoff, &yoff, &sx, &sy);
if (x < xoff || x > xoff + sx)
continue;
if (y < yoff || y > yoff + sy)
if ((int)x < xoff || x > xoff + sx)
continue;
if (pane_status == PANE_STATUS_TOP) {
if ((int)y <= yoff - 2 || y > yoff + sy - 1)
continue;
} else {
if ((int)y < yoff || y > yoff + sy)
continue;
}
return (wp);
}
return (NULL);
@@ -659,6 +667,7 @@ window_zoom(struct window_pane *wp)
if (w->active != wp)
window_set_active_pane(w, wp, 1);
wp->flags |= PANE_ZOOMED;
TAILQ_FOREACH(wp1, &w->panes, entry) {
wp1->saved_layout_cell = wp1->layout_cell;
@@ -689,6 +698,7 @@ window_unzoom(struct window *w, int notify)
TAILQ_FOREACH(wp, &w->panes, entry) {
wp->layout_cell = wp->saved_layout_cell;
wp->saved_layout_cell = NULL;
wp->flags ^= PANE_ZOOMED;
}
layout_fix_panes(w, NULL);
@@ -959,6 +969,7 @@ window_pane_create(struct window *w, u_int sx, u_int sy, u_int hlimit)
window_pane_default_cursor(wp);
screen_init(&wp->status_screen, 1, 1, 0);
style_ranges_init(&wp->border_status_line.ranges);
if (gethostname(host, sizeof host) == 0)
screen_set_title(&wp->base, host);
@@ -1007,6 +1018,7 @@ window_pane_destroy(struct window_pane *wp)
free(wp->shell);
cmd_free_argv(wp->argc, wp->argv);
colour_palette_free(&wp->palette);
style_ranges_free(&wp->border_status_line.ranges);
free(wp);
}
@@ -1958,3 +1970,31 @@ window_pane_send_theme_update(struct window_pane *wp)
break;
}
}
struct style_range *
window_pane_border_status_get_range(struct window_pane *wp, u_int x, u_int y)
{
struct style_ranges *srs;
struct window *w = wp->window;
struct options *wo = w->options;
u_int line;
int pane_status;
if (wp == NULL)
return (NULL);
srs = &wp->border_status_line.ranges;
pane_status = options_get_number(wo, "pane-border-status");
if (pane_status == PANE_STATUS_TOP)
line = wp->yoff - 1;
else if (pane_status == PANE_STATUS_BOTTOM)
line = wp->yoff + wp->sy;
if (pane_status == PANE_STATUS_OFF || line != y)
return (NULL);
/*
* The border formats start 2 off but that isn't reflected in
* the stored bounds of the range.
*/
return (style_ranges_get_range(srs, x - wp->xoff - 2));
}