aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Rudalics2012-09-25 10:20:05 +0200
committerMartin Rudalics2012-09-25 10:20:05 +0200
commit9c52dd5a2ef4457d3a4bc33720ca5eb766d939a5 (patch)
tree4f88c6c085584c01e785f6eb7e6f131a431dd0eb
parent54d629be4a0dce166762691eba8fd50930225c4f (diff)
downloademacs-9c52dd5a2ef4457d3a4bc33720ca5eb766d939a5.tar.gz
emacs-9c52dd5a2ef4457d3a4bc33720ca5eb766d939a5.zip
Improve resizing of minibuffer windows (Bug#12419).
* window.el (window--resize-child-windows): When resizing child windows proportionally, process them in reverse order to preserve the "when splitting a window the new one gets the odd line" behavior. (window--resize-root-window-vertically): When resizing the minibuffer window try to affect only windows at the bottom of the frame. (Bug#12419)
-rw-r--r--lisp/ChangeLog10
-rw-r--r--lisp/window.el68
2 files changed, 47 insertions, 31 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 090a8bef4e9..283e1844a98 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,13 @@
12012-09-25 Martin Rudalics <rudalics@gmx.at>
2
3 * window.el (window--resize-child-windows): When resizing child
4 windows proportionally, process them in reverse order to
5 preserve the "when splitting a window the new one gets the odd
6 line" behavior.
7 (window--resize-root-window-vertically): When resizing the
8 minibuffer window try to affect only windows at the bottom of the
9 frame. (Bug#12419)
10
12012-09-25 Chong Yidong <cyd@gnu.org> 112012-09-25 Chong Yidong <cyd@gnu.org>
2 12
3 * subr.el (declare): Doc fix. 13 * subr.el (declare): Doc fix.
diff --git a/lisp/window.el b/lisp/window.el
index 87817fb8773..68f1370e9d1 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -2079,9 +2079,9 @@ preferably only resize windows adjacent to EDGE.
2079Return the symbol `normalized' if new normal sizes have been 2079Return the symbol `normalized' if new normal sizes have been
2080already set by this routine." 2080already set by this routine."
2081 (let* ((first (window-child parent)) 2081 (let* ((first (window-child parent))
2082 (sub first) 2082 (last (window-last-child parent))
2083 (parent-total (+ (window-total-size parent horizontal) delta)) 2083 (parent-total (+ (window-total-size parent horizontal) delta))
2084 best-window best-value) 2084 sub best-window best-value)
2085 2085
2086 (if (and edge (memq trail '(before after)) 2086 (if (and edge (memq trail '(before after))
2087 (progn 2087 (progn
@@ -2125,7 +2125,7 @@ already set by this routine."
2125 ;; normal sizes have been already set. 2125 ;; normal sizes have been already set.
2126 'normalized) 2126 'normalized)
2127 ;; Resize all windows proportionally. 2127 ;; Resize all windows proportionally.
2128 (setq sub first) 2128 (setq sub last)
2129 (while sub 2129 (while sub
2130 (cond 2130 (cond
2131 ((or (window--resize-child-windows-skip-p sub) 2131 ((or (window--resize-child-windows-skip-p sub)
@@ -2154,14 +2154,14 @@ already set by this routine."
2154 parent-total) 2154 parent-total)
2155 (window-normal-size sub horizontal))))) 2155 (window-normal-size sub horizontal)))))
2156 2156
2157 (setq sub (window-right sub))) 2157 (setq sub (window-left sub)))
2158 2158
2159 (cond 2159 (cond
2160 ((< delta 0) 2160 ((< delta 0)
2161 ;; Shrink windows by delta. 2161 ;; Shrink windows by delta.
2162 (setq best-window t) 2162 (setq best-window t)
2163 (while (and best-window (not (zerop delta))) 2163 (while (and best-window (not (zerop delta)))
2164 (setq sub first) 2164 (setq sub last)
2165 (setq best-window nil) 2165 (setq best-window nil)
2166 (setq best-value most-negative-fixnum) 2166 (setq best-value most-negative-fixnum)
2167 (while sub 2167 (while sub
@@ -2171,7 +2171,7 @@ already set by this routine."
2171 (setq best-window sub) 2171 (setq best-window sub)
2172 (setq best-value (cdr (window-new-normal sub)))) 2172 (setq best-value (cdr (window-new-normal sub))))
2173 2173
2174 (setq sub (window-right sub))) 2174 (setq sub (window-left sub)))
2175 2175
2176 (when best-window 2176 (when best-window
2177 (setq delta (1+ delta))) 2177 (setq delta (1+ delta)))
@@ -2188,7 +2188,7 @@ already set by this routine."
2188 ;; Enlarge windows by delta. 2188 ;; Enlarge windows by delta.
2189 (setq best-window t) 2189 (setq best-window t)
2190 (while (and best-window (not (zerop delta))) 2190 (while (and best-window (not (zerop delta)))
2191 (setq sub first) 2191 (setq sub last)
2192 (setq best-window nil) 2192 (setq best-window nil)
2193 (setq best-value most-positive-fixnum) 2193 (setq best-value most-positive-fixnum)
2194 (while sub 2194 (while sub
@@ -2197,7 +2197,7 @@ already set by this routine."
2197 (setq best-window sub) 2197 (setq best-window sub)
2198 (setq best-value (window-new-normal sub))) 2198 (setq best-value (window-new-normal sub)))
2199 2199
2200 (setq sub (window-right sub))) 2200 (setq sub (window-left sub)))
2201 2201
2202 (when best-window 2202 (when best-window
2203 (setq delta (1- delta))) 2203 (setq delta (1- delta)))
@@ -2209,7 +2209,7 @@ already set by this routine."
2209 (window-normal-size best-window horizontal)))))) 2209 (window-normal-size best-window horizontal))))))
2210 2210
2211 (when best-window 2211 (when best-window
2212 (setq sub first) 2212 (setq sub last)
2213 (while sub 2213 (while sub
2214 (when (or (consp (window-new-normal sub)) 2214 (when (or (consp (window-new-normal sub))
2215 (numberp (window-new-normal sub))) 2215 (numberp (window-new-normal sub)))
@@ -2227,7 +2227,7 @@ already set by this routine."
2227 ;; recursively even if it's size does not change. 2227 ;; recursively even if it's size does not change.
2228 (window--resize-this-window 2228 (window--resize-this-window
2229 sub delta horizontal ignore nil trail edge)))) 2229 sub delta horizontal ignore nil trail edge))))
2230 (setq sub (window-right sub))))))) 2230 (setq sub (window-left sub)))))))
2231 2231
2232(defun window--resize-siblings (window delta &optional horizontal ignore trail edge) 2232(defun window--resize-siblings (window delta &optional horizontal ignore trail edge)
2233 "Resize other windows when WINDOW is resized vertically by DELTA lines. 2233 "Resize other windows when WINDOW is resized vertically by DELTA lines.
@@ -2406,27 +2406,33 @@ Return the number of lines that were recovered.
2406This function is only called by the minibuffer window resizing 2406This function is only called by the minibuffer window resizing
2407routines. It resizes windows proportionally and never deletes 2407routines. It resizes windows proportionally and never deletes
2408any windows." 2408any windows."
2409 (when (numberp delta) 2409 (let ((frame (window-frame window))
2410 (let (ignore) 2410 ignore)
2411 (cond 2411 (cond
2412 ((< delta 0) 2412 ((not (numberp delta))
2413 (setq delta (window-sizable window delta))) 2413 (setq delta 0))
2414 ((> delta 0) 2414 ((zerop delta))
2415 (unless (window-sizable window delta) 2415 ((< delta 0)
2416 (setq ignore t)))) 2416 (setq delta (window-sizable window delta))
2417 2417 (window--resize-reset frame)
2418 (window--resize-reset (window-frame window)) 2418 ;; When shrinking the root window, emulate an edge drag in order
2419 ;; Ideally, we would resize just the last window in a combination 2419 ;; to not resize other windows if we can avoid it (Bug#12419).
2420 ;; but that's not feasible for the following reason: If we grow 2420 (window--resize-this-window
2421 ;; the minibuffer window and the last window cannot be shrunk any 2421 window delta nil ignore t 'before
2422 ;; more, we shrink another window instead. But if we then shrink 2422 (+ (window-top-line window) (window-total-size window)))
2423 ;; the minibuffer window again, the last window might get enlarged 2423 ;; Don't record new normal sizes to make sure that shrinking back
2424 ;; and the state after shrinking is not the state before growing. 2424 ;; proportionally works as intended.
2425 ;; So, in practice, we'd need a history variable to record how to 2425 (walk-window-tree
2426 ;; proceed. But I'm not sure how such a variable could work with 2426 (lambda (window) (set-window-new-normal window 'ignore)) frame t))
2427 ;; repeated minibuffer window growing steps. 2427 ((> delta 0)
2428 (window--resize-this-window window delta nil ignore t) 2428 (window--resize-reset frame)
2429 delta))) 2429 (unless (window-sizable window delta)
2430 (setq ignore t))
2431 ;; When growing the root window, resize proportionally. This
2432 ;; should give windows back their original sizes (hopefully).
2433 (window--resize-this-window window delta nil ignore t)))
2434 ;; Return the possibly adjusted DELTA.
2435 delta))
2430 2436
2431(defun adjust-window-trailing-edge (window delta &optional horizontal) 2437(defun adjust-window-trailing-edge (window delta &optional horizontal)
2432 "Move WINDOW's bottom edge by DELTA lines. 2438 "Move WINDOW's bottom edge by DELTA lines.