all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#59547: 28.2; The bottom border is not displayed when setting the pixel height of a child frame smaller than 1 line
@ 2022-11-24 16:31 Yuwei Tian
  2022-11-28 10:27 ` martin rudalics
  0 siblings, 1 reply; 6+ messages in thread
From: Yuwei Tian @ 2022-11-24 16:31 UTC (permalink / raw)
  To: 59547

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/openssl@1.1/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/openssl@1.1/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))





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#59547: 28.2; The bottom border is not displayed when setting the pixel height of a child frame smaller than 1 line
  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
  2022-11-28 13:02   ` Eli Zaretskii
  2022-11-28 14:01   ` Yuwei Tian
  0 siblings, 2 replies; 6+ messages in thread
From: martin rudalics @ 2022-11-28 10:27 UTC (permalink / raw)
  To: Yuwei Tian, 59547

 > 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





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#59547: 28.2; The bottom border is not displayed when setting the pixel height of a child frame smaller than 1 line
  2022-11-28 10:27 ` martin rudalics
@ 2022-11-28 13:02   ` Eli Zaretskii
  2022-11-28 14:01   ` Yuwei Tian
  1 sibling, 0 replies; 6+ messages in thread
From: Eli Zaretskii @ 2022-11-28 13:02 UTC (permalink / raw)
  To: martin rudalics; +Cc: 59547, fishtai0

> Date: Mon, 28 Nov 2022 11:27:17 +0100
> From: martin rudalics <rudalics@gmx.at>
> 
> 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.

To tell the truth, I hesitate to make changes just to cater to such a
problematic use case.





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#59547: 28.2; The bottom border is not displayed when setting the pixel height of a child frame smaller than 1 line
  2022-11-28 10:27 ` martin rudalics
  2022-11-28 13:02   ` Eli Zaretskii
@ 2022-11-28 14:01   ` Yuwei Tian
  2022-11-29 10:39     ` martin rudalics
  1 sibling, 1 reply; 6+ messages in thread
From: Yuwei Tian @ 2022-11-28 14:01 UTC (permalink / raw)
  To: martin rudalics, 59547

The problem reproduction code I gave is indeed problematic, and it is
indeed wrong to adjust 'window-safe-min-height' to 0.

The use case is to create a child frame with a height smaller than the
default line height, because the character size in the child frame is
set smaller than the default. How can this be achieved? Thanks.

On Mon, Nov 28, 2022 at 6:27 PM martin rudalics <rudalics@gmx.at> wrote:
>
>  > 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





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#59547: 28.2; The bottom border is not displayed when setting the pixel height of a child frame smaller than 1 line
  2022-11-28 14:01   ` Yuwei Tian
@ 2022-11-29 10:39     ` martin rudalics
  2022-11-29 12:13       ` Yuwei Tian
  0 siblings, 1 reply; 6+ messages in thread
From: martin rudalics @ 2022-11-29 10:39 UTC (permalink / raw)
  To: Yuwei Tian, 59547

 > The use case is to create a child frame with a height smaller than the
 > default line height, because the character size in the child frame is
 > set smaller than the default. How can this be achieved? Thanks.

Why don't you specify an appropriate font parameter like say

           (make-frame
            `((parent-frame . ,(window-frame))
	     (font . "-PfEd-DejaVu Sans Mono-regular-normal-normal-*-04-*-*-*-m-0-iso10646-1")
	     (no-accept-focus . t)

martin





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#59547: 28.2; The bottom border is not displayed when setting the pixel height of a child frame smaller than 1 line
  2022-11-29 10:39     ` martin rudalics
@ 2022-11-29 12:13       ` Yuwei Tian
  0 siblings, 0 replies; 6+ messages in thread
From: Yuwei Tian @ 2022-11-29 12:13 UTC (permalink / raw)
  To: martin rudalics, 59547

> Why don't you specify an appropriate font parameter like say
>
>            (make-frame
>             `((parent-frame . ,(window-frame))
>              (font . "-PfEd-DejaVu Sans Mono-regular-normal-normal-*-0
> 4-*-*-*-m-0-iso10646-1")
>              (no-accept-focus . t)

It works. Thanks so much.


On Tue, Nov 29, 2022 at 6:39 PM martin rudalics <rudalics@gmx.at> wrote:
>
>  > The use case is to create a child frame with a height smaller than the
>  > default line height, because the character size in the child frame is
>  > set smaller than the default. How can this be achieved? Thanks.
>
> Why don't you specify an appropriate font parameter like say
>
>            (make-frame
>             `((parent-frame . ,(window-frame))
>              (font . "-PfEd-DejaVu Sans Mono-regular-normal-normal-*-04-*-*-*-m-0-iso10646-1")
>              (no-accept-focus . t)
>
> martin





^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-11-29 12:13 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.