From: yvs Date: Fri, 8 May 2026 13:50:22 +0000 (+0400) Subject: curses: drain queued resize events X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=refs%2Fpull%2F630%2Fhead;p=thirdparty%2Fmtr.git curses: drain queued resize events Port the bounded KEY_RESIZE drain from the mtr085 fork so repeated terminal resize events do not keep curses input stuck on resize notifications. Ported-from: yvs2014/mtr085@249b8e97db05f4deb80c8df44cebb71f6424ec54 Original-author: yvs --- diff --git a/ui/curses.c b/ui/curses.c index aa9a57c..cc53e95 100644 --- a/ui/curses.c +++ b/ui/curses.c @@ -147,6 +147,25 @@ int mtr_curses_keyaction( float f = 0.0; char buf[MAXFLD + 1]; +#ifdef KEY_RESIZE + /* + Some curses implementations may queue many resize events while the + terminal is being dragged. Drain a bounded batch so real key input + can be handled again after the resize settles. + */ + if (c == KEY_RESIZE) { + int resize_events; + + for (resize_events = 0; resize_events < 100 && c == KEY_RESIZE; + resize_events++) { + c = getch(); + } + if (c == KEY_RESIZE) { + flushinp(); + } + } +#endif + if (c == 'Q') { /* must be checked before c = tolower(c) */ mvprintw(2, 0, "Type of Service(tos): %d\n", ctl->tos); mvprintw(3, 0,