fix visualizer

This commit is contained in:
Andrzej Rybczak
2009-10-25 23:24:12 +01:00
parent b947575528
commit dd866e9337
4 changed files with 19 additions and 2 deletions

View File

@@ -1990,6 +1990,13 @@ int main(int argc, char *argv[])
myServerInfo->SwitchTo(); myServerInfo->SwitchTo();
} }
// key mapping end // 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; return 0;
} }

View File

@@ -44,7 +44,6 @@ const unsigned Visualizer::FFTResults = Samples/2+1;
void Visualizer::Init() void Visualizer::Init()
{ {
w = new Window(0, MainStartY, COLS, MainHeight, "", Config.main_color, brNone); 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(); ResetFD();
# ifdef HAVE_FFTW3_H # ifdef HAVE_FFTW3_H
@@ -73,6 +72,8 @@ void Visualizer::SwitchTo()
SetFD(); SetFD();
if (itsFifo >= 0)
Global::wFooter->SetTimeout(1000/25);
Global::RedrawHeader = 1; Global::RedrawHeader = 1;
} }

View File

@@ -400,7 +400,7 @@ void Window::ReadKey(int &read_key) const
FD_SET(it->first, &fdset); 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) # if !defined(USE_PDCURSES)
read_key = FD_ISSET(STDIN_FILENO, &fdset) ? wgetch(itsWindow) : ERR; read_key = FD_ISSET(STDIN_FILENO, &fdset) ? wgetch(itsWindow) : ERR;
@@ -748,6 +748,11 @@ Border Window::GetBorder() const
return itsBorder; return itsBorder;
} }
int Window::GetTimeout() const
{
return itsWindowTimeout;
}
void Window::Scroll(Where where) void Window::Scroll(Where where)
{ {
idlok(itsWindow, 1); idlok(itsWindow, 1);

View File

@@ -207,6 +207,10 @@ namespace NCurses
/// ///
Border GetBorder() const; Border GetBorder() const;
/// @return current window's timeout
///
int GetTimeout() const;
/// Reads the string from standard input. Note that this is much more complex /// Reads the string from standard input. Note that this is much more complex
/// function than getstr() from curses library. It allows for moving through /// function than getstr() from curses library. It allows for moving through
/// letters with arrows, supports scrolling if string's length is bigger than /// letters with arrows, supports scrolling if string's length is bigger than