summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 9cb1329)
raw | patch | inline | side by side (parent: 9cb1329)
author | Max Kellermann <max@duempel.org> | |
Mon, 2 Nov 2009 17:29:06 +0000 (18:29 +0100) | ||
committer | Max Kellermann <max@duempel.org> | |
Mon, 2 Nov 2009 17:29:06 +0000 (18:29 +0100) |
Don't look up the playlist. Just use the position provided by MPD.
Side effect: we can pass the mpd_status object to
center_playing_item(), not the whole mpdclient object.
Side effect: we can pass the mpd_status object to
center_playing_item(), not the whole mpdclient object.
src/screen_queue.c | patch | blob | history |
diff --git a/src/screen_queue.c b/src/screen_queue.c
index 4eb3c734e8614c58085edf9c0176d0436d340140..b20aa2496a62d506fe81f2b15feaf360d5025e42 100644 (file)
--- a/src/screen_queue.c
+++ b/src/screen_queue.c
}
static void
-center_playing_item(struct mpdclient *c, bool center_cursor)
+center_playing_item(const struct mpd_status *status, bool center_cursor)
{
int idx;
+ if (status == NULL ||
+ (mpd_status_get_state(status) != MPD_STATE_PLAY &&
+ mpd_status_get_state(status) != MPD_STATE_PAUSE))
+ return;
+
/* try to center the song that are playing */
- idx = playlist_get_index(&c->playlist, c->song);
+ idx = mpd_status_get_song_pos(status);
if (idx < 0)
return;
current_song_id = get_current_song_id(c->status);
/* center the cursor */
- if (options.auto_center && current_song_id != -1 && ! lw->range_selection)
- center_playing_item(c, false);
+ if (options.auto_center && !lw->range_selection)
+ center_playing_item(c->status, false);
screen_queue_repaint();
} else if (c->events & MPD_IDLE_PLAYLIST) {
switch(cmd) {
case CMD_SCREEN_UPDATE:
- center_playing_item(c, prev_cmd == CMD_SCREEN_UPDATE);
+ center_playing_item(c->status, prev_cmd == CMD_SCREEN_UPDATE);
screen_queue_repaint();
return false;
case CMD_SELECT_PLAYING: