change window timeout more transparently

This commit is contained in:
Andrzej Rybczak
2014-08-31 10:09:47 +02:00
parent 966f3ef927
commit 9c9c190742
7 changed files with 39 additions and 28 deletions

View File

@@ -141,6 +141,7 @@ int main(int argc, char **argv)
myPlaylist->switchTo();
// local variables
int nc_wtimeout;
Key input(0, Key::Standard);
auto past = boost::posix_time::from_time_t(0);
@@ -243,18 +244,16 @@ int main(int argc, char **argv)
{
Statusbar::printf("Unexpected error: %1%", e.what());
}
// set appropriate window timeout
nc_wtimeout = std::numeric_limits<int>::max();
applyToVisibleWindows([&nc_wtimeout](BaseScreen *s) {
nc_wtimeout = std::min(nc_wtimeout, s->windowTimeout());
});
wFooter->setTimeout(nc_wtimeout);
if (myScreen == myPlaylist)
myPlaylist->EnableHighlighting();
# ifdef ENABLE_VISUALIZER
// visualizer sets timeout to 40ms, but since only it needs such small
// value, we should restore default one after switching to another screen.
if (wFooter->getTimeout() < 500
&& !(myScreen == myVisualizer || myLockedScreen == myVisualizer || myInactiveScreen == myVisualizer)
)
wFooter->setTimeout(500);
# endif // ENABLE_VISUALIZER
}
catch (MPD::ClientError &e)
{