aboutsummaryrefslogtreecommitdiffstats
path: root/src/xterm.c
diff options
context:
space:
mode:
authorKim F. Storm2003-03-21 22:56:52 +0000
committerKim F. Storm2003-03-21 22:56:52 +0000
commite080d3ebbf5823a103ff1f9c7614f05e55d91793 (patch)
tree2289a36a54a56d6edf18cb0b8d983a31701cf0ad /src/xterm.c
parent1853f74c1cede3a355e61ee504ec6289e0c58833 (diff)
downloademacs-e080d3ebbf5823a103ff1f9c7614f05e55d91793.tar.gz
emacs-e080d3ebbf5823a103ff1f9c7614f05e55d91793.zip
* xdisp.c (pixel_to_glyph_coords, glyph_to_pixel_coords):
Add generic versions here. Remove system specific versions defined elsewhere.
Diffstat (limited to 'src/xterm.c')
-rw-r--r--src/xterm.c93
1 files changed, 0 insertions, 93 deletions
diff --git a/src/xterm.c b/src/xterm.c
index b4fdd5c360e..c8baf8ffe35 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -3474,99 +3474,6 @@ x_get_keysym_name (keysym)
3474 3474
3475/* Mouse clicks and mouse movement. Rah. */ 3475/* Mouse clicks and mouse movement. Rah. */
3476 3476
3477/* Given a pixel position (PIX_X, PIX_Y) on frame F, return glyph
3478 co-ordinates in (*X, *Y). Set *BOUNDS to the rectangle that the
3479 glyph at X, Y occupies, if BOUNDS != 0. If NOCLIP is non-zero, do
3480 not force the value into range. */
3481
3482void
3483pixel_to_glyph_coords (f, pix_x, pix_y, x, y, bounds, noclip)
3484 FRAME_PTR f;
3485 register int pix_x, pix_y;
3486 register int *x, *y;
3487 XRectangle *bounds;
3488 int noclip;
3489{
3490 /* Arrange for the division in PIXEL_TO_CHAR_COL etc. to round down
3491 even for negative values. */
3492 if (pix_x < 0)
3493 pix_x -= FONT_WIDTH ((f)->output_data.x->font) - 1;
3494 if (pix_y < 0)
3495 pix_y -= (f)->output_data.x->line_height - 1;
3496
3497 pix_x = PIXEL_TO_CHAR_COL (f, pix_x);
3498 pix_y = PIXEL_TO_CHAR_ROW (f, pix_y);
3499
3500 if (bounds)
3501 {
3502 bounds->width = FONT_WIDTH (f->output_data.x->font);
3503 bounds->height = f->output_data.x->line_height;
3504 bounds->x = CHAR_TO_PIXEL_COL (f, pix_x);
3505 bounds->y = CHAR_TO_PIXEL_ROW (f, pix_y);
3506 }
3507
3508 if (!noclip)
3509 {
3510 if (pix_x < 0)
3511 pix_x = 0;
3512 else if (pix_x > FRAME_WINDOW_WIDTH (f))
3513 pix_x = FRAME_WINDOW_WIDTH (f);
3514
3515 if (pix_y < 0)
3516 pix_y = 0;
3517 else if (pix_y > f->height)
3518 pix_y = f->height;
3519 }
3520
3521 *x = pix_x;
3522 *y = pix_y;
3523}
3524
3525
3526/* Given HPOS/VPOS in the current matrix of W, return corresponding
3527 frame-relative pixel positions in *FRAME_X and *FRAME_Y. If we
3528 can't tell the positions because W's display is not up to date,
3529 return 0. */
3530
3531int
3532glyph_to_pixel_coords (w, hpos, vpos, frame_x, frame_y)
3533 struct window *w;
3534 int hpos, vpos;
3535 int *frame_x, *frame_y;
3536{
3537 int success_p;
3538
3539 xassert (hpos >= 0 && hpos < w->current_matrix->matrix_w);
3540 xassert (vpos >= 0 && vpos < w->current_matrix->matrix_h);
3541
3542 if (display_completed)
3543 {
3544 struct glyph_row *row = MATRIX_ROW (w->current_matrix, vpos);
3545 struct glyph *glyph = row->glyphs[TEXT_AREA];
3546 struct glyph *end = glyph + min (hpos, row->used[TEXT_AREA]);
3547
3548 *frame_y = row->y;
3549 *frame_x = row->x;
3550 while (glyph < end)
3551 {
3552 *frame_x += glyph->pixel_width;
3553 ++glyph;
3554 }
3555
3556 success_p = 1;
3557 }
3558 else
3559 {
3560 *frame_y = *frame_x = 0;
3561 success_p = 0;
3562 }
3563
3564 *frame_y = WINDOW_TO_FRAME_PIXEL_Y (w, *frame_y);
3565 *frame_x = WINDOW_TO_FRAME_PIXEL_X (w, *frame_x);
3566 return success_p;
3567}
3568
3569
3570/* Prepare a mouse-event in *RESULT for placement in the input queue. 3477/* Prepare a mouse-event in *RESULT for placement in the input queue.
3571 3478
3572 If the event is a button press, then note that we have grabbed 3479 If the event is a button press, then note that we have grabbed