diff options
author | Bent Bisballe Nyeng <deva@aasimon.org> | 2017-02-10 18:39:27 +0100 |
---|---|---|
committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2017-02-10 18:39:27 +0100 |
commit | 09e923d965a86a944dad7d77b336721386f6bf63 (patch) | |
tree | 1000abf99b16bb6d70d8d88f1cd26096b634b027 /plugingui/eventhandler.cc | |
parent | 53fa1c76c27726670f2724793d867d817c029709 (diff) |
Return a list of events form native window instead of one event at a time.
Diffstat (limited to 'plugingui/eventhandler.cc')
-rw-r--r-- | plugingui/eventhandler.cc | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/plugingui/eventhandler.cc b/plugingui/eventhandler.cc index a5249a6..9643d3f 100644 --- a/plugingui/eventhandler.cc +++ b/plugingui/eventhandler.cc @@ -40,23 +40,38 @@ EventHandler::EventHandler(NativeWindow& nativeWindow, Window& window) bool EventHandler::hasEvent() { - return nativeWindow.hasEvent(); + return !events.empty(); } std::shared_ptr<Event> EventHandler::getNextEvent() { - return nativeWindow.getNextEvent(); + if(events.empty()) + { + return nullptr; + } + + auto event = events.front(); + events.pop(); + return event; } std::shared_ptr<Event> EventHandler::peekNextEvent() { - return nativeWindow.peekNextEvent(); + if(events.empty()) + { + return nullptr; + } + + auto event = events.front(); + return event; } void EventHandler::processEvents() { Painter p(window); // Make sure we only redraw buffer one time. + events = nativeWindow.getEvents(); + while(hasEvent()) { auto event = getNextEvent(); |