Subject: bug#23966: 25.1.50; Frame resizing due to tool bar + Gnus

From: martin rudalics <[email-masked]>
Date: Thu, 14 Jul 2016 11:01:39 +0200

> I did in fact see this lack of height change, but only once among the
 > probably dozens of times I executed that code before filing the bug
 > report; I was surprised but since I couldn't reproduce it, I thought it
 > was a fluke.  All the other times, *Messages* showed this with emacs-25
 > and master:
 >
 > Emacs started; frame height: 36
 > Gnus started; frame height: 36
 > Reading /home/steve/.newsrc.eld...
 > Opening nnfolder server on archive...done
 > No new newsgroups
 > Checking new news...
 > Reading active file via nnnil...done
 > Reading active file from archive via nnfolder...done
 > Reading active file via nndraft...done
 > Checking new news...done
 > Opening nndoc server on /home/steve/tool-bar-Gnus-frame-bug...done
 > Tool bar disabled; frame height: 36
 > Entered Summary buffer; frame height: 36
 > Tool bar enabled; frame height: 36
 > Other buffer; frame height: 38
 > Back to Summary buffer; frame height: 38

‘frame-height’ is not necessarily a reliable reflection of what you see
on screen.

 > With 24.5 the frame height numbers were 35 (five times) followed by 37
 > (twice).
 >
 > When the tool bar was enabled in the Gnus Summary buffer, did you see it
 > displayed as I describe in the OP: an empty 8-pixel high strip?

No.  I see a 35-pixel high strip.  With the following definitions
adapted from yours

(defun gtk-tool-bar-height (&optional frame)
   (let* ((frame (window-normalize-frame frame))
	 (geometry (frame-geometry frame)))
     (cddr (assq 'tool-bar-size geometry))))

(let ((testfile "~/tool-bar-Gnus-frame-bug"))
   (with-temp-file testfile
     (insert "From nobody Wed Jul 13 13:55:54 CEST 2016
To: [email-masked]
Subject: bug test message
From: Stephen Berman <[email-masked]>
Date: Wed Jul 13 13:55:54 CEST 2016
Message-ID: <[email-masked]>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Lines: 1

test
"))
   (sit-for 0.1) (message "Emacs started; frame pixel height: %d  toolbar height: %d" (frame-pixel-height) (gtk-tool-bar-height))
   (require 'gnus)
   (let ((gnus-select-method '(nnnil "")))
     (sit-for 0.1) (message "Gnus started; frame pixel height: %d  toolbar height: %d" (frame-pixel-height) (gtk-tool-bar-height))
     (gnus-1)
     (gnus-group-make-doc-group testfile 'mbox)
     (tool-bar-mode -1)
     (sit-for 0.1) (message "Tool bar disabled; frame pixel height: %d  toolbar height: %d" (frame-pixel-height) (gtk-tool-bar-height))
     (sit-for 1)
     (gnus-group-select-group)
     (sit-for 0.1) (message "Entered Summary buffer; frame pixel height: %d  toolbar height: %d" (frame-pixel-height) (gtk-tool-bar-height))
     (sit-for 1)
     ;; Uncommenting these three lines and commenting out the same three
     ;; lines above results in a normal tool bar and no resizing.
     ;; (tool-bar-mode -1)
     ;; (sit-for 0.1) (message "Tool bar disabled; frame pixel height: %d  toolbar height: %d" (frame-pixel-height) (gtk-tool-bar-height))
     ;; (sit-for 1)
     (tool-bar-mode 1)
     (sit-for 0.1) (message "Tool bar enabled; frame pixel height: %d  toolbar height: %d" (frame-pixel-height) (gtk-tool-bar-height))
     (sit-for 3)
     (switch-to-buffer (other-buffer))
     (sit-for 0.1) (message "Other buffer; frame pixel height: %d  toolbar height: %d" (frame-pixel-height) (gtk-tool-bar-height))
     (sit-for 3)
     (switch-to-buffer (other-buffer))
     (sit-for 0.1) (message "Back to Summary buffer; frame pixel height: %d  toolbar height: %d" (frame-pixel-height) (gtk-tool-bar-height)))
     (sit-for 3)
   ;; Suppress further messages and clean up in order to repeat the test
   ;; simply by evaluating this sexp.
   (let (message-log-max)
     (gnus-summary-exit-no-update t)
     (goto-char (point-min))
     (gnus-group-kill-group)
     (let ((gnus-expert-user t))
       (gnus-group-quit))
     (delete-file testfile)
     (when (file-exists-p (gnus-dribble-file-name))
       (delete-file (gnus-dribble-file-name))))
   (sit-for 0.1) (message "Final; frame pixel height: %d  toolbar height: %d" (frame-pixel-height) (gtk-tool-bar-height))
   (sit-for 5)
   (switch-to-buffer "*Messages*"))

and `eval-buffer' of these in an emacs -Q of the release version I get

Emacs started; frame pixel height: 648  toolbar height: 44
Gnus started; frame pixel height: 648  toolbar height: 44
Opening nnfolder server on archive...done
No new newsgroups
Checking new news...
Reading active file via nnnil...done
Checking new news...done
No news is good news
Opening nndoc server on /home/martin/tool-bar-Gnus-frame-bug...done
Tool bar disabled; frame pixel height: 648  toolbar height: 0
Entered Summary buffer; frame pixel height: 648  toolbar height: 0
Tool bar enabled; frame pixel height: 657  toolbar height: 35
Other buffer; frame pixel height: 648  toolbar height: 44
Back to Summary buffer; frame pixel height: 657  toolbar height: 35
Final; frame pixel height: 648  toolbar height: 44
You can run the command ‘eval-buffer’ with M-x ev-b RET
Final; frame pixel height: 648  toolbar height: 44

So the "empty strips" here have a height of 35 pixels while the "normal"
toolbar has 44 pixels.  BTW, before getting the "Tool bar enabled"
message I briefly see some toolbar contents flashing and getting erased
immediately thereafter.

The entire frame height doesn't change here probably due to rounding and
size hints.  However, when I set `frame-resize-pixelwise' to t it
changes as follows:

Emacs started; frame pixel height: 648  toolbar height: 44
Gnus started; frame pixel height: 648  toolbar height: 44
Opening nnfolder server on archive...done
No new newsgroups
Checking new news...
Reading active file via nnnil...done
Checking new news...done
No news is good news
Opening nndoc server on /home/martin/tool-bar-Gnus-frame-bug...done
Tool bar disabled; frame pixel height: 648  toolbar height: 0
Entered Summary buffer; frame pixel height: 648  toolbar height: 0
Tool bar enabled; frame pixel height: 657  toolbar height: 35
Other buffer; frame pixel height: 657  toolbar height: 44
Back to Summary buffer; frame pixel height: 666  toolbar height: 35
Final; frame pixel height: 666  toolbar height: 44

So the pixel height of my frame has increased by 18 (2 times 9 pixels
from the difference between 44 and 35).

What do you get with my modifications?

martin