From: Max Kellermann Date: Mon, 28 Sep 2009 16:21:54 +0000 (+0200) Subject: screen_play: repaint hscrolling only if selected item is wide X-Git-Tag: release-0.16~320 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=1a4b44ee075dfd385a523b9977582b82a0fa82da;p=ncmpc.git screen_play: repaint hscrolling only if selected item is wide When the "scroll" option is active, ncmpc repainted the whole screen with each tick, even if the selected item is not wider than the screen. This wasted a lot of CPU cycles. --- diff --git a/src/screen_play.c b/src/screen_play.c index fb5e82b..ed17499 100644 --- a/src/screen_play.c +++ b/src/screen_play.c @@ -52,6 +52,8 @@ typedef struct GList **dir_list; struct mpdclient *c; } completion_callback_data_t; + +static bool must_scroll; #endif static struct mpdclient_playlist *playlist; @@ -141,6 +143,8 @@ list_callback(unsigned idx, bool *highlight, char **second_column, G_GNUC_UNUSED static unsigned current_song; char *tmp; + must_scroll = true; + if (current_song != lw->selected) { st.offset = 0; current_song = lw->selected; @@ -537,6 +541,10 @@ play_title(char *str, size_t size) static void play_paint(void) { +#ifndef NCMPC_MINI + must_scroll = false; +#endif + list_window_paint(lw, list_callback, NULL); } @@ -558,7 +566,7 @@ play_update(struct mpdclient *c) playlist_repaint(); #ifndef NCMPC_MINI - } else if (options.scroll) { + } else if (options.scroll && must_scroll) { /* always repaint if horizontal scrolling is enabled */ playlist_repaint();