From c2323f4397630349feb0b6afc3b09bd38d196fcc Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Sat, 14 Oct 2017 11:52:27 -0400 Subject: [PATCH] Do not queue up mouse wheel scroll events while others are still processing --- src/gui/jtk/Jtk_event.cc | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/gui/jtk/Jtk_event.cc b/src/gui/jtk/Jtk_event.cc index efd39e2..5d390ea 100644 --- a/src/gui/jtk/Jtk_event.cc +++ b/src/gui/jtk/Jtk_event.cc @@ -276,6 +276,15 @@ static bool ProcessXKeyReleaseEvent(XEvent * x_event, Jtk_Event * event) return false; } +static Bool MatchButtonPress(Display * display, XEvent * event, XPointer arg) +{ + XEvent * match_event = (XEvent *)arg; + return (event->type == match_event->type) && + (event->xbutton.window == match_event->xbutton.window) && + (event->xbutton.state == match_event->xbutton.state) && + (event->xbutton.button == match_event->xbutton.button); +} + /** * Process an X button press event. */ @@ -283,6 +292,15 @@ static bool ProcessXButtonPressEvent(XEvent * x_event, Jtk_Event * event) { event->type = JTK_EVENT_BUTTON_PRESS; event->button.button = x_event->xbutton.button; + /* If this is a mouse wheel scroll event, remove any following scroll + * events. */ + if ((event->button.button == 4) || (event->button.button == 5)) + { + XEvent remove_event; + while (XCheckIfEvent(g_display, &remove_event, MatchButtonPress, (XPointer)x_event) == True) + { + } + } return true; }