diff options
| author | Po Lu | 2023-07-17 20:42:56 +0800 |
|---|---|---|
| committer | Po Lu | 2023-07-17 20:43:10 +0800 |
| commit | ac566bcdee31a260cbdce336e76f20a317b6dd06 (patch) | |
| tree | b6dc80e02bc6b477870e692fea02fdc4d96745ca /src | |
| parent | 91424cb9aded01bc14912dcf037f7aa0e11c97d8 (diff) | |
| download | emacs-ac566bcdee31a260cbdce336e76f20a317b6dd06.tar.gz emacs-ac566bcdee31a260cbdce336e76f20a317b6dd06.zip | |
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')
| -rw-r--r-- | src/xfns.c | 42 | ||||
| -rw-r--r-- | src/xterm.c | 30 |
2 files changed, 58 insertions, 14 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) | |||
| 4036 | selected->mask = ((unsigned char *) selected) + sizeof *selected; | 4036 | selected->mask = ((unsigned char *) selected) + sizeof *selected; |
| 4037 | selected->mask_len = l; | 4037 | selected->mask_len = l; |
| 4038 | selected->deviceid = XIAllMasterDevices; | 4038 | selected->deviceid = XIAllMasterDevices; |
| 4039 | #endif | 4039 | #endif /* !HAVE_XINPUT2_1 */ |
| 4040 | 4040 | ||
| 4041 | mask.mask = m = alloca (l); | 4041 | mask.mask = m = alloca (l); |
| 4042 | memset (m, 0, l); | 4042 | memset (m, 0, l); |
| @@ -4056,7 +4056,19 @@ setup_xi_event_mask (struct frame *f) | |||
| 4056 | XISetMask (m, XI_FocusOut); | 4056 | XISetMask (m, XI_FocusOut); |
| 4057 | XISetMask (m, XI_KeyPress); | 4057 | XISetMask (m, XI_KeyPress); |
| 4058 | XISetMask (m, XI_KeyRelease); | 4058 | XISetMask (m, XI_KeyRelease); |
| 4059 | #endif | 4059 | #endif /* !USE_GTK */ |
| 4060 | #if defined HAVE_XINPUT2_4 | ||
| 4061 | if (FRAME_DISPLAY_INFO (f)->xi2_version >= 4) | ||
| 4062 | { | ||
| 4063 | /* Select for gesture events. Since this configuration doesn't | ||
| 4064 | use GTK 3, Emacs is the only code that can change the XI | ||
| 4065 | event mask, and can safely select for gesture events on | ||
| 4066 | master pointers only. */ | ||
| 4067 | XISetMask (m, XI_GesturePinchBegin); | ||
| 4068 | XISetMask (m, XI_GesturePinchUpdate); | ||
| 4069 | XISetMask (m, XI_GesturePinchEnd); | ||
| 4070 | } | ||
| 4071 | #endif /* HAVE_XINPUT2_4 */ | ||
| 4060 | XISelectEvents (FRAME_X_DISPLAY (f), | 4072 | XISelectEvents (FRAME_X_DISPLAY (f), |
| 4061 | FRAME_X_WINDOW (f), | 4073 | FRAME_X_WINDOW (f), |
| 4062 | &mask, 1); | 4074 | &mask, 1); |
| @@ -4065,7 +4077,7 @@ setup_xi_event_mask (struct frame *f) | |||
| 4065 | to get the event mask from the X server. */ | 4077 | to get the event mask from the X server. */ |
| 4066 | #ifndef HAVE_XINPUT2_1 | 4078 | #ifndef HAVE_XINPUT2_1 |
| 4067 | memcpy (selected->mask, m, l); | 4079 | memcpy (selected->mask, m, l); |
| 4068 | #endif | 4080 | #endif /* !HAVE_XINPUT2_1 */ |
| 4069 | 4081 | ||
| 4070 | memset (m, 0, l); | 4082 | memset (m, 0, l); |
| 4071 | #endif /* !HAVE_GTK3 */ | 4083 | #endif /* !HAVE_GTK3 */ |
| @@ -4080,35 +4092,45 @@ setup_xi_event_mask (struct frame *f) | |||
| 4080 | FRAME_OUTER_WINDOW (f), | 4092 | FRAME_OUTER_WINDOW (f), |
| 4081 | &mask, 1); | 4093 | &mask, 1); |
| 4082 | memset (m, 0, l); | 4094 | memset (m, 0, l); |
| 4083 | #endif | 4095 | #endif /* USE_X_TOOLKIT */ |
| 4084 | 4096 | ||
| 4085 | #ifdef HAVE_XINPUT2_2 | 4097 | #ifdef HAVE_XINPUT2_2 |
| 4086 | if (FRAME_DISPLAY_INFO (f)->xi2_version >= 2) | 4098 | if (FRAME_DISPLAY_INFO (f)->xi2_version >= 2) |
| 4087 | { | 4099 | { |
| 4100 | /* Select for touch events from all devices. | ||
| 4101 | |||
| 4102 | Emacs will only process touch events originating | ||
| 4103 | from slave devices, as master pointers may also | ||
| 4104 | represent dependent touch devices. */ | ||
| 4088 | mask.deviceid = XIAllDevices; | 4105 | mask.deviceid = XIAllDevices; |
| 4089 | 4106 | ||
| 4090 | XISetMask (m, XI_TouchBegin); | 4107 | XISetMask (m, XI_TouchBegin); |
| 4091 | XISetMask (m, XI_TouchUpdate); | 4108 | XISetMask (m, XI_TouchUpdate); |
| 4092 | XISetMask (m, XI_TouchEnd); | 4109 | XISetMask (m, XI_TouchEnd); |
| 4093 | #ifdef HAVE_XINPUT2_4 | 4110 | |
| 4111 | #if defined HAVE_XINPUT2_4 && defined USE_GTK3 | ||
| 4094 | if (FRAME_DISPLAY_INFO (f)->xi2_version >= 4) | 4112 | if (FRAME_DISPLAY_INFO (f)->xi2_version >= 4) |
| 4095 | { | 4113 | { |
| 4114 | /* Now select for gesture events from all pointer devices. | ||
| 4115 | Emacs will only handle gesture events from the master | ||
| 4116 | pointer, but cannot afford to overwrite the event mask | ||
| 4117 | set by GDK. */ | ||
| 4118 | |||
| 4096 | XISetMask (m, XI_GesturePinchBegin); | 4119 | XISetMask (m, XI_GesturePinchBegin); |
| 4097 | XISetMask (m, XI_GesturePinchUpdate); | 4120 | XISetMask (m, XI_GesturePinchUpdate); |
| 4098 | XISetMask (m, XI_GesturePinchEnd); | 4121 | XISetMask (m, XI_GesturePinchEnd); |
| 4099 | } | 4122 | } |
| 4100 | #endif | 4123 | #endif /* HAVE_XINPUT2_4 && USE_GTK3 */ |
| 4101 | 4124 | ||
| 4102 | XISelectEvents (FRAME_X_DISPLAY (f), | 4125 | XISelectEvents (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), |
| 4103 | FRAME_X_WINDOW (f), | ||
| 4104 | &mask, 1); | 4126 | &mask, 1); |
| 4105 | } | 4127 | } |
| 4106 | #endif | 4128 | #endif /* HAVE_XINPUT2_2 */ |
| 4107 | 4129 | ||
| 4108 | #ifndef HAVE_XINPUT2_1 | 4130 | #ifndef HAVE_XINPUT2_1 |
| 4109 | FRAME_X_OUTPUT (f)->xi_masks = selected; | 4131 | FRAME_X_OUTPUT (f)->xi_masks = selected; |
| 4110 | FRAME_X_OUTPUT (f)->num_xi_masks = 1; | 4132 | FRAME_X_OUTPUT (f)->num_xi_masks = 1; |
| 4111 | #endif | 4133 | #endif /* HAVE_XINPUT2_1 */ |
| 4112 | 4134 | ||
| 4113 | unblock_input (); | 4135 | unblock_input (); |
| 4114 | } | 4136 | } |
diff --git a/src/xterm.c b/src/xterm.c index 9ecead03b08..5cc2dfdae1d 100644 --- a/src/xterm.c +++ b/src/xterm.c | |||
| @@ -24259,7 +24259,13 @@ handle_one_xevent (struct x_display_info *dpyinfo, | |||
| 24259 | x_display_set_last_user_time (dpyinfo, xev->time, | 24259 | x_display_set_last_user_time (dpyinfo, xev->time, |
| 24260 | xev->send_event, true); | 24260 | xev->send_event, true); |
| 24261 | 24261 | ||
| 24262 | if (!device) | 24262 | /* Don't process touch sequences from this device if |
| 24263 | it's a master pointer. Touch sequences aren't | ||
| 24264 | canceled by the X server if a slave device is | ||
| 24265 | detached, and master pointers may also represent | ||
| 24266 | dependent touch devices. */ | ||
| 24267 | |||
| 24268 | if (!device || device->use == XIMasterPointer) | ||
| 24263 | goto XI_OTHER; | 24269 | goto XI_OTHER; |
| 24264 | 24270 | ||
| 24265 | if (xi_find_touch_point (device, xev->detail)) | 24271 | if (xi_find_touch_point (device, xev->detail)) |
| @@ -24427,12 +24433,22 @@ handle_one_xevent (struct x_display_info *dpyinfo, | |||
| 24427 | x_display_set_last_user_time (dpyinfo, xev->time, | 24433 | x_display_set_last_user_time (dpyinfo, xev->time, |
| 24428 | xev->send_event, true); | 24434 | xev->send_event, true); |
| 24429 | 24435 | ||
| 24436 | /* Don't process touch sequences from this device if | ||
| 24437 | it's a master pointer. Touch sequences aren't | ||
| 24438 | canceled by the X server if a slave device is | ||
| 24439 | detached, and master pointers may also represent | ||
| 24440 | dependent touch devices. */ | ||
| 24441 | |||
| 24430 | if (!device) | 24442 | if (!device) |
| 24431 | goto XI_OTHER; | 24443 | goto XI_OTHER; |
| 24432 | 24444 | ||
| 24433 | touchpoint = xi_find_touch_point (device, xev->detail); | 24445 | touchpoint = xi_find_touch_point (device, xev->detail); |
| 24434 | 24446 | ||
| 24435 | if (!touchpoint) | 24447 | if (!touchpoint |
| 24448 | /* Don't send this event if nothing has changed | ||
| 24449 | either. */ | ||
| 24450 | || (touchpoint->x == (int) xev->event_x | ||
| 24451 | && touchpoint->y == (int) xev->event_y)) | ||
| 24436 | goto XI_OTHER; | 24452 | goto XI_OTHER; |
| 24437 | 24453 | ||
| 24438 | touchpoint->x = xev->event_x; | 24454 | touchpoint->x = xev->event_x; |
| @@ -24475,7 +24491,13 @@ handle_one_xevent (struct x_display_info *dpyinfo, | |||
| 24475 | x_display_set_last_user_time (dpyinfo, xev->time, | 24491 | x_display_set_last_user_time (dpyinfo, xev->time, |
| 24476 | xev->send_event, true); | 24492 | xev->send_event, true); |
| 24477 | 24493 | ||
| 24478 | if (!device) | 24494 | /* Don't process touch sequences from this device if |
| 24495 | it's a master pointer. Touch sequences aren't | ||
| 24496 | canceled by the X server if a slave device is | ||
| 24497 | detached, and master pointers may also represent | ||
| 24498 | dependent touch devices. */ | ||
| 24499 | |||
| 24500 | if (!device || device->use == XIMasterPointer) | ||
| 24479 | goto XI_OTHER; | 24501 | goto XI_OTHER; |
| 24480 | 24502 | ||
| 24481 | unlinked_p = xi_unlink_touch_point (xev->detail, device); | 24503 | unlinked_p = xi_unlink_touch_point (xev->detail, device); |
| @@ -24543,7 +24565,7 @@ handle_one_xevent (struct x_display_info *dpyinfo, | |||
| 24543 | x_display_set_last_user_time (dpyinfo, pev->time, | 24565 | x_display_set_last_user_time (dpyinfo, pev->time, |
| 24544 | pev->send_event, true); | 24566 | pev->send_event, true); |
| 24545 | 24567 | ||
| 24546 | if (!device) | 24568 | if (!device || device->use != XIMasterPointer) |
| 24547 | goto XI_OTHER; | 24569 | goto XI_OTHER; |
| 24548 | 24570 | ||
| 24549 | #ifdef HAVE_XWIDGETS | 24571 | #ifdef HAVE_XWIDGETS |