Use scoped window timeout

This commit is contained in:
Andrzej Rybczak
2017-02-13 10:55:46 +01:00
parent 05bf53d0ab
commit 0ab5fbb809
2 changed files with 20 additions and 4 deletions

View File

@@ -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