summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKim F. Storm <storm@cua.dk>2004-04-20 22:16:19 +0000
committerKim F. Storm <storm@cua.dk>2004-04-20 22:16:19 +0000
commitcedd7cd9f175280c4da0a4d62d9e5fa484ce03e3 (patch)
treeed4916c411566cde1b7c28dce6f7663bf81272f3
parent0633d52c3e2c278a293a30da354e43ed92e5816d (diff)
downloademacs-cedd7cd9f175280c4da0a4d62d9e5fa484ce03e3.tar.gz
emacs-cedd7cd9f175280c4da0a4d62d9e5fa484ce03e3.tar.bz2
emacs-cedd7cd9f175280c4da0a4d62d9e5fa484ce03e3.zip
(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.
-rw-r--r--src/dispnew.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/src/dispnew.c b/src/dispnew.c
index 987562b0bef..5ceebdecf34 100644
--- a/src/dispnew.c
+++ b/src/dispnew.c
@@ -5730,6 +5730,9 @@ buffer_posn_from_coords (w, x, y, pos, object, dx, dy, width, height)
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 @@ buffer_posn_from_coords (w, x, y, pos, object, dx, dy, width, height)
#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 @@ buffer_posn_from_coords (w, x, y, pos, object, dx, dy, width, height)
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 @@ marginal_area_string (w, part, x, y, charpos, object, dx, dy, width, height)
if (img != NULL)
*object = img->spec;
y0 -= row->ascent - glyph->ascent;
+ x0 += glyph->slice.x;
+ y0 += glyph->slice.y;
}
#endif
}