Subject: 25.0.50; window-size-change-functions not called after mini-window resize
From: Pip Cet <[email-masked]>
To: [email-masked]
Date: Sun, 23 Aug 2015 22:06:45 +0000
List-Id: <debbugs-submit.debbugs.gnu.org>

This is possibly only a documentation issue.

Recipe: eval
(progn (push (lambda (&rest args) (message "window size changed"))
window-size-change-functions)
    (message (make-string 3000 ?*)))

Expected result: a "window size changed" message.

Actual result: no such message.

The symptom is that the window size change function is not run after a
mini-window size change.

So far, I can produce this behavior only when the minibuffer or echo
area grows to several lines; when it shrinks afterwards, my window size
change function is called. I cannot reproduce the behavior with other
windows.

Is this a bug? The documentation says:

    [...] to be called if the size of any window changes for any reason.

Please correct me if I'm wrong, but when the minibuffer/echo area gets
resized (and the windows on top of it, too), that counts as a change of
size, I would say.

If this is merely a documentation issue, the exception should be noted
in the manual.

Analysis:
First, some warnings:
 - `window_resize_apply' and `Fwindow_resize_apply' (aka
   `window-resize-apply') are two different functions
 - `resize-mini-window' and `resize-mini-window-internal' are called
   only when the mini-window is explicitly resized by a Lisp call of
   `resize-mini-window'. Implicit resizes as a consequence of having
   too much text in the echo area do not appear to call it.

The problem is that FRAME_WINDOW_SIZES_CHANGED (f) is not set to true
after a mini-window resize. Fwindow_resize_apply would set this flag,
but window_resize_apply does not.

If this behavior is deliberate, I believe it is inconsistent to set
FRAME_WINDOW_SIZES_CHANGED (f) in `resize-mini-window-internal'.

Suggested solution:

Trivial. Add FRAME_WINDOW_SIZES_CHANGED (f) = true to all callers of
window_resize_apply.

In GNU Emacs 25.0.50.51 (x86_64-unknown-linux-gnu, GTK+ Version 3.16.6)
 of 2015-08-23 on ...
Repository revision: bfb06826feac9151877069590d5dc91b60337b6b
Windowing system distributor `The X.Org Foundation', version 11.0.11702000
System Description:    Debian GNU/Linux unstable (sid)

Configured using:
 `configure 'CFLAGS=-O0 -g3''

Configured features:
XPM JPEG TIFF GIF PNG RSVG SOUND DBUS GCONF GSETTINGS NOTIFY LIBSELINUX
GNUTLS LIBXML2 FREETYPE XFT ZLIB TOOLKIT_SCROLL_BARS GTK3 X11

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

Major mode: Lisp Interaction

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-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
  transient-mark-mode: t

Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.

Load-path shadows:
None found.

Features:
(shadow sort gnus-util mail-extr emacsbug message dired format-spec
rfc822 mml mml-sec mm-decode mm-bodies mm-encode mail-parse rfc2231
mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums
mm-util help-fns help-mode easymenu cl-loaddefs pcase cl-lib mail-prsvr
mail-utils misearch multi-isearch time-date mule-util tooltip eldoc
electric uniquify ediff-hook vc-hooks lisp-float-type mwheel x-win
term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe
tabulated-list newcomment elisp-mode lisp-mode prog-mode register page
menu-bar rfn-eshadow timer select scroll-bar mouse jit-lock font-lock
syntax facemenu font-core frame 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 charscript case-table epa-hook jka-cmpr-hook help
simple abbrev minibuffer cl-preloaded nadvice loaddefs button faces
cus-face macroexp files text-properties overlay sha1 md5 base64 format
env code-pages mule custom widget hashtable-print-readable backquote
dbusbind inotify dynamic-setting system-font-setting font-render-setting
move-toolbar gtk x-toolkit x multi-tty make-network-process emacs)

Memory information:
((conses 16 81668 9633)
 (symbols 48 19040 0)
 (miscs 40 42 136)
 (strings 32 13288 4444)
 (string-bytes 1 380166)
 (vectors 16 11279)
 (vector-slots 8 414205 3702)
 (floats 8 131 186)
 (intervals 56 190 0)
 (buffers 976 11)
 (heap 1024 18666 1015))
From 243be700591979554e61bbdff0f00f30cc386f7b Mon Sep 17 00:00:00 2001
From: Philip <[email-masked]>
Date: Sun, 23 Aug 2015 21:46:42 +0000
Subject: [PATCH] Call `window-size-change-functions' after mini-window size
 changes.

	* window.c (resize_frame_windows): Set
	FRAME_WINDOW_SIZES_CHANGED flag.  (grow_mini_window):
	Likewise.  (shrink_mini_window): Likewise.
---
 src/window.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/window.c b/src/window.c
index 863a792..68bc9e5 100644
--- a/src/window.c
+++ b/src/window.c
@@ -4094,6 +4094,7 @@ resize_frame_windows (struct frame *f, int size, bool horflag, bool pixelwise)
     }
 
   fset_redisplay (f);
+  FRAME_WINDOW_SIZES_CHANGED (f) = true;
 }

@@ -4531,6 +4532,7 @@ grow_mini_window (struct window *w, int delta, bool pixelwise)
 	  /* Enforce full redisplay of the frame.  */
 	  /* FIXME: Shouldn't window--resize-root-window-vertically do it?  */
 	  fset_redisplay (f);
+	  FRAME_WINDOW_SIZES_CHANGED (f) = true;
 	  adjust_frame_glyphs (f);
 	  unblock_input ();
 	}
@@ -4570,6 +4572,7 @@ shrink_mini_window (struct window *w, bool pixelwise)
 	  /* Enforce full redisplay of the frame.  */
 	  /* FIXME: Shouldn't window--resize-root-window-vertically do it?  */
 	  fset_redisplay (f);
+	  FRAME_WINDOW_SIZES_CHANGED (f) = true;
 	  adjust_frame_glyphs (f);
 	  unblock_input ();
 	}
-- 
2.5.0