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

From: Stephen Berman <[email-masked]>
Date: Wed, 13 Jul 2016 14:16:33 +0200

When I disable the tool bar before entering the Gnus Summary buffer and
then re-enable it while in that buffer, it appears as an 8-pixel high
empty strip below the menu bar.  When I switch to another buffer, the
tool bar is displayed normally but the frame height increases by two
lines, and when I switch back to the Gnus Summary buffer the tool bar
again appears as an empty strip and the frame height stays at the new
height; this pattern can be repeated and each time the frame height
increases.  I see the same thing when the tool bar is displayed at the
bottom of the frame; if it is displayed on the left or right side of the
frame, the frame width increases instead of the height.

I see this in builds from emacs-25 and master, as well as in 24.5, all
64-bit GNU/Linux, GTK+ Version 3.14.15 (not built --with-cairo).  In the
24.5 build, when switching back to the Gnus Summary buffer, the console
displays a message like this:

(emacs:4487): Gtk-WARNING **: GtkToolbar 0x313ca90 reported min size 42
and natural size 8 in get_preferred_width(); natural size must be >= min
size

There is no such message with the emacs-25 or master builds.  (In the
latter two builds, the initial frame height is 36 and increases to 38;
in the 24.5 build, the initial height is 35 and increases to 37.)

I haven't seen this issue with any other buffer than the Gnus Summary
buffer.  Moreover, if I disable the tool bar only after entering the
Gnus Summary buffer and then re-enable it there, the tool bar is
displayed in that buffer normally and there is no resizing after
switching away and back.

To reproduce, start emacs with -Q and evaluate the following sexp in
*scratch*:

(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
"))
  (message "Emacs started; frame height: %d" (frame-height))
  (require 'gnus)
  (let ((gnus-select-method '(nnnil "")))
    (message "Gnus started; frame height: %d" (frame-height))
    (gnus-1)
    (gnus-group-make-doc-group testfile 'mbox)
    (tool-bar-mode -1)
    (message "Tool bar disabled; frame height: %d" (frame-height))
    (sit-for 1)
    (gnus-group-select-group)
    (message "Entered Summary buffer; frame height: %d" (frame-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)
    ;; (message "Tool bar disabled; frame height: %d" (frame-height))
    ;; (sit-for 1)
    (tool-bar-mode 1)
    (message "Tool bar enabled; frame height: %d" (frame-height))
    (sit-for 2)
    (switch-to-buffer (other-buffer))
    (message "Other buffer; frame height: %d" (frame-height))
    (sit-for 1)
    (switch-to-buffer (other-buffer))
    (message "Back to Summary buffer; frame height: %d" (frame-height)))
    (sit-for 1)
  ;; 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))))
  (switch-to-buffer "*Messages*"))