diff --git a/src/global.h b/src/global.h index 22f5b8a7..6e9f0162 100644 --- a/src/global.h +++ b/src/global.h @@ -44,6 +44,7 @@ namespace Global extern bool BlockItemListUpdate; + extern bool UpdateStatusImmediately; extern bool MessagesAllowed; extern bool RedrawHeader; diff --git a/src/ncmpcpp.cpp b/src/ncmpcpp.cpp index 9941ba42..425f16f1 100644 --- a/src/ncmpcpp.cpp +++ b/src/ncmpcpp.cpp @@ -196,7 +196,7 @@ int main(int argc, char *argv[]) { ShowMessage("Connected to %s!", Mpd->GetHostname().c_str()); MessagesAllowed = 0; - Mpd->UpdateStatus(); + UpdateStatusImmediately = 1; } } @@ -551,17 +551,17 @@ int main(int argc, char *argv[]) else if (Keypressed(input, Key.Prev)) { Mpd->Prev(); - Mpd->UpdateStatus(); + UpdateStatusImmediately = 1; } else if (Keypressed(input, Key.Next)) { Mpd->Next(); - Mpd->UpdateStatus(); + UpdateStatusImmediately = 1; } else if (Keypressed(input, Key.Pause)) { Mpd->Pause(); - Mpd->UpdateStatus(); + UpdateStatusImmediately = 1; } else if (Keypressed(input, Key.SavePlaylist)) { @@ -618,7 +618,7 @@ int main(int argc, char *argv[]) else if (Keypressed(input, Key.Stop)) { Mpd->Stop(); - Mpd->UpdateStatus(); + UpdateStatusImmediately = 1; } else if (Keypressed(input, Key.MvSongUp)) { @@ -991,7 +991,7 @@ int main(int argc, char *argv[]) wFooter->Refresh(); } Mpd->Seek(songpos); - Mpd->UpdateStatus(); + UpdateStatusImmediately = 1; UnlockProgressbar(); UnlockStatusbar(); @@ -1081,17 +1081,17 @@ int main(int argc, char *argv[]) else if (Keypressed(input, Key.ToggleRepeat)) { Mpd->SetRepeat(!Mpd->GetRepeat()); - Mpd->UpdateStatus(); + UpdateStatusImmediately = 1; } else if (Keypressed(input, Key.Shuffle)) { Mpd->Shuffle(); - Mpd->UpdateStatus(); + UpdateStatusImmediately = 1; } else if (Keypressed(input, Key.ToggleRandom)) { Mpd->SetRandom(!Mpd->GetRandom()); - Mpd->UpdateStatus(); + UpdateStatusImmediately = 1; } else if (Keypressed(input, Key.ToggleSingle)) { @@ -1106,18 +1106,18 @@ int main(int argc, char *argv[]) else { Mpd->SetSingle(!Mpd->GetSingle()); - Mpd->UpdateStatus(); + UpdateStatusImmediately = 1; } } else if (Keypressed(input, Key.ToggleConsume)) { Mpd->SetConsume(!Mpd->GetConsume()); - Mpd->UpdateStatus(); + UpdateStatusImmediately = 1; } else if (Keypressed(input, Key.ToggleCrossfade)) { Mpd->SetCrossfade(Mpd->GetCrossfade() ? 0 : Config.crossfade_time); - Mpd->UpdateStatus(); + UpdateStatusImmediately = 1; } else if (Keypressed(input, Key.SetCrossfade)) { @@ -1130,7 +1130,7 @@ int main(int argc, char *argv[]) { Config.crossfade_time = cf; Mpd->SetCrossfade(cf); - Mpd->UpdateStatus(); + UpdateStatusImmediately = 1; } } else if (Keypressed(input, Key.EditTags)) @@ -1345,7 +1345,7 @@ int main(int argc, char *argv[]) else ShowMessage("Out of bounds, 1-99 possible for %, %d given.", newpos); } - Mpd->UpdateStatus(); + UpdateStatusImmediately = 1; } else if (Keypressed(input, Key.ReverseSelection)) { @@ -1551,7 +1551,6 @@ int main(int argc, char *argv[]) { Mpd->ClearPlaylist(); } - Mpd->UpdateStatus(); ShowMessage("Cleared playlist!"); } } diff --git a/src/playlist.cpp b/src/playlist.cpp index dfe345ff..37b8be7c 100644 --- a/src/playlist.cpp +++ b/src/playlist.cpp @@ -119,7 +119,7 @@ void Playlist::EnterPressed() if (!w->Empty()) { Mpd->PlayID(w->Current().GetID()); - Mpd->UpdateStatus(); + UpdateStatusImmediately = 1; } } diff --git a/src/status.cpp b/src/status.cpp index 175a9fa9..99430c2b 100644 --- a/src/status.cpp +++ b/src/status.cpp @@ -40,6 +40,8 @@ using std::string; string Global::VolumeState; +bool Global::UpdateStatusImmediately = 0; + namespace { time_t time_of_statusbar_lock; @@ -115,13 +117,15 @@ void TraceMpdStatus() static timeval past, now; gettimeofday(&now, 0); - if (Mpd->Connected() - && ((now.tv_sec == past.tv_sec && now.tv_usec >= past.tv_usec+500000) || now.tv_sec > past.tv_sec) + if ((Mpd->Connected() + && ((now.tv_sec == past.tv_sec && now.tv_usec >= past.tv_usec+500000) || now.tv_sec > past.tv_sec)) + || UpdateStatusImmediately ) { Mpd->UpdateStatus(); BlockItemListUpdate = 0; Playlist::BlockUpdate = 0; + UpdateStatusImmediately = 0; gettimeofday(&past, 0); } wFooter->Refresh();