aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJason Rumney2005-10-10 19:02:10 +0000
committerJason Rumney2005-10-10 19:02:10 +0000
commit9b909870cde9d5d7b101a3c21478f65e7d3a3b63 (patch)
treeecc2f80ee6e2e9318007bc4b2cacbfb8fcfcefaf /src
parent720a5d03f43895d0e5b3750c3aa109a1303e0c4c (diff)
downloademacs-9b909870cde9d5d7b101a3c21478f65e7d3a3b63.tar.gz
emacs-9b909870cde9d5d7b101a3c21478f65e7d3a3b63.zip
(remember_mouse_glyph): New function.
(note_mouse_movement): Use it to remember the current glyph if changed. (XTmouse_position): Fix calculation of fake glyph under mouse. Move code to calculate glyph under mouse into remember_mouse_glyph.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog9
-rw-r--r--src/xterm.c69
2 files changed, 52 insertions, 26 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index dada003404a..b1dca8abe3c 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,12 @@
12005-10-10 Jason Rumney <jasonr@gnu.org>
2
3 * xterm.c (remember_mouse_glyph): New function.
4 (note_mouse_movement): Use it to remember the current glyph if
5 changed.
6 (XTmouse_position): Fix calculation of fake glyph under mouse.
7 Move code to calculate glyph under mouse into
8 remember_mouse_glyph.
9
12005-10-10 Jan Dj,Ad(Brv <jan.h.d@swipnet.se> 102005-10-10 Jan Dj,Ad(Brv <jan.h.d@swipnet.se>
2 11
3 * emacs.c (USAGE3, standard_args): -nb => -nbi 12 * emacs.c (USAGE3, standard_args): -nb => -nbi
diff --git a/src/xterm.c b/src/xterm.c
index af62cfd0c75..c2fb207bcb1 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -3582,6 +3582,8 @@ construct_mouse_click (result, event, f)
3582static XMotionEvent last_mouse_motion_event; 3582static XMotionEvent last_mouse_motion_event;
3583static Lisp_Object last_mouse_motion_frame; 3583static Lisp_Object last_mouse_motion_frame;
3584 3584
3585static void remember_mouse_glyph P_ ((struct frame *, int, int));
3586
3585static void 3587static void
3586note_mouse_movement (frame, event) 3588note_mouse_movement (frame, event)
3587 FRAME_PTR frame; 3589 FRAME_PTR frame;
@@ -3607,6 +3609,8 @@ note_mouse_movement (frame, event)
3607 frame->mouse_moved = 1; 3609 frame->mouse_moved = 1;
3608 last_mouse_scroll_bar = Qnil; 3610 last_mouse_scroll_bar = Qnil;
3609 note_mouse_highlight (frame, event->x, event->y); 3611 note_mouse_highlight (frame, event->x, event->y);
3612 /* Remember which glyph we're now on. */
3613 remember_mouse_glyph (frame, event->x, event->y);
3610 } 3614 }
3611} 3615}
3612 3616
@@ -3677,6 +3681,44 @@ glyph_rect (f, x, y, rect)
3677} 3681}
3678 3682
3679 3683
3684/* Remember which glyph the mouse is over.
3685 */
3686static void
3687remember_mouse_glyph (f1, win_x, win_y)
3688 FRAME_PTR f1;
3689 int win_x, win_y;
3690{
3691 int width, height, gx, gy;
3692
3693 /* Try getting the rectangle of the actual glyph. */
3694 if (!glyph_rect (f1, win_x, win_y, &last_mouse_glyph))
3695 {
3696 /* If there is no glyph under the mouse, then we divide the screen
3697 into a grid of the smallest glyph in the frame, and use that
3698 as our "glyph". */
3699 width = FRAME_SMALLEST_CHAR_WIDTH (f1);
3700 height = FRAME_SMALLEST_FONT_HEIGHT (f1);
3701 gx = win_x;
3702 gy = win_y;
3703
3704 /* Arrange for the division in FRAME_PIXEL_X_TO_COL etc. to
3705 round down even for negative values. */
3706 if (gx < 0)
3707 gx -= width - 1;
3708 if (gy < 0)
3709 gy -= height - 1;
3710
3711 gx = gx / width * width;
3712 gy = gy / width * width;
3713
3714 last_mouse_glyph.width = width;
3715 last_mouse_glyph.height = height;
3716 last_mouse_glyph.x = gx;
3717 last_mouse_glyph.y = gy;
3718 }
3719}
3720
3721
3680/* Return the current position of the mouse. 3722/* Return the current position of the mouse.
3681 *FP should be a frame which indicates which display to ask about. 3723 *FP should be a frame which indicates which display to ask about.
3682 3724
@@ -3863,32 +3905,7 @@ XTmouse_position (fp, insist, bar_window, part, x, y, time)
3863 on it, i.e. into the same rectangles that matrices on 3905 on it, i.e. into the same rectangles that matrices on
3864 the frame are divided into. */ 3906 the frame are divided into. */
3865 3907
3866 int width, height, gx, gy; 3908 remember_mouse_glyph (f1, win_x, win_y);
3867 XRectangle rect;
3868
3869 if (glyph_rect (f1, win_x, win_y, &rect))
3870 last_mouse_glyph = rect;
3871 else
3872 {
3873 width = FRAME_SMALLEST_CHAR_WIDTH (f1);
3874 height = FRAME_SMALLEST_FONT_HEIGHT (f1);
3875 gx = win_x;
3876 gy = win_y;
3877
3878 /* Arrange for the division in FRAME_PIXEL_X_TO_COL etc. to
3879 round down even for negative values. */
3880 if (gx < 0)
3881 gx -= width - 1;
3882 if (gy < 0)
3883 gy -= height - 1;
3884 gx = (gx + width - 1) / width * width;
3885 gy = (gy + height - 1) / height * height;
3886
3887 last_mouse_glyph.width = width;
3888 last_mouse_glyph.height = height;
3889 last_mouse_glyph.x = gx;
3890 last_mouse_glyph.y = gy;
3891 }
3892 3909
3893 *bar_window = Qnil; 3910 *bar_window = Qnil;
3894 *part = 0; 3911 *part = 0;