virtual eventLoop, default displayname and exit eventLoop variable

This commit is contained in:
fluxgen 2002-11-27 21:50:32 +00:00
parent d39c023411
commit c9e62e7aee
2 changed files with 20 additions and 3 deletions

View file

@ -20,6 +20,9 @@
// DEALINGS IN THE SOFTWARE.
#include "App.hh"
#include "EventManager.hh"
#include <cassert>
#include <string>
@ -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

View file

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