]> icculus.org git repositories - mikachu/openbox.git/blob - otk/eventdispatcher.hh
kill the const
[mikachu/openbox.git] / otk / eventdispatcher.hh
1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
2 #ifndef __eventdispatcher
3 #define __eventdispatcher
4
5 #include "eventhandler.hh"
6 #include <map>
7 #include <utility>
8
9 namespace otk {
10
11 typedef std::map<unsigned int, EventHandler *> EventMap;
12
13 class EventDispatcher {
14 public:
15
16   EventDispatcher();
17   virtual ~EventDispatcher();
18
19   virtual void clearAllHandlers(void);
20   virtual void registerHandler(Window id, EventHandler *handler);
21   virtual void clearHandler(Window id);
22   //! Dispatch events from the X server to the appropriate EventHandlers
23   /*!
24     @param remote Is the Xserver on a remote (low bandwidth) connection or on a
25                   local (high bandwidth) connection. This allows you to specify
26                   'false' in which case slightly different semantics are used
27                   for event retrieval.<br>
28                   The default is 'true' since this should generally be used,
29                   only the Openbox window manager should need to specify
30                   'false' here.
31   */
32   virtual void dispatchEvents(bool remote = true);
33
34   inline void setFallbackHandler(EventHandler *fallback)
35   { _fallback = fallback; }
36   EventHandler *getFallbackHandler(void) const { return _fallback; }
37
38   //! Sets an event handler that gets all events for all handlers after
39   //! any specific handlers have received them
40   inline void setMasterHandler(EventHandler *master)
41   { _master = master; }
42   EventHandler *getMasterHandler(void) const { return _master; }
43
44   EventHandler *findHandler(Window win);
45
46   inline Time lastTime() const { return _lasttime; }
47   
48 private:
49   EventMap _map;
50   EventHandler *_fallback;
51   EventHandler *_master;
52
53   //! The time at which the last XEvent with a time was received
54   Time _lasttime;
55
56   void dispatch(Window win, const XEvent &e);
57   void dispatchFocus(const XEvent &e);
58 };
59
60 }
61
62 #endif