summaryrefslogtreecommitdiff
path: root/plugingui/eventhandler.cc
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2017-04-15 09:53:56 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2017-04-15 09:53:56 +0200
commit2a373d19a912fdd6b713bcb2150f19333d583174 (patch)
treeb272667c57d5997d925ceb9c5a22f1cfe13c6b80 /plugingui/eventhandler.cc
parent8b3506186e5c9c810bcbe4a4206874d9fd4dfe9b (diff)
Fix erronous event skips from mouse move event filter.
Diffstat (limited to 'plugingui/eventhandler.cc')
-rw-r--r--plugingui/eventhandler.cc16
1 files changed, 8 insertions, 8 deletions
diff --git a/plugingui/eventhandler.cc b/plugingui/eventhandler.cc
index 2177433..a57e74b 100644
--- a/plugingui/eventhandler.cc
+++ b/plugingui/eventhandler.cc
@@ -35,7 +35,6 @@ namespace GUI
EventHandler::EventHandler(NativeWindow& nativeWindow, Window& window)
: window(window)
, nativeWindow(nativeWindow)
-// , last_click(0)
, lastWasDoubleClick(false)
{}
@@ -44,6 +43,12 @@ bool EventHandler::hasEvent()
return !events.empty();
}
+bool EventHandler::queryNextEventType(EventType type)
+{
+ return !events.empty() &&
+ (events.front()->type() == type);
+}
+
std::shared_ptr<Event> EventHandler::getNextEvent()
{
if(events.empty())
@@ -94,13 +99,9 @@ void EventHandler::processEvents()
case EventType::mouseMove:
{
- while(true)
+ // Skip all consecutive mouse move events and handle only the last one.
+ while(queryNextEventType(EventType::mouseMove))
{
- if(!hasEvent())
- {
- break;
- }
-
event = getNextEvent();
}
@@ -147,7 +148,6 @@ void EventHandler::processEvents()
case EventType::button:
{
auto buttonEvent = static_cast<ButtonEvent*>(event.get());
-
if(lastWasDoubleClick && (buttonEvent->direction == Direction::down))
{
lastWasDoubleClick = false;