From c9e62e7aee97862ec0e0527b4a963bc9d244e41c Mon Sep 17 00:00:00 2001 From: fluxgen Date: Wed, 27 Nov 2002 21:50:32 +0000 Subject: virtual eventLoop, default displayname and exit eventLoop variable --- src/FbTk/App.cc | 18 +++++++++++++++++- src/FbTk/App.hh | 5 +++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/FbTk/App.cc b/src/FbTk/App.cc index 89b5921..e32c806 100644 --- a/src/FbTk/App.cc +++ b/src/FbTk/App.cc @@ -20,6 +20,9 @@ // DEALINGS IN THE SOFTWARE. #include "App.hh" + +#include "EventManager.hh" + #include #include @@ -33,7 +36,7 @@ App *App::instance() { return s_app; } -App::App(const char *displayname) { +App::App(const char *displayname):m_done(false) { if (s_app != 0) throw std::string("Can't create more than one instance of FbTk::App"); s_app = this; @@ -48,4 +51,17 @@ App::~App() { s_app = 0; } +void App::eventLoop() { + XEvent ev; + while (!m_done) { + XNextEvent(display(), &ev); + EventManager::instance()->handleEvent(ev); + } +} + + +void App::end() { + m_done = true; //end loop in App::eventLoop +} + }; // end namespace FbTk diff --git a/src/FbTk/App.hh b/src/FbTk/App.hh index ef5836c..bbaa249 100644 --- a/src/FbTk/App.hh +++ b/src/FbTk/App.hh @@ -32,16 +32,17 @@ class App { public: /// @return singleton instance of App static App *instance(); - explicit App(const char *displayname); + explicit App(const char *displayname=0); virtual ~App(); /// display connection Display *display() const { return m_display; } /// starts event loop - void eventLoop(); + virtual void eventLoop(); /// ends event loop void end(); private: static App *s_app; + bool m_done; Display *m_display; }; -- cgit v0.11.2