@code{window-pixel-height-before-size-change} and
@code{window-pixel-height} for that window (@pxref{Window Sizes}).
+The buffer-local value of this hook is run once for the buffer and the
+frame in question, provided at least one window showing the buffer on
+that frame has changed its size. As it still receives the frame as
+its sole argument, any function called on a buffer-local basis will be
+oblivious to which window(s) showing the buffer changed its (their)
+size and has to check out these windows by using the method described
+in the previous paragraph.
+
These function are usually only called when at least one window was
added or has changed size since the last time this hook was run for the
associated frame. In some rare cases this hook also runs when a window
{
struct frame *f = XFRAME (frame);
struct window *r = XWINDOW (FRAME_ROOT_WINDOW (f));
- Lisp_Object functions = Vwindow_size_change_functions;
+
+ if (NILP (Vrun_hooks)
+ || !(f->can_x_set_window_size)
+ || !(f->after_make_frame))
+ return;
if (FRAME_WINDOW_CONFIGURATION_CHANGED (f)
/* Here we implicitly exclude the possibility that the height of
of FRAME's root window alone. */
|| window_size_changed (r))
{
- while (CONSP (functions))
+ Lisp_Object globals = Fdefault_value (Qwindow_size_change_functions);
+ Lisp_Object windows = Fwindow_list (frame, Qlambda, Qnil);
+ /* The buffers for which the local hook was already run. */
+ Lisp_Object buffers = Qnil;
+
+ for (; CONSP (windows); windows = XCDR (windows))
+ {
+ Lisp_Object window = XCAR (windows);
+ Lisp_Object buffer = Fwindow_buffer (window);
+
+ /* Run a buffer-local value only once for that buffer and
+ only if at least one window showing that buffer on FRAME
+ actually changed its size. Note that the function is run
+ with FRAME as its argument and as such oblivious to the
+ window checked below. */
+ if (window_size_changed (XWINDOW (window))
+ && !Fmemq (buffer, buffers)
+ && Flocal_variable_p (Qwindow_size_change_functions, buffer))
+ {
+ Lisp_Object locals
+ = Fbuffer_local_value (Qwindow_size_change_functions, buffer);
+
+ while (CONSP (locals))
+ {
+ if (!EQ (XCAR (locals), Qt))
+ safe_call1 (XCAR (locals), frame);
+ locals = XCDR (locals);
+ }
+
+ buffers = Fcons (buffer, buffers);
+ }
+ }
+
+ while (CONSP (globals))
{
- if (!EQ (XCAR (functions), Qt))
- safe_call1 (XCAR (functions), frame);
- functions = XCDR (functions);
+ if (!EQ (XCAR (globals), Qt))
+ safe_call1 (XCAR (globals), frame);
+ globals = XCDR (globals);
}
window_set_before_size_change_sizes (r);
Fput (Qscroll_down, Qscroll_command, Qt);
DEFSYM (Qwindow_configuration_change_hook, "window-configuration-change-hook");
+ DEFSYM (Qwindow_size_change_functions, "window-size-change-functions");
DEFSYM (Qwindowp, "windowp");
DEFSYM (Qwindow_configuration_p, "window-configuration-p");
DEFSYM (Qwindow_live_p, "window-live-p");