diff options
| author | Jason Rumney | 2002-02-18 23:31:06 +0000 |
|---|---|---|
| committer | Jason Rumney | 2002-02-18 23:31:06 +0000 |
| commit | 1e2eddb4358e25d0d6a1d749a5a2398c97924d77 (patch) | |
| tree | a5cbfe3d52da4659310be7c4c2983a98c7401355 /src | |
| parent | 653479ad87f91d036dd5d12febe119c111a561eb (diff) | |
| download | emacs-1e2eddb4358e25d0d6a1d749a5a2398c97924d77.tar.gz emacs-1e2eddb4358e25d0d6a1d749a5a2398c97924d77.zip | |
(glyph_rect): Determine the row and glyph more precisely.
Diffstat (limited to 'src')
| -rw-r--r-- | src/w32term.c | 39 |
1 files changed, 28 insertions, 11 deletions
diff --git a/src/w32term.c b/src/w32term.c index 3c0e7c7deae..89b591cb0f3 100644 --- a/src/w32term.c +++ b/src/w32term.c | |||
| @@ -7609,7 +7609,7 @@ glyph_rect (f, x, y, rect) | |||
| 7609 | RECT *rect; | 7609 | RECT *rect; |
| 7610 | { | 7610 | { |
| 7611 | Lisp_Object window; | 7611 | Lisp_Object window; |
| 7612 | int part, found = 0; | 7612 | int part; |
| 7613 | 7613 | ||
| 7614 | window = window_from_coordinates (f, x, y, &part, 0); | 7614 | window = window_from_coordinates (f, x, y, &part, 0); |
| 7615 | if (!NILP (window)) | 7615 | if (!NILP (window)) |
| @@ -7619,27 +7619,44 @@ glyph_rect (f, x, y, rect) | |||
| 7619 | struct glyph_row *end = r + w->current_matrix->nrows - 1; | 7619 | struct glyph_row *end = r + w->current_matrix->nrows - 1; |
| 7620 | 7620 | ||
| 7621 | frame_to_window_pixel_xy (w, &x, &y); | 7621 | frame_to_window_pixel_xy (w, &x, &y); |
| 7622 | 7622 | ||
| 7623 | for (; !found && r < end && r->enabled_p; ++r) | 7623 | for (; r < end && r->enabled_p; ++r) |
| 7624 | if (r->y + r->height >= y) | 7624 | if (r->y <= y && r->y + r->height > y) |
| 7625 | { | 7625 | { |
| 7626 | /* Found the row at y. */ | ||
| 7626 | struct glyph *g = r->glyphs[TEXT_AREA]; | 7627 | struct glyph *g = r->glyphs[TEXT_AREA]; |
| 7627 | struct glyph *end = g + r->used[TEXT_AREA]; | 7628 | struct glyph *end = g + r->used[TEXT_AREA]; |
| 7628 | int gx; | 7629 | int gx; |
| 7629 | 7630 | ||
| 7630 | for (gx = r->x; !found && g < end; gx += g->pixel_width, ++g) | 7631 | rect->top = WINDOW_TO_FRAME_PIXEL_Y (w, r->y); |
| 7631 | if (gx + g->pixel_width >= x) | 7632 | rect->bottom = rect->top + r->height; |
| 7633 | |||
| 7634 | if (x < r->x) | ||
| 7635 | { | ||
| 7636 | /* x is to the left of the first glyph in the row. */ | ||
| 7637 | rect->left = XINT (w->left); | ||
| 7638 | rect->right = WINDOW_TO_FRAME_PIXEL_X (w, r->x); | ||
| 7639 | return 1; | ||
| 7640 | } | ||
| 7641 | |||
| 7642 | for (gx = r->x; g < end; gx += g->pixel_width, ++g) | ||
| 7643 | if (gx <= x && gx + g->pixel_width > x) | ||
| 7632 | { | 7644 | { |
| 7645 | /* x is on a glyph. */ | ||
| 7633 | rect->left = WINDOW_TO_FRAME_PIXEL_X (w, gx); | 7646 | rect->left = WINDOW_TO_FRAME_PIXEL_X (w, gx); |
| 7634 | rect->top = WINDOW_TO_FRAME_PIXEL_Y (w, r->y); | ||
| 7635 | rect->right = rect->left + g->pixel_width; | 7647 | rect->right = rect->left + g->pixel_width; |
| 7636 | rect->bottom = rect->top + r->height; | 7648 | return 1; |
| 7637 | found = 1; | ||
| 7638 | } | 7649 | } |
| 7650 | |||
| 7651 | /* x is to the right of the last glyph in the row. */ | ||
| 7652 | rect->left = WINDOW_TO_FRAME_PIXEL_X (w, gx); | ||
| 7653 | rect->right = XINT (w->left) + XINT (w->width); | ||
| 7654 | return 1; | ||
| 7639 | } | 7655 | } |
| 7640 | } | 7656 | } |
| 7641 | 7657 | ||
| 7642 | return found; | 7658 | /* The y is not on any row. */ |
| 7659 | return 0; | ||
| 7643 | } | 7660 | } |
| 7644 | 7661 | ||
| 7645 | /* Record the position of the mouse in last_mouse_glyph. */ | 7662 | /* Record the position of the mouse in last_mouse_glyph. */ |