diff src/window.c @ 5118:e0db3c197671 ben-lisp-object

merge up to latest default branch, doesn't compile yet
author Ben Wing <ben@xemacs.org>
date Sat, 26 Dec 2009 21:18:49 -0600
parents 3742ea8250b5 1d61580e0cf7
children d1247f3cc363
line wrap: on
line diff
--- a/src/window.c	Sat Dec 26 00:20:27 2009 -0600
+++ b/src/window.c	Sat Dec 26 21:18:49 2009 -0600
@@ -181,40 +181,73 @@
   { XD_END }
 };
 
+#ifdef NEW_GC
+DEFINE_DUMPABLE_INTERNAL_LISP_OBJECT ("face-cachel", face_cachel,
+				      0, face_cachel_description_1,
+				      Lisp_Face_Cachel);
+#endif /* NEW_GC */
+
 static const struct sized_memory_description face_cachel_description = {
   sizeof (face_cachel),
   face_cachel_description_1
 };
 
 static const struct memory_description face_cachel_dynarr_description_1[] = {
+#ifdef NEW_GC
+  XD_LISP_DYNARR_DESC (face_cachel_dynarr, &face_cachel_description),
+#else /* not NEW_GC */
   XD_DYNARR_DESC (face_cachel_dynarr, &face_cachel_description),
+#endif /* not NEW_GC */
   { XD_END }
 };
 
+#ifdef NEW_GC
+DEFINE_DUMPABLE_INTERNAL_LISP_OBJECT ("face-cachel-dynarr", face_cachel_dynarr,
+				      0, face_cachel_dynarr_description_1,
+				      face_cachel_dynarr);
+#else /* not NEW_GC */
 static const struct sized_memory_description face_cachel_dynarr_description = {
   sizeof (face_cachel_dynarr),
   face_cachel_dynarr_description_1
 };
+#endif /* not NEW_GC */
 
 static const struct memory_description glyph_cachel_description_1[] = {
   { XD_LISP_OBJECT, offsetof (glyph_cachel, glyph) },
   { XD_END }
 };
 
+#ifdef NEW_GC
+DEFINE_DUMPABLE_INTERNAL_LISP_OBJECT ("glyph-cachel", glyph_cachel,
+				      0, glyph_cachel_description_1,
+				      Lisp_Glyph_Cachel);
+#endif /* NEW_GC */
+
 static const struct sized_memory_description glyph_cachel_description = {
   sizeof (glyph_cachel),
   glyph_cachel_description_1
 };
 
 static const struct memory_description glyph_cachel_dynarr_description_1[] = {
+#ifdef NEW_GC
+  XD_LISP_DYNARR_DESC (glyph_cachel_dynarr, &glyph_cachel_description),
+#else /* not NEW_GC */
   XD_DYNARR_DESC (glyph_cachel_dynarr, &glyph_cachel_description),
+#endif /* not NEW_GC */
   { XD_END }
 };
 
+#ifdef NEW_GC
+DEFINE_DUMPABLE_INTERNAL_LISP_OBJECT ("glyph-cachel-dynarr",
+				      glyph_cachel_dynarr, 0,
+				      glyph_cachel_dynarr_description_1,
+				      glyph_cachel_dynarr);
+#else /* not NEW_GC */
 static const struct sized_memory_description glyph_cachel_dynarr_description = {
   sizeof (glyph_cachel_dynarr),
   glyph_cachel_dynarr_description_1
 };
+#endif /* not NEW_GC */
 
 static const struct memory_description line_start_cache_description_1[] = {
   { XD_END }
@@ -241,10 +274,15 @@
   { XD_LISP_OBJECT_ARRAY, offsetof (struct window, slot), size },
 #include "winslots.h"
 
+#ifdef NEW_GC
+  { XD_LISP_OBJECT, offsetof (struct window, face_cachels) },
+  { XD_LISP_OBJECT, offsetof (struct window, glyph_cachels) },
+#else /* not NEW_GC */
   { XD_BLOCK_PTR, offsetof (struct window, face_cachels),
     1, { &face_cachel_dynarr_description } },
   { XD_BLOCK_PTR, offsetof (struct window, glyph_cachels),
     1, { &glyph_cachel_dynarr_description } },
+#endif /* not NEW_GC */
   { XD_BLOCK_PTR, offsetof (struct window, line_start_cache),
     1, { &line_start_cache_dynarr_description }, XD_FLAG_NO_KKCC },
   { XD_END }
@@ -324,7 +362,7 @@
   return make_lisp_hash_table (20, HASH_TABLE_KEY_WEAK, HASH_TABLE_EQ);
 }
 
