From dd866e933793df78f5c95b90ea2d4b02fc2f9715 Mon Sep 17 00:00:00 2001 From: Andrzej Rybczak Date: Sun, 25 Oct 2009 23:24:12 +0100 Subject: [PATCH] fix visualizer --- src/ncmpcpp.cpp | 7 +++++++ src/visualizer.cpp | 3 ++- src/window.cpp | 7 ++++++- src/window.h | 4 ++++ 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/ncmpcpp.cpp b/src/ncmpcpp.cpp index ad0b3a82..f31de1c7 100644 --- a/src/ncmpcpp.cpp +++ b/src/ncmpcpp.cpp @@ -1990,6 +1990,13 @@ int main(int argc, char *argv[]) myServerInfo->SwitchTo(); } // key mapping end + +# ifdef ENABLE_VISUALIZER + // visualizer sets timmeout to 40ms, but since only it needs such small + // value, we should restore defalt one after switching to another screen. + if (wFooter->GetTimeout() < ncmpcpp_window_timeout && myScreen != myVisualizer) + wFooter->SetTimeout(ncmpcpp_window_timeout); +# endif // ENABLE_VISUALIZER } return 0; } diff --git a/src/visualizer.cpp b/src/visualizer.cpp index 3979c1f7..0b050471 100644 --- a/src/visualizer.cpp +++ b/src/visualizer.cpp @@ -44,7 +44,6 @@ const unsigned Visualizer::FFTResults = Samples/2+1; void Visualizer::Init() { w = new Window(0, MainStartY, COLS, MainHeight, "", Config.main_color, brNone); - w->SetTimeout(Config.visualizer_fifo_path.empty() ? ncmpcpp_window_timeout : 40 /* this gives us 25 fps */); ResetFD(); # ifdef HAVE_FFTW3_H @@ -73,6 +72,8 @@ void Visualizer::SwitchTo() SetFD(); + if (itsFifo >= 0) + Global::wFooter->SetTimeout(1000/25); Global::RedrawHeader = 1; } diff --git a/src/window.cpp b/src/window.cpp index 8fd0beaa..e1bd045d 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -400,7 +400,7 @@ void Window::ReadKey(int &read_key) const FD_SET(it->first, &fdset); } - if (select(fd_max+1, &fdset, 0, 0, &timeout) > 0) + if (select(fd_max+1, &fdset, 0, 0, itsWindowTimeout < 0 ? 0 : &timeout) > 0) { # if !defined(USE_PDCURSES) read_key = FD_ISSET(STDIN_FILENO, &fdset) ? wgetch(itsWindow) : ERR; @@ -748,6 +748,11 @@ Border Window::GetBorder() const return itsBorder; } +int Window::GetTimeout() const +{ + return itsWindowTimeout; +} + void Window::Scroll(Where where) { idlok(itsWindow, 1); diff --git a/src/window.h b/src/window.h index 59ecd014..5c3c8758 100644 --- a/src/window.h +++ b/src/window.h @@ -207,6 +207,10 @@ namespace NCurses /// Border GetBorder() const; + /// @return current window's timeout + /// + int GetTimeout() const; + /// Reads the string from standard input. Note that this is much more complex /// function than getstr() from curses library. It allows for moving through /// letters with arrows, supports scrolling if string's length is bigger than