emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r110193: Improve resizing of minibuff


From: martin rudalics
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r110193: Improve resizing of minibuffer windows (Bug#12419).
Date: Tue, 25 Sep 2012 10:20:05 +0200
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 110193
committer: martin rudalics <address@hidden>
branch nick: trunk
timestamp: Tue 2012-09-25 10:20:05 +0200
message:
  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)
modified:
  lisp/ChangeLog
  lisp/window.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2012-09-25 05:33:43 +0000
+++ b/lisp/ChangeLog    2012-09-25 08:20:05 +0000
@@ -1,3 +1,13 @@
+2012-09-25  Martin Rudalics  <address@hidden>
+
+       * 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)
+
 2012-09-25  Chong Yidong  <address@hidden>
 
        * subr.el (declare): Doc fix.

=== modified file 'lisp/window.el'
--- a/lisp/window.el    2012-09-22 12:56:08 +0000
+++ b/lisp/window.el    2012-09-25 08:20:05 +0000
@@ -2079,9 +2079,9 @@
 Return the symbol `normalized' if new normal sizes have been
 already set by this routine."
   (let* ((first (window-child parent))
-        (sub first)
+        (last (window-last-child parent))
         (parent-total (+ (window-total-size parent horizontal) delta))
-        best-window best-value)
+        sub best-window best-value)
 
     (if (and edge (memq trail '(before after))
             (progn
@@ -2125,7 +2125,7 @@
          ;; normal sizes have been already set.
          'normalized)
       ;; Resize all windows proportionally.
-      (setq sub first)
+      (setq sub last)
       (while sub
        (cond
         ((or (window--resize-child-windows-skip-p sub)
@@ -2154,14 +2154,14 @@
                 parent-total)
              (window-normal-size sub horizontal)))))
 
-       (setq sub (window-right sub)))
+       (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 first)
+         (setq sub last)
          (setq best-window nil)
          (setq best-value most-negative-fixnum)
          (while sub
@@ -2171,7 +2171,7 @@
              (setq best-window sub)
              (setq best-value (cdr (window-new-normal sub))))
 
-           (setq sub (window-right sub)))
+           (setq sub (window-left sub)))
 
          (when best-window
            (setq delta (1+ delta)))
@@ -2188,7 +2188,7 @@
        ;; Enlarge windows by delta.
        (setq best-window t)
        (while (and best-window (not (zerop delta)))
-         (setq sub first)
+         (setq sub last)
          (setq best-window nil)
          (setq best-value most-positive-fixnum)
          (while sub
@@ -2197,7 +2197,7 @@
              (setq best-window sub)
              (setq best-value (window-new-normal sub)))
 
-           (setq sub (window-right sub)))
+           (setq sub (window-left sub)))
 
          (when best-window
            (setq delta (1- delta)))
@@ -2209,7 +2209,7 @@
              (window-normal-size best-window horizontal))))))
 
       (when best-window
-       (setq sub first)
+       (setq sub last)
        (while sub
          (when (or (consp (window-new-normal sub))
                    (numberp (window-new-normal sub)))
@@ -2227,7 +2227,7 @@
                ;; recursively even if it's size does not change.
                (window--resize-this-window
                 sub delta horizontal ignore nil trail edge))))
-         (setq sub (window-right sub)))))))
+         (setq sub (window-left sub)))))))
 
 (defun window--resize-siblings (window delta &optional horizontal ignore trail 
edge)
   "Resize other windows when WINDOW is resized vertically by DELTA lines.
@@ -2406,27 +2406,33 @@
 This function is only called by the minibuffer window resizing
 routines.  It resizes windows proportionally and never deletes
 any windows."
-  (when (numberp delta)
-    (let (ignore)
-      (cond
-       ((< delta 0)
-       (setq delta (window-sizable window delta)))
-       ((> delta 0)
-       (unless (window-sizable window delta)
-         (setq ignore t))))
-
-      (window--resize-reset (window-frame window))
-      ;; Ideally, we would resize just the last window in a combination
-      ;; but that's not feasible for the following reason: If we grow
-      ;; the minibuffer window and the last window cannot be shrunk any
-      ;; more, we shrink another window instead.  But if we then shrink
-      ;; the minibuffer window again, the last window might get enlarged
-      ;; and the state after shrinking is not the state before growing.
-      ;; So, in practice, we'd need a history variable to record how to
-      ;; proceed.  But I'm not sure how such a variable could work with
-      ;; repeated minibuffer window growing steps.
-      (window--resize-this-window window delta nil ignore t)
-      delta)))
+  (let ((frame (window-frame window))
+       ignore)
+    (cond
+     ((not (numberp delta))
+      (setq delta 0))
+     ((zerop delta))
+     ((< delta 0)
+      (setq delta (window-sizable window delta))
+      (window--resize-reset frame)
+      ;; When shrinking the root window, emulate an edge drag in order
+      ;; to not resize other windows if we can avoid it (Bug#12419).
+      (window--resize-this-window
+       window delta nil ignore t 'before
+       (+ (window-top-line window) (window-total-size window)))
+      ;; Don't record new normal sizes to make sure that shrinking back
+      ;; proportionally works as intended.
+      (walk-window-tree
+       (lambda (window) (set-window-new-normal window 'ignore)) frame t))
+     ((> delta 0)
+      (window--resize-reset frame)
+      (unless (window-sizable window delta)
+       (setq ignore t))
+      ;; When growing the root window, resize proportionally.  This
+      ;; should give windows back their original sizes (hopefully).
+      (window--resize-this-window window delta nil ignore t)))
+     ;; Return the possibly adjusted DELTA.
+     delta))
 
 (defun adjust-window-trailing-edge (window delta &optional horizontal)
   "Move WINDOW's bottom edge by DELTA lines.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]