aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPo Lu2022-11-14 14:07:04 +0800
committerPo Lu2022-11-14 14:07:04 +0800
commit83a497ee879959cd1b052fa9138adb79b480394d (patch)
tree55e0f28e3fd49595df290d6c962ff4df281da189 /src
parentc0474ca21dd76cafbd1a04fd32d4a0bd42de6351 (diff)
downloademacs-83a497ee879959cd1b052fa9138adb79b480394d.tar.gz
emacs-83a497ee879959cd1b052fa9138adb79b480394d.zip
Prevent crashes upon trying to focus a child frame on click
* src/xterm.c (handle_one_xevent): Do not try to activate override-redirect frames. Explain why. (x_focus_frame): Catch errors around XSetInputFocus.
Diffstat (limited to 'src')
-rw-r--r--src/xterm.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/xterm.c b/src/xterm.c
index 48ddd175681..7a1fd6086cf 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -21135,8 +21135,11 @@ handle_one_xevent (struct x_display_info *dpyinfo,
21135 21135
21136 if (FRAME_PARENT_FRAME (f) || (hf && frame_ancestor_p (f, hf))) 21136 if (FRAME_PARENT_FRAME (f) || (hf && frame_ancestor_p (f, hf)))
21137 { 21137 {
21138 x_ignore_errors_for_next_request (dpyinfo);
21138 XSetInputFocus (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f), 21139 XSetInputFocus (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f),
21139 RevertToParent, event->xbutton.time); 21140 RevertToParent, event->xbutton.time);
21141 x_stop_ignoring_errors (dpyinfo);
21142
21140 if (FRAME_PARENT_FRAME (f)) 21143 if (FRAME_PARENT_FRAME (f))
21141 XRaiseWindow (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f)); 21144 XRaiseWindow (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f));
21142 } 21145 }
@@ -22838,9 +22841,13 @@ handle_one_xevent (struct x_display_info *dpyinfo,
22838 } 22841 }
22839#else 22842#else
22840 /* Non-no toolkit builds without GTK 3 use core 22843 /* Non-no toolkit builds without GTK 3 use core
22841 events to handle focus. */ 22844 events to handle focus. Errors are still
22845 caught here in case the window is not
22846 viewable. */
22847 x_ignore_errors_for_next_request (dpyinfo);
22842 XSetInputFocus (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f), 22848 XSetInputFocus (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f),
22843 RevertToParent, xev->time); 22849 RevertToParent, xev->time);
22850 x_stop_ignoring_errors (dpyinfo);
22844#endif 22851#endif
22845 if (FRAME_PARENT_FRAME (f)) 22852 if (FRAME_PARENT_FRAME (f))
22846 XRaiseWindow (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f)); 22853 XRaiseWindow (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f));
@@ -27602,6 +27609,10 @@ x_focus_frame (struct frame *f, bool noactivate)
27602 else 27609 else
27603 { 27610 {
27604 if (!noactivate 27611 if (!noactivate
27612 /* If F is override-redirect, use SetInputFocus instead.
27613 Override-redirect frames are not subject to window
27614 management. */
27615 && !FRAME_OVERRIDE_REDIRECT (f)
27605 /* If F is a child frame, use SetInputFocus instead. This 27616 /* If F is a child frame, use SetInputFocus instead. This
27606 may not work if its parent is not activated. */ 27617 may not work if its parent is not activated. */
27607 && !FRAME_PARENT_FRAME (f) 27618 && !FRAME_PARENT_FRAME (f)