changeset 55021:78fbab658433

(buffer_posn_from_coords): Return full image width and height even for image slices (posn is relative to full image). (marginal_area_string): Adjust x0,y0 for image slice.
author Kim F. Storm <storm@cua.dk>
date Tue, 20 Apr 2004 22:16:19 +0000
parents e09f199d1b5b
children dda0bae93c73
files src/dispnew.c
diffstat 1 files changed, 19 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/dispnew.c	Tue Apr 20 22:16:07 2004 +0000
+++ b/src/dispnew.c	Tue Apr 20 22:16:19 2004 +0000
@@ -5730,6 +5730,9 @@
   struct text_pos startp;
   Lisp_Object string;
   struct glyph_row *row;
+#ifdef HAVE_WINDOW_SYSTEM
+  struct image *img = 0;
+#endif
   int x0, x1;
 
   current_buffer = XBUFFER (w->buffer);
@@ -5755,7 +5758,6 @@
 #ifdef HAVE_WINDOW_SYSTEM
   if (it.what == IT_IMAGE)
     {
-      struct image *img;
       if ((img = IMAGE_FROM_ID (it.f, it.image_id)) != NULL
 	  && !NILP (img->spec))
 	*object = img->spec;
@@ -5768,12 +5770,22 @@
       if (it.hpos < row->used[TEXT_AREA])
 	{
 	  struct glyph *glyph = row->glyphs[TEXT_AREA] + it.hpos;
-	  *width = glyph->pixel_width;
-	  *height = glyph->ascent + glyph->descent;
 #ifdef HAVE_WINDOW_SYSTEM
-	  if (glyph->type == IMAGE_GLYPH)
-	    *dy -= row->ascent - glyph->ascent;
+	  if (img)
+	    {
+	      *dy -= row->ascent - glyph->ascent;
+	      *dx += glyph->slice.x;
+	      *dy += glyph->slice.y;
+	      /* Image slices positions are still relative to the entire image */
+	      *width = img->width;
+	      *height = img->height;
+	    }
+	  else
 #endif
+	    {
+	      *width = glyph->pixel_width;
+	      *height = glyph->ascent + glyph->descent;
+	    }
 	}
       else
 	{
@@ -5939,6 +5951,8 @@
 	      if (img != NULL)
 		*object = img->spec;
 	      y0 -= row->ascent - glyph->ascent;
+	      x0 += glyph->slice.x;
+	      y0 += glyph->slice.y;
 	    }
 #endif
 	}