diff options
| author | Simon Tatham <anakin@pobox.com> | 2004-04-28 12:34:37 +0000 |
|---|---|---|
| committer | Simon Tatham <anakin@pobox.com> | 2004-04-28 12:34:37 +0000 |
| commit | d44034bcf699661a11b587c884365a8aa4d6bd39 (patch) | |
| tree | 578dfeb40bd4dd8185a66e99f329fe1d614e9cdb | |
| parent | 3d8e7585b7a9d215e4b40d9f83f7fa5a0fd79b43 (diff) | |
| download | puzzles-d44034bcf699661a11b587c884365a8aa4d6bd39.zip puzzles-d44034bcf699661a11b587c884365a8aa4d6bd39.tar.gz puzzles-d44034bcf699661a11b587c884365a8aa4d6bd39.tar.bz2 puzzles-d44034bcf699661a11b587c884365a8aa4d6bd39.tar.xz | |
More robust timer handling in GTK: never create a new timer when one
is already active.
[originally from svn r4159]
| -rw-r--r-- | gtk.c | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -52,7 +52,7 @@ struct frontend { midend_data *me; GdkGC *gc; int bbox_l, bbox_r, bbox_u, bbox_d; - int timer_active; + int timer_active, timer_id; }; void frontend_default_colour(frontend *fe, float *output) @@ -233,12 +233,15 @@ static gint timer_func(gpointer data) void deactivate_timer(frontend *fe) { + if (fe->timer_active) + gtk_timeout_remove(fe->timer_id); fe->timer_active = FALSE; } void activate_timer(frontend *fe) { - gtk_timeout_add(20, timer_func, fe); + if (!fe->timer_active) + fe->timer_id = gtk_timeout_add(20, timer_func, fe); fe->timer_active = TRUE; } @@ -390,6 +393,8 @@ static frontend *new_window(void) fe->pixmap = NULL; + fe->timer_active = FALSE; + gtk_signal_connect(GTK_OBJECT(fe->window), "destroy", GTK_SIGNAL_FUNC(destroy), fe); gtk_signal_connect(GTK_OBJECT(fe->window), "key_press_event", |