]> git.eshelyaron.com Git - emacs.git/commitdiff
* window.c (shrink_windows): Handle special case of one window left
authorJan Djärv <jan.h.d@swipnet.se>
Sun, 14 Nov 2004 11:59:21 +0000 (11:59 +0000)
committerJan Djärv <jan.h.d@swipnet.se>
Sun, 14 Nov 2004 11:59:21 +0000 (11:59 +0000)
when trying to shrink the final reminder.  Grow windows if
total_removed is less than total_shrink.

src/ChangeLog
src/window.c

index 7977fd9c9a132f07155dd504842ddc834f2693ad..f9ffecff3bc66893fa167e3edba6e32acf2baf53 100644 (file)
@@ -1,5 +1,9 @@
 2004-11-14  Jan Dj\e,Ad\e(Brv  <jan.h.d@swipnet.se>
 
+       * window.c (shrink_windows): Handle special case of one window left
+       when trying to shrink the final reminder.  Grow windows if
+       total_removed is less than total_shrink.
+
        * xmenu.c (pop_down_menu): Remove global variable current_menu,
        extract pointer from arg with XSAVE_VALUE.
        (create_and_show_popup_menu, create_and_show_dialog,
index 24be93a3943badb0bd10fde852756067185296e9..7c2fbc60612e3bce719787c8a59548339385cb30 100644 (file)
@@ -2657,6 +2657,9 @@ shrink_windows (total, size, nchildren, shrinkable,
             --shrinkable;
             total_removed += smallest;
 
+            /* We don't know what the smallest is now.  */
+            smallest = total;
+
             /* Out of for, just remove one window at the time and
                check again if we have enough space.  */
             break;
@@ -2681,6 +2684,16 @@ shrink_windows (total, size, nchildren, shrinkable,
      that are left and still can be shrunk.  */
   while (total_shrink > total_removed)
     {
+      int nonzero_sizes = 0;
+      int nonzero_idx = -1;
+
+      for (i = 0; i < nchildren; ++i)
+        if (new_sizes[i] > 0)
+          {
+            ++nonzero_sizes;
+            nonzero_idx = i;
+          }
+      
       for (i = 0; i < nchildren; ++i)
         if (new_sizes[i] > min_size)
           {
@@ -2691,6 +2704,25 @@ shrink_windows (total, size, nchildren, shrinkable,
                check again if we have enough space.  */
             break;
           }
+
+
+      /* Special case, only one window left.  */
+      if (nonzero_sizes == 1)
+        break;
+    }
+
+  /* Any surplus due to rounding, we add to windows that are left.  */
+  while (total_shrink < total_removed)
+    {
+      for (i = 0; i < nchildren; ++i)
+        {
+          if (new_sizes[i] != 0 && total_shrink < total_removed)
+            {
+              ++new_sizes[i];
+              --total_removed;
+              break;
+            }
+        }
     }
 
   return new_sizes;