aboutsummaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
authorMartin Rudalics2016-02-23 12:08:55 +0100
committerMartin Rudalics2016-02-23 12:08:55 +0100
commit8e7712c7afc47a8a861a9f4d6a10be1f78a2dac6 (patch)
tree46b7a58fae8aa09fc316cec8231697f84282a319 /doc
parentef52e66efd78aac4c4e5bd5e11870e5ba3b37a1e (diff)
downloademacs-8e7712c7afc47a8a861a9f4d6a10be1f78a2dac6.tar.gz
emacs-8e7712c7afc47a8a861a9f4d6a10be1f78a2dac6.zip
Fix `window-configuration-change-hook' and `window-size-change-functions'
(1) Run `window-configuration-change-hook' if and only if at least one window was deleted or created or shows another buffer since last redisplay. (2) Run `window-size-change-functions' if and only if at least one window changed its size since last redisplay (in a few cases `window-size-change-functions' will also run when no window changed its size). (3) Provide two functions `window-pixel-height-before-size-change' and `window-pixel-width-before-size-change' 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 pixel_width_before_size_change and pixel_height_before_size_change. (WINDOW_INTERNAL_P): New macro. * src/window.c (Fwindow_pixel_width_before_size_change) (Fwindow_pixel_height_before_size_change): 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_before_size_change_sizes) (run_window_size_change_functions): New functions. (make_window): Initialize pixel_width_before_size_change and pixel_height_before_size_change. (Fdelete_window_internal): Don't call run_window_configuration_change_hook. (struct saved_window): Add pixel_height_before_size_change and pixel_width_before_size_change. (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 pixel_height_before_size_change and pixel_width_before_size_change fields. (Vwindow_size_change_functions): Move here 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-pixel-height-before-size-change' and `window-pixel-width-before-size-change'. (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'.
Diffstat (limited to 'doc')
-rw-r--r--doc/lispref/windows.texi67
1 files changed, 42 insertions, 25 deletions
diff --git a/doc/lispref/windows.texi b/doc/lispref/windows.texi
index f61f08a7f24..f215eb727a5 100644
--- a/doc/lispref/windows.texi
+++ b/doc/lispref/windows.texi
@@ -545,6 +545,12 @@ its pixel height is the pixel height of the screen areas spanned by its
545children. 545children.
546@end defun 546@end defun
547 547
548@defun window-pixel-height-before-size-change &optional Lisp_Object &optional window
549This function returns the height of window @var{window} in pixels at the
550time @code{window-size-change-functions} was run for the last time on
551@var{window}'s frame (@pxref{Window Hooks}).
552@end defun
553
548@cindex window pixel width 554@cindex window pixel width
549@cindex pixel width of a window 555@cindex pixel width of a window
550@cindex total pixel width of a window 556@cindex total pixel width of a window
@@ -559,6 +565,12 @@ If @var{window} is an internal window, its pixel width is the width of
559the screen areas spanned by its children. 565the screen areas spanned by its children.
560@end defun 566@end defun
561 567
568@defun window-pixel-width-before-size-change &optional Lisp_Object &optional window
569This function returns the width of window @var{window} in pixels at the
570time @code{window-size-change-functions} was run for the last time on
571@var{window}'s frame (@pxref{Window Hooks}).
572@end defun
573
562@cindex full-width window 574@cindex full-width window
563@cindex full-height window 575@cindex full-height window
564 The following functions can be used to determine whether a given 576 The following functions can be used to determine whether a given
@@ -4087,11 +4099,11 @@ was created for.
4087The argument @var{configuration} must be a value that was previously 4099The argument @var{configuration} must be a value that was previously
4088returned by @code{current-window-configuration}. The configuration is 4100returned by @code{current-window-configuration}. The configuration is
4089restored in the frame from which @var{configuration} was made, whether 4101restored in the frame from which @var{configuration} was made, whether
4090that frame is selected or not. This always counts as a window size 4102that frame is selected or not. In some rare cases this may trigger
4091change and triggers execution of the @code{window-size-change-functions} 4103execution of the @code{window-size-change-functions} (@pxref{Window
4092(@pxref{Window Hooks}), because @code{set-window-configuration} doesn't 4104Hooks}) even if the size of windows did not change at all. The
4093know how to tell whether the new configuration actually differs from the 4105@code{window-configuration-change-hook} functions will be called if and
4094old one. 4106only if at least one window was added to or deleted from the frame.
4095 4107
4096If the frame from which @var{configuration} was saved is dead, all this 4108If the frame from which @var{configuration} was saved is dead, all this
4097function does is restore the three variables @code{window-min-height}, 4109function does is restore the three variables @code{window-min-height},
@@ -4378,33 +4390,38 @@ work.
4378@end defvar 4390@end defvar
4379 4391
4380@defvar window-size-change-functions 4392@defvar window-size-change-functions
4381This variable holds a list of functions to be called if the size of 4393This variable holds a list of functions to be called if the size of any
4382any window changes for any reason. The functions are called at the 4394window changes for any reason. The functions are called once per
4383beginning of a redisplay cycle, and just once for each frame on which 4395redisplay, and once for each frame on which size changes have occurred.
4384size changes have occurred. 4396
4385 4397Each function receives the frame as its sole argument. To find out
4386Each function receives the frame as its sole argument. There is no 4398whether a specific window has changed size, compare the return values of
4387direct way to find out which windows on that frame have changed size, or 4399@code{window-pixel-width-before-size-change} and
4388precisely how. However, if a size-change function records, at each 4400@code{window-pixel-width} respectively
4389call, the existing windows and their sizes, it can also compare the 4401@code{window-pixel-height-before-size-change} and
4390present sizes and the previous sizes. 4402@code{window-pixel-height} for that window (@pxref{Window Sizes}).
4391 4403
4392Creating or deleting windows counts as a size change, and therefore 4404These function are usually only called when at least one window was
4393causes these functions to be called. Changing the frame size also 4405added or has changed size since the last time this hook was run for the
4394counts, because it changes the sizes of the existing windows. 4406associated frame. In some rare cases this hook also runs when a window
4407that was added intermittently has been deleted afterwards. In these
4408cases none of the windows on the frame will appear to have changed its
4409size.
4395 4410
4396You may use @code{save-selected-window} in these functions 4411You may use @code{save-selected-window} in these functions
4397(@pxref{Selecting Windows}). However, do not use 4412(@pxref{Selecting Windows}). However, do not use
4398@code{save-window-excursion} (@pxref{Window Configurations}); exiting 4413@code{save-window-excursion} (@pxref{Window Configurations}); exiting
4399that macro counts as a size change, which would cause these functions 4414that macro counts as a size change, which would cause these functions to
4400to be called over and over. 4415be called again.
4401@end defvar 4416@end defvar
4402 4417
4403@defvar window-configuration-change-hook 4418@defvar window-configuration-change-hook
4404A normal hook that is run every time you change the window configuration 4419A normal hook that is run every time the window configuration of a frame
4405of an existing frame. This includes splitting or deleting windows, 4420changes. Window configuration changes include splitting and deleting
4406changing the sizes of windows, or displaying a different buffer in a 4421windows and the display of a different buffer in a window. Resizing the
4407window. 4422frame or individual windows do not count as configuration changes. Use
4423@code{window-size-change-functions}, see above, when you want to track
4424size changes that are not caused by the deletion or creation of windows.
4408 4425
4409The buffer-local part of this hook is run once for each window on the 4426The buffer-local part of this hook is run once for each window on the
4410affected frame, with the relevant window selected and its buffer 4427affected frame, with the relevant window selected and its buffer