Code

Fixed rogue character after volume change
authorThomas Jansen <mithi@mithi.net>
Mon, 17 Aug 2009 10:19:37 +0000 (12:19 +0200)
committerThomas Jansen <mithi@mithi.net>
Mon, 17 Aug 2009 10:19:37 +0000 (12:19 +0200)
Volume changes that result in a shorter string length did not clean up the
now unused characters. We check the expected (relative) string length before
updating the screen and do a full repaint in that case.

src/screen.c

index 30a017d1edcdbb711ac48d66b9187f5673b0d176..1c44bf7e9cf991cf334e9d0f0d4f0d9dc69b7a9c 100644 (file)
@@ -238,6 +238,18 @@ paint_top_window2(const char *header, mpdclient_t *c)
        wnoutrefresh(w);
 }
 
+static inline int
+volume_length(int volume)
+{
+       if (volume == 100)
+               return 3;
+       if (volume >= 10 && volume < 100)
+               return 2;
+       if (volume >= 0 && volume < 10)
+               return 1;
+       return -1;
+}
+
 static void
 paint_top_window(const char *header, mpdclient_t *c, int full_repaint)
 {
@@ -250,6 +262,10 @@ paint_top_window(const char *header, mpdclient_t *c, int full_repaint)
                full_repaint = 1;
        }
 
+       if (c->status &&
+           volume_length(prev_volume) != volume_length(c->status->volume))
+               full_repaint = 1;
+
        if (full_repaint) {
                wmove(w, 0, 0);
                wclrtoeol(w);