Subject: bug#55970: 29.0.50; Emacs crashes when dragging the scroll bar with "--with-pgtk" and "--without-toolkit-scroll-bars" configure flags

From: Po Lu <[email-masked]>
Date: Wed, 15 Jun 2022 21:14:16 +0800

Eli Zaretskii <[email-masked]> writes:

> Then how come the code which aborted got executed contrary to what you
> say?

Because USE_TOOLKIT_SCROLL_BARS was not defined.  The reporter passed
`--without-toolkit-scroll-bars' to configure, which is not supported on
PGTK.

The configure script is supposed to prohibit that combination of
options, but somehow that did not happen.

> And given that it did, would it do any harm to install the fix I
> proposed?

Yes, since the events generated would also still be broken, but more
subtly.  USE_TOOLKIT_SCROLL_BARS should always be defined on window
systems other than X, since no other window system implements "native"
scroll bars.

> More importantly, does it really make sense to "fix" events in
> keyboard.c, rather than generate them correctly in low-level
> toolkit-specific code to begin with?  I mean this part:
>
> 	/* Always treat scroll bar events as clicks.  */
> 	event->modifiers |= click_modifier;
> 	event->modifiers &= ~up_modifier;
>
> Why do we override the modifiers of the event, and why in keyboard.c
> of all places?  Can we do this cleaner, or at least in
> toolkit-specific code?

I don't really understand that piece of code.  It seems wrong to me,
since toolkit scroll bar events should not have modifiers at all.

But it's probably there for a reason, which I will look into.