=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/tty.c,v retrieving revision 1.415 retrieving revision 1.416 diff -c -r1.415 -r1.416 *** src/usr.bin/tmux/tty.c 2021/12/31 11:35:49 1.415 --- src/usr.bin/tmux/tty.c 2022/02/15 13:03:02 1.416 *************** *** 1,4 **** ! /* $OpenBSD: tty.c,v 1.415 2021/12/31 11:35:49 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott --- 1,4 ---- ! /* $OpenBSD: tty.c,v 1.416 2022/02/15 13:03:02 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott *************** *** 83,88 **** --- 83,90 ---- #define TTY_BLOCK_START(tty) (1 + ((tty)->sx * (tty)->sy) * 8) #define TTY_BLOCK_STOP(tty) (1 + ((tty)->sx * (tty)->sy) / 8) + #define TTY_QUERY_TIMEOUT 5 + void tty_create_log(void) { *************** *** 307,313 **** { struct client *c = tty->client; struct termios tio; ! struct timeval tv = { .tv_sec = 3 }; setblocking(c->fd, 0); event_add(&tty->event_in, NULL); --- 309,315 ---- { struct client *c = tty->client; struct termios tio; ! struct timeval tv = { .tv_sec = TTY_QUERY_TIMEOUT }; setblocking(c->fd, 0); event_add(&tty->event_in, NULL); *************** *** 2917,2919 **** --- 2919,2944 ---- gc.bg = bg; tty_attributes(tty, &gc, defaults, palette); } + + static void + tty_query_timer_callback(__unused int fd, __unused short events, void *data) + { + struct tty *tty = data; + + tty->flags &= ~TTY_OSC52QUERY; + } + + void + tty_send_osc52_query(struct tty *tty) + { + struct timeval tv = { .tv_sec = TTY_QUERY_TIMEOUT }; + + if ((~tty->flags & TTY_STARTED) || (tty->flags & TTY_OSC52QUERY)) + return; + tty_putcode_ptr2(tty, TTYC_MS, "", "?"); + tty->flags |= TTY_OSC52QUERY; + + evtimer_set(&tty->query_timer, tty_query_timer_callback, tty); + evtimer_add(&tty->query_timer, &tv); + } +