Revision: miles@gnu.org--gnu-2005/emacs--unicode--0--patch-91
[bpt/emacs.git] / src / dispnew.c
index a505727..d0a1ba6 100644 (file)
@@ -37,7 +37,7 @@ Boston, MA 02110-1301, USA.  */
 #include "dispextern.h"
 #include "cm.h"
 #include "buffer.h"
-#include "charset.h"
+#include "character.h"
 #include "keyboard.h"
 #include "frame.h"
 #include "window.h"
@@ -1185,6 +1185,9 @@ increment_row_positions (row, delta, delta_bytes)
   MATRIX_ROW_END_CHARPOS (row) += delta;
   MATRIX_ROW_END_BYTEPOS (row) += delta_bytes;
 
+  if (!row->enabled_p)
+    return;
+
   /* Increment positions in glyphs.  */
   for (area = 0; area < LAST_AREA; ++area)
     for (i = 0; i < row->used[area]; ++i)
@@ -2259,7 +2262,6 @@ static void
 adjust_frame_glyphs_for_frame_redisplay (f)
      struct frame *f;
 {
-  struct dim ch_dim;
   struct dim matrix_dim;
   int pool_changed_p;
   int window_change_flags;
@@ -2268,10 +2270,6 @@ adjust_frame_glyphs_for_frame_redisplay (f)
   if (!FRAME_LIVE_P (f))
     return;
 
-  /* Determine the smallest character in any font for F.  On
-     console windows, all characters have dimension (1, 1).  */
-  ch_dim.width = ch_dim.height = 1;
-
   top_window_y = FRAME_TOP_MARGIN (f);
 
   /* Allocate glyph pool structures if not already done.  */
@@ -2360,19 +2358,10 @@ static void
 adjust_frame_glyphs_for_window_redisplay (f)
      struct frame *f;
 {
-  struct dim ch_dim;
   struct window *w;
 
   xassert (FRAME_WINDOW_P (f) && FRAME_LIVE_P (f));
 
-  /* Get minimum sizes.  */
-#ifdef HAVE_WINDOW_SYSTEM
-  ch_dim.width = FRAME_SMALLEST_CHAR_WIDTH (f);
-  ch_dim.height = FRAME_SMALLEST_FONT_HEIGHT (f);
-#else
-  ch_dim.width = ch_dim.height = 1;
-#endif
-
   /* Allocate/reallocate window matrices.  */
   allocate_matrices_for_window_redisplay (XWINDOW (FRAME_ROOT_WINDOW (f)));
 
@@ -3321,9 +3310,7 @@ window_to_frame_hpos (w, hpos)
      struct window *w;
      int hpos;
 {
-  struct frame *f = XFRAME (w->frame);
-
-  xassert (!FRAME_WINDOW_P (f));
+  xassert (!FRAME_WINDOW_P (XFRAME (w->frame)));
   hpos += WINDOW_LEFT_EDGE_COL (w);
   return hpos;
 }
@@ -3962,6 +3949,7 @@ update_single_window (w, force_p)
     }
 }
 
+#ifdef HAVE_WINDOW_SYSTEM
 
 /* Redraw lines from the current matrix of window W that are
    overlapped by other rows.  YB is bottom-most y-position in W.  */
@@ -4034,23 +4022,33 @@ redraw_overlapping_rows (w, yb)
 
       if (row->overlapping_p && i > 0 && bottom_y < yb)
        {
-         if (row->used[LEFT_MARGIN_AREA])
-           rif->fix_overlapping_area (w, row, LEFT_MARGIN_AREA);
-
-         if (row->used[TEXT_AREA])
-           rif->fix_overlapping_area (w, row, TEXT_AREA);
-
-         if (row->used[RIGHT_MARGIN_AREA])
-           rif->fix_overlapping_area (w, row, RIGHT_MARGIN_AREA);
-
-         /* Record in neighbour rows that ROW overwrites part of their
-            display.  */
-         if (row->phys_ascent > row->ascent && i > 0)
-           MATRIX_ROW (w->current_matrix, i - 1)->overlapped_p = 1;
-         if ((row->phys_height - row->phys_ascent
-              > row->height - row->ascent)
-             && bottom_y < yb)
-           MATRIX_ROW (w->current_matrix, i + 1)->overlapped_p = 1;
+         int overlaps = 0;
+
+         if (MATRIX_ROW_OVERLAPS_PRED_P (row)
+             && !MATRIX_ROW (w->current_matrix, i - 1)->overlapped_p)
+           overlaps |= OVERLAPS_PRED;
+         if (MATRIX_ROW_OVERLAPS_SUCC_P (row)
+             && !MATRIX_ROW (w->current_matrix, i + 1)->overlapped_p)
+           overlaps |= OVERLAPS_SUCC;
+
+         if (overlaps)
+           {
+             if (row->used[LEFT_MARGIN_AREA])
+               rif->fix_overlapping_area (w, row, LEFT_MARGIN_AREA, overlaps);
+
+             if (row->used[TEXT_AREA])
+               rif->fix_overlapping_area (w, row, TEXT_AREA, overlaps);
+
+             if (row->used[RIGHT_MARGIN_AREA])
+               rif->fix_overlapping_area (w, row, RIGHT_MARGIN_AREA, overlaps);
+
+             /* Record in neighbour rows that ROW overwrites part of
+                their display.  */
+             if (overlaps & OVERLAPS_PRED)
+               MATRIX_ROW (w->current_matrix, i - 1)->overlapped_p = 1;
+             if (overlaps & OVERLAPS_SUCC)
+               MATRIX_ROW (w->current_matrix, i + 1)->overlapped_p = 1;
+           }
        }
 
       if (bottom_y >= yb)
@@ -4058,6 +4056,8 @@ redraw_overlapping_rows (w, yb)
     }
 }
 
+#endif /* HAVE_WINDOW_SYSTEM */
+
 
 #ifdef GLYPH_DEBUG
 
@@ -4098,10 +4098,8 @@ update_window (w, force_p)
   extern int input_pending;
   extern Lisp_Object do_mouse_tracking;
 #if GLYPH_DEBUG
-  struct frame *f = XFRAME (WINDOW_FRAME (w));
-
   /* Check that W's frame doesn't have glyph matrices.  */
-  xassert (FRAME_WINDOW_P (f));
+  xassert (FRAME_WINDOW_P (XFRAME (WINDOW_FRAME (w))));
   xassert (updating_frame != NULL);
 #endif
 
@@ -4220,11 +4218,13 @@ update_window (w, force_p)
       /* Fix the appearance of overlapping/overlapped rows.  */
       if (!paused_p && !w->pseudo_window_p)
        {
+#ifdef HAVE_WINDOW_SYSTEM
          if (changed_p && rif->fix_overlapping_area)
            {
              redraw_overlapped_rows (w, yb);
              redraw_overlapping_rows (w, yb);
            }
+#endif
 
          /* Make cursor visible at cursor position of W.  */
          set_window_cursor_after_update (w);
@@ -5798,8 +5798,9 @@ buffer_posn_from_coords (w, x, y, pos, object, dx, dy, width, height)
     }
 #endif
 
-  row = MATRIX_ROW (w->current_matrix, it.vpos);
-  if (row->enabled_p)
+  if (it.vpos < w->current_matrix->nrows
+      && (row = MATRIX_ROW (w->current_matrix, it.vpos),
+         row->enabled_p))
     {
       if (it.hpos < row->used[TEXT_AREA])
        {