aboutsummaryrefslogtreecommitdiffstats
path: root/src/macterm.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/macterm.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/macterm.c')
-rw-r--r--src/macterm.c101
1 files changed, 0 insertions, 101 deletions
diff --git a/src/macterm.c b/src/macterm.c
index 68c599caa3e..23ce917f282 100644
--- a/src/macterm.c
+++ b/src/macterm.c
@@ -3464,107 +3464,6 @@ x_get_keysym_name (keysym)
3464 3464
3465/* Mouse clicks and mouse movement. Rah. */ 3465/* Mouse clicks and mouse movement. Rah. */
3466 3466
3467/* Given a pixel position (PIX_X, PIX_Y) on frame F, return glyph
3468 co-ordinates in (*X, *Y). Set *BOUNDS to the rectangle that the
3469 glyph at X, Y occupies, if BOUNDS != 0. If NOCLIP is non-zero, do
3470 not force the value into range. */
3471
3472void
3473pixel_to_glyph_coords (f, pix_x, pix_y, x, y, bounds, noclip)
3474 FRAME_PTR f;
3475 register int pix_x, pix_y;
3476 register int *x, *y;
3477 Rect *bounds;
3478 int noclip;
3479{
3480 /* Support tty mode: if Vwindow_system is nil, behave correctly. */
3481 if (NILP (Vwindow_system))
3482 {
3483 *x = pix_x;
3484 *y = pix_y;
3485 return;
3486 }
3487
3488 /* Arrange for the division in PIXEL_TO_CHAR_COL etc. to round down
3489 even for negative values. */
3490 if (pix_x < 0)
3491 pix_x -= FONT_WIDTH (FRAME_FONT (f)) - 1;
3492 if (pix_y < 0)
3493 pix_y -= (f)->output_data.mac->line_height - 1;
3494
3495 pix_x = PIXEL_TO_CHAR_COL (f, pix_x);
3496 pix_y = PIXEL_TO_CHAR_ROW (f, pix_y);
3497
3498 if (bounds)
3499 {
3500 bounds->left = CHAR_TO_PIXEL_COL (f, pix_x);
3501 bounds->top = CHAR_TO_PIXEL_ROW (f, pix_y);
3502 bounds->right = bounds->left + FONT_WIDTH (FRAME_FONT (f)) - 1;
3503 bounds->bottom = bounds->top + f->output_data.mac->line_height - 1;
3504 }
3505
3506 if (!noclip)
3507 {
3508 if (pix_x < 0)
3509 pix_x = 0;
3510 else if (pix_x > FRAME_WINDOW_WIDTH (f))
3511 pix_x = FRAME_WINDOW_WIDTH (f);
3512
3513 if (pix_y < 0)
3514 pix_y = 0;
3515 else if (pix_y > f->height)
3516 pix_y = f->height;
3517 }
3518
3519 *x = pix_x;
3520 *y = pix_y;
3521}
3522
3523
3524/* Given HPOS/VPOS in the current matrix of W, return corresponding
3525 frame-relative pixel positions in *FRAME_X and *FRAME_Y. If we
3526 can't tell the positions because W's display is not up to date,
3527 return 0. */
3528
3529int
3530glyph_to_pixel_coords (w, hpos, vpos, frame_x, frame_y)
3531 struct window *w;
3532 int hpos, vpos;
3533 int *frame_x, *frame_y;
3534{
3535 int success_p;
3536
3537 xassert (hpos >= 0 && hpos < w->current_matrix->matrix_w);
3538 xassert (vpos >= 0 && vpos < w->current_matrix->matrix_h);
3539
3540 if (display_completed)
3541 {
3542 struct glyph_row *row = MATRIX_ROW (w->current_matrix, vpos);
3543 struct glyph *glyph = row->glyphs[TEXT_AREA];
3544 struct glyph *end = glyph + min (hpos, row->used[TEXT_AREA]);
3545
3546 *frame_y = row->y;
3547 *frame_x = row->x;
3548 while (glyph < end)
3549 {
3550 *frame_x += glyph->pixel_width;
3551 ++glyph;
3552 }
3553
3554 success_p = 1;
3555 }
3556 else
3557 {
3558 *frame_y = *frame_x = 0;
3559 success_p = 0;
3560 }
3561
3562 *frame_y = WINDOW_TO_FRAME_PIXEL_Y (w, *frame_y);
3563 *frame_x = WINDOW_TO_FRAME_PIXEL_X (w, *frame_x);
3564 return success_p;
3565}
3566
3567
3568/* Prepare a mouse-event in *RESULT for placement in the input queue. 3467/* Prepare a mouse-event in *RESULT for placement in the input queue.
3569 3468
3570 If the event is a button press, then note that we have grabbed 3469 If the event is a button press, then note that we have grabbed