emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Fix `window-configuration-change-hook' and `window-size-change-functions


From: martin rudalics
Subject: Fix `window-configuration-change-hook' and `window-size-change-functions'
Date: Mon, 22 Feb 2016 13:59:54 +0100

From archived bug#21333: 25.0.50; window-size-change-functions not called after 
mini-window resize:

 > If anything, IMO we should _reduce_ the number of unrelated events
 > that trigger a call to these functions.  For example, currently any
 > command that reads from the minibuffer will trigger it, because when
 > read-from-minibuffer exits, it restores the window configuration by
 > calling set-window-configuration, which is documented to trigger these
 > functions.  That just doesn't make any sense to me, since most reads
 > from the minibuffer don't resize any windows!

I plan to install in the next days the attached patch which tries to fix
this and also some other issues discussed in this thread.  Please have a
look.

martin


Fix `window-configuration-change-hook' and `window-size-change-functions'

(1) Run `window-configuration-change-hook' if and only if a window was
deleted/created or shows another buffer.

(2) Run `window-size-change-functions' if and only if at least one
window changed its size (in a few cases `window-size-change-functions'
will also run when no window changed its size).

(3) Provide two functions `window-old-pixel-height' and
`window-old-pixel-width' that allow to easily detect which window
changed size.

* src/frame.h (struct frame): New boolean member
window_configuration_changed.
(FRAME_WINDOW_SIZES_CHANGED): Remove macro.
(FRAME_WINDOW_CONFIGURATION_CHANGED): New macro.
* src/frame.c (adjust_frame_size): Don't run
`window-configuration-change-hook'.
* src/window.h (struct window): New fields old_pixel_width and
old_pixel_height.
(WINDOW_INTERNAL_P): New macro.
* src/window.c (Fwindow_old_pixel_width)
(Fwindow_old_pixel_height): New functions.
(Fdelete_other_windows_internal, Fwindow_resize_apply)
(resize_frame_windows, Fsplit_window_internal)
(Fdelete_window_internal, grow_mini_window)
(shrink_mini_window, Fresize_mini_window_internal): Don't call
FRAME_WINDOW_SIZES_CHANGED.
(window_size_changed, window_set_old_pixel_sizes)
(run_window_size_change_functions): New functions.
(make_window): Initialize old_pixel_width and old_pixel_height
fields.
(Fdelete_window_internal): Don't call
run_window_configuration_change_hook.
(struct saved_window): Add old_pixel_height and old_pixel_width
fields.
(Fset_window_configuration): Try to identify window configuration
changes correctly so run_window_configuration_change_hook and
run_window_size_change_functions run only if configuration and size
really changed.
(save_window_save): Set the old_pixel_height and
old_pixel_width fields.
(Vwindow_size_change_functions): Move definiton from xdisp.c.
* src/xdisp.c (prepare_menu_bars, redisplay_internal): Call
run_window_size_change_functions.
(Vwindow_size_change_functions): Move definition to window.c.
* src/xfns.c (x_set_menu_bar_lines): Don't call
run_window_configuration_change_hook.
* doc/lispref/windows.texi (Window Sizes): Document new
functions `window-old-pixel-height' and `window-old-pixel-width'.
(Window Configurations): Mention that this may trigger
execution of `window-size-change-functions' although no window
changed size.
(Window Hooks): Update descriptions of `window-size-change-functions'
and `window-configuration-change-hook'.

Attachment: window-hooks.diff
Description: Text document


reply via email to

[Prev in Thread] Current Thread [Next in Thread]