=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/server-client.c,v retrieving revision 1.387 retrieving revision 1.388 diff -c -r1.387 -r1.388 *** src/usr.bin/tmux/server-client.c 2021/09/27 19:12:00 1.387 --- src/usr.bin/tmux/server-client.c 2021/10/11 13:27:50 1.388 *************** *** 1,4 **** ! /* $OpenBSD: server-client.c,v 1.387 2021/09/27 19:12:00 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott --- 1,4 ---- ! /* $OpenBSD: server-client.c,v 1.388 2021/10/11 13:27:50 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott *************** *** 145,150 **** --- 145,198 ---- c->tty.flags &= ~(TTY_FREEZE|TTY_NOCURSOR); server_redraw_client(c); + } + + /* + * Given overlay position and dimensions, return parts of the input range which + * are visible. + */ + void + 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 ox, onx; + + /* Return up to 2 ranges. */ + r->px[2] = 0; + r->nx[2] = 0; + + /* 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; + } + + /* 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; + } else { + r->px[0] = 0; + r->nx[0] = 0; + } + + /* Visible bit to the right of the popup. */ + ox = x + sx; + if (px > ox) + ox = px; + onx = px + nx; + if (onx > ox) { + r->px[1] = ox; + r->nx[1] = onx - ox; + } else { + r->px[1] = 0; + r->nx[1] = 0; + } } /* Check if this client is inside this server. */