diff options
| author | Po Lu | 2022-08-10 19:30:55 +0800 |
|---|---|---|
| committer | Po Lu | 2022-08-10 19:31:21 +0800 |
| commit | 8c0c9398f324bed79200c85ca9b0d4e95bf4a686 (patch) | |
| tree | d9327cd78e0e99476adf8a96ba3e81c0396f5f28 /src | |
| parent | d8d582dc3c30e184e6f849eb302d0c89be019c83 (diff) | |
| download | emacs-8c0c9398f324bed79200c85ca9b0d4e95bf4a686.tar.gz emacs-8c0c9398f324bed79200c85ca9b0d4e95bf4a686.zip | |
Fix some undesirable frame focus changes
* src/xterm.c (handle_one_xevent): Only detach upon actual
device tree change.
Diffstat (limited to 'src')
| -rw-r--r-- | src/xterm.c | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/src/xterm.c b/src/xterm.c index 41537ade155..17043e078c7 100644 --- a/src/xterm.c +++ b/src/xterm.c | |||
| @@ -22436,11 +22436,14 @@ handle_one_xevent (struct x_display_info *dpyinfo, | |||
| 22436 | 22436 | ||
| 22437 | case XI_HierarchyChanged: | 22437 | case XI_HierarchyChanged: |
| 22438 | { | 22438 | { |
| 22439 | XIHierarchyEvent *hev = (XIHierarchyEvent *) xi_event; | 22439 | XIHierarchyEvent *hev; |
| 22440 | XIDeviceInfo *info; | 22440 | XIDeviceInfo *info; |
| 22441 | int i, ndevices, n_disabled, *disabled; | 22441 | int i, ndevices, n_disabled, *disabled; |
| 22442 | struct xi_device_t *device; | 22442 | struct xi_device_t *device; |
| 22443 | bool any_changed; | ||
| 22443 | 22444 | ||
| 22445 | any_changed = false; | ||
| 22446 | hev = (XIHierarchyEvent *) xi_event; | ||
| 22444 | disabled = SAFE_ALLOCA (sizeof *disabled * hev->num_info); | 22447 | disabled = SAFE_ALLOCA (sizeof *disabled * hev->num_info); |
| 22445 | n_disabled = 0; | 22448 | n_disabled = 0; |
| 22446 | 22449 | ||
| @@ -22450,8 +22453,17 @@ handle_one_xevent (struct x_display_info *dpyinfo, | |||
| 22450 | { | 22453 | { |
| 22451 | /* Handle all disabled devices now, to prevent | 22454 | /* Handle all disabled devices now, to prevent |
| 22452 | things happening out-of-order later. */ | 22455 | things happening out-of-order later. */ |
| 22453 | xi_disable_devices (dpyinfo, disabled, n_disabled); | 22456 | |
| 22454 | n_disabled = 0; | 22457 | if (ndevices) |
| 22458 | { | ||
| 22459 | xi_disable_devices (dpyinfo, disabled, n_disabled); | ||
| 22460 | n_disabled = 0; | ||
| 22461 | |||
| 22462 | /* This flag really just means that disabled | ||
| 22463 | devices were handled early and should be | ||
| 22464 | used in conjunction with n_disabled. */ | ||
| 22465 | any_changed = true; | ||
| 22466 | } | ||
| 22455 | 22467 | ||
| 22456 | x_catch_errors (dpyinfo->display); | 22468 | x_catch_errors (dpyinfo->display); |
| 22457 | info = XIQueryDevice (dpyinfo->display, hev->info[i].deviceid, | 22469 | info = XIQueryDevice (dpyinfo->display, hev->info[i].deviceid, |
| @@ -22502,9 +22514,12 @@ handle_one_xevent (struct x_display_info *dpyinfo, | |||
| 22502 | event. */ | 22514 | event. */ |
| 22503 | xi_disable_devices (dpyinfo, disabled, n_disabled); | 22515 | xi_disable_devices (dpyinfo, disabled, n_disabled); |
| 22504 | 22516 | ||
| 22505 | /* Now that the device hierarchy has been changed, | 22517 | /* If the device hierarchy has been changed, recompute |
| 22506 | recompute focus. */ | 22518 | focus. This might seem like a micro-optimization but |
| 22507 | xi_handle_focus_change (dpyinfo); | 22519 | it actually keeps the focus from changing in some |
| 22520 | cases where it would be undesierable. */ | ||
| 22521 | if (any_changed || n_disabled) | ||
| 22522 | xi_handle_focus_change (dpyinfo); | ||
| 22508 | 22523 | ||
| 22509 | goto XI_OTHER; | 22524 | goto XI_OTHER; |
| 22510 | } | 22525 | } |