changeset 26046:9204dfa34c1b

(enum save_restore_action): New. (save_restore_orig_size): Change parameter list. Add functionality to check for valid orig_top and orig_height members in a window tree. (grow_mini_window): Call save_restore_orig_size with new parameter list. (shrink_mini_window): Restore old window sizes only if old size information is valid in all windows in a window tree.
author Gerd Moellmann <gerd@gnu.org>
date Sat, 16 Oct 1999 11:24:23 +0000
parents 03ebfe42764f
children e6efd0ace0f3
files src/window.c
diffstat 1 files changed, 61 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/src/window.c	Sat Oct 16 04:11:07 1999 +0000
+++ b/src/window.c	Sat Oct 16 11:24:23 1999 +0000
@@ -3318,8 +3318,16 @@
  ***********************************************************************/
 
 static void shrink_window_lowest_first P_ ((struct window *, int));
-static void save_restore_orig_size P_ ((struct window *, int));
-
+
+enum save_restore_action
+{
+    CHECK_ORIG_SIZES,
+    SAVE_ORIG_SIZES,
+    RESTORE_ORIG_SIZES
+};
+
+static int save_restore_orig_size P_ ((struct window *, 
+                                       enum save_restore_action));
 
 /* Shrink windows rooted in window W to HEIGHT.  Take the space needed
    from lowest windows first.  */
@@ -3393,40 +3401,70 @@
 }
 
 
-/* Save or restore positions and sizes in the window tree rooted at W.
-   SAVE_P non-zero means save top position and height in orig_top and
-   orig_height members of the window structure.  Otherwise, restore top
-   and height from orig_top and orig_height.  */
-
-static void
-save_restore_orig_size (w, save_p)
+/* Save, restore, or check positions and sizes in the window tree
+   rooted at W.  ACTION says what to do.
+
+   If ACTION is CHECK_ORIG_SIZES, check if orig_top and orig_height
+   members are valid for all windows in the window tree.  Value is
+   non-zero if they are valid.
+   
+   If ACTION is SAVE_ORIG_SIZES, save members top and height in
+   orig_top and orig_height for all windows in the tree.
+
+   If ACTION is RESTORE_ORIG_SIZES, restore top and height from
+   values stored in orig_top and orig_height for all windows.  */
+
+static int
+save_restore_orig_size (w, action)
      struct window *w;
-     int save_p;
+     enum save_restore_action action;
 {
+  int success_p = 1;
+
   while (w)
     {
       if (!NILP (w->hchild))
-	save_restore_orig_size (XWINDOW (w->hchild), save_p);
+	{
+	  if (!save_restore_orig_size (XWINDOW (w->hchild), action))
+	    success_p = 0;
+	}
       else if (!NILP (w->vchild))
-	save_restore_orig_size (XWINDOW (w->vchild), save_p);
+	{
+	  if (!save_restore_orig_size (XWINDOW (w->vchild), action))
+	    success_p = 0;
+	}
       
-      if (save_p)
+      switch (action)
 	{
+	case CHECK_ORIG_SIZES:
+	  if (!INTEGERP (w->orig_top) || !INTEGERP (w->orig_height))
+	    return 0;
+	  break;
+
+	case SAVE_ORIG_SIZES:
 	  w->orig_top = w->top;
 	  w->orig_height = w->height;
-	}
-      else
-	{
+          XSETFASTINT (w->last_modified, 0);
+          XSETFASTINT (w->last_overlay_modified, 0);
+	  break;
+
+	case RESTORE_ORIG_SIZES:
 	  xassert (INTEGERP (w->orig_top) && INTEGERP (w->orig_height));
 	  w->top = w->orig_top;
 	  w->height = w->orig_height;
 	  w->orig_height = w->orig_top = Qnil;
+          XSETFASTINT (w->last_modified, 0);
+          XSETFASTINT (w->last_overlay_modified, 0);
+	  break;
+
+	default:
+	  abort ();
 	}
-      
-      XSETFASTINT (w->last_modified, 0);
-      XSETFASTINT (w->last_overlay_modified, 0);
+
       w = NILP (w->next) ? NULL : XWINDOW (w->next);
     }
+
+  return success_p;
 }
 
 
@@ -3461,8 +3499,8 @@
   if (delta)
     {
       /* Save original window sizes and positions, if not already done.  */
-      if (NILP (root->orig_top))
-	save_restore_orig_size (root, 1);
+      if (!save_restore_orig_size (root, CHECK_ORIG_SIZES))
+	save_restore_orig_size (root, SAVE_ORIG_SIZES);
 
       /* Shrink other windows.  */
       shrink_window_lowest_first (root, XFASTINT (root->height) - delta);
@@ -3490,9 +3528,9 @@
   struct frame *f = XFRAME (w->frame);
   struct window *root = XWINDOW (FRAME_ROOT_WINDOW (f));
 
-  if (!NILP (root->orig_height))
+  if (save_restore_orig_size (root, CHECK_ORIG_SIZES))
     {
-      save_restore_orig_size (root, 0);
+      save_restore_orig_size (root, RESTORE_ORIG_SIZES);
       adjust_glyphs (f);
       FRAME_WINDOW_SIZES_CHANGED (f) = 1;
       windows_or_buffers_changed = 1;