From ab7dbe9cbec9302234a7f68d69540641b88b5629 Mon Sep 17 00:00:00 2001 From: Andrzej Rybczak Date: Tue, 28 Apr 2009 16:22:06 +0200 Subject: [PATCH] redraw statusbar after terminal resize previous changes broke this, so here is the fix. --- src/global.h | 1 + src/ncmpcpp.cpp | 7 +------ src/status.cpp | 6 ++++-- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/global.h b/src/global.h index 6e9f0162..2ecde78d 100644 --- a/src/global.h +++ b/src/global.h @@ -47,6 +47,7 @@ namespace Global extern bool UpdateStatusImmediately; extern bool MessagesAllowed; extern bool RedrawHeader; + extern bool RedrawStatusbar; extern std::string VolumeState; } diff --git a/src/ncmpcpp.cpp b/src/ncmpcpp.cpp index 3b6e36b7..574ffba3 100644 --- a/src/ncmpcpp.cpp +++ b/src/ncmpcpp.cpp @@ -376,14 +376,9 @@ int main(int argc, char *argv[]) wFooter->Resize(COLS, wFooter->GetHeight()); myScreen->Refresh(); - PlayerState mpd_state = Mpd->GetState(); + RedrawStatusbar = 1; StatusChanges changes; changes.StatusFlags = 1; // force status update - if (mpd_state == psPlay || mpd_state == psPause) - changes.ElapsedTime = 1; // restore status - else - changes.PlayerState = 1; - NcmpcppStatusChanged(Mpd, changes, NULL); } else if (Keypressed(input, Key.GoToParentDir)) diff --git a/src/status.cpp b/src/status.cpp index 97de7de4..cc65a023 100644 --- a/src/status.cpp +++ b/src/status.cpp @@ -41,6 +41,7 @@ using std::string; string Global::VolumeState; bool Global::UpdateStatusImmediately = 0; +bool Global::RedrawStatusbar = 0; namespace { @@ -360,7 +361,7 @@ void NcmpcppStatusChanged(Connection *Mpd, StatusChanges changed, void *) } static time_t now, past = 0; time(&now); - if ((now > past || changed.SongID) && Mpd->GetState() > psStop) + if (((now > past || changed.SongID) && Mpd->GetState() > psStop) || RedrawStatusbar) { time(&past); if (np.Empty()) @@ -373,7 +374,7 @@ void NcmpcppStatusChanged(Connection *Mpd, StatusChanges changed, void *) int mpd_elapsed = Mpd->GetElapsedTime(); if (elapsed < mpd_elapsed-2 || elapsed+1 > mpd_elapsed) elapsed = mpd_elapsed; - else if (Mpd->GetState() == psPlay) + else if (Mpd->GetState() == psPlay && !RedrawStatusbar) elapsed++; if (!block_statusbar_update && Config.statusbar_visibility) @@ -412,6 +413,7 @@ void NcmpcppStatusChanged(Connection *Mpd, StatusChanges changed, void *) } wFooter->SetColor(Config.statusbar_color); } + RedrawStatusbar = 0; } else {