comparison src/w32term.c @ 43408:5710b2d512a9

(glyph_rect): Determine the row and glyph more precisely.
author Jason Rumney <jasonr@gnu.org>
date Mon, 18 Feb 2002 23:31:06 +0000
parents 9b50c09298f6
children 842910bb2fc0
comparison
equal deleted inserted replaced
43407:e3889da94892 43408:5710b2d512a9
7607 struct frame *f; 7607 struct frame *f;
7608 int x, y; 7608 int x, y;
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))
7616 { 7616 {
7617 struct window *w = XWINDOW (window); 7617 struct window *w = XWINDOW (window);
7618 struct glyph_row *r = MATRIX_FIRST_TEXT_ROW (w->current_matrix); 7618 struct glyph_row *r = MATRIX_FIRST_TEXT_ROW (w->current_matrix);
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. */
7646 static void 7663 static void
7647 remember_mouse_glyph (f1, gx, gy) 7664 remember_mouse_glyph (f1, gx, gy)