virtual eventLoop, default displayname and exit eventLoop variable
fluxgen fluxgen
2 files changed,
20 insertions(+),
3 deletions(-)
M
src/FbTk/App.cc
→
src/FbTk/App.cc
@@ -20,6 +20,9 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. #include "App.hh" + +#include "EventManager.hh" + #include <cassert> #include <string>@@ -33,7 +36,7 @@ throw std::string("You must create an instance of FbTk::App first!");
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;@@ -46,6 +49,19 @@ XCloseDisplay(m_display);
m_display = 0; } 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
M
src/FbTk/App.hh
→
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; };