diff --git a/hyperlinks.c b/hyperlinks.c index 27af5c4f0..1f2f3eaae 100644 --- a/hyperlinks.c +++ b/hyperlinks.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hyperlinks.c,v 1.5 2026/06/29 16:44:06 nicm Exp $ */ +/* $OpenBSD: hyperlinks.c,v 1.6 2026/09/28 10:42:01 nicm Exp $ */ /* * Copyright (c) 2021 Will @@ -87,7 +87,11 @@ hyperlinks_by_uri_cmp(struct hyperlinks_uri *left, struct hyperlinks_uri *right) return (-1); if (*right->internal_id != '\0') return (1); - return (left->inner - right->inner); + if (left->inner < right->inner) + return (-1); + if (left->inner > right->inner) + return (1); + return (0); } r = strcmp(left->internal_id, right->internal_id); @@ -104,7 +108,11 @@ static int hyperlinks_by_inner_cmp(struct hyperlinks_uri *left, struct hyperlinks_uri *right) { - return (left->inner - right->inner); + if (left->inner < right->inner) + return (-1); + if (left->inner > right->inner) + return (1); + return (0); } RB_PROTOTYPE_STATIC(hyperlinks_by_inner_tree, hyperlinks_uri, by_inner_entry, hyperlinks_by_inner_cmp); diff --git a/screen-write.c b/screen-write.c index 0f3ceafb1..c3f34ff61 100644 --- a/screen-write.c +++ b/screen-write.c @@ -1,4 +1,4 @@ -/* $OpenBSD: screen-write.c,v 1.293 2026/09/24 11:19:39 nicm Exp $ */ +/* $OpenBSD: screen-write.c,v 1.294 2026/09/28 10:10:16 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -201,15 +201,7 @@ screen_write_pane_is_obscured(struct screen_write_ctx *ctx) } while ((wp = TAILQ_PREV(wp, window_panes, zentry)) != NULL) { - if (window_pane_is_floating(wp) && - ((wp->yoff >= ctx->wp->yoff && - wp->yoff <= ctx->wp->yoff + (int)ctx->wp->sy) || - (wp->yoff + (int)wp->sy >= ctx->wp->yoff && - wp->yoff + wp->sy <= ctx->wp->yoff + ctx->wp->sy)) && - ((wp->xoff >= ctx->wp->xoff && - wp->xoff <= ctx->wp->xoff + (int)ctx->wp->sx) || - (wp->xoff + (int)wp->sx >= ctx->wp->xoff && - wp->xoff + wp->sx <= ctx->wp->xoff + ctx->wp->sx))) { + if (window_pane_floating_overlaps(wp, ctx->wp)) { ctx->flags |= SCREEN_WRITE_OBSCURED; return (1); } diff --git a/sort.c b/sort.c index 3b4d77301..ab3f5905b 100644 --- a/sort.c +++ b/sort.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sort.c,v 1.11 2026/09/28 09:41:53 nicm Exp $ */ +/* $OpenBSD: sort.c,v 1.12 2026/09/28 10:42:01 nicm Exp $ */ /* * Copyright (c) 2026 Dane Jensen @@ -25,6 +25,16 @@ static struct sort_criteria *sort_criteria; +static int +sort_number_cmp(unsigned long long a, unsigned long long b) +{ + if (a < b) + return (-1); + if (a > b) + return (1); + return (0); +} + static void sort_qsort(void *l, u_int len, u_int size, int (*cmp)(const void *, const void *), struct sort_criteria *sort_crit) @@ -73,7 +83,7 @@ sort_buffer_cmp(const void *a0, const void *b0) result = 0; break; case SORT_SIZE: - result = pa->size - pb->size; + result = sort_number_cmp(pa->size, pb->size); break; case SORT_ACTIVITY: case SORT_INDEX: @@ -107,9 +117,9 @@ sort_client_cmp(const void *a0, const void *b0) result = strcmp(ca->name, cb->name); break; case SORT_SIZE: - result = ca->tty.sx - cb->tty.sx; + result = sort_number_cmp(ca->tty.sx, cb->tty.sx); if (result == 0) - result = ca->tty.sy - cb->tty.sy; + result = sort_number_cmp(ca->tty.sy, cb->tty.sy); break; case SORT_CREATION: if (timercmp(&ca->creation_time, &cb->creation_time, >)) @@ -151,7 +161,7 @@ sort_session_cmp(const void *a0, const void *b0) switch (sort_crit->order) { case SORT_INDEX: - result = sa->id - sb->id; + result = sort_number_cmp(sa->id, sb->id); break; case SORT_CREATION: if (timercmp(&sa->creation_time, &sb->creation_time, >)) { @@ -203,18 +213,18 @@ sort_pane_cmp(const void *a0, const void *b0) switch (sort_crit->order) { case SORT_ACTIVITY: - result = a->active_point - b->active_point; + result = sort_number_cmp(a->active_point, b->active_point); break; case SORT_CREATION: - result = a->id - b->id; + result = sort_number_cmp(a->id, b->id); break; case SORT_SIZE: - result = a->sx * a->sy - b->sx * b->sy; + result = sort_number_cmp(a->sx * a->sy, b->sx * b->sy); break; case SORT_INDEX: window_pane_index(a, &ai); window_pane_index(b, &bi); - result = ai - bi; + result = sort_number_cmp(ai, bi); break; case SORT_NAME: result = strcmp(a->screen->title, b->screen->title); @@ -222,7 +232,7 @@ sort_pane_cmp(const void *a0, const void *b0) case SORT_Z: window_pane_zindex(a, &ai); window_pane_zindex(b, &bi); - result = ai - bi; + result = sort_number_cmp(ai, bi); break; case SORT_MODIFIER: case SORT_ORDER: @@ -278,7 +288,7 @@ sort_winlink_cmp(const void *a0, const void *b0) result = strcmp(wa->name, wb->name); break; case SORT_SIZE: - result = wa->sx * wa->sy - wb->sx * wb->sy; + result = sort_number_cmp(wa->sx * wa->sy, wb->sx * wb->sy); break; case SORT_MODIFIER: case SORT_ORDER: @@ -302,14 +312,16 @@ sort_key_binding_cmp(const void *a0, const void *b0) const struct key_binding *a = *(struct key_binding **)a0; const struct key_binding *b = *(struct key_binding **)b0; int result = 0; + key_code ak, bk; switch (sort_crit->order) { case SORT_INDEX: - result = a->key - b->key; + result = sort_number_cmp(a->key, b->key); break; case SORT_MODIFIER: - result = (a->key & KEYC_MASK_MODIFIERS) - - (b->key & KEYC_MASK_MODIFIERS); + ak = (a->key & KEYC_MASK_MODIFIERS); + bk = (b->key & KEYC_MASK_MODIFIERS); + result = sort_number_cmp(ak, bk); break; case SORT_NAME: result = strcasecmp(a->tablename, b->tablename); @@ -325,12 +337,8 @@ sort_key_binding_cmp(const void *a0, const void *b0) if (result == 0) result = strcasecmp(a->tablename, b->tablename); - if (result == 0) { - if (a->key < b->key) - result = -1; - else if (a->key > b->key) - result = 1; - } + if (result == 0) + result = sort_number_cmp(a->key, b->key); if (sort_crit->reversed) result = -result; diff --git a/tmux.h b/tmux.h index 273053b4a..dee768686 100644 --- a/tmux.h +++ b/tmux.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.h,v 1.1448 2026/09/24 11:19:39 nicm Exp $ */ +/* $OpenBSD: tmux.h,v 1.1449 2026/09/28 10:10:16 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -3705,6 +3705,8 @@ struct window_pane *window_find_string(struct window *, const char *); int window_has_floating_panes(struct window *); int window_has_pane(struct window *, struct window_pane *); int window_pane_contains(struct window_pane *, u_int, u_int); +int window_pane_floating_overlaps(struct window_pane *, + struct window_pane *); int window_set_active_pane(struct window *, struct window_pane *, int); void window_fire_pane_moved(struct window_pane *, struct window *, diff --git a/window.c b/window.c index 777788862..515c2ffc6 100644 --- a/window.c +++ b/window.c @@ -1,4 +1,4 @@ -/* $OpenBSD: window.c,v 1.379 2026/09/25 08:46:06 nicm Exp $ */ +/* $OpenBSD: window.c,v 1.383 2026/09/28 10:42:01 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -92,7 +92,11 @@ struct window_pane_prompt { int window_cmp(struct window *w1, struct window *w2) { - return (w1->id - w2->id); + if (w1->id < w2->id) + return (-1); + if (w1->id > w2->id) + return (1); + return (0); } static void @@ -199,7 +203,11 @@ winlink_cmp(struct winlink *wl1, struct winlink *wl2) int window_pane_cmp(struct window_pane *wp1, struct window_pane *wp2) { - return (wp1->id - wp2->id); + if (wp1->id < wp2->id) + return (-1); + if (wp1->id > wp2->id) + return (1); + return (0); } struct winlink * @@ -667,6 +675,34 @@ window_pane_contains(struct window_pane *wp, u_int x, u_int y) return (1); } +/* + * Does floating pane, including its borders and scrollbar, overlap any cell of + * another pane, including its scrollbar? + */ +int +window_pane_floating_overlaps(struct window_pane *fwp, struct window_pane *wp) +{ + int fxoff, fyoff, xoff, yoff, border = 0; + u_int fsx, fsy, sx, sy; + + if (!window_pane_is_floating(fwp)) + return (0); + + window_pane_full_size_offset(fwp, &fxoff, &fyoff, &fsx, &fsy); + window_pane_full_size_offset(wp, &xoff, &yoff, &sx, &sy); + + if (window_pane_get_pane_lines(fwp) != PANE_LINES_NONE) + border = 1; + + if (fxoff - border >= xoff + (int)sx || + fxoff + (int)fsx + border <= xoff) + return (0); + if (fyoff - border >= yoff + (int)sy || + fyoff + (int)fsy + border <= yoff) + return (0); + return (1); +} + void window_update_focus(struct window *w) { @@ -823,6 +859,16 @@ window_get_active_at(struct window *w, u_int x, u_int y) return (NULL); } + /* + * A floating pane is above every tiled pane, including their status + * lines, so check those first. + */ + TAILQ_FOREACH(wp, &w->z_index, zentry) { + if (window_pane_is_floating(wp) && + window_pane_contains(wp, x, y)) + return (wp); + } + if (pane_status == PANE_STATUS_TOP) { /* * Prefer a pane's top border status line over the pane above's @@ -1440,7 +1486,7 @@ window_pane_wait_finish(struct window_pane *wp) { struct cmdq_item *item = wp->wait_item; struct client *c; - int retval = 0; + int retval = 128 + SIGHUP; if (item == NULL) return;