Subject: bug#65129: 30.0.50; pinch gestures suddenly stops being recognised

From: Po Lu <[email-masked]>
Date: Wed, 09 Aug 2023 20:37:07 +0800

Visuwesh <[email-masked]> writes:

> [Wednesday August 09, 2023] Po Lu via "Bug reports for GNU Emacs, the Swiss army knife of text editors" wrote:
>
>>> P.S., to confirm that I did apply the patch correctly, this is under
>>> "case XI_GesturePinchUpdate:" under handle_one_xevent function right?
>>> When I tried C-c C-a from a diff buffer, I got prompted
>>>
>>>     Try to auto-fix whitespace loss? (y or n)
>>>
>>> (to which I said yes) so I am not so confident that the patch applied
>>> correctly.
>>
>> Does gesture recognition cease immediately subsequent to displaying a
>> toolkit menu?
>
> Yes, you are right!
>
>> Thanks.

Does the following patch fix your problem?

diff --git a/src/xmenu.c b/src/xmenu.c
index 6d32aa3e078..d4b5b385e11 100644
--- a/src/xmenu.c
+++ b/src/xmenu.c
@@ -1680,6 +1680,19 @@ leave_toolkit_menu (void *data)
   XISetMask (m, XI_Enter);
   XISetMask (m, XI_Leave);
 
+#ifdef HAVE_XINPUT2_4
+  /* Select for gesture events.  Emacs selects for gesture events from
+     all master devices on non-GTK3 builds, so that event mask is also
+     clobbered by prepare_for_entry_into_toolkit_menu.  (bug#65129) */
+
+  if (dpyinfo->xi2_version >= 4)
+    {
+      XISetMask (m, XI_GesturePinchBegin);
+      XISetMask (m, XI_GesturePinchUpdate);
+      XISetMask (m, XI_GesturePinchEnd);
+    }
+#endif /* HAVE_XINPUT2_4 */
+
   FOR_EACH_FRAME (tail, frame)
     {
       f = XFRAME (frame);