aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/FbTk/App.cc18
-rw-r--r--src/FbTk/App.hh5
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 @@
20// DEALINGS IN THE SOFTWARE. 20// DEALINGS IN THE SOFTWARE.
21 21
22#include "App.hh" 22#include "App.hh"
23
24#include "EventManager.hh"
25
23#include <cassert> 26#include <cassert>
24#include <string> 27#include <string>
25 28
@@ -33,7 +36,7 @@ App *App::instance() {
33 return s_app; 36 return s_app;
34} 37}
35 38
36App::App(const char *displayname) { 39App::App(const char *displayname):m_done(false) {
37 if (s_app != 0) 40 if (s_app != 0)
38 throw std::string("Can't create more than one instance of FbTk::App"); 41 throw std::string("Can't create more than one instance of FbTk::App");
39 s_app = this; 42 s_app = this;
@@ -48,4 +51,17 @@ App::~App() {
48 s_app = 0; 51 s_app = 0;
49} 52}
50 53
54void App::eventLoop() {
55 XEvent ev;
56 while (!m_done) {
57 XNextEvent(display(), &ev);
58 EventManager::instance()->handleEvent(ev);
59 }
60}
61
62
63void App::end() {
64 m_done = true; //end loop in App::eventLoop
65}
66
51}; // end namespace FbTk 67}; // 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 {
32public: 32public:
33 /// @return singleton instance of App 33 /// @return singleton instance of App
34 static App *instance(); 34 static App *instance();
35 explicit App(const char *displayname); 35 explicit App(const char *displayname=0);
36 virtual ~App(); 36 virtual ~App();
37 /// display connection 37 /// display connection
38 Display *display() const { return m_display; } 38 Display *display() const { return m_display; }
39 /// starts event loop 39 /// starts event loop
40 void eventLoop(); 40 virtual void eventLoop();
41 /// ends event loop 41 /// ends event loop
42 void end(); 42 void end();
43private: 43private:
44 static App *s_app; 44 static App *s_app;
45 bool m_done;
45 Display *m_display; 46 Display *m_display;
46}; 47};
47 48