Make 'update_environment' action also update local mpd status

This commit is contained in:
Andrzej Rybczak
2017-01-06 02:25:10 +01:00
parent 401e732056
commit 0d8b2aee4b
4 changed files with 14 additions and 6 deletions

View File

@@ -330,7 +330,7 @@ UpdateEnvironment::UpdateEnvironment()
, m_past(boost::posix_time::from_time_t(0))
{ }
void UpdateEnvironment::run(bool update_timer, bool refresh_window)
void UpdateEnvironment::run(bool update_timer, bool refresh_window, bool mpd_sync)
{
using Global::Timer;
@@ -352,11 +352,19 @@ void UpdateEnvironment::run(bool update_timer, bool refresh_window)
if (refresh_window)
myScreen->refreshWindow();
// We want to synchronize with MPD during execution of an action chain.
if (mpd_sync)
{
int flags = Mpd.noidle();
if (flags)
Status::update(flags);
}
}
void UpdateEnvironment::run()
{
run(true, true);
run(true, true, true);
}
bool MouseEvent::canBeRun()

View File

@@ -231,7 +231,7 @@ struct UpdateEnvironment: BaseAction
{
UpdateEnvironment();
void run(bool update_status, bool refresh_window);
void run(bool update_status, bool refresh_window, bool mpd_sync);
private:
boost::posix_time::ptime m_past;

View File

@@ -161,8 +161,7 @@ int main(int argc, char **argv)
auto input = NC::Key::None;
auto connect_attempt = boost::posix_time::from_time_t(0);
auto update_environment = static_cast<Actions::UpdateEnvironment &>(
Actions::get(Actions::Type::UpdateEnvironment)
);
Actions::get(Actions::Type::UpdateEnvironment));
while (!Actions::ExitMainLoop)
{
@@ -196,7 +195,7 @@ int main(int argc, char **argv)
run_resize_screen = false;
}
update_environment.run(!key_pressed, key_pressed);
update_environment.run(!key_pressed, key_pressed, false);
input = readKey(*wFooter);
key_pressed = input != NC::Key::None;