GNU bug report logs - #72331
29.4; Modifying horizontal-scroll-bar does not fully work (MacOS only)

Previous Next

Package: emacs;

Reported by: Jared Finder <jared <at> finder.org>

Date: Sun, 28 Jul 2024 05:11:02 UTC

Severity: normal

Found in version 29.4

Fixed in version 30.1

Done: Gerd Möllmann <gerd.moellmann <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


Message #14 received at 72331 <at> debbugs.gnu.org (full text, mbox):

From: Gerd Möllmann <gerd.moellmann <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: Po Lu <luangruo <at> yahoo.com>, Jared Finder <jared <at> finder.org>,
 72331 <at> debbugs.gnu.org
Subject: Re: bug#72331: 29.4; Modifying horizontal-scroll-bar does not fully
 work (MacOS  only)
Date: Thu, 08 Aug 2024 08:45:31 +0200
[Message part 1 (text/plain, inline)]
Gerd Möllmann <gerd.moellmann <at> gmail.com> writes:

> Eli Zaretskii <eliz <at> gnu.org> writes:
>
>>> Date: Sat, 27 Jul 2024 22:10:06 -0700
>>> From:  Jared Finder via "Bug reports for GNU Emacs,
>>>  the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
>>> 
>>> Directly modifying the variable horizontal-scroll-bar on MacOS doesn't
>>> show a scroll bar unless the frame also has the horizontal-scroll-bars
>>> frame  parameter set.  This only happens on MacOS, on Linux and Windows
>>> everything behaves as I would expect.
>>> 
>>> To reproduce, define the following function:
>>> 
>>> (defun bug-report-toggle-buffer-horizontal-scroll-bar ()
>>>    "Like `toggle-scroll-bar', but for just the current buffer.
>>> And for horizontal scroll bars.  I guess it's acutally very
>>> different."
>>>    (interactive)
>>>    (setq horizontal-scroll-bar (if horizontal-scroll-bar nil 'bottom))
>>>    (set-window-buffer (selected-window) (current-buffer)))
>>> 
>>> Then run M-x bug-report-toggle-buffer-horizontal-scroll-bar repeatedly
>>> and observe that on MacOS space gets reserved for the horizontal scroll
>>> bar but no scroll bar is rendered.  Finally, run M-x
>>> horizontal-scroll-bar-mode and observe that now the horizontal scroll
>>> bar is properly shown and hidden.
>>> 
>>> I also tested this on master and observed the same behavior.
>>
>> Thanks.
>>
>> Could some macOS user please look into this?
>
> Same for vertical-scroll-bar, BTW. From reading the code and setting a
> breakpoint in ns_set_horizontal_scroll_bar, I'd say it's the definition
> of these macros in nsterm.h:
>
>   /* Compute pixel size for vertical scroll bars.  */
>   #define NS_SCROLL_BAR_WIDTH(f)						\
>     (FRAME_HAS_VERTICAL_SCROLL_BARS (f)					\
>      ? rint (FRAME_CONFIG_SCROLL_BAR_WIDTH (f) > 0			\
>              ? FRAME_CONFIG_SCROLL_BAR_WIDTH (f)				\
>              : (FRAME_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f)))	\
>      : 0)
>
>   /* Compute pixel size for horizontal scroll bars.  */
>   #define NS_SCROLL_BAR_HEIGHT(f)						\
>     (FRAME_HAS_HORIZONTAL_SCROLL_BARS (f)					\
>      ? rint (FRAME_CONFIG_SCROLL_BAR_HEIGHT (f) > 0			\
>              ? FRAME_CONFIG_SCROLL_BAR_HEIGHT (f)				\
>              : (FRAME_SCROLL_BAR_LINES (f) * FRAME_LINE_HEIGHT (f)))	\
>      : 0)
>
> Both check FRAME_HAS_H/V_SCROLL_BARS which in this case results in width
> or height being 0, which is a bit small.
>
> A change like the one below makes the horizontal scroll bar visible with
> Jared's test function.

I think the fix is the attached patch. Jared, could you please try it?

[0001-NS-Fix-scroll-bar-setting-code-bug-72331.patch (text/x-patch, attachment)]

This bug report was last modified 286 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.