diff options
| author | Martin Rudalics | 2016-02-23 12:08:55 +0100 |
|---|---|---|
| committer | Martin Rudalics | 2016-02-23 12:08:55 +0100 |
| commit | 8e7712c7afc47a8a861a9f4d6a10be1f78a2dac6 (patch) | |
| tree | 46b7a58fae8aa09fc316cec8231697f84282a319 /doc | |
| parent | ef52e66efd78aac4c4e5bd5e11870e5ba3b37a1e (diff) | |
| download | emacs-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.texi | 67 |
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 | |||
| 545 | children. | 545 | children. |
| 546 | @end defun | 546 | @end defun |
| 547 | 547 | ||
| 548 | @defun window-pixel-height-before-size-change &optional Lisp_Object &optional window | ||
| 549 | This function returns the height of window @var{window} in pixels at the | ||
| 550 | time @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 | |||
| 559 | the screen areas spanned by its children. | 565 | the 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 | ||
| 569 | This function returns the width of window @var{window} in pixels at the | ||
| 570 | time @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. | |||
| 4087 | The argument @var{configuration} must be a value that was previously | 4099 | The argument @var{configuration} must be a value that was previously |
| 4088 | returned by @code{current-window-configuration}. The configuration is | 4100 | returned by @code{current-window-configuration}. The configuration is |
| 4089 | restored in the frame from which @var{configuration} was made, whether | 4101 | restored in the frame from which @var{configuration} was made, whether |
| 4090 | that frame is selected or not. This always counts as a window size | 4102 | that frame is selected or not. In some rare cases this may trigger |
| 4091 | change and triggers execution of the @code{window-size-change-functions} | 4103 | execution of the @code{window-size-change-functions} (@pxref{Window |
| 4092 | (@pxref{Window Hooks}), because @code{set-window-configuration} doesn't | 4104 | Hooks}) even if the size of windows did not change at all. The |
| 4093 | know how to tell whether the new configuration actually differs from the | 4105 | @code{window-configuration-change-hook} functions will be called if and |
| 4094 | old one. | 4106 | only if at least one window was added to or deleted from the frame. |
| 4095 | 4107 | ||
| 4096 | If the frame from which @var{configuration} was saved is dead, all this | 4108 | If the frame from which @var{configuration} was saved is dead, all this |
| 4097 | function does is restore the three variables @code{window-min-height}, | 4109 | function 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 |
| 4381 | This variable holds a list of functions to be called if the size of | 4393 | This variable holds a list of functions to be called if the size of any |
| 4382 | any window changes for any reason. The functions are called at the | 4394 | window changes for any reason. The functions are called once per |
| 4383 | beginning of a redisplay cycle, and just once for each frame on which | 4395 | redisplay, and once for each frame on which size changes have occurred. |
| 4384 | size changes have occurred. | 4396 | |
| 4385 | 4397 | Each function receives the frame as its sole argument. To find out | |
| 4386 | Each function receives the frame as its sole argument. There is no | 4398 | whether a specific window has changed size, compare the return values of |
| 4387 | direct way to find out which windows on that frame have changed size, or | 4399 | @code{window-pixel-width-before-size-change} and |
| 4388 | precisely how. However, if a size-change function records, at each | 4400 | @code{window-pixel-width} respectively |
| 4389 | call, the existing windows and their sizes, it can also compare the | 4401 | @code{window-pixel-height-before-size-change} and |
| 4390 | present sizes and the previous sizes. | 4402 | @code{window-pixel-height} for that window (@pxref{Window Sizes}). |
| 4391 | 4403 | ||
| 4392 | Creating or deleting windows counts as a size change, and therefore | 4404 | These function are usually only called when at least one window was |
| 4393 | causes these functions to be called. Changing the frame size also | 4405 | added or has changed size since the last time this hook was run for the |
| 4394 | counts, because it changes the sizes of the existing windows. | 4406 | associated frame. In some rare cases this hook also runs when a window |
| 4407 | that was added intermittently has been deleted afterwards. In these | ||
| 4408 | cases none of the windows on the frame will appear to have changed its | ||
| 4409 | size. | ||
| 4395 | 4410 | ||
| 4396 | You may use @code{save-selected-window} in these functions | 4411 | You 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 |
| 4399 | that macro counts as a size change, which would cause these functions | 4414 | that macro counts as a size change, which would cause these functions to |
| 4400 | to be called over and over. | 4415 | be called again. |
| 4401 | @end defvar | 4416 | @end defvar |
| 4402 | 4417 | ||
| 4403 | @defvar window-configuration-change-hook | 4418 | @defvar window-configuration-change-hook |
| 4404 | A normal hook that is run every time you change the window configuration | 4419 | A normal hook that is run every time the window configuration of a frame |
| 4405 | of an existing frame. This includes splitting or deleting windows, | 4420 | changes. Window configuration changes include splitting and deleting |
| 4406 | changing the sizes of windows, or displaying a different buffer in a | 4421 | windows and the display of a different buffer in a window. Resizing the |
| 4407 | window. | 4422 | frame or individual windows do not count as configuration changes. Use |
| 4423 | @code{window-size-change-functions}, see above, when you want to track | ||
| 4424 | size changes that are not caused by the deletion or creation of windows. | ||
| 4408 | 4425 | ||
| 4409 | The buffer-local part of this hook is run once for each window on the | 4426 | The buffer-local part of this hook is run once for each window on the |
| 4410 | affected frame, with the relevant window selected and its buffer | 4427 | affected frame, with the relevant window selected and its buffer |