unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: martin rudalics <rudalics@gmx.at>
To: Yuwei Tian <fishtai0@gmail.com>, 59547@debbugs.gnu.org
Subject: bug#59547: 28.2; The bottom border is not displayed when setting the pixel height of a child frame smaller than 1 line
Date: Mon, 28 Nov 2022 11:27:17 +0100	[thread overview]
Message-ID: <57b46e7e-e1fd-774b-f39c-e55e9782398b@gmx.at> (raw)
In-Reply-To: <CAC9=Ai=o8hjR_7U3aPWc2mdUUGrvzL8hSqTBe-bGBr6Lb-DyzA@mail.gmail.com>

 > Start Emacs from 'Emacs -Q' and make a child frame with the following
 > code:
 >
 > (let ((window-min-height 1)
 >        (window-min-width 1))

The last line is problematic since 'window-safe-min-width' being 2
will override it.

 >    (fit-frame-to-buffer my-child-frame)
 >    (let ((window-min-height 0)
 > (window-safe-min-height 0))
 >      (set-frame-size my-child-frame
 >      (frame-pixel-width my-child-frame)
 >      (floor (* 0.5 (frame-pixel-height my-child-frame)))
 >      t)))

This is overly complicated.

   (let ((window-min-height 0)
	(window-safe-min-height 0))
     (set-frame-size my-child-frame 50 8 t)))

suffices to show the problem here.  In either case, you do two things
which most people would classify as pilot errors.

- You bind 'window-safe-min-height' which is defined as a constant
   variable and according to the doc-string of 'defconst' "neither
   programs nor users should ever change the value".

- You temporarily bind 'window-min-height' around the 'set-frame-size'
   call which means that it may not affect future resize operations on
   'my-child-frame' or its windows.  In particular, it may not affect the
   frame size adjustment triggered by 'set-frame-size' itself if that
   happens asynchronously (not within the scope of 'set-frame-size').

 > The bottom border of the child frame is not displayed. Try to resize the
 > child frame again:
 >
 > (let ((window-min-height 0)
 >        (window-safe-min-height 0))
 >    (set-frame-size my-child-frame 50 8 t))
 >
 > And select other window, then the bottom border of the child frame appears.

Here clicking into the child frame with the mouse suffices to make the
bottom border appear.

 > This behavior seems to be platform dependent, but it is indeed
 > problematic. It also seems to have problems on Emacs 28, Linux/X11.

The immediate cause of the problem are these two lines in window.c's
resize_frame_windows code:

   new_pixel_size = max (horflag ? size : size - mini_height, unit);
   new_size = new_pixel_size / unit;

where unit is defined as

   int unit = horflag ? FRAME_COLUMN_WIDTH (f) : FRAME_LINE_HEIGHT (f);

As a consequence, 'compute_line_metrics' in xdisp.c will calculate

       max_y = WINDOW_BOX_HEIGHT_NO_MODE_LINE (it->w);

       if (row->y + row->height > max_y)
	row->visible_height -= row->y + row->height - max_y;

from the value of 'unit' above, the text is not clipped and whether you
see the lower border or the lower part of the buffer text reduces to the
question of who succeeds in drawing later into that area - the code
displaying the buffer text or the one filling the border rectangle.

If you replace these two lines with say

   new_pixel_size = max (horflag ? size : size - mini_height, 1);
   new_size = max (new_pixel_size / unit, unit);

you should get the bottom border immediately.  Whether applying such a
"fix" is safe, is a question I cannot answer though.  Here I'm living
happily with fixes for this and many related problems but have no hope
that they will ever see the light of master.

martin





  reply	other threads:[~2022-11-28 10:27 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-24 16:31 bug#59547: 28.2; The bottom border is not displayed when setting the pixel height of a child frame smaller than 1 line Yuwei Tian
2022-11-28 10:27 ` martin rudalics [this message]
2022-11-28 13:02   ` Eli Zaretskii
2022-11-28 14:01   ` Yuwei Tian
2022-11-29 10:39     ` martin rudalics
2022-11-29 12:13       ` Yuwei Tian

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=57b46e7e-e1fd-774b-f39c-e55e9782398b@gmx.at \
    --to=rudalics@gmx.at \
    --cc=59547@debbugs.gnu.org \
    --cc=fishtai0@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).