From f4a47d5dc83c5c18ea41e172c775e2fbcd81a49a Mon Sep 17 00:00:00 2001 From: Thomas Jansen Date: Mon, 17 Aug 2009 12:19:37 +0200 Subject: [PATCH] Fixed rogue character after volume change 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 | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/screen.c b/src/screen.c index 30a017d..1c44bf7 100644 --- a/src/screen.c +++ b/src/screen.c @@ -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); -- 2.30.2