From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#38828: 26.3; Customized mode line breaks height of vertical scroll bar Date: Wed, 01 Jan 2020 18:10:44 +0200 Message-ID: <83tv5fjgxn.fsf@gnu.org> References: <840ae56c-467b-21f2-7109-bb744897e71b@gmx.at> Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="110140"; mail-complaints-to="usenet@blaine.gmane.org" Cc: 38828@debbugs.gnu.org To: martin rudalics Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Jan 01 17:11:12 2020 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.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1imgaW-000SVP-Fq for geb-bug-gnu-emacs@m.gmane.org; Wed, 01 Jan 2020 17:11:12 +0100 Original-Received: from localhost ([::1]:59562 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1imgaV-0000tr-35 for geb-bug-gnu-emacs@m.gmane.org; Wed, 01 Jan 2020 11:11:11 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:56888) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1imgaO-0000rg-IF for bug-gnu-emacs@gnu.org; Wed, 01 Jan 2020 11:11:05 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1imgaN-0004Rf-9w for bug-gnu-emacs@gnu.org; Wed, 01 Jan 2020 11:11:04 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:59683) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1imgaM-0004QT-N4 for bug-gnu-emacs@gnu.org; Wed, 01 Jan 2020 11:11:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1imgaM-0001Sh-Hi for bug-gnu-emacs@gnu.org; Wed, 01 Jan 2020 11:11:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 01 Jan 2020 16:11:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 38828 X-GNU-PR-Package: emacs Original-Received: via spool by 38828-submit@debbugs.gnu.org id=B38828.15778950455594 (code B ref 38828); Wed, 01 Jan 2020 16:11:02 +0000 Original-Received: (at 38828) by debbugs.gnu.org; 1 Jan 2020 16:10:45 +0000 Original-Received: from localhost ([127.0.0.1]:37423 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1imga5-0001SA-6h for submit@debbugs.gnu.org; Wed, 01 Jan 2020 11:10:45 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:47421) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1imga4-0001Ry-1T for 38828@debbugs.gnu.org; Wed, 01 Jan 2020 11:10:44 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:37908) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1imgZy-0003PG-Gg; Wed, 01 Jan 2020 11:10:38 -0500 Original-Received: from [176.228.60.248] (port=3656 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1imgZs-0007y6-6R; Wed, 01 Jan 2020 11:10:37 -0500 In-reply-to: <840ae56c-467b-21f2-7109-bb744897e71b@gmx.at> (message from martin rudalics on Tue, 31 Dec 2019 10:57:55 +0100) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] 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:174041 Archived-At: > From: martin rudalics > Date: Tue, 31 Dec 2019 10:57:55 +0100 > > Now hit any other key. This sould shrink the echo area and redisplay > the *scratch* window as before but "extends" the vertical scroll bar > into the mode line. > > The reason for this behavior is that the vertical scroll bar height in > the first case is calculated from a window_box_height call where > ml_row->mode_line_p is set and thus ml_row->height is used. > > In the second case ml_row->mode_line_p is not set and the value is > taken via estimate_mode_line_height which, given the specification > from 'test-mode-line', doesn't estimate the height well. AFAICT, when the ml_row->mode_line_p flag is reset, ml_row->height is also zero, so disregarding the flag would not have helped us in this case. > For the record: Rewriting 'window_box_height' as > > int > window_box_height (struct window *w) > { > return WINDOW_BOX_TEXT_HEIGHT (w); > } > > fixes the problem here. Thanks, but that's not an idea I would like entertaining. As much as window_box_text_height and WINDOW_BOX_TEXT_HEIGHT look similar, there's a subtle difference between them. The latter is supposed not to be called during redisplay, because window's mode_line_height field is not guaranteed to be accurate then, and the fallback is the same estimate_mode_line_height which doesn't support non-character display elements. It is generally okay to use WINDOW_BOX_TEXT_HEIGHT in window.c, because that code runs outside of redisplay, and the window object should be up-to-date. But window_box_text_height is called _a_lot_ from within redisplay itself. And here we get to another subtlety: window_box_text_height uses the window's current_matrix, which might not be up-to-date yet, depending on where it is called, because we only update it in update_frame, and set_vertical_scroll_bar is called long before that. When a window is resized, as happens in this scenario when the echo-area message is cleared, the mode-line row changes to a different one (because it is always the last row of the window), and the new row didn't yet get updated. We have the correct data in the desired_matrix, but not in the current_matrix. I considered using the desired_matrix in this case, but that is also somewhat scary: the desired matrix could be very sparse under some redisplay optimizations, so we'd need some logic to verify the data is valid before using it. Eventually, a simpler solution is just to fall back to the window's mode_line_height field, before falling back to estimate_mode_line_height, because when the mode-line height changes, we schedule an immediate thorough redisplay of the window, and invalidate that window's mode_line_height field, to be recomputed by the rescheduled redisplay. See the proposed patch below. diff --git a/src/xdisp.c b/src/xdisp.c index 6b677b63ae..fab95076fe 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -1105,6 +1105,8 @@ window_box_height (struct window *w) : 0); if (ml_row && ml_row->mode_line_p) height -= ml_row->height; + else if (w->mode_line_height >= 0) + height -= w->mode_line_height; else height -= estimate_mode_line_height (f, CURRENT_MODE_LINE_FACE_ID (w)); } @@ -1117,6 +1119,8 @@ window_box_height (struct window *w) : 0); if (tl_row && tl_row->mode_line_p) height -= tl_row->height; + else if (w->tab_line_height >= 0) + height -= w->tab_line_height; else height -= estimate_mode_line_height (f, TAB_LINE_FACE_ID); } @@ -1129,6 +1133,8 @@ window_box_height (struct window *w) : 0); if (hl_row && hl_row->mode_line_p) height -= hl_row->height; + else if (w->header_line_height >= 0) + height -= w->header_line_height; else height -= estimate_mode_line_height (f, HEADER_LINE_FACE_ID); }