From 6f060462d5d0d505802a82c43102b1612a493d7c Mon Sep 17 00:00:00 2001
From: Mamoru TASAKA <mtasaka@fedoraproject.org>
Date: Wed, 12 May 2021 22:55:46 +0900
Subject: [PATCH] xinput_event_to_xlib: don't call duplicate_xinput_event_p
when debug mode
When xscreensaver is running with -debug option,
in gui_main_loop in dialog.c, print_xinput_event is called (when debug mode),
which calls xinput_event_to_xlib, which calls duplicate_xinput_event_p .
Later gui_main_loop calls xinput_event_to_xlib (when debug mode or not),
here xinput events are always considered as duplicate.
When xinput_event_to_xlib is called from print_xinput_event, don't check
duplicate event.
---
driver/dialog.c | 2 +-
driver/test-xinput.c | 3 ++-
driver/xinput.c | 7 ++++---
driver/xinput.h | 2 +-
4 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/driver/dialog.c b/driver/dialog.c
index 3020880..e571627 100644
--- a/driver/dialog.c
+++ b/driver/dialog.c
@@ -2192,7 +2192,7 @@ gui_main_loop (window_state *ws, Bool splash_p, Bool notification_p)
{
XEvent ev2;
Bool ok =
- xinput_event_to_xlib (xev.xcookie.evtype, xev.xcookie.data, &ev2);
+ xinput_event_to_xlib (xev.xcookie.evtype, xev.xcookie.data, &ev2, True);
XFreeEventData (ws->dpy, &xev.xcookie);
if (ok)
xev = ev2;
diff --git a/driver/test-xinput.c b/driver/test-xinput.c
index e3a6487..57667a5 100644
--- a/driver/test-xinput.c
+++ b/driver/test-xinput.c
@@ -242,7 +242,8 @@ main (int argc, char **argv)
XEvent ev2;
Bool ok = xinput_event_to_xlib (xev.xcookie.evtype,
(XIDeviceEvent *) re,
- &ev2);
+ &ev2,
+ True);
if (!ok)
fprintf (stderr, "%s: unable to translate XInput2 event\n",
blurb());
diff --git a/driver/xinput.c b/driver/xinput.c
index c64ee21..8ddb6bf 100644
--- a/driver/xinput.c
+++ b/driver/xinput.c
@@ -143,7 +143,7 @@ duplicate_xinput_event_p (XIDeviceEvent *in)
Returns true on success.
*/
Bool
-xinput_event_to_xlib (int evtype, XIDeviceEvent *in, XEvent *out)
+xinput_event_to_xlib (int evtype, XIDeviceEvent *in, XEvent *out, Bool check_duplicate_p)
{
Display *dpy = in->display;
Bool ok = False;
@@ -247,7 +247,7 @@ xinput_event_to_xlib (int evtype, XIDeviceEvent *in, XEvent *out)
break;
}
- if (duplicate_xinput_event_p (in))
+ if (check_duplicate_p && duplicate_xinput_event_p (in))
ok = False;
return ok;
@@ -348,7 +348,8 @@ print_xinput_event (Display *dpy, XEvent *xev, const char *desc)
XEvent ev2;
Bool ok = xinput_event_to_xlib (xev->xcookie.evtype,
(XIDeviceEvent *) re,
- &ev2);
+ &ev2,
+ False);
if (!ok)
fprintf (stderr, "%s: unable to translate XInput2 event\n", blurb());
else
diff --git a/driver/xinput.h b/driver/xinput.h
index 2ee20ee..93dcd6e 100644
--- a/driver/xinput.h
+++ b/driver/xinput.h
@@ -13,7 +13,7 @@
#define __XSCREENSAVER_XINPUT_H__
extern Bool init_xinput (Display *dpy, int *opcode_ret);
-extern Bool xinput_event_to_xlib (int evtype, XIDeviceEvent *in, XEvent *out);
+extern Bool xinput_event_to_xlib (int evtype, XIDeviceEvent *in, XEvent *out, Bool check_duplicate_p);
extern void print_xinput_event (Display *, XEvent *, const char *desc);
#endif /* __XSCREENSAVER_XINPUT_H__ */
--
2.31.1