otk/eventdispatcher.hh (raw)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
#ifndef __eventdispatcher #define __eventdispatcher #include "eventhandler.hh" #include <map> #include <utility> namespace otk { typedef std::map<unsigned int, OtkEventHandler *> OtkEventMap; class OtkEventDispatcher { public: OtkEventDispatcher(); virtual ~OtkEventDispatcher(); virtual void clearAllHandlers(void); virtual void registerHandler(Window id, otk::OtkEventHandler *handler); virtual void clearHandler(Window id); virtual void dispatchEvents(void); inline void setFallbackHandler(otk::OtkEventHandler *fallback) { _fallback = fallback; } otk::OtkEventHandler *getFallbackHandler(void) const { return _fallback; } //! Sets an event handler that gets all events for all handlers after //! any specific handlers have received them inline void setMasterHandler(otk::OtkEventHandler *master) { _master = master; } otk::OtkEventHandler *getMasterHandler(void) const { return _master; } otk::OtkEventHandler *findHandler(Window win); inline Time lastTime() const { return _lasttime; } private: OtkEventMap _map; OtkEventHandler *_fallback; OtkEventHandler *_master; Window _focus; XEvent _focus_e; XEvent _crossing_e; //! The time at which the last XEvent with a time was received Time _lasttime; void dispatch(const XEvent &e); }; } #endif |