Fix GC protection of scroll bar windows

* src/xterm.c (x_atom_refs): Add _EMACS prefix to
vendor-specific scroll-bar atoms.
(handle_one_xevent): Unprotect windows immediately upon
receiving an _EMACS_SCROLLBAR event, instead of waiting for the
event to be put on the keyboard buffer.  Reported by martin
rudalics <rudalics@gmx.at>.
This commit is contained in:
Po Lu 2022-09-19 09:35:58 +08:00
parent 7c8a131984
commit a5405e5644

View file

@ -970,8 +970,8 @@ static const struct x_atom_ref x_atom_refs[] =
/* Ghostscript support. */
ATOM_REFS_INIT ("DONE", Xatom_DONE)
ATOM_REFS_INIT ("PAGE", Xatom_PAGE)
ATOM_REFS_INIT ("SCROLLBAR", Xatom_Scrollbar)
ATOM_REFS_INIT ("HORIZONTAL_SCROLLBAR", Xatom_Horizontal_Scrollbar)
ATOM_REFS_INIT ("_EMACS_SCROLLBAR", Xatom_Scrollbar)
ATOM_REFS_INIT ("_EMACS_HORIZONTAL_SCROLLBAR", Xatom_Horizontal_Scrollbar)
ATOM_REFS_INIT ("_XEMBED", Xatom_XEMBED)
/* EWMH */
ATOM_REFS_INIT ("_NET_WM_STATE", Xatom_net_wm_state)
@ -18103,12 +18103,24 @@ handle_one_xevent (struct x_display_info *dpyinfo,
if (event->xclient.message_type == dpyinfo->Xatom_Scrollbar)
{
x_scroll_bar_to_input_event (event, &inev.ie);
/* Unprotect the first window to be sent in a
ClientMessage event, since it is now on the stack and
thereby subject to garbage collection. */
x_unprotect_window_for_callback (dpyinfo);
*finish = X_EVENT_GOTO_OUT;
goto done;
}
else if (event->xclient.message_type == dpyinfo->Xatom_Horizontal_Scrollbar)
{
x_horizontal_scroll_bar_to_input_event (event, &inev.ie);
/* Unprotect the first window to be sent in a
ClientMessage event, since it is now on the stack and
thereby subject to garbage collection. */
x_unprotect_window_for_callback (dpyinfo);
*finish = X_EVENT_GOTO_OUT;
goto done;
}
@ -23709,12 +23721,6 @@ handle_one_xevent (struct x_display_info *dpyinfo,
count++;
}
#ifdef USE_TOOLKIT_SCROLL_BARS
if (event->xany.type == ClientMessage
&& inev.ie.kind == SCROLL_BAR_CLICK_EVENT)
x_unprotect_window_for_callback (dpyinfo);
#endif
if (do_help
&& !(hold_quit && hold_quit->kind != NO_EVENT))
{