From: Max Kellermann Date: Sun, 11 Oct 2009 17:01:57 +0000 (+0200) Subject: screen_queue: check current song only if PLAYER idle event is set X-Git-Tag: release-0.16~111 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=0d2b8719ca48a2998e83b5735c6f7cfaaf689f7f;p=ncmpc.git screen_queue: check current song only if PLAYER idle event is set --- diff --git a/src/screen_queue.c b/src/screen_queue.c index 0381d52..750e940 100644 --- a/src/screen_queue.c +++ b/src/screen_queue.c @@ -549,21 +549,26 @@ screen_queue_paint(void) list_window_paint(lw, screen_queue_lw_callback, NULL); } +G_GNUC_PURE +static int +get_current_song_id(const struct mpd_status *status) +{ + return status != NULL && + (mpd_status_get_state(status) == MPD_STATE_PLAY || + mpd_status_get_state(status) == MPD_STATE_PAUSE) + ? (int)mpd_status_get_song_id(status) + : -1; +} + static void screen_queue_update(struct mpdclient *c) { - static int prev_song_id = -1; - if (c->events & MPD_IDLE_PLAYLIST) screen_queue_restore_selection(); - current_song_id = c->status != NULL && - (mpd_status_get_state(c->status) == MPD_STATE_PLAY || - mpd_status_get_state(c->status) == MPD_STATE_PAUSE) - ? (int)mpd_status_get_song_id(c->status) : -1; - - if (current_song_id != prev_song_id) { - prev_song_id = current_song_id; + if ((c->events & MPD_IDLE_PLAYER) != 0 && + get_current_song_id(c->status) != current_song_id) { + current_song_id = get_current_song_id(c->status); /* center the cursor */ if (options.auto_center && current_song_id != -1 && ! lw->range_selection)