use flag to force status update rather than doing additional update

This commit is contained in:
Andrzej Rybczak
2009-04-01 16:15:19 +02:00
parent 89c06db1f4
commit 7f85a0dcd1
4 changed files with 22 additions and 18 deletions

View File

@@ -44,6 +44,7 @@ namespace Global
extern bool BlockItemListUpdate; extern bool BlockItemListUpdate;
extern bool UpdateStatusImmediately;
extern bool MessagesAllowed; extern bool MessagesAllowed;
extern bool RedrawHeader; extern bool RedrawHeader;

View File

@@ -196,7 +196,7 @@ int main(int argc, char *argv[])
{ {
ShowMessage("Connected to %s!", Mpd->GetHostname().c_str()); ShowMessage("Connected to %s!", Mpd->GetHostname().c_str());
MessagesAllowed = 0; MessagesAllowed = 0;
Mpd->UpdateStatus(); UpdateStatusImmediately = 1;
} }
} }
@@ -551,17 +551,17 @@ int main(int argc, char *argv[])
else if (Keypressed(input, Key.Prev)) else if (Keypressed(input, Key.Prev))
{ {
Mpd->Prev(); Mpd->Prev();
Mpd->UpdateStatus(); UpdateStatusImmediately = 1;
} }
else if (Keypressed(input, Key.Next)) else if (Keypressed(input, Key.Next))
{ {
Mpd->Next(); Mpd->Next();
Mpd->UpdateStatus(); UpdateStatusImmediately = 1;
} }
else if (Keypressed(input, Key.Pause)) else if (Keypressed(input, Key.Pause))
{ {
Mpd->Pause(); Mpd->Pause();
Mpd->UpdateStatus(); UpdateStatusImmediately = 1;
} }
else if (Keypressed(input, Key.SavePlaylist)) else if (Keypressed(input, Key.SavePlaylist))
{ {
@@ -618,7 +618,7 @@ int main(int argc, char *argv[])
else if (Keypressed(input, Key.Stop)) else if (Keypressed(input, Key.Stop))
{ {
Mpd->Stop(); Mpd->Stop();
Mpd->UpdateStatus(); UpdateStatusImmediately = 1;
} }
else if (Keypressed(input, Key.MvSongUp)) else if (Keypressed(input, Key.MvSongUp))
{ {
@@ -991,7 +991,7 @@ int main(int argc, char *argv[])
wFooter->Refresh(); wFooter->Refresh();
} }
Mpd->Seek(songpos); Mpd->Seek(songpos);
Mpd->UpdateStatus(); UpdateStatusImmediately = 1;
UnlockProgressbar(); UnlockProgressbar();
UnlockStatusbar(); UnlockStatusbar();
@@ -1081,17 +1081,17 @@ int main(int argc, char *argv[])
else if (Keypressed(input, Key.ToggleRepeat)) else if (Keypressed(input, Key.ToggleRepeat))
{ {
Mpd->SetRepeat(!Mpd->GetRepeat()); Mpd->SetRepeat(!Mpd->GetRepeat());
Mpd->UpdateStatus(); UpdateStatusImmediately = 1;
} }
else if (Keypressed(input, Key.Shuffle)) else if (Keypressed(input, Key.Shuffle))
{ {
Mpd->Shuffle(); Mpd->Shuffle();
Mpd->UpdateStatus(); UpdateStatusImmediately = 1;
} }
else if (Keypressed(input, Key.ToggleRandom)) else if (Keypressed(input, Key.ToggleRandom))
{ {
Mpd->SetRandom(!Mpd->GetRandom()); Mpd->SetRandom(!Mpd->GetRandom());
Mpd->UpdateStatus(); UpdateStatusImmediately = 1;
} }
else if (Keypressed(input, Key.ToggleSingle)) else if (Keypressed(input, Key.ToggleSingle))
{ {
@@ -1106,18 +1106,18 @@ int main(int argc, char *argv[])
else else
{ {
Mpd->SetSingle(!Mpd->GetSingle()); Mpd->SetSingle(!Mpd->GetSingle());
Mpd->UpdateStatus(); UpdateStatusImmediately = 1;
} }
} }
else if (Keypressed(input, Key.ToggleConsume)) else if (Keypressed(input, Key.ToggleConsume))
{ {
Mpd->SetConsume(!Mpd->GetConsume()); Mpd->SetConsume(!Mpd->GetConsume());
Mpd->UpdateStatus(); UpdateStatusImmediately = 1;
} }
else if (Keypressed(input, Key.ToggleCrossfade)) else if (Keypressed(input, Key.ToggleCrossfade))
{ {
Mpd->SetCrossfade(Mpd->GetCrossfade() ? 0 : Config.crossfade_time); Mpd->SetCrossfade(Mpd->GetCrossfade() ? 0 : Config.crossfade_time);
Mpd->UpdateStatus(); UpdateStatusImmediately = 1;
} }
else if (Keypressed(input, Key.SetCrossfade)) else if (Keypressed(input, Key.SetCrossfade))
{ {
@@ -1130,7 +1130,7 @@ int main(int argc, char *argv[])
{ {
Config.crossfade_time = cf; Config.crossfade_time = cf;
Mpd->SetCrossfade(cf); Mpd->SetCrossfade(cf);
Mpd->UpdateStatus(); UpdateStatusImmediately = 1;
} }
} }
else if (Keypressed(input, Key.EditTags)) else if (Keypressed(input, Key.EditTags))
@@ -1345,7 +1345,7 @@ int main(int argc, char *argv[])
else else
ShowMessage("Out of bounds, 1-99 possible for %, %d given.", newpos); ShowMessage("Out of bounds, 1-99 possible for %, %d given.", newpos);
} }
Mpd->UpdateStatus(); UpdateStatusImmediately = 1;
} }
else if (Keypressed(input, Key.ReverseSelection)) else if (Keypressed(input, Key.ReverseSelection))
{ {
@@ -1551,7 +1551,6 @@ int main(int argc, char *argv[])
{ {
Mpd->ClearPlaylist(); Mpd->ClearPlaylist();
} }
Mpd->UpdateStatus();
ShowMessage("Cleared playlist!"); ShowMessage("Cleared playlist!");
} }
} }

