Change overlay_ranges to visible_ranges.

This commit is contained in:
Nicholas Marriott
2026-01-20 21:09:30 +00:00
parent 25f72cf240
commit b108653f02
7 changed files with 209 additions and 92 deletions

View File

@@ -165,34 +165,37 @@ server_client_clear_overlay(struct client *c)
* Given overlay position and dimensions, return parts of the input range which
* are visible.
*/
void
struct visible_ranges *
server_client_overlay_range(u_int x, u_int y, u_int sx, u_int sy, u_int px,
u_int py, u_int nx, struct overlay_ranges *r)
u_int py, u_int nx)
{
u_int ox, onx;
u_int ox, onx;
static struct visible_ranges r = {NULL, NULL, 0, 0};
/* Return up to 2 ranges. */
r->px[2] = 0;
r->nx[2] = 0;
/* For efficiency vr is static and space reused. */
if (r.size == 0) {
r.px = xcalloc(2, sizeof(u_int));
r.nx = xcalloc(2, sizeof(u_int));
r.size = 2;
}
/* Trivial case of no overlap in the y direction. */
if (py < y || py > y + sy - 1) {
r->px[0] = px;
r->nx[0] = nx;
r->px[1] = 0;
r->nx[1] = 0;
return;
r.px[0] = px;
r.nx[0] = nx;
r.used = 1;
return (&r);
}
/* Visible bit to the left of the popup. */
if (px < x) {
r->px[0] = px;
r->nx[0] = x - px;
if (r->nx[0] > nx)
r->nx[0] = nx;
r.px[0] = px;
r.nx[0] = x - px;
if (r.nx[0] > nx)
r.nx[0] = nx;
} else {
r->px[0] = 0;
r->nx[0] = 0;
r.px[0] = 0;
r.nx[0] = 0;
}
/* Visible bit to the right of the popup. */
@@ -201,12 +204,14 @@ server_client_overlay_range(u_int x, u_int y, u_int sx, u_int sy, u_int px,
ox = px;
onx = px + nx;
if (onx > ox) {
r->px[1] = ox;
r->nx[1] = onx - ox;
r.px[1] = ox;
r.nx[1] = onx - ox;
} else {
r->px[1] = 0;
r->nx[1] = 0;
r.px[1] = 0;
r.nx[1] = 0;
}
r.used = 2;
return (&r);
}
/* Check if this client is inside this server. */