summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 2ff7f4c)
raw | patch | inline | side by side (parent: 2ff7f4c)
author | Max Kellermann <max@duempel.org> | |
Mon, 2 Nov 2009 17:31:17 +0000 (18:31 +0100) | ||
committer | Max Kellermann <max@duempel.org> | |
Mon, 2 Nov 2009 17:31:17 +0000 (18:31 +0100) |
When the queue screen is not open, and the song changes, it was not
updated, not even if you switch back and press Ctrl-L.
This patch moves some common code to screen_queue_song_change(), which
is also called by the open() method.
updated, not even if you switch back and press Ctrl-L.
This patch moves some common code to screen_queue_song_change(), which
is also called by the open() method.
src/screen_queue.c | patch | blob | history |
diff --git a/src/screen_queue.c b/src/screen_queue.c
index b20aa2496a62d506fe81f2b15feaf360d5025e42..79a112b60468e889615ec525dcf1f7b484b5d25d 100644 (file)
--- a/src/screen_queue.c
+++ b/src/screen_queue.c
list_window_fetch_cursor(lw);
}
+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 bool
+screen_queue_song_change(const struct mpd_status *status)
+{
+ if (get_current_song_id(status) == current_song_id)
+ return false;
+
+ current_song_id = get_current_song_id(status);
+
+ /* center the cursor */
+ if (options.auto_center && !lw->range_selection)
+ center_playing_item(status, false);
+
+ return true;
+}
+
#ifndef NCMPC_MINI
static void
save_pre_completion_cb(GCompletion *gcmp, G_GNUC_UNUSED gchar *line,
}
screen_queue_restore_selection();
+ screen_queue_song_change(c->status);
}
static void
list_window_paint2(lw, screen_queue_paint_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)
{
if (c->events & MPD_IDLE_PLAYLIST)
screen_queue_restore_selection();
- 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 && !lw->range_selection)
- center_playing_item(c->status, false);
-
+ if (((c->events & MPD_IDLE_PLAYER) != 0 &&
+ screen_queue_song_change(c->status)) ||
+ c->events & MPD_IDLE_PLAYLIST)
+ /* the queue or the current song has changed, we must
+ paint the new version */
screen_queue_repaint();
- } else if (c->events & MPD_IDLE_PLAYLIST) {
- /* the playlist has changed, we must paint the new
- version */
- screen_queue_repaint();
- }
}
#ifdef HAVE_GETMOUSE