summaryrefslogtreecommitdiff
path: root/usr.bin/tmux/popup.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2021-10-11 13:27:51 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2021-10-11 13:27:51 +0000
commit9005ab924af56df5945d74d8db7d9ba3d48f57b7 (patch)
treee8c3bb7b75a94fdc5786307d0509539449bba557 /usr.bin/tmux/popup.c
parent0438c56b034e2c55a51d27f64912e3ee08720cf2 (diff)
Make positions hidden by overlays range-based rather than character-based,
from Anindya Mukherjee.
Diffstat (limited to 'usr.bin/tmux/popup.c')
-rw-r--r--usr.bin/tmux/popup.c51
1 files changed, 41 insertions, 10 deletions
diff --git a/usr.bin/tmux/popup.c b/usr.bin/tmux/popup.c
index 76f9e4c8d99..0f035a2443b 100644
--- a/usr.bin/tmux/popup.c
+++ b/usr.bin/tmux/popup.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: popup.c,v 1.35 2021/10/11 10:55:30 nicm Exp $ */
+/* $OpenBSD: popup.c,v 1.36 2021/10/11 13:27:50 nicm Exp $ */
/*
* Copyright (c) 2020 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -157,18 +157,49 @@ popup_mode_cb(__unused struct client *c, void *data, u_int *cx, u_int *cy)
return (&pd->s);
}
-static int
-popup_check_cb(struct client *c, void *data, u_int px, u_int py)
+/* Return parts of the input range which are not obstructed by the popup. */
+static void
+popup_check_cb(struct client* c, void *data, u_int px, u_int py, u_int nx,
+ struct overlay_ranges *r)
{
struct popup_data *pd = data;
+ struct overlay_ranges or[2];
+ u_int i, j, k = 0;
- if (pd->md != NULL && menu_check_cb(c, pd->md, px, py) == 0)
- return (0);
- if (px < pd->px || px > pd->px + pd->sx - 1)
- return (1);
- if (py < pd->py || py > pd->py + pd->sy - 1)
- return (1);
- return (0);
+ if (pd->md != NULL) {
+ /* Check each returned range for the menu against the popup. */
+ menu_check_cb(c, pd->md, px, py, nx, r);
+ for (i = 0; i < 2; i++) {
+ server_client_overlay_range(pd->px, pd->py, pd->sx,
+ pd->sy, r->px[i], py, r->nx[i], &or[i]);
+ }
+
+ /*
+ * or has up to OVERLAY_MAX_RANGES non-overlapping ranges,
+ * ordered from left to right. Collect them in the output.
+ */
+ for (i = 0; i < 2; i++) {
+ /* Each or[i] only has 2 ranges. */
+ for (j = 0; j < 2; j++) {
+ if (or[i].nx[j] > 0) {
+ r->px[k] = or[i].px[j];
+ r->nx[k] = or[i].nx[j];
+ k++;
+ }
+ }
+ }
+
+ /* Zero remaining ranges if any. */
+ for (i = k; i < OVERLAY_MAX_RANGES; i++) {
+ r->px[i] = 0;
+ r->nx[i] = 0;
+ }
+
+ return;
+ }
+
+ server_client_overlay_range(pd->px, pd->py, pd->sx, pd->sy, px, py, nx,
+ r);
}
static void