GNU bug report logs - #67654
29.1; Hiding menu bar makes new frames very small

Previous Next

Package: emacs;

Reported by: Roshan Shariff <roshan.shariff <at> gmail.com>

Date: Wed, 6 Dec 2023 07:57:02 UTC

Severity: normal

Merged with 68463

Found in version 29.1

Full log


Message #39 received at 67654 <at> debbugs.gnu.org (full text, mbox):

From: John Avery <jkavery <at> fastmail.net>
To: Roshan Shariff <roshan.shariff <at> gmail.com>, Eli Zaretskii <eliz <at> gnu.org>
Cc: Po Lu <luangruo <at> yahoo.com>, 67654 <at> debbugs.gnu.org
Subject: Re: bug#67654: 29.1; Hiding menu bar makes new frames very small
Date: Tue, 18 Jun 2024 21:57:18 -0400
On 12/11/23 02:13, Roshan Shariff wrote:
> I tried a git bisect only to find that commits as far back as ~2015
> exhibit the bug; I wasn't able to compile older versions on my system
> because of segfaults during compilation. So it seems plausible that
> the GTK3 build of Emacs has always had this issue.
> 
> While coming up with a workaround (see below) I noticed something odd.
> I added a hook to after-make-frame-functions that prints out the
> frame-{char,native,text,outer}-{width,height} of the newly created
> frame. I found that immediately after the frame is created, these
> values are fine. But when printing them out after a brief sleep-for,
> or using run-with-timer, the values actually match the size of the
> tiny frame. So it seems that Emacs thinks the frame has the correct
> size on creation, but learns of its actual size a little bit later.
> 
> The following workaround needs the run-with-timer (and the duration
> needs to be long enough):
> 
> (add-hook 'after-make-frame-functions
>     (defun +resize-after-make-frame (frame)
>       ;; HACK Resize new frames shortly after creation.  Works around
>       ;; https://debbugs.gnu.org/cgi/bugreport.cgi?bug=67654
>       (when-let ((width (alist-get 'width default-frame-alist))
>                  (height (alist-get 'height default-frame-alist)))
>         (run-with-timer (/ 1.0 60) nil #'set-frame-size frame width height))))
> 
> I figure there's little chance of finding the root cause, but
> hopefully the workaround will help people who come across this.
> 

I have only seen the problem since moving to Ubuntu 24.04 (with Gnu 
Emacs 29.3).  Previously I was running Ubuntu 23.10 with its default Emacs.

Before seeing any bug reports I came up with an after make frame 
function.  It now incorporates most of your code and also takes 
advantage of your observation about 
frame-{char,native,text,outer}-{width,height} of the newly created 
frame.  Thank you!

I have not tested it extensively, but it has worked without fail for 
nearly two weeks.

(add-hook 'after-make-frame-functions
   (defun +resize-after-make-frame (frame)
     "HACK Resize new frames shortly after creation.  Works around 
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=67654"
     (let ((width (/ (frame-text-width frame) (frame-char-width frame)))
           (height (/ (frame-text-height frame) (frame-char-height 
frame))))
       (sleep-for 0 1)
       (set-frame-size frame width height))))




This bug report was last modified 1 year ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.