Subject: Re: bug#34569: 26.1.90; Zero wide scroll bars

From: martin rudalics <[email-masked]>
Date: Sat, 23 Feb 2019 15:01:54 +0100

> Why would users set 'scroll-bar-width' to zero, instead of turning off
 > scroll-bar-mode?

When they want to turn scroll bars off for a specific frame.  Turning
scroll bars on later would leave the frame with zero width scroll bars
alone.  It won't work but it could be the idea.

 > Or are you saying that turning off scroll-bar-mode
 > also produces the same bugs?

No (otherwise this would have been an issue known ever since).

 > If turning off scroll-bar-mode does work, then how about disabling the
 > direct setting of 'scroll-bar-width', either silently or noisily?

Setting 'scroll-bar-width' is fragile.  With GTK builds you can set
it, Emacs will respect it and GTK will either overdraw or leave a gap
because you can't change the GTK scroll bar from within Emacs.  Note
the dual use of this parameter: 'scroll-bar-width' is (1) passed on to
the toolkit to draw scroll bars of the desired width and (2) used by
Emacs to clear various areas of the window and calculate the width of
the text area.

But yes: One way to fix the aborts should be to disallow setting the
'scroll-bar-width' frame parameter to zero.

 >> /* Width that a scroll bar in frame F should have, if there is one.
 >>      Measured in pixels.
 >>      If scroll bars are turned off, this is still nonzero.  */
 >> #define FRAME_CONFIG_SCROLL_BAR_WIDTH(f) ((f)->config_scroll_bar_width)
 >>
 >> This comment is, unfortunately, wrong
 >
 > But the comment says "disabled", not "width set to zero".  is it
 > correct when scroll-bar-mode is turned off?  If so, perhaps just
 > qualifying the comment by the method by which the scroll bars are
 > disabled will be good enough?

This hints at another way of fixing the aborts: Handle zero wide
scroll bars just as if scroll bars were disabled/turned off.

 >> Note also that with emacs 27.1 the bug can be produced more directly by
 >> including
 >>
 >> (setq default-frame-alist '((vertical-scroll-bars . nil) (scroll-bar-width . 0)))
 >>
 >> in the early-init.el and then enabling vertical scroll bars.  The
 >> indirection via 'frame-notice-user-settings' is not needed there.
 >
 > If we disallow setting this parameter directly, or at least setting it
 > to zero, this problem will also go away, right?

Why would we disallow setting this parameter directly?  On Windows it
works perfectly.  On Lucid and Motif all widths but zero work well.

martin