From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: martin rudalics Newsgroups: gmane.emacs.bugs Subject: bug#34569: 26.1.90; Zero wide scroll bars Date: Tue, 19 Feb 2019 10:08:15 +0100 Message-ID: <5C6BC77F.6020104@gmx.at> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="35676"; mail-complaints-to="usenet@blaine.gmane.org" To: 34569@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Feb 19 10:09:24 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gw1P2-00096n-Km for geb-bug-gnu-emacs@m.gmane.org; Tue, 19 Feb 2019 10:09:24 +0100 Original-Received: from localhost ([127.0.0.1]:44650 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gw1Ow-0003ox-CB for geb-bug-gnu-emacs@m.gmane.org; Tue, 19 Feb 2019 04:09:18 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:59898) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gw1Oi-0003od-Rv for bug-gnu-emacs@gnu.org; Tue, 19 Feb 2019 04:09:05 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gw1Oh-00086v-N2 for bug-gnu-emacs@gnu.org; Tue, 19 Feb 2019 04:09:04 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:54586) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gw1Og-00085m-EB for bug-gnu-emacs@gnu.org; Tue, 19 Feb 2019 04:09:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1gw1Og-0003Wn-8C for bug-gnu-emacs@gnu.org; Tue, 19 Feb 2019 04:09:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: martin rudalics Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 19 Feb 2019 09:09:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 34569 X-GNU-PR-Package: emacs X-Debbugs-Original-To: Bug-Gnu-Emacs Original-Received: via spool by submit@debbugs.gnu.org id=B.155056731413513 (code B ref -1); Tue, 19 Feb 2019 09:09:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 19 Feb 2019 09:08:34 +0000 Original-Received: from localhost ([127.0.0.1]:53867 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gw1OD-0003Vt-UR for submit@debbugs.gnu.org; Tue, 19 Feb 2019 04:08:34 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:45356) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gw1OB-0003Vd-KR for submit@debbugs.gnu.org; Tue, 19 Feb 2019 04:08:31 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:45487) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gw1O5-0007x4-SQ for submit@debbugs.gnu.org; Tue, 19 Feb 2019 04:08:26 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:59737) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gw1O4-0003gt-MJ for bug-gnu-emacs@gnu.org; Tue, 19 Feb 2019 04:08:25 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gw1O2-0007wd-NK for bug-gnu-emacs@gnu.org; Tue, 19 Feb 2019 04:08:23 -0500 Original-Received: from mout.gmx.net ([212.227.15.18]:43115) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gw1O2-0007wE-Ad for bug-gnu-emacs@gnu.org; Tue, 19 Feb 2019 04:08:22 -0500 Original-Received: from [192.168.1.101] ([213.162.73.134]) by mail.gmx.com (mrgmx003 [212.227.17.190]) with ESMTPSA (Nemesis) id 0MNq8p-1gxQ2J2PiV-007RTn for ; Tue, 19 Feb 2019 10:08:20 +0100 X-Provags-ID: V03:K1:Mw2vlXvRNC77TrH242tZ8i7TUGdKvMvsDah2qII5Dwz5Aehe3ql 5O3g98WzQnKZxOhtRCFVnAt66s3GkvBFgVdHzgpwtcNBe4JkcY85dxGz1So7Vl3RA749omd y2BqlrvEHXCTDnxwFbqih6rU6cJK3soQ5Rt2h9k3MoSQcwRAeuE3pYQNKWwIZbVDxX/3TUd YEoIgHTSA6Id25Wmxx1Rw== X-UI-Out-Filterresults: notjunk:1;V03:K0:3XWrpKHxl0c=:fjX+EuydSfum8JU0yOckga /Uz0auEoj17nTKtA6dYdVIJbYfElZZ0yU5zqwzPfAUxguHrYIfpL0xStQK5u9kWvA5NWlX9ip wcTPxgI892vN5ulX0FFzHth4VhSuUM3j6LtnKK4YTODCyFVS0ogyinyJw1d+3EioedPW4uRs3 maaiaUXxo6pRWkOnFBgqL0zhzj7bHlBn0sPA4azmKucONiz2MdmKiYjj7V0fP46poPm5uEXRO B16/wuRV6uQBiuXyG6FHfbRJZG3IY9vO9Nx1x3XiZXBmHRJo3S7CBK17IUPv19Mz3aw2v9GCX V9fc+lFmLNbouML1suj/fqyQQ3ZZQ5WMOme0C3JqiTTHDBu5MksgX9p0nxbjOqQ0p/xVHxLak a7icTytwOfNNqgwlWyyESzTeQgtDARDFtYd2Z5wyYh4+x6WWmFE9xgoPIOzhzKVNmIrpd/RBY /6bur8gplwlq3+rOHWTLPN30OkXUswH/4MdM6F+PEkFVHAhkZBfsApJJud3UGzBTzk7azicaH GXWbz8dhcVyD1O4DDvypiW63g1pXBPGNnPWh4fb8l+FtuEc53IhZY2u6b27HhAb/8K79h5CeU 1Yn9TYwKgZt3yxTPM0V4sabBuUiB1OUUxLeYIWPPL9qt2aCFFQ/sGdU0ww2OGNKAFOzsgfQVU U3qjQYsbD3N+TgE1h4fMMRVDsexVIOETc+SL6JDgH7zAXt+hNINd5a9t053MkO9cmi2/ydYXA okivR25umQqD0fKzpOCQEiP4c7sQQWIget2fRS3/82Rb57ES1F1XnpkQ25f1znuNo/ZtYqJ/ X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:155548 Archived-At: Setting 'scroll-bar-width' to zero can have unforeseen consequences depending on the toolkit used. To reproduce with Emacs 26 run a Lucid or Motif build as emacs - Q --eval "(setq default-frame-alist '((minibuffer . nil) (vertical-scroll-bars . nil) (scroll-bar-width . 0)))" Then evaluate (set-frame-parameter nil 'vertical-scroll-bars 'left) Emacs aborts with a X protocol error: BadValue (integer parameter out of range for operation) on protocol request 12 GTK builds do not abort but have for example a scroll bar on the left overwrite buffer text. A similar bug can be produced with horizontal scroll bars. It's not entirely trivial to explain why Emacs aborts here. The cause is a combination of contrived logic and the absence of a more cautious initial setting for X builds. For starters, frame.h says that /* 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 because in our example 'frame-notice-user-settings' (setq parms (frame-parameters frame-initial-frame)) 'frame-parameters' creates a zero entry for the 'scroll-bar-width' frame parameter since our initial frame has no scroll bars and 'frame-notice-user-settings' passes that parameter on to 'make-frame'. In frame.c this subsequently bypasses both checks in x_set_scroll_bar_width (struct frame *f, Lisp_Object arg, Lisp_Object oldval) { int unit = FRAME_COLUMN_WIDTH (f); if (NILP (arg)) { x_set_scroll_bar_default_width (f); ... } else if (RANGED_INTEGERP (1, arg, INT_MAX) && XFASTINT (arg) != FRAME_CONFIG_SCROLL_BAR_WIDTH (f)) { FRAME_CONFIG_SCROLL_BAR_WIDTH (f) = XFASTINT (arg); ... since ARG is zero which is neither nil nor a ranged integer > 0. So we continue with the initially zero FRAME_CONFIG_SCROLL_BAR_WIDTH (f) and try to make a window with a zero wide scroll bar produced from the initial w->scroll_bar_width (which equals -1) and these definitions in window.h: /* Width that a scroll bar in window W should have, if there is one. Measured in pixels. If scroll bars are turned off, this is still nonzero. */ #define WINDOW_CONFIG_SCROLL_BAR_WIDTH(W) \ (W->scroll_bar_width >= 0 \ ? W->scroll_bar_width \ : FRAME_CONFIG_SCROLL_BAR_WIDTH (WINDOW_XFRAME (W))) /* Width of scroll bar area in window W, measured in pixels. */ #define WINDOW_SCROLL_BAR_AREA_WIDTH(W) \ (WINDOW_HAS_VERTICAL_SCROLL_BAR (W) \ ? WINDOW_CONFIG_SCROLL_BAR_WIDTH (W) \ : 0) Here the first comment is wrong again, WINDOW_CONFIG_SCROLL_BAR_WIDTH is zero and X is rightfully annoyed. The easisest fix I could come up with is switching the two branches of the if clause in x_set_scroll_bar_width thusly: void x_set_scroll_bar_width (struct frame *f, Lisp_Object arg, Lisp_Object oldval) { int unit = FRAME_COLUMN_WIDTH (f); if (RANGED_INTEGERP (1, arg, INT_MAX) && XFASTINT (arg) != FRAME_CONFIG_SCROLL_BAR_WIDTH (f)) { FRAME_CONFIG_SCROLL_BAR_WIDTH (f) = XFASTINT (arg); FRAME_CONFIG_SCROLL_BAR_COLS (f) = (XFASTINT (arg) + unit - 1) / unit; if (FRAME_X_WINDOW (f)) adjust_frame_size (f, -1, -1, 3, 0, Qscroll_bar_width); SET_FRAME_GARBAGED (f); } else { x_set_scroll_bar_default_width (f); if (FRAME_X_WINDOW (f)) adjust_frame_size (f, -1, -1, 3, 0, Qscroll_bar_width); SET_FRAME_GARBAGED (f); } XWINDOW (FRAME_SELECTED_WINDOW (f))->cursor.hpos = 0; XWINDOW (FRAME_SELECTED_WINDOW (f))->cursor.x = 0; } But maybe someone has a better idea. Note that Windows builds sidestep the problem by unconditionally doing /* By default, make scrollbars the system standard width and height. */ FRAME_CONFIG_SCROLL_BAR_WIDTH (f) = GetSystemMetrics (SM_CXVSCROLL); in 'x-create-frame'. 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. Thanks, martin