diff options
author | Martin Rudalics <rudalics@gmx.at> | 2019-01-11 10:02:47 +0100 |
---|---|---|
committer | Martin Rudalics <rudalics@gmx.at> | 2019-01-11 10:02:47 +0100 |
commit | e567ac149518967f992b1286d90d94df6bb589b7 (patch) | |
tree | 32464d12a2b3fcc7ecf7e4cd5d6fc2d4ef7c729b /lisp | |
parent | 470082de55f7b1c1cde8aabbb5b8de55b4b08f83 (diff) | |
download | emacs-e567ac149518967f992b1286d90d94df6bb589b7.tar.gz |
Run window change functions during redisplay
* doc/lispref/windows.texi (Window Sizes): Move (and rename)
descriptions of 'window-pixel-height-before-size-change' and
'window-pixel-width-before-size-change' to Window Hooks
section.
(Window Configurations): Remove warning against use of
'save-window-excursion' in 'window-size-change-functions'.
(Window Hooks): Rewrite section according to redesign of
window change functions.
* lisp/erc/erc-track.el (erc-window-configuration-change)
(erc-modified-channels-update): Call latter directly from
'window-configuration-change-hook' instead via
'post-command-hook'.
* lisp/frame.el (frame-size-changed-p): Change nomenclature
in let bindings.
* lisp/net/rcirc.el (rcirc-window-configuration-change)
(rcirc-window-configuration-change-1): Call latter directly
from 'window-configuration-change-hook' instead via
'post-command-hook'.
* lisp/window.el (window-pixel-width-before-size-change)
(window-pixel-height-before-size-change): Defalias.
(window--resize-mini-window, window-resize)
(adjust-window-trailing-edge, delete-window)
(delete-other-windows, balance-windows): Don't run
'window-configuration-change-hook' any more from here.
(split-window): Don't run 'window-configuration-change-hook'
from here. 'run-window-scroll-functions' from here.
(window--adjust-process-windows): Run from
'window-configuration-change-hook' only.
* src/frame.c (old_selected_frame): New Lisp variable.
(make_frame): Initialize frame's change_stamp slot.
(Fold_selected_frame): New function.
* src/frame.h (struct frame): New slots old_selected_window,
window_change, change_stamp and number_of_windows.
(fset_old_selected_window): New inlined function.
(FRAME_WINDOW_CHANGE, FRAME_OLD_SELECTED_WINDOW): New macros.
* src/window.c (old_selected_window): New Lisp variable.
(wset_old_buffer): New inlined function.
(Fframe_old_selected_window, Fold_selected_window)
(Fwindow_old_buffer): New functions.
(Fwindow_old_pixel_width, Fwindow_old_pixel_height): Rename
from Fwindow_pixel_width_before_size_change and
Fwindow_pixel_height_before_size_change. Update doc-strings.
(Fwindow_old_body_pixel_width, Fwindow_old_body_pixel_height):
New functions.
(Fdelete_other_windows_internal): Set frame's window_change
slot instead of running 'window-configuration-change-hook'.
(Frun_window_configuration_change_hook): In doc-string tell
that this function is no more needed.
(Frun_window_scroll_functions): Amend doc-string. Run with
window's buffer current.
(window_sub_list, window_change_record_windows)
(window_change_record_frame, window_change_record)
(run_window_change_functions_1, run_window_change_functions):
New functions.
(set_window_buffer): Set frame's window_change slot instead of
running 'window-configuration-change-hook'.
(make_window): Don't initialize pixel_width_before_size_change
and pixel_height_before_size_change slots.
(window_resize_apply, Fdelete_window_internal): Set frame's
window_change slot.
(Fsplit_window_internal): Set frame's window_change slot.
Don't run 'window-scroll-functions' from here.
* src/window.h (struct window): New slots old_buffer,
change_stamp, old_pixel_width (renamed from
pixel_width_before_size_change), old_pixel_height (renamed
from pixel_height_before_size_change), old_body_pixel_width
and old_body_pixel_height.
* src/xdisp.c (init_iterator): Set frame's window_change slot
when the body height or width changes.
(prepare_menu_bars): Don't run_window_size_change_functions.
(redisplay_internal): Don't run_window_size_change_functions,
run_window_change_functions instead.
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/erc/erc-track.el | 5 | ||||
-rw-r--r-- | lisp/frame.el | 11 | ||||
-rw-r--r-- | lisp/net/rcirc.el | 8 | ||||
-rw-r--r-- | lisp/window.el | 30 |
4 files changed, 15 insertions, 39 deletions
diff --git a/lisp/erc/erc-track.el b/lisp/erc/erc-track.el index c966cf86270..f42bd648725 100644 --- a/lisp/erc/erc-track.el +++ b/lisp/erc/erc-track.el @@ -640,7 +640,7 @@ only consider active buffers visible.") (unless (minibuffer-window-active-p (minibuffer-window)) ;; delay this until command has finished to make sure window is ;; actually visible before clearing activity - (add-hook 'post-command-hook 'erc-modified-channels-update))) + (erc-modified-channels-update))) (defvar erc-modified-channels-update-inside nil "Variable to prevent running `erc-modified-channels-update' multiple @@ -669,8 +669,7 @@ ARGS are ignored." (erc-modified-channels-remove-buffer buffer)))) erc-modified-channels-alist) (when removed-channel - (erc-modified-channels-display))) - (remove-hook 'post-command-hook 'erc-modified-channels-update))) + (erc-modified-channels-display))))) (defvar erc-track-mouse-face (if (featurep 'xemacs) 'modeline-mousable diff --git a/lisp/frame.el b/lisp/frame.el index 8341ba1707f..dc81302939e 100644 --- a/lisp/frame.el +++ b/lisp/frame.el @@ -1745,20 +1745,17 @@ for FRAME." (let* ((frame (window-normalize-frame frame)) (root (frame-root-window frame)) (mini (minibuffer-window frame)) - (mini-height-before-size-change 0) + (mini-old-height 0) (mini-height 0)) ;; FRAME's minibuffer window counts iff it's on FRAME and FRAME is ;; not a minibuffer-only frame. (when (and (eq (window-frame mini) frame) (not (eq mini root))) - (setq mini-height-before-size-change - (window-pixel-height-before-size-change mini)) + (setq mini-old-height (window-old-pixel-height mini)) (setq mini-height (window-pixel-height mini))) ;; Return non-nil when either the width of the root or the sum of ;; the heights of root and minibuffer window changed. - (or (/= (window-pixel-width-before-size-change root) - (window-pixel-width root)) - (/= (+ (window-pixel-height-before-size-change root) - mini-height-before-size-change) + (or (/= (window-old-pixel-width root) (window-pixel-width root)) + (/= (+ (window-old-pixel-height root) mini-old-height) (+ (window-pixel-height root) mini-height))))) ;;;; Frame/display capabilities. diff --git a/lisp/net/rcirc.el b/lisp/net/rcirc.el index 863554604e8..47681ccfe79 100644 --- a/lisp/net/rcirc.el +++ b/lisp/net/rcirc.el @@ -2064,9 +2064,7 @@ activity. Only run if the buffer is not visible and (defvar rcirc-visible-buffers nil) (defun rcirc-window-configuration-change () (unless (minibuffer-window-active-p (minibuffer-window)) - ;; delay this until command has finished to make sure window is - ;; actually visible before clearing activity - (add-hook 'post-command-hook 'rcirc-window-configuration-change-1))) + (rcirc-window-configuration-change-1))) (defun rcirc-window-configuration-change-1 () ;; clear activity and overlay arrows @@ -2090,9 +2088,7 @@ activity. Only run if the buffer is not visible and rcirc-activity))) ;; update the mode-line string (unless (equal old-activity rcirc-activity) - (rcirc-update-activity-string))) - - (remove-hook 'post-command-hook 'rcirc-window-configuration-change-1)) + (rcirc-update-activity-string)))) ;;; buffer name abbreviation diff --git a/lisp/window.el b/lisp/window.el index 751263c9259..424d0525f4e 100644 --- a/lisp/window.el +++ b/lisp/window.el @@ -2043,6 +2043,8 @@ doc-string of `window-resizable'." ;; Aliases of functions defined in window.c. (defalias 'window-height 'window-total-height) (defalias 'window-width 'window-body-width) +(defalias 'window-pixel-width-before-size-change 'window-old-pixel-width) +(defalias 'window-pixel-height-before-size-change 'window-old-pixel-height) (defun window-full-height-p (&optional window) "Return t if WINDOW is as high as its containing frame. @@ -2759,8 +2761,7 @@ as small) as possible, but don't signal an error." ;; The following routine catches the case where we want to resize ;; a minibuffer-only frame. (when (resize-mini-window-internal window) - (window--pixel-to-total frame) - (run-window-configuration-change-hook frame)))))) + (window--pixel-to-total frame)))))) (defun window--resize-apply-p (frame &optional horizontal) "Return t when a window on FRAME shall be resized vertically. @@ -2858,9 +2859,7 @@ instead." (window--resize-siblings window delta horizontal ignore)) (when (window--resize-apply-p frame horizontal) (if (window-resize-apply frame horizontal) - (progn - (window--pixel-to-total frame horizontal) - (run-window-configuration-change-hook frame)) + (window--pixel-to-total frame horizontal) (error "Failed to apply resizing %s" window)))) (t (error "Cannot resize window %s" window))))) @@ -3579,9 +3578,7 @@ move it as far as possible in the desired direction." ;; Don't report an error in the standard case. (when (window--resize-apply-p frame horizontal) (if (window-resize-apply frame horizontal) - (progn - (window--pixel-to-total frame horizontal) - (run-window-configuration-change-hook frame)) + (window--pixel-to-total frame horizontal) ;; But do report an error if applying the changes fails. (error "Failed adjusting window %s" window)))))))) @@ -4112,7 +4109,6 @@ that is its frame's root window." ;; `delete-window-internal' has selected a window that should ;; not be selected, fix this here. (other-window -1 frame)) - (run-window-configuration-change-hook frame) (window--check frame) ;; Always return nil. nil)))) @@ -4198,7 +4194,6 @@ any window whose `no-delete-other-windows' parameter is non-nil." ;; If WINDOW is the main window of its frame do nothing. (unless (eq window main) (delete-other-windows-internal window main) - (run-window-configuration-change-hook frame) (window--check frame)) ;; Always return nil. nil))) @@ -5186,7 +5181,6 @@ frame. The selected window is not changed by this function." (unless size (window--sanitize-window-sizes horizontal)) - (run-window-configuration-change-hook frame) (run-window-scroll-functions new) (window--check frame) ;; Always return the new window. @@ -5417,15 +5411,13 @@ window." (balance-windows-1 window) (when (window--resize-apply-p frame) (window-resize-apply frame) - (window--pixel-to-total frame) - (run-window-configuration-change-hook frame)) + (window--pixel-to-total frame)) ;; Balance horizontally. (window--resize-reset (window-frame window) t) (balance-windows-1 window t) (when (window--resize-apply-p frame t) (window-resize-apply frame t) - (window--pixel-to-total frame t) - (run-window-configuration-change-hook frame)))) + (window--pixel-to-total frame t)))) (defun window-fixed-size-p (&optional window direction) "Return t if WINDOW cannot be resized in DIRECTION. @@ -9441,15 +9433,7 @@ displaying that processes's buffer." (when size (set-process-window-size process (cdr size) (car size)))))))))) -;; Remove the following call in Emacs 27, running -;; 'window-size-change-functions' should suffice. (add-hook 'window-configuration-change-hook 'window--adjust-process-windows) - -;; Catch any size changes not handled by -;; 'window-configuration-change-hook' (Bug#32720, "another issue" in -;; Bug#33230). -(add-hook 'window-size-change-functions (lambda (_frame) - (window--adjust-process-windows))) ;; Some of these are in tutorial--default-keys, so update that if you ;; change these. |