Mercurial > emacs
comparison src/xterm.c @ 66036:699f7f132908
(glyph_rect, remember_mouse_glyph): Remove X versions.
(note_mouse_movement, XTmouse_position): Use generic
remember_mouse_glyph, add last_mouse_glyph arg.
author | Kim F. Storm <storm@cua.dk> |
---|---|
date | Tue, 11 Oct 2005 22:37:01 +0000 |
parents | eefcdbee90bc |
children | 351bf0fec9aa 08b4dd6a6e87 |
comparison
equal
deleted
inserted
replaced
66035:1b9ba63aad7e | 66036:699f7f132908 |
---|---|
3580 another motion event, so we can check again the next time it moves. */ | 3580 another motion event, so we can check again the next time it moves. */ |
3581 | 3581 |
3582 static XMotionEvent last_mouse_motion_event; | 3582 static XMotionEvent last_mouse_motion_event; |
3583 static Lisp_Object last_mouse_motion_frame; | 3583 static Lisp_Object last_mouse_motion_frame; |
3584 | 3584 |
3585 static void remember_mouse_glyph P_ ((struct frame *, int, int)); | |
3586 | |
3587 static void | 3585 static void |
3588 note_mouse_movement (frame, event) | 3586 note_mouse_movement (frame, event) |
3589 FRAME_PTR frame; | 3587 FRAME_PTR frame; |
3590 XMotionEvent *event; | 3588 XMotionEvent *event; |
3591 { | 3589 { |
3608 { | 3606 { |
3609 frame->mouse_moved = 1; | 3607 frame->mouse_moved = 1; |
3610 last_mouse_scroll_bar = Qnil; | 3608 last_mouse_scroll_bar = Qnil; |
3611 note_mouse_highlight (frame, event->x, event->y); | 3609 note_mouse_highlight (frame, event->x, event->y); |
3612 /* Remember which glyph we're now on. */ | 3610 /* Remember which glyph we're now on. */ |
3613 remember_mouse_glyph (frame, event->x, event->y); | 3611 remember_mouse_glyph (frame, event->x, event->y, &last_mouse_glyph); |
3614 } | 3612 } |
3615 } | 3613 } |
3616 | 3614 |
3617 | 3615 |
3618 /************************************************************************ | 3616 /************************************************************************ |
3627 note_mouse_highlight (XFRAME (last_mouse_motion_frame), | 3625 note_mouse_highlight (XFRAME (last_mouse_motion_frame), |
3628 last_mouse_motion_event.x, | 3626 last_mouse_motion_event.x, |
3629 last_mouse_motion_event.y); | 3627 last_mouse_motion_event.y); |
3630 } | 3628 } |
3631 | 3629 |
3632 | |
3633 static int glyph_rect P_ ((struct frame *f, int, int, XRectangle *)); | |
3634 | |
3635 | |
3636 /* Try to determine frame pixel position and size of the glyph under | |
3637 frame pixel coordinates X/Y on frame F . Return the position and | |
3638 size in *RECT. Value is non-zero if we could compute these | |
3639 values. */ | |
3640 | |
3641 static int | |
3642 glyph_rect (f, x, y, rect) | |
3643 struct frame *f; | |
3644 int x, y; | |
3645 XRectangle *rect; | |
3646 { | |
3647 Lisp_Object window; | |
3648 struct window *w; | |
3649 struct glyph_row *r, *end_row; | |
3650 enum window_part part; | |
3651 | |
3652 window = window_from_coordinates (f, x, y, &part, &x, &y, 0); | |
3653 if (NILP (window)) | |
3654 return 0; | |
3655 | |
3656 w = XWINDOW (window); | |
3657 r = MATRIX_FIRST_TEXT_ROW (w->current_matrix); | |
3658 end_row = r + w->current_matrix->nrows - 1; | |
3659 | |
3660 if (part != ON_TEXT) | |
3661 return 0; | |
3662 | |
3663 for (; r < end_row && r->enabled_p; ++r) | |
3664 { | |
3665 if (r->y >= y) | |
3666 { | |
3667 struct glyph *g = r->glyphs[TEXT_AREA]; | |
3668 struct glyph *end = g + r->used[TEXT_AREA]; | |
3669 int gx = r->x; | |
3670 while (g < end && gx < x) | |
3671 gx += g->pixel_width, ++g; | |
3672 if (g < end) | |
3673 { | |
3674 rect->width = g->pixel_width; | |
3675 rect->height = r->height; | |
3676 rect->x = WINDOW_TO_FRAME_PIXEL_X (w, gx); | |
3677 rect->y = WINDOW_TO_FRAME_PIXEL_Y (w, r->y); | |
3678 return 1; | |
3679 } | |
3680 break; | |
3681 } | |
3682 } | |
3683 | |
3684 return 0; | |
3685 } | |
3686 | |
3687 | |
3688 /* Remember which glyph the mouse is over. | |
3689 */ | |
3690 static void | |
3691 remember_mouse_glyph (f1, win_x, win_y) | |
3692 FRAME_PTR f1; | |
3693 int win_x, win_y; | |
3694 { | |
3695 int width, height, gx, gy; | |
3696 | |
3697 /* Try getting the rectangle of the actual glyph. */ | |
3698 if (!glyph_rect (f1, win_x, win_y, &last_mouse_glyph)) | |
3699 { | |
3700 /* If there is no glyph under the mouse, then we divide the screen | |
3701 into a grid of the smallest glyph in the frame, and use that | |
3702 as our "glyph". */ | |
3703 width = FRAME_SMALLEST_CHAR_WIDTH (f1); | |
3704 height = FRAME_SMALLEST_FONT_HEIGHT (f1); | |
3705 gx = win_x; | |
3706 gy = win_y; | |
3707 | |
3708 /* Arrange for the division in FRAME_PIXEL_X_TO_COL etc. to | |
3709 round down even for negative values. */ | |
3710 if (gx < 0) | |
3711 gx -= width - 1; | |
3712 if (gy < 0) | |
3713 gy -= height - 1; | |
3714 | |
3715 gx = gx / width * width; | |
3716 gy = gy / width * width; | |
3717 | |
3718 last_mouse_glyph.width = width; | |
3719 last_mouse_glyph.height = height; | |
3720 last_mouse_glyph.x = gx; | |
3721 last_mouse_glyph.y = gy; | |
3722 } | |
3723 } | |
3724 | 3630 |
3725 | 3631 |
3726 /* Return the current position of the mouse. | 3632 /* Return the current position of the mouse. |
3727 *FP should be a frame which indicates which display to ask about. | 3633 *FP should be a frame which indicates which display to ask about. |
3728 | 3634 |
3907 events, we must divide the frame into rectangles of the | 3813 events, we must divide the frame into rectangles of the |
3908 size of the smallest character that could be displayed | 3814 size of the smallest character that could be displayed |
3909 on it, i.e. into the same rectangles that matrices on | 3815 on it, i.e. into the same rectangles that matrices on |
3910 the frame are divided into. */ | 3816 the frame are divided into. */ |
3911 | 3817 |
3912 remember_mouse_glyph (f1, win_x, win_y); | 3818 remember_mouse_glyph (f1, win_x, win_y, &last_mouse_glyph); |
3913 | 3819 |
3914 *bar_window = Qnil; | 3820 *bar_window = Qnil; |
3915 *part = 0; | 3821 *part = 0; |
3916 *fp = f1; | 3822 *fp = f1; |
3917 XSETINT (*x, win_x); | 3823 XSETINT (*x, win_x); |