diff --git a/src/actions.cpp b/src/actions.cpp index 71329f0c..f183541f 100644 --- a/src/actions.cpp +++ b/src/actions.cpp @@ -2895,8 +2895,7 @@ void seek(SearchDirection sd) unsigned songpos = Status::State::elapsedTime(); auto t = Timer; - int old_timeout = wFooter->getTimeout(); - wFooter->setTimeout(BaseScreen::defaultWindowTimeout); + NC::Window::ScopedTimeout stimeout{*wFooter, BaseScreen::defaultWindowTimeout}; // Accept single action of a given type or action chain for which all actions // can be run and one of them is of the given type. This will still not work @@ -3007,8 +3006,6 @@ void seek(SearchDirection sd) } SeekingInProgress = false; Mpd.Seek(Status::State::currentSongPosition(), songpos); - - wFooter->setTimeout(old_timeout); } void findItem(const SearchDirection direction) diff --git a/src/curses/window.h b/src/curses/window.h index 413e563a..686961fd 100644 --- a/src/curses/window.h +++ b/src/curses/window.h @@ -254,6 +254,25 @@ struct Window PromptHook m_hook; }; + struct ScopedTimeout + { + ScopedTimeout(Window &w, int new_timeout) + : m_w(w) + { + m_timeout = w.getTimeout(); + w.setTimeout(new_timeout); + } + + ~ScopedTimeout() + { + m_w.setTimeout(m_timeout); + } + + private: + Window &m_w; + int m_timeout; + }; + Window() : m_window(nullptr) { } /// Constructs an empty window with given parameters