openbox/otk/eventdispatcher.hh

53 lines
1.3 KiB
C++
Raw Normal View History

// -*- 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 {
typedef std::map<unsigned int, EventHandler *> EventMap;
2002-11-16 02:11:44 +00:00
class EventDispatcher {
2002-11-16 02:11:44 +00:00
public:
EventDispatcher();
virtual ~EventDispatcher();
2002-11-16 02:11:44 +00:00
virtual void clearAllHandlers(void);
virtual void registerHandler(Window id, EventHandler *handler);
2002-11-16 02:11:44 +00:00
virtual void clearHandler(Window id);
virtual void dispatchEvents(void);
inline void setFallbackHandler(EventHandler *fallback)
2002-11-16 02:11:44 +00:00
{ _fallback = fallback; }
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
inline void setMasterHandler(EventHandler *master)
2002-12-04 07:55:52 +00:00
{ _master = master; }
EventHandler *getMasterHandler(void) const { return _master; }
2002-12-18 11:34:29 +00:00
EventHandler *findHandler(Window win);
inline Time lastTime() const { return _lasttime; }
2002-12-04 07:55:52 +00:00
2002-11-16 02:11:44 +00:00
private:
EventMap _map;
EventHandler *_fallback;
EventHandler *_master;
2002-11-16 02:11:44 +00:00
//! The time at which the last XEvent with a time was received
Time _lasttime;
void dispatch(Window win, const XEvent &e);
void dispatchFocus(const XEvent &e);
2002-11-16 02:11:44 +00:00
};
}
#endif