diff options
| author | Martin Rudalics | 2019-01-17 10:21:07 +0100 |
|---|---|---|
| committer | Martin Rudalics | 2019-01-17 10:21:07 +0100 |
| commit | 0aece3e1181e66f2a1a067ae876e55bdaa45edd5 (patch) | |
| tree | 240c9dca3ff8a81460e5150d6b24993766bd707e /src/window.c | |
| parent | 978cf88bda9c9b41f1cc20cf8e53a9e6caeb91be (diff) | |
| download | emacs-0aece3e1181e66f2a1a067ae876e55bdaa45edd5.tar.gz emacs-0aece3e1181e66f2a1a067ae876e55bdaa45edd5.zip | |
Expand spectrum of window change functions
* src/window.c (run_window_change_functions): Run window
change functions for Qwindow_state_change_functions.
(resize_frame_windows): Set frame's window_change slot when
single-window frames change size.
(Qwindow_state_change_functions): New symbol.
(Vwindow_state_change_functions): New Lisp variable.
* doc/lispref/windows.texi (Selecting Windows): Mention
'window-selection/state-change-functions' and add reference to
Window Hooks.
(Window Hooks): Document 'window-state-change-functions'.
* etc/NEWS: Mention new hook 'window-state-change-functions'.
Diffstat (limited to 'src/window.c')
| -rw-r--r-- | src/window.c | 53 |
1 files changed, 52 insertions, 1 deletions
diff --git a/src/window.c b/src/window.c index 7eb532f78cf..c0d745995a8 100644 --- a/src/window.c +++ b/src/window.c | |||
| @@ -3799,7 +3799,7 @@ run_window_change_functions (void) | |||
| 3799 | run_window_change_functions_1 | 3799 | run_window_change_functions_1 |
| 3800 | (Qwindow_size_change_functions, buffer, window); | 3800 | (Qwindow_size_change_functions, buffer, window); |
| 3801 | 3801 | ||
| 3802 | /* This window's selection has changed when it it was | 3802 | /* This window's selection has changed when it was |
| 3803 | (de-)selected as its frame's or the globally selected | 3803 | (de-)selected as its frame's or the globally selected |
| 3804 | window. */ | 3804 | window. */ |
| 3805 | if (((frame_selected_change | 3805 | if (((frame_selected_change |
| @@ -3811,6 +3811,21 @@ run_window_change_functions (void) | |||
| 3811 | && WINDOW_LIVE_P (window)) | 3811 | && WINDOW_LIVE_P (window)) |
| 3812 | run_window_change_functions_1 | 3812 | run_window_change_functions_1 |
| 3813 | (Qwindow_selection_change_functions, buffer, window); | 3813 | (Qwindow_selection_change_functions, buffer, window); |
| 3814 | |||
| 3815 | /* This window's state has changed when its buffer or size | ||
| 3816 | changed or it was (de-)selected as its frame's or the | ||
| 3817 | globally selected window. */ | ||
| 3818 | if ((window_buffer_change | ||
| 3819 | || window_size_change | ||
| 3820 | || ((frame_selected_change | ||
| 3821 | && (EQ (window, old_selected_window) | ||
| 3822 | || EQ (window, selected_window))) | ||
| 3823 | || (frame_selected_window_change | ||
| 3824 | && (EQ (window, FRAME_OLD_SELECTED_WINDOW (f)) | ||
| 3825 | || EQ (window, FRAME_SELECTED_WINDOW (f)))))) | ||
| 3826 | && WINDOW_LIVE_P (window)) | ||
| 3827 | run_window_change_functions_1 | ||
| 3828 | (Qwindow_state_change_functions, buffer, window); | ||
| 3814 | } | 3829 | } |
| 3815 | 3830 | ||
| 3816 | /* When the number of windows on a frame has decreased, at least | 3831 | /* When the number of windows on a frame has decreased, at least |
| @@ -3840,6 +3855,15 @@ run_window_change_functions (void) | |||
| 3840 | run_window_change_functions_1 | 3855 | run_window_change_functions_1 |
| 3841 | (Qwindow_selection_change_functions, Qnil, frame); | 3856 | (Qwindow_selection_change_functions, Qnil, frame); |
| 3842 | 3857 | ||
| 3858 | /* A frame has changed state when a size or buffer change | ||
| 3859 | occurrd or its selected window has changed or when it was | ||
| 3860 | (de-)selected. */ | ||
| 3861 | if ((frame_selected_change || frame_selected_window_change | ||
| 3862 | || frame_buffer_change || window_deleted || frame_size_change) | ||
| 3863 | && FRAME_LIVE_P (f)) | ||
| 3864 | run_window_change_functions_1 | ||
| 3865 | (Qwindow_state_change_functions, Qnil, frame); | ||
| 3866 | |||
| 3843 | /* A frame's configuration changed when one of its windows has | 3867 | /* A frame's configuration changed when one of its windows has |
| 3844 | changed buffer or size or at least one window was deleted. */ | 3868 | changed buffer or size or at least one window was deleted. */ |
| 3845 | if ((frame_size_change || window_deleted) && FRAME_LIVE_P (f)) | 3869 | if ((frame_size_change || window_deleted) && FRAME_LIVE_P (f)) |
| @@ -4650,16 +4674,26 @@ resize_frame_windows (struct frame *f, int size, bool horflag, bool pixelwise) | |||
| 4650 | /* For a leaf root window just set the size. */ | 4674 | /* For a leaf root window just set the size. */ |
| 4651 | if (horflag) | 4675 | if (horflag) |
| 4652 | { | 4676 | { |
| 4677 | bool changed = r->pixel_width != new_pixel_size; | ||
| 4678 | |||
| 4653 | r->total_cols = new_size; | 4679 | r->total_cols = new_size; |
| 4654 | r->pixel_width = new_pixel_size; | 4680 | r->pixel_width = new_pixel_size; |
| 4681 | |||
| 4682 | if (changed && !WINDOW_PSEUDO_P (r)) | ||
| 4683 | FRAME_WINDOW_CHANGE (f) = true; | ||
| 4655 | } | 4684 | } |
| 4656 | else | 4685 | else |
| 4657 | { | 4686 | { |
| 4687 | bool changed = r->pixel_height != new_pixel_size; | ||
| 4688 | |||
| 4658 | r->top_line = FRAME_TOP_MARGIN (f); | 4689 | r->top_line = FRAME_TOP_MARGIN (f); |
| 4659 | r->pixel_top = FRAME_TOP_MARGIN_HEIGHT (f); | 4690 | r->pixel_top = FRAME_TOP_MARGIN_HEIGHT (f); |
| 4660 | 4691 | ||
| 4661 | r->total_lines = new_size; | 4692 | r->total_lines = new_size; |
| 4662 | r->pixel_height = new_pixel_size; | 4693 | r->pixel_height = new_pixel_size; |
| 4694 | |||
| 4695 | if (changed && !WINDOW_PSEUDO_P (r)) | ||
| 4696 | FRAME_WINDOW_CHANGE (f) = true; | ||
| 4663 | } | 4697 | } |
| 4664 | else | 4698 | else |
| 4665 | { | 4699 | { |
| @@ -7953,6 +7987,7 @@ syms_of_window (void) | |||
| 7953 | Fput (Qscroll_down, Qscroll_command, Qt); | 7987 | Fput (Qscroll_down, Qscroll_command, Qt); |
| 7954 | 7988 | ||
| 7955 | DEFSYM (Qwindow_configuration_change_hook, "window-configuration-change-hook"); | 7989 | DEFSYM (Qwindow_configuration_change_hook, "window-configuration-change-hook"); |
| 7990 | DEFSYM (Qwindow_state_change_functions, "window-state-change-functions"); | ||
| 7956 | DEFSYM (Qwindow_size_change_functions, "window-size-change-functions"); | 7991 | DEFSYM (Qwindow_size_change_functions, "window-size-change-functions"); |
| 7957 | DEFSYM (Qwindow_buffer_change_functions, "window-buffer-change-functions"); | 7992 | DEFSYM (Qwindow_buffer_change_functions, "window-buffer-change-functions"); |
| 7958 | DEFSYM (Qwindow_selection_change_functions, "window-selection-change-functions"); | 7993 | DEFSYM (Qwindow_selection_change_functions, "window-selection-change-functions"); |
| @@ -8074,6 +8109,22 @@ the frame's selected window has changed since the last redisplay. In | |||
| 8074 | this case the frame is passed as argument. */); | 8109 | this case the frame is passed as argument. */); |
| 8075 | Vwindow_selection_change_functions = Qnil; | 8110 | Vwindow_selection_change_functions = Qnil; |
| 8076 | 8111 | ||
| 8112 | DEFVAR_LISP ("window-state-change-functions", Vwindow_state_change_functions, | ||
| 8113 | doc: /* Functions called during redisplay when the window state changed. | ||
| 8114 | The value should be a list of functions that take one argument. | ||
| 8115 | |||
| 8116 | Functions specified buffer-locally are called for each window showing | ||
| 8117 | the corresponding buffer if and only if that window has been added, | ||
| 8118 | resized, changed its buffer or has been (de-)selected since the last | ||
| 8119 | redisplay. In this case the window is passed as argument. | ||
| 8120 | |||
| 8121 | Functions specified by the default value are called for each frame if | ||
| 8122 | at least one window on that frame has been added, deleted, changed its | ||
| 8123 | buffer or its total or body size or the frame has been (de-)selected | ||
| 8124 | or its selected window has changed since the last redisplay. In this | ||
| 8125 | case the frame is passed as argument. */); | ||
| 8126 | Vwindow_selection_change_functions = Qnil; | ||
| 8127 | |||
| 8077 | DEFVAR_LISP ("window-configuration-change-hook", Vwindow_configuration_change_hook, | 8128 | DEFVAR_LISP ("window-configuration-change-hook", Vwindow_configuration_change_hook, |
| 8078 | doc: /* Functions called during redisplay when window configuration has changed. | 8129 | doc: /* Functions called during redisplay when window configuration has changed. |
| 8079 | The value should be a list of functions that take no argument. | 8130 | The value should be a list of functions that take no argument. |