1
0
mirror of https://github.com/openbsd/src.git synced 2026-06-17 23:03:29 +02:00

Add a helper to free the list of pending resizes.

This commit is contained in:
nicm
2026-06-11 14:19:59 +00:00
parent 22e93cbe62
commit 7238ecfd40
4 changed files with 24 additions and 27 deletions
+2 -6
View File
@@ -1,4 +1,4 @@
/* $OpenBSD: screen-write.c,v 1.266 2026/06/09 21:22:22 nicm Exp $ */
/* $OpenBSD: screen-write.c,v 1.267 2026/06/11 14:19:59 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -2772,7 +2772,6 @@ screen_write_alternateon(struct screen_write_ctx *ctx, struct grid_cell *gc,
{
struct tty_ctx ttyctx;
struct window_pane *wp = ctx->wp;
struct window_pane_resize *r, *r1;
if (wp != NULL && !options_get_number(wp->options, "alternate-screen"))
return;
@@ -2782,10 +2781,7 @@ screen_write_alternateon(struct screen_write_ctx *ctx, struct grid_cell *gc,
return;
if (wp != NULL) {
TAILQ_FOREACH_SAFE (r, &wp->resize_queue, entry, r1) {
TAILQ_REMOVE(&wp->resize_queue, r, entry);
free(r);
}
window_pane_clear_resizes(wp, NULL);
layout_fix_panes(wp->window, NULL);
server_redraw_window_borders(wp->window);
}
+4 -12
View File
@@ -1,4 +1,4 @@
/* $OpenBSD: server-client.c,v 1.464 2026/06/08 23:06:21 nicm Exp $ */
/* $OpenBSD: server-client.c,v 1.465 2026/06/11 14:19:59 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -1586,7 +1586,7 @@ server_client_resize_timer(__unused int fd, __unused short events, void *data)
static void
server_client_check_pane_resize(struct window_pane *wp)
{
struct window_pane_resize *r, *r1, *first, *last;
struct window_pane_resize *r, *first, *last;
struct timeval tv = { .tv_usec = 250000 };
if (TAILQ_EMPTY(&wp->resize_queue))
@@ -1626,10 +1626,7 @@ server_client_check_pane_resize(struct window_pane *wp)
} else if (last->sx != first->osx || last->sy != first->osy) {
/* Multiple resizes ending up with a different size. */
window_pane_send_resize(wp, last->sx, last->sy);
TAILQ_FOREACH_SAFE(r, &wp->resize_queue, entry, r1) {
TAILQ_REMOVE(&wp->resize_queue, r, entry);
free(r);
}
window_pane_clear_resizes(wp, NULL);
} else {
/*
* Multiple resizes ending up with the same size. There will
@@ -1640,12 +1637,7 @@ server_client_check_pane_resize(struct window_pane *wp)
*/
r = TAILQ_PREV(last, window_pane_resizes, entry);
window_pane_send_resize(wp, r->sx, r->sy);
TAILQ_FOREACH_SAFE(r, &wp->resize_queue, entry, r1) {
if (r == last)
break;
TAILQ_REMOVE(&wp->resize_queue, r, entry);
free(r);
}
window_pane_clear_resizes(wp, last);
tv.tv_usec = 10000;
}
evtimer_add(&wp->resize_timer, &tv);
+3 -1
View File
@@ -1,4 +1,4 @@
/* $OpenBSD: tmux.h,v 1.1344 2026/06/11 10:16:19 nicm Exp $ */
/* $OpenBSD: tmux.h,v 1.1345 2026/06/11 14:19:59 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -3418,6 +3418,8 @@ struct window_pane *window_pane_find_by_id_str(const char *);
struct window_pane *window_pane_find_by_id(u_int);
int window_pane_destroy_ready(struct window_pane *);
void window_pane_resize(struct window_pane *, u_int, u_int);
void window_pane_clear_resizes(struct window_pane *,
struct window_pane_resize *);
int window_pane_set_mode(struct window_pane *,
struct window_pane *, const struct window_mode *,
struct cmd_find_state *, struct args *);
+15 -8
View File
@@ -1,4 +1,4 @@
/* $OpenBSD: window.c,v 1.334 2026/06/10 16:03:14 nicm Exp $ */
/* $OpenBSD: window.c,v 1.335 2026/06/11 14:19:59 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -1112,9 +1112,6 @@ window_pane_wait_finish(struct window_pane *wp)
static void
window_pane_destroy(struct window_pane *wp)
{
struct window_pane_resize *r;
struct window_pane_resize *r1;
window_pane_wait_finish(wp);
window_pane_reset_mode_all(wp);
@@ -1140,10 +1137,7 @@ window_pane_destroy(struct window_pane *wp)
event_del(&wp->resize_timer);
if (event_initialized(&wp->sync_timer))
event_del(&wp->sync_timer);
TAILQ_FOREACH_SAFE(r, &wp->resize_queue, entry, r1) {
TAILQ_REMOVE(&wp->resize_queue, r, entry);
free(r);
}
window_pane_clear_resizes(wp, NULL);
RB_REMOVE(window_pane_tree, &all_window_panes, wp);
@@ -1211,6 +1205,19 @@ window_pane_set_event(struct window_pane *wp)
bufferevent_enable(wp->event, EV_READ|EV_WRITE);
}
void
window_pane_clear_resizes(struct window_pane *wp, struct window_pane_resize *except)
{
struct window_pane_resize *r, *r1;
TAILQ_FOREACH_SAFE(r, &wp->resize_queue, entry, r1) {
if (r == except)
continue;
TAILQ_REMOVE(&wp->resize_queue, r, entry);
free(r);
}
}
void
window_pane_resize(struct window_pane *wp, u_int sx, u_int sy)
{