summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 295034a)
raw | patch | inline | side by side (parent: 295034a)
author | Thomas Jansen <mithi@mithi.net> | |
Fri, 11 Sep 2009 14:11:30 +0000 (16:11 +0200) | ||
committer | Thomas Jansen <mithi@mithi.net> | |
Fri, 11 Sep 2009 14:11:30 +0000 (16:11 +0200) |
When a new song starts and the lyrics screen is displayed, fetch the lyrics
for the new song and display them. Don't switch to the new song's lyrics if
the lyrics screen was opened for a specific song.
for the new song and display them. Don't switch to the new song's lyrics if
the lyrics screen was opened for a specific song.
diff --git a/src/screen.c b/src/screen.c
index 1c44bf7e9cf991cf334e9d0f0d4f0d9dc69b7a9c..8e31d148ed7b804419ac69226b8da79cbc83ae95 100644 (file)
--- a/src/screen.c
+++ b/src/screen.c
#endif
#ifdef ENABLE_LYRICS_SCREEN
else if (mode_fn_prev == &screen_lyrics)
- screen_lyrics_switch(c, song);
+ screen_lyrics_switch(c, song, true);
#endif
else
screen_switch(mode_fn_prev, c);
diff --git a/src/screen.h b/src/screen.h
index 601548c0158ecf7edfd0d278b54aceccbb5a664e..343f9441ca65cb655fe57ca37ae5f437923edd4d 100644 (file)
--- a/src/screen.h
+++ b/src/screen.h
#ifdef ENABLE_LYRICS_SCREEN
void
-screen_lyrics_switch(struct mpdclient *c, const struct mpd_song *song);
+screen_lyrics_switch(struct mpdclient *c, const struct mpd_song *song, bool follow);
#endif
#endif
diff --git a/src/screen_browser.c b/src/screen_browser.c
index f8386bb426a45e1904ded9680882238fcb311ff1..e1b2e5fb6cf2688260ec95893d31615a564b6872 100644 (file)
--- a/src/screen_browser.c
+++ b/src/screen_browser.c
entry->entity->type != MPD_INFO_ENTITY_TYPE_SONG)
return true;
- screen_lyrics_switch(c, entry->entity->info.song);
+ screen_lyrics_switch(c, entry->entity->info.song, false);
return true;
#endif
case CMD_SCREEN_SWAP:
diff --git a/src/screen_lyrics.c b/src/screen_lyrics.c
index 51bb903a88ad108edb153d7a9f946433021646fd..a1556aec582bbdf2cf2d2eb3ad9d013a41b3b812 100644 (file)
--- a/src/screen_lyrics.c
+++ b/src/screen_lyrics.c
static struct screen_text text;
static const struct mpd_song *next_song;
+static bool follow = false;
static struct {
struct mpd_song *song;
next_song = NULL;
}
+static void
+lyrics_update(mpdclient_t *c)
+{
+ if (!follow)
+ return;
+
+ next_song = c->song;
+
+ if (next_song != NULL &&
+ (current.song == NULL ||
+ strcmp(next_song->file, current.song->file) != 0))
+ screen_lyrics_load(next_song);
+
+ next_song = NULL;
+}
static const char *
lyrics_title(char *str, size_t size)
.init = lyrics_screen_init,
.exit = lyrics_exit,
.open = lyrics_open,
+ .update = lyrics_update,
.close = NULL,
.resize = lyrics_resize,
.paint = lyrics_paint,
};
void
-screen_lyrics_switch(struct mpdclient *c, const struct mpd_song *song)
+screen_lyrics_switch(struct mpdclient *c, const struct mpd_song *song, bool f)
{
assert(song != NULL);
+ follow = f;
next_song = song;
screen_switch(&screen_lyrics, c);
}
diff --git a/src/screen_play.c b/src/screen_play.c
index 46ad68eb24dead84bafa53c51bd8fe6c3505d2e6..3f79ad75f7e71ed20ea5295ab37c6fa6ef4af146 100644 (file)
--- a/src/screen_play.c
+++ b/src/screen_play.c
#ifdef ENABLE_LYRICS_SCREEN
case CMD_SCREEN_LYRICS:
if (lw->selected < playlist_length(&c->playlist)) {
- screen_lyrics_switch(c, playlist_get(&c->playlist, lw->selected));
+ struct mpd_song *selected = playlist_get(&c->playlist, lw->selected);
+ bool follow = false;
+
+ if (c->song && selected &&
+ !strcmp(selected->file, c->song->file))
+ follow = true;
+
+ screen_lyrics_switch(c, selected, follow);
return true;
}
diff --git a/src/screen_song.c b/src/screen_song.c
index 8328415bf413a48bd63ba06c977e7733e91db68d..6d27e564a6ca8a23811f42f2f1986839cfdf493e 100644 (file)
--- a/src/screen_song.c
+++ b/src/screen_song.c
#ifdef ENABLE_LYRICS_SCREEN
case CMD_SCREEN_LYRICS:
if (current.selected_song != NULL) {
- screen_lyrics_switch(c, current.selected_song);
+ screen_lyrics_switch(c, current.selected_song, false);
return true;
}
if (current.played_song != NULL) {
- screen_lyrics_switch(c, current.played_song);
+ screen_lyrics_switch(c, current.played_song, true);
return true;
}
return false;