X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=scherzo.c;h=98f70bd99ff2485e0cf3e0b4ad542341353f41f5;hb=0d91a08ddeea3e07edb853e01f3b3dfde18ea7d7;hp=955f5b7551d773f865feabb1761424515a49a233;hpb=3f6a9cdbf572c83c323f40cc66e301bdf128f076;p=scherzo diff --git a/scherzo.c b/scherzo.c index 955f5b7..98f70bd 100644 --- a/scherzo.c +++ b/scherzo.c @@ -92,7 +92,7 @@ on_expose_event_draw (GtkWidget *widget, cairo_paint (cr); /* Add some padding on the sides and top */ - cairo_translate (cr, pad, 2 * scherzo->staff_height); + cairo_translate (cr, pad, scherzo->staff_height); score_set_staff_height (score, scherzo->staff_height); score_set_width (score, widget_width - 2 * pad); @@ -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); @@ -369,6 +370,7 @@ on_midi_input (unused (GIOChannel *channel), next, remaining, &event); remaining -= consumed; + next += consumed; switch (event.type) { case SND_SEQ_EVENT_NONE: @@ -377,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. */ @@ -396,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; }