-DEFINE_NONDUMPABLE_LISP_OBJECT ("window", window,
+DEFINE_NODUMP_LISP_OBJECT ("window", window,
 					   mark_window, print_window, finalize_window,
 					   0, 0, window_description, struct window);
 
@@ -361,8 +399,17 @@
   INIT_DISP_VARIABLE (last_point, Fmake_marker ());
   INIT_DISP_VARIABLE (last_start, Fmake_marker ());
   INIT_DISP_VARIABLE (last_facechange, Qzero);
+#ifdef NEW_GC
+  p->face_cachels = Dynarr_lisp_new (face_cachel,
+				     &lrecord_face_cachel_dynarr,
+				     &lrecord_face_cachel);
+  p->glyph_cachels = Dynarr_lisp_new (glyph_cachel,
+				      &lrecord_glyph_cachel_dynarr,
+				      &lrecord_glyph_cachel);
+#else /* not NEW_GC */
   p->face_cachels     = Dynarr_new (face_cachel);
   p->glyph_cachels    = Dynarr_new (glyph_cachel);
+#endif /* not NEW_GC */
   p->line_start_cache = Dynarr_new (line_start_cache);
   p->subwindow_instance_cache = make_image_instance_cache_hash_table ();
 
@@ -470,7 +517,7 @@
     return Qnil;
 }
 
