]> git.ipfire.org Git - thirdparty/mtr.git/commitdiff
curses: drain queued resize events 630/head
authoryvs <VSYakovetsky@gmail.com>
Fri, 8 May 2026 13:50:22 +0000 (17:50 +0400)
committerDarafei Praliaskouski <me@komzpa.net>
Fri, 8 May 2026 13:50:22 +0000 (17:50 +0400)
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 <VSYakovetsky@gmail.com>

ui/curses.c

index aa9a57c4cb8cbb673dc83bdf52deac9c569bbd19..cc53e95a9934a6f352da811c08db12798cb0b65d 100644 (file)
@@ -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,