Function: window--resize-child-windows
window--resize-child-windows is a byte-compiled function defined in
window.el.gz.
Signature
(window--resize-child-windows PARENT DELTA &optional HORIZONTAL WINDOW IGNORE TRAIL EDGE CHAR-SIZE)
Documentation
Resize child windows of window PARENT vertically by DELTA pixels.
PARENT must be a vertically combined internal window.
Optional argument HORIZONTAL non-nil means resize child windows of PARENT horizontally by DELTA pixels. In this case PARENT must be a horizontally combined internal window.
WINDOW, if specified, must denote a child window of PARENT that is resized by DELTA pixels.
The optional argument IGNORE has the same meaning as for
window-resizable.
Optional arguments TRAIL and EDGE, when non-nil, restrict the set
of windows that shall be resized. If TRAIL equals before,
resize only windows on the left or above EDGE. If TRAIL equals
after, resize only windows on the right or below EDGE. Also,
preferably only resize windows adjacent to EDGE.
If the optional argument CHAR-SIZE is a positive integer, it specifies
the number of pixels by which windows are incrementally resized.
If CHAR-SIZE is nil, this means to use the value of
frame-char-height or frame-char-width of WINDOW's frame.
Return the symbol normalized if new normal sizes have been
already set by this routine.
Source Code
;; Defined in /usr/src/emacs/lisp/window.el.gz
(defun window--resize-child-windows (parent delta &optional horizontal window ignore trail edge char-size)
"Resize child windows of window PARENT vertically by DELTA pixels.
PARENT must be a vertically combined internal window.
Optional argument HORIZONTAL non-nil means resize child windows
of PARENT horizontally by DELTA pixels. In this case PARENT must
be a horizontally combined internal window.
WINDOW, if specified, must denote a child window of PARENT that
is resized by DELTA pixels.
The optional argument IGNORE has the same meaning as for
`window-resizable'.
Optional arguments TRAIL and EDGE, when non-nil, restrict the set
of windows that shall be resized. If TRAIL equals `before',
resize only windows on the left or above EDGE. If TRAIL equals
`after', resize only windows on the right or below EDGE. Also,
preferably only resize windows adjacent to EDGE.
If the optional argument CHAR-SIZE is a positive integer, it specifies
the number of pixels by which windows are incrementally resized.
If CHAR-SIZE is nil, this means to use the value of
`frame-char-height' or `frame-char-width' of WINDOW's frame.
Return the symbol `normalized' if new normal sizes have been
already set by this routine."
(let* ((first (window-child parent))
(last (window-last-child parent))
(parent-total (+ (window-size parent horizontal t)
delta))
(char-size (or char-size
(and window-resize-pixelwise 1)
(frame-char-size window horizontal)))
sub best-window best-value best-delta)
(if (and edge (memq trail '(before after))
(progn
(setq sub first)
(while (and (window-right sub)
(or (and (eq trail 'before)
(not (window--resize-child-windows-skip-p
(window-right sub))))
(and (eq trail 'after)
(window--resize-child-windows-skip-p sub))))
(setq sub (window-right sub)))
sub)
(if horizontal
(if (eq trail 'before)
(= (+ (window-pixel-left sub) (window-pixel-width sub))
edge)
(= (window-pixel-left sub) edge))
(if (eq trail 'before)
(= (+ (window-pixel-top sub) (window-pixel-height sub))
edge)
(= (window-pixel-top sub) edge)))
(window-sizable-p sub delta horizontal ignore t))
;; Resize only windows adjacent to EDGE.
(progn
(window--resize-this-window
sub delta horizontal ignore t trail edge)
(if (and window (eq (window-parent sub) parent))
(progn
;; Assign new normal sizes.
(set-window-new-normal
sub (/ (float (window-new-pixel sub)) parent-total))
(set-window-new-normal
window (- (window-normal-size window horizontal)
(- (window-new-normal sub)
(window-normal-size sub horizontal)))))
(window--resize-child-windows-normal
parent horizontal sub 0 trail delta))
;; Return 'normalized to notify `window--resize-siblings' that
;; normal sizes have been already set.
'normalized)
;; Resize all windows proportionally.
(setq sub last)
(while sub
(cond
((or (window--resize-child-windows-skip-p sub)
;; Ignore windows to skip and fixed-size child windows -
;; in the latter case make it a window to skip.
(and (not ignore)
(window-size-fixed-p sub horizontal ignore)
(set-window-new-normal sub 'ignore))))
((< delta 0)
;; When shrinking store the number of lines/cols we can get
;; from this window here together with the total/normal size
;; factor.
(set-window-new-normal
sub
(cons
;; We used to call this with NODOWN t, "fixed" 2011-05-11.
(window-min-delta sub horizontal ignore trail t nil t)
(- (/ (float (window-size sub horizontal t))
parent-total)
(window-normal-size sub horizontal)))))
((> delta 0)
;; When enlarging store the total/normal size factor only
(set-window-new-normal
sub
(- (/ (float (window-size sub horizontal t))
parent-total)
(window-normal-size sub horizontal)))))
(setq sub (window-left sub)))
(cond
((< delta 0)
;; Shrink windows by delta.
(setq best-window t)
(while (and best-window (not (zerop delta)))
(setq sub last)
(setq best-window nil)
(setq best-value nil)
(while sub
(when (and (consp (window-new-normal sub))
(not (<= (car (window-new-normal sub)) 0))
(or (not best-value)
(> (cdr (window-new-normal sub)) best-value)))
(setq best-window sub)
(setq best-value (cdr (window-new-normal sub))))
(setq sub (window-left sub)))
(when best-window
(setq best-delta (min (car (window-new-normal best-window))
char-size (- delta)))
(setq delta (+ delta best-delta))
(set-window-new-pixel best-window (- best-delta) t)
(set-window-new-normal
best-window
(if (= (car (window-new-normal best-window)) best-delta)
'skip ; We can't shrink best-window any further.
(cons (- (car (window-new-normal best-window)) best-delta)
(- (/ (float (window-new-pixel best-window))
parent-total)
(window-normal-size best-window horizontal))))))))
((> delta 0)
;; Enlarge windows by delta.
(setq best-window t)
(while (and best-window (not (zerop delta)))
(setq sub last)
(setq best-window nil)
(setq best-value nil)
(while sub
(when (and (numberp (window-new-normal sub))
(or (not best-value)
(< (window-new-normal sub) best-value)))
(setq best-window sub)
(setq best-value (window-new-normal sub)))
(setq sub (window-left sub)))
(when best-window
(setq best-delta (min delta char-size))
(setq delta (- delta best-delta))
(set-window-new-pixel best-window best-delta t)
(set-window-new-normal
best-window
(- (/ (float (window-new-pixel best-window))
parent-total)
(window-normal-size best-window horizontal)))))))
(when best-window
(setq sub last)
(while sub
(when (or (consp (window-new-normal sub))
(numberp (window-new-normal sub)))
;; Reset new normal size fields so `window-resize-apply'
;; won't use them to apply new sizes.
(set-window-new-normal sub))
(unless (eq (window-new-normal sub) 'ignore)
;; Resize this window's child windows (back-engineering
;; delta from sub's old and new total sizes).
(let ((delta (- (window-new-pixel sub)
(window-size sub horizontal t))))
(unless (and (zerop delta) (not trail))
;; For the TRAIL non-nil case we have to resize SUB
;; recursively even if it's size does not change.
(window--resize-this-window
sub delta horizontal ignore nil trail edge))))
(setq sub (window-left sub)))))))