[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master b079cfa: Fix handling of 'window-combination-resize
From: |
Martin Rudalics |
Subject: |
[Emacs-diffs] master b079cfa: Fix handling of 'window-combination-resize' with fixed-size windows |
Date: |
Wed, 6 Mar 2019 04:12:08 -0500 (EST) |
branch: master
commit b079cfa8461ba890285268962715eef07a10eae3
Author: Martin Rudalics <address@hidden>
Commit: Martin Rudalics <address@hidden>
Fix handling of 'window-combination-resize' with fixed-size windows
* lisp/window.el (window-combinations): New optional argument
IGNORE-FIXED.
(window--combination-resizable): New function.
(split-window): Fix handling of 'window-combination-resize'
in the presence of fixed-size windows.
---
lisp/window.el | 44 +++++++++++++++++++++++++++++++++-----------
1 file changed, 33 insertions(+), 11 deletions(-)
diff --git a/lisp/window.el b/lisp/window.el
index 9566429..98cdf98 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -509,11 +509,14 @@ child if WINDOW is a horizontal combination."
(window-left-child window)
(window-top-child window)))
-(defun window-combinations (window &optional horizontal)
+(defun window-combinations (window &optional horizontal ignore-fixed)
"Return largest number of windows vertically arranged within WINDOW.
WINDOW must be a valid window and defaults to the selected one.
If HORIZONTAL is non-nil, return the largest number of
-windows horizontally arranged within WINDOW."
+windows horizontally arranged within WINDOW.
+
+Optional argument IGNORE-FIXED, if non-nil, means to ignore
+fixed-size windows in the calculation."
(setq window (window-normalize-window window))
(cond
((window-live-p window)
@@ -527,9 +530,10 @@ windows horizontally arranged within WINDOW."
(let ((child (window-child window))
(count 0))
(while child
- (setq count
- (+ (window-combinations child horizontal)
- count))
+ (unless (and ignore-fixed (window-size-fixed-p child horizontal))
+ (setq count
+ (+ (window-combinations child horizontal ignore-fixed)
+ count)))
(setq child (window-right child)))
count))
(t
@@ -538,9 +542,10 @@ windows horizontally arranged within WINDOW."
(let ((child (window-child window))
(count 1))
(while child
- (setq count
- (max (window-combinations child horizontal)
- count))
+ (unless (and ignore-fixed (window-size-fixed-p child horizontal))
+ (setq count
+ (max (window-combinations child horizontal ignore-fixed)
+ count)))
(setq child (window-right child)))
count))))
@@ -4905,6 +4910,24 @@ showing BUFFER-OR-NAME."
;; If a window doesn't show BUFFER, unrecord BUFFER in it.
(unrecord-window-buffer window buffer)))))
+(defun window--combination-resizable (parent &optional horizontal)
+ "Return number of pixels recoverable from height of window PARENT.
+PARENT must be a vertical (horizontal if HORIZONTAL is non-nil)
+window combination. The return value is the sum of the pixel
+heights of all non-fixed height child windows of PARENT divided
+by their number plus 1. If HORIZONTAL is non-nil, return the sum
+of the pixel widths of all non-fixed width child windows of
+PARENT divided by their number plus 1."
+ (let ((sibling (window-child parent))
+ (number 0)
+ (size 0))
+ (while sibling
+ (unless (window-size-fixed-p sibling horizontal)
+ (setq number (1+ number))
+ (setq size (+ (window-size sibling horizontal t) size)))
+ (setq sibling (window-next-sibling sibling)))
+ (/ size (1+ number))))
+
(defun split-window (&optional window size side pixelwise)
"Make a new window adjacent to WINDOW.
WINDOW must be a valid window and defaults to the selected one.
@@ -5042,8 +5065,7 @@ frame. The selected window is not changed by this
function."
;; average size of a window in its combination.
(max (min (- parent-pixel-size
(window-min-size parent horizontal nil t))
- (/ parent-pixel-size
- (1+ (window-combinations parent horizontal))))
+ (window--combination-resizable parent horizontal))
(window-min-pixel-size))
;; Else try to give the new window half the size
;; of WINDOW (plus an eventual odd pixel).
@@ -5128,7 +5150,7 @@ frame. The selected window is not changed by this
function."
(pixel-size (/ (float new-pixel-size)
(if new-parent old-pixel-size parent-pixel-size)))
(new-parent 0.5)
- (resize (/ 1.0 (1+ (window-combinations parent horizontal))))
+ (resize (/ 1.0 (1+ (window-combinations parent horizontal t))))
(t (/ (window-normal-size window horizontal) 2.0))))
(if resize
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master b079cfa: Fix handling of 'window-combination-resize' with fixed-size windows,
Martin Rudalics <=