From 4000561216687a173abf597a0fd26d2c336954fc Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Mon, 26 Sep 2011 10:36:09 -0700 Subject: [PATCH] Don't queue up as many widget redraws. For multiple MIDI messages in a single buffer, only queue a single redraw. GTK+ should be coalescing these anyway, but we might as well not make it work any harder than it has too. --- scherzo.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/scherzo.c b/scherzo.c index 88cae44..0ff68d1 100644 --- a/scherzo.c +++ b/scherzo.c @@ -358,6 +358,7 @@ on_midi_input (unused (GIOChannel *channel), ssize_t remaining; snd_seq_event_t event; score_note_t *note; + int need_redraw = FALSE; remaining = read (scherzo->midi_fd, buf, MIDI_BUF_SIZE); @@ -378,12 +379,12 @@ on_midi_input (unused (GIOChannel *channel), case SND_SEQ_EVENT_NOTEON: note = scherzo_add_note_midi (scherzo, event.data.note.note); _judge_note (scherzo, note); - gtk_widget_queue_draw (scherzo->window); + need_redraw = TRUE; break; case SND_SEQ_EVENT_NOTEOFF: scherzo_remove_note_midi (scherzo, event.data.note.note); _score_challenge (scherzo); - gtk_widget_queue_draw (scherzo->window); + need_redraw = TRUE; break; case SND_SEQ_EVENT_CLOCK: /* Ignore for now as my piano sends a constant stream of these. */ @@ -397,7 +398,10 @@ on_midi_input (unused (GIOChannel *channel), break; } } - + + if (need_redraw) + gtk_widget_queue_draw (scherzo->window); + /* Return TRUE to continue to get called in the future. */ return TRUE; } -- 2.43.0