From 4721571b8bcfc2c0266d0f20dcd5ddc7b0e58889 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Sun, 19 Dec 2021 13:13:37 +0000 Subject: [PATCH] GTK: run toplevel callbacks when an fd is active. Normally, the GTK code runs toplevel callbacks from a GTK 'idle function'. But those mean what they say: they are considered low-priority, to be run _only_ when the system is idle - so they can fail to run at all in conditions of a steady stream of higher-priority things, e.g. something is throwing data at the application so fast that every main-loop iteration finds a readable fd. And that's not good, because _we_ don't think our callbacks are low-priority: they do a lot of really important work like redrawing the window. So if they never get round to happening, PuTTY or pterm can appear to lock up. Simple solution to that one: whenever we process a select notification on any fd, we _also_ call run_toplevel_callbacks(). Then our callbacks are bound to happen reasonably regularly. --- unix/gtk-common.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/unix/gtk-common.c b/unix/gtk-common.c index da653253..4fcc0335 100644 --- a/unix/gtk-common.c +++ b/unix/gtk-common.c @@ -86,6 +86,8 @@ gboolean fd_input_func(GIOChannel *source, GIOCondition condition, if (condition & G_IO_OUT) select_result(sourcefd, SELECT_W); + run_toplevel_callbacks(); + return true; } #else @@ -97,6 +99,8 @@ void fd_input_func(gpointer data, gint sourcefd, GdkInputCondition condition) select_result(sourcefd, SELECT_R); if (condition & GDK_INPUT_WRITE) select_result(sourcefd, SELECT_W); + + run_toplevel_callbacks(); } #endif