summaryrefslogtreecommitdiff
path: root/src/xfns.c
diff options
context:
space:
mode:
authorPo Lu <luangruo@yahoo.com>2023-07-17 20:42:56 +0800
committerPo Lu <luangruo@yahoo.com>2023-07-17 20:43:10 +0800
commitac566bcdee31a260cbdce336e76f20a317b6dd06 (patch)
treeb6dc80e02bc6b477870e692fea02fdc4d96745ca /src/xfns.c
parent91424cb9aded01bc14912dcf037f7aa0e11c97d8 (diff)
downloademacs-ac566bcdee31a260cbdce336e76f20a317b6dd06.tar.gz
Don't deliver touch or pinch events from master or slave devices
* src/xfns.c (setup_xi_event_mask): Select for gesture events on only master devices if safe. * src/xterm.c (handle_one_xevent): Deliver touchscreen events only from direct slave devices, and gesture events only from master pointers.
Diffstat (limited to 'src/xfns.c')
-rw-r--r--src/xfns.c42
1 files changed, 32 insertions, 10 deletions
diff --git a/src/xfns.c b/src/xfns.c
index 5c9f58e3a96..fd4807fd5f5 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -4036,7 +4036,7 @@ setup_xi_event_mask (struct frame *f)
selected->mask = ((unsigned char *) selected) + sizeof *selected;
selected->mask_len = l;
selected->deviceid = XIAllMasterDevices;
-#endif
+#endif /* !HAVE_XINPUT2_1 */
mask.mask = m = alloca (l);
memset (m, 0, l);
@@ -4056,7 +4056,19 @@ setup_xi_event_mask (struct frame *f)
XISetMask (m, XI_FocusOut);
XISetMask (m, XI_KeyPress);
XISetMask (m, XI_KeyRelease);
-#endif
+#endif /* !USE_GTK */
+#if defined HAVE_XINPUT2_4
+ if (FRAME_DISPLAY_INFO (f)->xi2_version >= 4)
+ {
+ /* Select for gesture events. Since this configuration doesn't
+ use GTK 3, Emacs is the only code that can change the XI
+ event mask, and can safely select for gesture events on
+ master pointers only. */
+ XISetMask (m, XI_GesturePinchBegin);
+ XISetMask (m, XI_GesturePinchUpdate);
+ XISetMask (m, XI_GesturePinchEnd);
+ }
+#endif /* HAVE_XINPUT2_4 */
XISelectEvents (FRAME_X_DISPLAY (f),
FRAME_X_WINDOW (f),
&mask, 1);
@@ -4065,7 +4077,7 @@ setup_xi_event_mask (struct frame *f)
to get the event mask from the X server. */
#ifndef HAVE_XINPUT2_1
memcpy (selected->mask, m, l);
-#endif
+#endif /* !HAVE_XINPUT2_1 */
memset (m, 0, l);
#endif /* !HAVE_GTK3 */
@@ -4080,35 +4092,45 @@ setup_xi_event_mask (struct frame *f)
FRAME_OUTER_WINDOW (f),
&mask, 1);
memset (m, 0, l);
-#endif
+#endif /* USE_X_TOOLKIT */
#ifdef HAVE_XINPUT2_2
if (FRAME_DISPLAY_INFO (f)->xi2_version >= 2)
{
+ /* Select for touch events from all devices.
+
+ Emacs will only process touch events originating
+ from slave devices, as master pointers may also
+ represent dependent touch devices. */
mask.deviceid = XIAllDevices;
XISetMask (m, XI_TouchBegin);
XISetMask (m, XI_TouchUpdate);
XISetMask (m, XI_TouchEnd);
-#ifdef HAVE_XINPUT2_4
+
+#if defined HAVE_XINPUT2_4 && defined USE_GTK3
if (FRAME_DISPLAY_INFO (f)->xi2_version >= 4)
{
+ /* Now select for gesture events from all pointer devices.
+ Emacs will only handle gesture events from the master
+ pointer, but cannot afford to overwrite the event mask
+ set by GDK. */
+
XISetMask (m, XI_GesturePinchBegin);
XISetMask (m, XI_GesturePinchUpdate);
XISetMask (m, XI_GesturePinchEnd);
}
-#endif
+#endif /* HAVE_XINPUT2_4 && USE_GTK3 */
- XISelectEvents (FRAME_X_DISPLAY (f),
- FRAME_X_WINDOW (f),
+ XISelectEvents (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
&mask, 1);
}
-#endif
+#endif /* HAVE_XINPUT2_2 */
#ifndef HAVE_XINPUT2_1
FRAME_X_OUTPUT (f)->xi_masks = selected;
FRAME_X_OUTPUT (f)->num_xi_masks = 1;
-#endif
+#endif /* HAVE_XINPUT2_1 */
unblock_input ();
}