summaryrefslogtreecommitdiff
path: root/otk/eventdispatcher.cc
diff options
context:
space:
mode:
authorMarius Nita <marius@cs.pdx.edu>2002-11-16 02:11:44 +0000
committerMarius Nita <marius@cs.pdx.edu>2002-11-16 02:11:44 +0000
commite53fbcf092c40b22ccc4c5f23795e12c9862c338 (patch)
tree1af236afed9fba729d9220f26e8edcd9e64cc470 /otk/eventdispatcher.cc
parent1210e6d688b62aceec2395bd3833e7c280d57326 (diff)
event handling classes
Diffstat (limited to 'otk/eventdispatcher.cc')
-rw-r--r--otk/eventdispatcher.cc49
1 files changed, 49 insertions, 0 deletions
diff --git a/otk/eventdispatcher.cc b/otk/eventdispatcher.cc
new file mode 100644
index 00000000..0d861b36
--- /dev/null
+++ b/otk/eventdispatcher.cc
@@ -0,0 +1,49 @@
+#include "eventdispatcher.hh"
+#include "display.hh"
+
+namespace otk {
+
+OtkEventDispatcher::OtkEventDispatcher()
+{
+}
+
+OtkEventDispatcher::~OtkEventDispatcher()
+{
+}
+
+void OtkEventDispatcher::clearAllHandlers(void)
+{
+ _map.clear();
+}
+
+void OtkEventDispatcher::registerHandler(Window id, OtkEventHandler *handler)
+{
+ _map.insert(std::pair<Window, OtkEventHandler*>(id, handler));
+}
+
+void OtkEventDispatcher::clearHandler(Window id)
+{
+ _map.erase(id);
+}
+
+void OtkEventDispatcher::dispatchEvents(void)
+{
+ XEvent e;
+ OtkEventHandler *handler;
+ OtkEventMap::iterator it;
+
+ while (XPending(OBDisplay::display)) {
+ XNextEvent(OBDisplay::display, &e);
+ it = _map.find(e.xany.window);
+
+ if (it == _map.end())
+ handler = _fallback;
+ else
+ handler = it->second;
+
+ if (handler)
+ handler->handle(e);
+ }
+}
+
+}