From a334f2f1942d7dc44d00ecbb416f0f4b9264e5bd Mon Sep 17 00:00:00 2001 From: yvs Date: Fri, 8 May 2026 17:50:22 +0400 Subject: [PATCH] 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 --- ui/curses.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) 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, -- 2.47.3