From 0c8ce9dabaeb9767aa80542de539d8d93b38b95f Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Tue, 19 Jan 2021 21:06:30 +1100 Subject: [PATCH] [client] x11: filter out duplicate button press events --- client/displayservers/X11/x11.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/client/displayservers/X11/x11.c b/client/displayservers/X11/x11.c index 554d6ddc..b32cf2e8 100644 --- a/client/displayservers/X11/x11.c +++ b/client/displayservers/X11/x11.c @@ -343,6 +343,16 @@ static bool x11EventFilter(SDL_Event * event) return true; XIRawEvent *raw = cookie->data; + + /* filter out duplicate events */ + static Time prev_time = 0; + static unsigned int prev_detail = 0; + if (raw->time == prev_time && raw->detail == prev_detail) + return true; + + prev_time = raw->time; + prev_detail = raw->detail; + app_handleButtonPress( raw->detail > 5 ? raw->detail - 2 : raw->detail); return true; @@ -354,6 +364,16 @@ static bool x11EventFilter(SDL_Event * event) return true; XIRawEvent *raw = cookie->data; + + /* filter out duplicate events */ + static Time prev_time = 0; + static unsigned int prev_detail = 0; + if (raw->time == prev_time && raw->detail == prev_detail) + return true; + + prev_time = raw->time; + prev_detail = raw->detail; + app_handleButtonRelease( raw->detail > 5 ? raw->detail - 2 : raw->detail); return true;