diff options
Diffstat (limited to 'common/events.h')
-rw-r--r-- | common/events.h | 42 |
1 files changed, 30 insertions, 12 deletions
diff --git a/common/events.h b/common/events.h index 371080c1b2..f5ace7481b 100644 --- a/common/events.h +++ b/common/events.h @@ -97,7 +97,7 @@ struct Event { * Virtual screen coordinates means: the coordinate system of the * screen area as defined by the most recent call to initSize(). */ - Common::Point mouse; + Point mouse; Event() : type(EVENT_INVALID), synthetic(false) {} }; @@ -139,13 +139,13 @@ public: */ class ArtificialEventSource : public EventSource { protected: - Common::Queue<Common::Event> _artificialEventQueue; + Queue<Event> _artificialEventQueue; public: - void addEvent(const Common::Event &ev) { + void addEvent(const Event &ev) { _artificialEventQueue.push(ev); } - bool pollEvent(Common::Event &ev) { + bool pollEvent(Event &ev) { if (!_artificialEventQueue.empty()) { ev = _artificialEventQueue.pop(); return true; @@ -184,6 +184,14 @@ public: * false otherwise. */ virtual bool notifyEvent(const Event &event) = 0; + + /** + * Notifies the observer of pollEvent() query. + * + * @return true if the event should not be passed to other observers, + * false otherwise. + */ + virtual bool notifyPoll() { return false; } }; /** @@ -255,8 +263,11 @@ public: /** * Registers a new EventObserver with the Dispatcher. + * + * @param listenPools if set, then all pollEvent() calls are passed to observer + * currently it is used by keyMapper */ - void registerObserver(EventObserver *obs, uint priority, bool autoFree); + void registerObserver(EventObserver *obs, uint priority, bool autoFree, bool listenPolls = false); /** * Unregisters a EventObserver. @@ -275,16 +286,18 @@ private: EventSource *source; }; - Common::List<SourceEntry> _sources; + List<SourceEntry> _sources; struct ObserverEntry : public Entry { uint priority; EventObserver *observer; + bool poll; }; - Common::List<ObserverEntry> _observers; + List<ObserverEntry> _observers; void dispatchEvent(const Event &event); + void dispatchPoll(); }; class Keymapper; @@ -315,15 +328,15 @@ public: * @param event point to an Event struct, which will be filled with the event data. * @return true if an event was retrieved. */ - virtual bool pollEvent(Common::Event &event) = 0; + virtual bool pollEvent(Event &event) = 0; /** * Pushes a "fake" event into the event queue */ - virtual void pushEvent(const Common::Event &event) = 0; + virtual void pushEvent(const Event &event) = 0; /** Return the current mouse position */ - virtual Common::Point getMousePos() const = 0; + virtual Point getMousePos() const = 0; /** * Return a bitmask with the button states: @@ -362,7 +375,7 @@ public: // TODO: Consider removing OSystem::getScreenChangeID and // replacing it by a generic getScreenChangeID method here #ifdef ENABLE_KEYMAPPER - virtual Common::Keymapper *getKeymapper() = 0; + virtual Keymapper *getKeymapper() = 0; #endif enum { @@ -370,7 +383,12 @@ public: * Priority of the event manager, for now it's lowest since it eats * *all* events, we might to change that in the future though. */ - kEventManPriority = 0 + kEventManPriority = 0, + /** + * Priority of the event recorder. It has to go after event manager + * in order to record events generated by it + */ + kEventRecorderPriority = 1 }; /** |