View File

@@ -119,7 +119,7 @@ void Playlist::EnterPressed()
if (!w->Empty()) if (!w->Empty())
{ {
Mpd->PlayID(w->Current().GetID()); Mpd->PlayID(w->Current().GetID());
Mpd->UpdateStatus(); UpdateStatusImmediately = 1;
} }
} }

View File

@@ -40,6 +40,8 @@ using std::string;
string Global::VolumeState; string Global::VolumeState;
bool Global::UpdateStatusImmediately = 0;
namespace namespace
{ {
time_t time_of_statusbar_lock; time_t time_of_statusbar_lock;
@@ -115,13 +117,15 @@ void TraceMpdStatus()
static timeval past, now; static timeval past, now;
gettimeofday(&now, 0); gettimeofday(&now, 0);
if (Mpd->Connected() if ((Mpd->Connected()
&& ((now.tv_sec == past.tv_sec && now.tv_usec >= past.tv_usec+500000) || now.tv_sec > past.tv_sec) && ((now.tv_sec == past.tv_sec && now.tv_usec >= past.tv_usec+500000) || now.tv_sec > past.tv_sec))
|| UpdateStatusImmediately
) )
{ {
Mpd->UpdateStatus(); Mpd->UpdateStatus();
BlockItemListUpdate = 0; BlockItemListUpdate = 0;
Playlist::BlockUpdate = 0; Playlist::BlockUpdate = 0;
UpdateStatusImmediately = 0;
gettimeofday(&past, 0); gettimeofday(&past, 0);
} }
wFooter->Refresh(); wFooter->Refresh();