2003-01-11 19:17:13 +00:00
|
|
|
// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
|
2002-11-16 02:11:44 +00:00
|
|
|
#ifndef __eventdispatcher
|
|
|
|
#define __eventdispatcher
|
|
|
|
|
|
|
|
#include "eventhandler.hh"
|
|
|
|
#include <map>
|
|
|
|
#include <utility>
|
|
|
|
|
|
|
|
namespace otk {
|
|
|
|
|
2003-01-11 19:17:13 +00:00
|
|
|
typedef std::map<unsigned int, EventHandler *> EventMap;
|
2002-11-16 02:11:44 +00:00
|
|
|
|
2003-01-11 19:17:13 +00:00
|
|
|
class EventDispatcher {
|
2002-11-16 02:11:44 +00:00
|
|
|
public:
|
|
|
|
|
2003-01-11 19:17:13 +00:00
|
|
|
EventDispatcher();
|
|
|
|
virtual ~EventDispatcher();
|
2002-11-16 02:11:44 +00:00
|
|
|
|
|
|
|
virtual void clearAllHandlers(void);
|
2003-01-11 19:17:13 +00:00
|
|
|
virtual void registerHandler(Window id, EventHandler *handler);
|
2002-11-16 02:11:44 +00:00
|
|
|
virtual void clearHandler(Window id);
|
|
|
|
virtual void dispatchEvents(void);
|
|
|
|
|
2003-01-11 19:17:13 +00:00
|
|
|
inline void setFallbackHandler(EventHandler *fallback)
|
2002-11-16 02:11:44 +00:00
|
|
|
{ _fallback = fallback; }
|
2003-01-11 19:17:13 +00:00
|
|
|
EventHandler *getFallbackHandler(void) const { return _fallback; }
|
2002-11-16 02:11:44 +00:00
|
|
|
|
2002-12-04 07:55:52 +00:00
|
|
|
//! Sets an event handler that gets all events for all handlers after
|
|
|
|
//! any specific handlers have received them
|
2003-01-11 19:17:13 +00:00
|
|
|
inline void setMasterHandler(EventHandler *master)
|
2002-12-04 07:55:52 +00:00
|
|
|
{ _master = master; }
|
2003-01-11 19:17:13 +00:00
|
|
|
EventHandler *getMasterHandler(void) const { return _master; }
|
2002-12-18 11:34:29 +00:00
|
|
|
|
2003-01-11 19:17:13 +00:00
|
|
|
EventHandler *findHandler(Window win);
|
2003-01-04 01:18:24 +00:00
|
|
|
|
|
|
|
inline Time lastTime() const { return _lasttime; }
|
2002-12-04 07:55:52 +00:00
|
|
|
|
2002-11-16 02:11:44 +00:00
|
|
|
private:
|
2003-01-11 19:17:13 +00:00
|
|
|
EventMap _map;
|
|
|
|
EventHandler *_fallback;
|
|
|
|
EventHandler *_master;
|
2002-11-16 02:11:44 +00:00
|
|
|
|
2002-11-17 09:41:58 +00:00
|
|
|
//! The time at which the last XEvent with a time was received
|
2003-01-04 01:18:24 +00:00
|
|
|
Time _lasttime;
|
2002-12-25 22:02:34 +00:00
|
|
|
|
2003-01-07 09:30:00 +00:00
|
|
|
void dispatch(Window win, const XEvent &e);
|
2003-01-08 07:41:17 +00:00
|
|
|
void dispatchFocus(const XEvent &e);
|
2002-11-16 02:11:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|