From 326eaa8f0fcced90c99d4aa547dd0875555350ef Mon Sep 17 00:00:00 2001 From: Matt Birkholz Date: Sat, 2 Feb 2013 12:27:59 -0700 Subject: [PATCH] gtk: Update the time-slice window BEFORE sleeping. Thus when the toolkit flames out, the time-slice window stops on the list of file descriptors Scheme IS waiting on (NOT the descriptors it WAS waiting on). --- src/gtk/gtkio.c.stay | 41 ++++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/src/gtk/gtkio.c.stay b/src/gtk/gtkio.c.stay index 42b67ce77..9010cdd64 100644 --- a/src/gtk/gtkio.c.stay +++ b/src/gtk/gtkio.c.stay @@ -1,6 +1,6 @@ /* -*-C-*- -Copyright (C) 2008, 2009, 2010, 2011 Matthew Birkholz +Copyright (C) 2008, 2009, 2010, 2011, 2012, 2013 Matthew Birkholz This file is part of MIT/GNU Scheme. @@ -148,7 +148,6 @@ scheme_source_prepare (GSource * source, gint * timeout) if (src->time_limit == 0.0) { trace (";scheme_source_prepare: polling\n"); - /* 0 here does not allow expose events to be delivered? */ *timeout = 0; return (FALSE); } @@ -243,24 +242,7 @@ pending_io (SchemeSource * src) static gboolean do_scheme (GSource *source) { - SchemeSource * src = (SchemeSource *)source; - slice_counter += 1; - if (slice_window != NULL) - { - gchar * fdstr, * text; - - text = g_strdup_printf ("Scheme time-slice: %d", slice_counter); - gtk_label_set_text (GTK_LABEL (slice_label), text); - g_free (text); - - fdstr = gpollfds_string (src->gpollfds); - text = g_strdup_printf ("Channels:%s", fdstr); - if (fdstr[0] != '\0') - g_free (fdstr); - gtk_label_set_text (GTK_LABEL (status_label), text); - g_free (text); - } trace (";scheme_source_dispatch: running time slice %d\n", slice_counter); Interpret (1); @@ -437,6 +419,23 @@ run_gtk (unsigned long registry, double time) if (fdstr[0] != '\0') g_free (fdstr); } + + /* Update the time-slice window before "sleeping". */ + if (slice_window != NULL) + { + gchar * fdstr, * text; + + text = g_strdup_printf ("Scheme time-slice: %d", slice_counter); + gtk_label_set_text (GTK_LABEL (slice_label), text); + g_free (text); + fdstr = gpollfds_string (scheme_source->gpollfds); + text = g_strdup_printf ("Channels:%s", fdstr); + if (fdstr[0] != '\0') + g_free (fdstr); + gtk_label_set_text (GTK_LABEL (status_label), text); + g_free (text); + } + /* Force expose event delivery, so that animations continue to move even when Scheme is not "idle". */ gdk_window_process_all_updates (); @@ -521,7 +520,7 @@ open_slice_window (void) { slice_window = gtk_window_new (GTK_WINDOW_TOPLEVEL); GtkWidget * grid = gtk_grid_new (); - status_label = gtk_label_new ("Channels:"); + status_label = gtk_label_new ("Channels: -"); slice_label = gtk_label_new ("Scheme time-slice: 0"); g_signal_connect (slice_window, "delete_event", G_CALLBACK (slice_window_delete_event), NULL); @@ -531,7 +530,7 @@ open_slice_window (void) gtk_container_add (GTK_CONTAINER (grid), status_label); gtk_container_add (GTK_CONTAINER (grid), slice_label); gtk_container_add (GTK_CONTAINER (slice_window), grid); - gtk_container_set_border_width (GTK_CONTAINER (slice_window), 2); + gtk_container_set_border_width (GTK_CONTAINER (slice_window), 5); gtk_window_set_title (GTK_WINDOW (slice_window), "Scheme Time-Slice Counter"); gtk_window_set_type_hint (GTK_WINDOW (slice_window), GDK_WINDOW_TYPE_HINT_UTILITY); -- 2.25.1