7511 |
RECT *rect; |
RECT *rect; |
7512 |
{ |
{ |
7513 |
Lisp_Object window; |
Lisp_Object window; |
7514 |
int part, found = 0; |
int part; |
7515 |
|
|
7516 |
|
|
7517 |
window = window_from_coordinates (f, x, y, &part, 0); |
window = window_from_coordinates (f, x, y, &part, 0); |
7518 |
if (!NILP (window)) |
if (!NILP (window)) |
7520 |
struct window *w = XWINDOW (window); |
struct window *w = XWINDOW (window); |
7521 |
struct glyph_row *r = MATRIX_FIRST_TEXT_ROW (w->current_matrix); |
struct glyph_row *r = MATRIX_FIRST_TEXT_ROW (w->current_matrix); |
7522 |
struct glyph_row *end = r + w->current_matrix->nrows - 1; |
struct glyph_row *end = r + w->current_matrix->nrows - 1; |
|
int area; |
|
7523 |
|
|
7524 |
frame_to_window_pixel_xy (w, &x, &y); |
frame_to_window_pixel_xy (w, &x, &y); |
7525 |
|
|
7526 |
for (; !found && r < end && r->enabled_p; ++r) |
for (; r < end && r->enabled_p; ++r) |
7527 |
if (r->y + r->height >= y) |
if (r->y <= y && r->y + r->height > y) |
7528 |
{ |
{ |
7529 |
|
/* Found the row at y. */ |
7530 |
struct glyph *g = r->glyphs[TEXT_AREA]; |
struct glyph *g = r->glyphs[TEXT_AREA]; |
7531 |
struct glyph *end = g + r->used[TEXT_AREA]; |
struct glyph *end = g + r->used[TEXT_AREA]; |
7532 |
int gx; |
int gx; |
7533 |
|
|
7534 |
for (gx = r->x; !found && g < end; gx += g->pixel_width, ++g) |
rect->top = WINDOW_TO_FRAME_PIXEL_Y (w, r->y); |
7535 |
if (gx + g->pixel_width >= x) |
rect->bottom = rect->top + r->height; |
7536 |
|
|
7537 |
|
if (x < r->x) |
7538 |
|
{ |
7539 |
|
/* x is to the left of the first glyph in the row. */ |
7540 |
|
rect->left = XINT (w->left); |
7541 |
|
rect->right = WINDOW_TO_FRAME_PIXEL_X (w, r->x); |
7542 |
|
return 1; |
7543 |
|
} |
7544 |
|
|
7545 |
|
for (gx = r->x; g < end; gx += g->pixel_width, ++g) |
7546 |
|
if (gx <= x && gx + g->pixel_width > x) |
7547 |
{ |
{ |
7548 |
|
/* x is on a glyph. */ |
7549 |
rect->left = WINDOW_TO_FRAME_PIXEL_X (w, gx); |
rect->left = WINDOW_TO_FRAME_PIXEL_X (w, gx); |
|
rect->top = WINDOW_TO_FRAME_PIXEL_Y (w, r->y); |
|
7550 |
rect->right = rect->left + g->pixel_width; |
rect->right = rect->left + g->pixel_width; |
7551 |
rect->bottom = rect->top + r->height; |
return 1; |
|
found = 1; |
|
7552 |
} |
} |
7553 |
|
|
7554 |
|
/* x is to the right of the last glyph in the row. */ |
7555 |
|
rect->left = WINDOW_TO_FRAME_PIXEL_X (w, gx); |
7556 |
|
rect->right = XINT (w->left) + XINT (w->width); |
7557 |
|
return 1; |
7558 |
} |
} |
7559 |
} |
} |
7560 |
|
|
7561 |
return found; |
/* The y is not on any row. */ |
7562 |
|
return 0; |
7563 |
} |
} |
7564 |
|
|
7565 |
/* Record the position of the mouse in last_mouse_glyph. */ |
/* Record the position of the mouse in last_mouse_glyph. */ |