-DEFINE_NONDUMPABLE_LISP_OBJECT ("window-mirror", window_mirror,
+DEFINE_NODUMP_LISP_OBJECT ("window-mirror", window_mirror,
 				mark_window_mirror, 0,
 				0, 0, 0, window_mirror_description,
 				struct window_mirror);
@@ -3464,8 +3511,6 @@
   int line_size;
   int defheight, defwidth;
 
-  /* #### This is very likely incorrect and instead the char_to_pixel_
-     functions should be called. */
   default_face_height_and_width (window, &defheight, &defwidth);
   line_size = (set_height ? defheight : defwidth);
 
@@ -3476,7 +3521,7 @@
 
   if (!nodelete
       && !TOP_LEVEL_WINDOW_P (w)
-      && new_pixsize < minsize)
+      && (new_pixsize + window_modeline_height (w)) < minsize)
     {
       Fdelete_window (window, Qnil);
       return;
@@ -3547,7 +3592,17 @@
 	  /* All but the last window should have a height which is
              a multiple of the default line height. */
 	  if (!NILP (c->next))
-	    pos = (pos / line_size) * line_size;
+	    {
+	      /*
+	       * Round up when we're shrinking, down when we're growing
+	       * to make sure that pairs of grow / shrink meant to
+	       * cancel out actually do cancel out.
+	       */
+	      if (pixel_adj_left < 0)
+		pos = ((pos + line_size -1) / line_size) * line_size;
+	      else
+		pos = (pos / line_size) * line_size;
+	    }
 
 	  /* Avoid confusion: don't delete child if it becomes too small */
 	  set_window_pixsize (child, pos + first - last_pos, 1, set_height);
@@ -3807,8 +3862,17 @@
   /* Don't copy the pointers to the line start cache or the face
      instances. */
   p->line_start_cache = Dynarr_new (line_start_cache);
+#ifdef NEW_GC
+  p->face_cachels = Dynarr_lisp_new (face_cachel,
+				     &lrecord_face_cachel_dynarr,
+				     &lrecord_face_cachel);
+  p->glyph_cachels = Dynarr_lisp_new (glyph_cachel,
+				      &lrecord_glyph_cachel_dynarr,
+				      &lrecord_glyph_cachel);
+#else /* not NEW_GC */
   p->face_cachels     = Dynarr_new (face_cachel);
   p->glyph_cachels    = Dynarr_new (glyph_cachel);
+#endif /* not NEW_GC */
   p->subwindow_instance_cache =
     make_image_instance_cache_hash_table ();
 
@@ -4041,7 +4105,7 @@
 {
   int avail_height;
   int defheight, defwidth;
-  int char_height;
+  int char_height = 0;
   Lisp_Object window = wrap_window (w);
 
 
@@ -4052,7 +4116,8 @@
 
   default_face_height_and_width (window, &defheight, &defwidth);
 
-  char_height = avail_height / defheight;
+  if (defheight)
+    char_height = avail_height / defheight;
 
   /* It's the calling function's responsibility to check these values
      and make sure they're not out of range.
@@ -4156,7 +4221,8 @@
       default_face_height_and_width (window, &defheight, &defwidth);
       /* #### This probably needs to know about the clipping area once a
          final definition is decided on. */
-      num_lines += ((ypos2 - ypos1) / defheight);
+      if (defheight)
+        num_lines += ((ypos2 - ypos1) / defheight);
     }
   else
     {
@@ -4184,7 +4250,7 @@
 				  int include_margins_p)
 {
   int avail_width;
-  int char_width;
+  int char_width = 0;
   int defheight, defwidth;
   Lisp_Object window = wrap_window (w);
 
@@ -4197,7 +4263,8 @@
 
   default_face_height_and_width (window, &defheight, &defwidth);
 
-  char_width = (avail_width / defwidth);
+  if (defwidth) 
+    char_width = (avail_width / defwidth);
 
   /* It's the calling function's responsibility to check these values
      and make sure they're not out of range.
@@ -4300,8 +4367,6 @@
   if (EQ (window, FRAME_ROOT_WINDOW (f)))
     invalid_operation ("Won't change only window", Qunbound);
 
-  /* #### This is very likely incorrect and instead the char_to_pixel_
-     functions should be called. */
   default_face_height_and_width (window, &defheight, &defwidth);
 
   while (1)
@@ -5192,28 +5257,6 @@
   mark_window_as_deleted (w);
 }
 
-Lisp_Object
-save_window_excursion_unwind (Lisp_Object window_config)
-{
-  Lisp_Object val = call1 (Qset_window_configuration, window_config);
-  return val;
-}
-
-DEFUN ("save-window-excursion", Fsave_window_excursion, 0, UNEVALLED, 0, /*
-Execute body, preserving window sizes and contents.
-Restores which buffer appears in which window, where display starts,
-as well as the current buffer.
-Does not restore the value of point in current buffer.
-*/
-       (args))
-{
-  /* This function can GC */
-  int speccount = specpdl_depth ();
-
-  record_unwind_protect (save_window_excursion_unwind,
-			 call1 (Qcurrent_window_configuration, Qnil));
-  return unbind_to_1 (speccount, Fprogn (args));
-}
 
 static int
 get_current_pixel_pos (Lisp_Object window, Lisp_Object pos,
@@ -5381,6 +5424,12 @@
 {
   INIT_LISP_OBJECT (window);
   INIT_LISP_OBJECT (window_mirror);
+#ifdef NEW_GC
+  INIT_LISP_OBJECT (face_cachel);
+  INIT_LISP_OBJECT (face_cachel_dynarr);
+  INIT_LISP_OBJECT (glyph_cachel);
+  INIT_LISP_OBJECT (glyph_cachel_dynarr);
+#endif /* NEW_GC */
 
   DEFSYMBOL (Qwindowp);
   DEFSYMBOL (Qwindow_live_p);
@@ -5475,7 +5524,6 @@
 #ifdef MEMORY_USAGE_STATS
   DEFSUBR (Fwindow_memory_usage);
 #endif
-  DEFSUBR (Fsave_window_excursion);
   DEFSUBR (Fcurrent_pixel_column);
   DEFSUBR (Fcurrent_pixel_row);
 }