Subject: bug#59547: 28.2; The bottom border is not displayed when setting the pixel height of a child frame smaller than 1 line

From: Yuwei Tian <[email-masked]>
Date: Fri, 25 Nov 2022 00:31:39 +0800

Start Emacs from 'Emacs -Q' and make a child frame with the following
code:

(let ((window-min-height 1)
      (window-min-width 1))
  (setq my-child-frame
        (let ((after-make-frame-functions nil))
          (make-frame
           `((parent-frame . ,(window-frame))
             (no-accept-focus . t)
             (min-width  . t)
             (min-height . t)
             (border-width . 0)
             (internal-border-width . 0)
             (child-frame-border-width . 1)
             (vertical-scroll-bars . nil)
             (horizontal-scroll-bars . nil)
             (left-fringe . 10)
             (right-fringe . 0)
             (menu-bar-lines . 0)
             (tool-bar-lines . 0)
             (line-spacing . 0)
             (unsplittable . t)
             (no-other-frame . t)
             (undecorated . t)
             (visibility . t)
             (cursor-type . nil)
             (minibuffer . nil)
             (width . 50)
             (height . 1)
             (no-special-glyphs . t)))))

  (let ((window (frame-root-window my-child-frame)))
    (set-window-parameter window 'mode-line-format 'none)
    (set-window-parameter window 'header-line-format 'none))

  (set-face-background 'child-frame-border "red" my-child-frame)

  (set-window-buffer
   (frame-root-window my-child-frame) (get-buffer-create "*foo*"))

  (with-current-buffer "*foo*"
    (erase-buffer)
    (insert "line 1\n"))

  (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)))

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.

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

In GNU Emacs 28.2 (build 1, x86_64-apple-darwin22.1.0, NS
appkit-2299.00 Version 13.0.1 (Build 22A400))
of 2022-11-18 built on fishtai0-macmini.local
Windowing system distributor 'Apple', version 10.3.2299
System Description:  macOS 13.0.1

Configured using:
'configure --disable-dependency-tracking --disable-silent-rules
--enable-locallisppath=/usr/local/share/emacs/site-lisp
--infodir=/usr/local/Cellar/emacs-plus@28/28.2/share/info/emacs
--prefix=/usr/local/Cellar/emacs-plus@28/28.2 --with-xml2 --with-gnutls
--without-dbus --without-imagemagick --with-modules --with-rsvg
--with-ns --disable-ns-self-contained 'CFLAGS=-Os -w -pipe
-march=nehalem -mmacosx-version-min=13
-isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk
-DFD_SETSIZE=10000 -DDARWIN_UNLIMITED_SELECT'
'CPPFLAGS=-I/usr/local/opt/icu4c/include
-I/usr/local/opt/[email-masked]/include -I/usr/local/opt/readline/include
-F/usr/local/Frameworks
-isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk'
'LDFLAGS=-L/usr/local/opt/icu4c/lib -L/usr/local/opt/[email-masked]/lib
-L/usr/local/opt/readline/lib -L/usr/local/lib -F/usr/local/Frameworks
-Wl,-headerpad_max_install_names
-isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk''

Configured features:
ACL GIF GLIB GMP GNUTLS JPEG JSON LCMS2 LIBXML2 MODULES NOTIFY KQUEUE NS
PDUMPER PNG RSVG THREADS TIFF TOOLKIT_SCROLL_BARS XIM ZLIB

Important settings:
  value of $LC_ALL: en_US.UTF-8
  value of $LC_CTYPE: UTF-8
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: ELisp/d

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  indent-tabs-mode: t
  transient-mark-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message rmc puny dired dired-loaddefs
rfc822 mml mml-sec epa derived epg rfc6068 epg-config gnus-util rmail
rmail-loaddefs auth-source cl-seq eieio eieio-core cl-macs
eieio-loaddefs password-cache json map text-property-search time-date
subr-x seq byte-opt gv bytecomp byte-compile cconv mm-decode mm-bodies
mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader cl-loaddefs
cl-lib sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils
iso-transl tooltip eldoc paren electric uniquify ediff-hook vc-hooks
lisp-float-type elisp-mode mwheel term/ns-win ns-win ucs-normalize
mule-util term/common-win tool-bar dnd fontset image regexp-opt fringe
tabulated-list replace newcomment text-mode lisp-mode prog-mode register
page tab-bar menu-bar rfn-eshadow isearch easymenu timer select
scroll-bar mouse jit-lock font-lock syntax font-core term/tty-colors
frame minibuffer cl-generic cham georgian utf-8-lang misc-lang
vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932
hebrew greek romanian slovak czech european ethiopic indian cyrillic
chinese composite emoji-zwj charscript charprop case-table epa-hook
jka-cmpr-hook help simple abbrev obarray cl-preloaded nadvice button
loaddefs faces cus-face macroexp files window text-properties overlay
sha1 md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote threads kqueue cocoa ns lcms2
multi-tty make-network-process emacs)

Memory information:
((conses 16 53479 11176)
(symbols 48 6556 1)
(strings 32 18558 2150)
(string-bytes 1 622619)
(vectors 16 13162)
(vector-slots 8 191879 9585)
(floats 8 25 191)
(intervals 56 508 34)
(buffers 992 14))