diff options
author | Thomas Adam <thomas@xteddy.org> | 2021-10-11 16:01:13 +0100 |
---|---|---|
committer | Thomas Adam <thomas@xteddy.org> | 2021-10-11 16:01:13 +0100 |
commit | aff2a473ec3c16396d6be9d61c5e5dc1201a725b (patch) | |
tree | 828bc514fff183f468c2f509bf509ea6042cdaa7 /server-client.c | |
parent | af82106fae823f55fd3c746e1b48bc8e52a55e68 (diff) | |
parent | b8581ec80e5339be5e2c08cfec70a77f21ba06b2 (diff) | |
download | rtmux-aff2a473ec3c16396d6be9d61c5e5dc1201a725b.tar.gz rtmux-aff2a473ec3c16396d6be9d61c5e5dc1201a725b.tar.bz2 rtmux-aff2a473ec3c16396d6be9d61c5e5dc1201a725b.zip |
Merge branch 'obsd-master' into master
Diffstat (limited to 'server-client.c')
-rw-r--r-- | server-client.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/server-client.c b/server-client.c index d8cbfdbf..03a24a8c 100644 --- a/server-client.c +++ b/server-client.c @@ -144,6 +144,54 @@ server_client_clear_overlay(struct client *c) 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. */ int server_client_check_nested(struct client *c) |