changeset 5486:58e320bde005

Handle redisplay edge case. With motion events when entering a frame and the minibuffer is active, row and column can be zero, and there aren't any runes.
author Mike Kupfer <mike.kupfer@xemacs.org>
date Sat, 30 Apr 2011 13:30:47 +0900
parents 661aba8350af
children dc37764a105b
files src/ChangeLog src/redisplay.c
diffstat 2 files changed, 29 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Sat Apr 30 13:24:10 2011 +0900
+++ b/src/ChangeLog	Sat Apr 30 13:30:47 2011 +0900
@@ -1,3 +1,10 @@
+2010-12-31  Mike Kupfer  <mike.kupfer@xemacs.org>
+
+	* redisplay.c (pixel_to_glyph_translation):
+	Handle redisplay edge case.
+	With motion events when entering a frame and the minibuffer is
+	active, row and column can be zero, and there aren't any runes.
+
 2011-04-30  Stephen J. Turnbull  <stephen@xemacs.org>
 
 	* specifier.c (Fspecifier_matching_instance):
--- a/src/redisplay.c	Sat Apr 30 13:24:10 2011 +0900
+++ b/src/redisplay.c	Sat Apr 30 13:30:47 2011 +0900
@@ -9165,19 +9165,27 @@
 
 	  for (*col = 0; *col <= Dynarr_length (db->runes); (*col)++)
 	    {
-	      int past_end = (*col == Dynarr_length (db->runes));
-
-	      if (!past_end)
-		rb = Dynarr_atp (db->runes, *col);
-
-	      if (past_end ||
-		  (rb->xpos <= x_coord && x_coord < rb->xpos + rb->width))
+	      if (*col == Dynarr_length (db->runes))
 		{
-		  if (past_end)
-		    {
-		      (*col)--;
-		      rb = Dynarr_atp (db->runes, *col);
-		    }
+		  /* We've run out of runes to look at.  Treat the same as
+		     the case below where we failed to find a non-glyph
+		     character. */
+		  if (dl->modeline)
+		    *modeline_closest = dl->end_charpos + dl->offset;
+		  else
+		    *closest = dl->end_charpos + dl->offset;
+
+		  if (check_margin_glyphs)
+		    get_position_object (dl, obj1, obj2, x_coord,
+					 &low_x_coord, &high_x_coord);
+
+		  UPDATE_CACHE_RETURN;
+		}
+
+	      rb = Dynarr_atp (db->runes, *col);
+
+	      if (rb->xpos <= x_coord && x_coord < rb->xpos + rb->width)
+		{
 
 		  *charpos = rb->charpos + dl->offset;
 		  low_x_coord = rb->xpos;
@@ -9251,9 +9259,8 @@
 
 		      UPDATE_CACHE_RETURN;
 		    }
-		  else if (past_end
-			   || (rb->type == RUNE_CHAR
-			       && rb->object.chr.ch == '\n'))
+		  else if (rb->type == RUNE_CHAR
+			   && rb->object.chr.ch == '\n')
 		    {
 		      (*row)--;
 		      /* At this point we may have glyphs in the right