aboutsummaryrefslogtreecommitdiffstats
path: root/src/xterm.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/xterm.c')
-rw-r--r--src/xterm.c106
1 files changed, 19 insertions, 87 deletions
diff --git a/src/xterm.c b/src/xterm.c
index 5b7d45fe228..ce46bd16f42 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -1305,7 +1305,7 @@ x_draw_glyph_string_foreground (s)
1305 XDrawImageString is usually faster than XDrawString.) Always 1305 XDrawImageString is usually faster than XDrawString.) Always
1306 use XDrawImageString when drawing the cursor so that there is 1306 use XDrawImageString when drawing the cursor so that there is
1307 no chance that characters under a box cursor are invisible. */ 1307 no chance that characters under a box cursor are invisible. */
1308 if (s->for_overlaps_p 1308 if (s->for_overlaps
1309 || (s->background_filled_p && s->hl != DRAW_CURSOR)) 1309 || (s->background_filled_p && s->hl != DRAW_CURSOR))
1310 { 1310 {
1311 /* Draw characters with 16-bit or 8-bit functions. */ 1311 /* Draw characters with 16-bit or 8-bit functions. */
@@ -2610,7 +2610,7 @@ x_draw_glyph_string (s)
2610 /* If S draws into the background of its successor, draw the 2610 /* If S draws into the background of its successor, draw the
2611 background of the successor first so that S can draw into it. 2611 background of the successor first so that S can draw into it.
2612 This makes S->next use XDrawString instead of XDrawImageString. */ 2612 This makes S->next use XDrawString instead of XDrawImageString. */
2613 if (s->next && s->right_overhang && !s->for_overlaps_p) 2613 if (s->next && s->right_overhang && !s->for_overlaps)
2614 { 2614 {
2615 xassert (s->next->img == NULL); 2615 xassert (s->next->img == NULL);
2616 x_set_glyph_string_gc (s->next); 2616 x_set_glyph_string_gc (s->next);
@@ -2623,7 +2623,7 @@ x_draw_glyph_string (s)
2623 2623
2624 /* Draw relief (if any) in advance for char/composition so that the 2624 /* Draw relief (if any) in advance for char/composition so that the
2625 glyph string can be drawn over it. */ 2625 glyph string can be drawn over it. */
2626 if (!s->for_overlaps_p 2626 if (!s->for_overlaps
2627 && s->face->box != FACE_NO_BOX 2627 && s->face->box != FACE_NO_BOX
2628 && (s->first_glyph->type == CHAR_GLYPH 2628 && (s->first_glyph->type == CHAR_GLYPH
2629 || s->first_glyph->type == COMPOSITE_GLYPH)) 2629 || s->first_glyph->type == COMPOSITE_GLYPH))
@@ -2649,7 +2649,7 @@ x_draw_glyph_string (s)
2649 break; 2649 break;
2650 2650
2651 case CHAR_GLYPH: 2651 case CHAR_GLYPH:
2652 if (s->for_overlaps_p) 2652 if (s->for_overlaps)
2653 s->background_filled_p = 1; 2653 s->background_filled_p = 1;
2654 else 2654 else
2655 x_draw_glyph_string_background (s, 0); 2655 x_draw_glyph_string_background (s, 0);
@@ -2657,7 +2657,7 @@ x_draw_glyph_string (s)
2657 break; 2657 break;
2658 2658
2659 case COMPOSITE_GLYPH: 2659 case COMPOSITE_GLYPH:
2660 if (s->for_overlaps_p || s->gidx > 0) 2660 if (s->for_overlaps || s->gidx > 0)
2661 s->background_filled_p = 1; 2661 s->background_filled_p = 1;
2662 else 2662 else
2663 x_draw_glyph_string_background (s, 1); 2663 x_draw_glyph_string_background (s, 1);
@@ -2668,7 +2668,7 @@ x_draw_glyph_string (s)
2668 abort (); 2668 abort ();
2669 } 2669 }
2670 2670
2671 if (!s->for_overlaps_p) 2671 if (!s->for_overlaps)
2672 { 2672 {
2673 /* Draw underline. */ 2673 /* Draw underline. */
2674 if (s->face->underline_p) 2674 if (s->face->underline_p)
@@ -3588,7 +3588,7 @@ construct_mouse_click (result, event, f)
3588static XMotionEvent last_mouse_motion_event; 3588static XMotionEvent last_mouse_motion_event;
3589static Lisp_Object last_mouse_motion_frame; 3589static Lisp_Object last_mouse_motion_frame;
3590 3590
3591static void 3591static int
3592note_mouse_movement (frame, event) 3592note_mouse_movement (frame, event)
3593 FRAME_PTR frame; 3593 FRAME_PTR frame;
3594 XMotionEvent *event; 3594 XMotionEvent *event;
@@ -3602,10 +3602,11 @@ note_mouse_movement (frame, event)
3602 frame->mouse_moved = 1; 3602 frame->mouse_moved = 1;
3603 last_mouse_scroll_bar = Qnil; 3603 last_mouse_scroll_bar = Qnil;
3604 note_mouse_highlight (frame, -1, -1); 3604 note_mouse_highlight (frame, -1, -1);
3605 return 1;
3605 } 3606 }
3606 3607
3607 /* Has the mouse moved off the glyph it was on at the last sighting? */ 3608 /* Has the mouse moved off the glyph it was on at the last sighting? */
3608 else if (event->x < last_mouse_glyph.x 3609 if (event->x < last_mouse_glyph.x
3609 || event->x >= last_mouse_glyph.x + last_mouse_glyph.width 3610 || event->x >= last_mouse_glyph.x + last_mouse_glyph.width
3610 || event->y < last_mouse_glyph.y 3611 || event->y < last_mouse_glyph.y
3611 || event->y >= last_mouse_glyph.y + last_mouse_glyph.height) 3612 || event->y >= last_mouse_glyph.y + last_mouse_glyph.height)
@@ -3613,7 +3614,12 @@ note_mouse_movement (frame, event)
3613 frame->mouse_moved = 1; 3614 frame->mouse_moved = 1;
3614 last_mouse_scroll_bar = Qnil; 3615 last_mouse_scroll_bar = Qnil;
3615 note_mouse_highlight (frame, event->x, event->y); 3616 note_mouse_highlight (frame, event->x, event->y);
3617 /* Remember which glyph we're now on. */
3618 remember_mouse_glyph (frame, event->x, event->y, &last_mouse_glyph);
3619 return 1;
3616 } 3620 }
3621
3622 return 0;
3617} 3623}
3618 3624
3619 3625
@@ -3632,56 +3638,6 @@ redo_mouse_highlight ()
3632} 3638}
3633 3639
3634 3640
3635static int glyph_rect P_ ((struct frame *f, int, int, XRectangle *));
3636
3637
3638/* Try to determine frame pixel position and size of the glyph under
3639 frame pixel coordinates X/Y on frame F . Return the position and
3640 size in *RECT. Value is non-zero if we could compute these
3641 values. */
3642
3643static int
3644glyph_rect (f, x, y, rect)
3645 struct frame *f;
3646 int x, y;
3647 XRectangle *rect;
3648{
3649 Lisp_Object window;
3650 struct window *w;
3651 struct glyph_row *r, *end_row;
3652
3653 window = window_from_coordinates (f, x, y, 0, &x, &y, 0);
3654 if (NILP (window))
3655 return 0;
3656
3657 w = XWINDOW (window);
3658 r = MATRIX_FIRST_TEXT_ROW (w->current_matrix);
3659 end_row = r + w->current_matrix->nrows - 1;
3660
3661 for (; r < end_row && r->enabled_p; ++r)
3662 {
3663 if (r->y >= y)
3664 {
3665 struct glyph *g = r->glyphs[TEXT_AREA];
3666 struct glyph *end = g + r->used[TEXT_AREA];
3667 int gx = r->x;
3668 while (g < end && gx < x)
3669 gx += g->pixel_width, ++g;
3670 if (g < end)
3671 {
3672 rect->width = g->pixel_width;
3673 rect->height = r->height;
3674 rect->x = WINDOW_TO_FRAME_PIXEL_X (w, gx);
3675 rect->y = WINDOW_TO_FRAME_PIXEL_Y (w, r->y);
3676 return 1;
3677 }
3678 break;
3679 }
3680 }
3681
3682 return 0;
3683}
3684
3685 3641
3686/* Return the current position of the mouse. 3642/* Return the current position of the mouse.
3687 *FP should be a frame which indicates which display to ask about. 3643 *FP should be a frame which indicates which display to ask about.
@@ -3869,32 +3825,7 @@ XTmouse_position (fp, insist, bar_window, part, x, y, time)
3869 on it, i.e. into the same rectangles that matrices on 3825 on it, i.e. into the same rectangles that matrices on
3870 the frame are divided into. */ 3826 the frame are divided into. */
3871 3827
3872 int width, height, gx, gy; 3828 remember_mouse_glyph (f1, win_x, win_y, &last_mouse_glyph);
3873 XRectangle rect;
3874
3875 if (glyph_rect (f1, win_x, win_y, &rect))
3876 last_mouse_glyph = rect;
3877 else
3878 {
3879 width = FRAME_SMALLEST_CHAR_WIDTH (f1);
3880 height = FRAME_SMALLEST_FONT_HEIGHT (f1);
3881 gx = win_x;
3882 gy = win_y;
3883
3884 /* Arrange for the division in FRAME_PIXEL_X_TO_COL etc. to
3885 round down even for negative values. */
3886 if (gx < 0)
3887 gx -= width - 1;
3888 if (gy < 0)
3889 gy -= height - 1;
3890 gx = (gx + width - 1) / width * width;
3891 gy = (gy + height - 1) / height * height;
3892
3893 last_mouse_glyph.width = width;
3894 last_mouse_glyph.height = height;
3895 last_mouse_glyph.x = gx;
3896 last_mouse_glyph.y = gy;
3897 }
3898 3829
3899 *bar_window = Qnil; 3830 *bar_window = Qnil;
3900 *part = 0; 3831 *part = 0;
@@ -6571,8 +6502,7 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit)
6571 case MotionNotify: 6502 case MotionNotify:
6572 { 6503 {
6573 previous_help_echo_string = help_echo_string; 6504 previous_help_echo_string = help_echo_string;
6574 help_echo_string = help_echo_object = help_echo_window = Qnil; 6505 help_echo_string = Qnil;
6575 help_echo_pos = -1;
6576 6506
6577 if (dpyinfo->grabbed && last_mouse_frame 6507 if (dpyinfo->grabbed && last_mouse_frame
6578 && FRAME_LIVE_P (last_mouse_frame)) 6508 && FRAME_LIVE_P (last_mouse_frame))
@@ -6611,7 +6541,8 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit)
6611 6541
6612 last_window=window; 6542 last_window=window;
6613 } 6543 }
6614 note_mouse_movement (f, &event.xmotion); 6544 if (!note_mouse_movement (f, &event.xmotion))
6545 help_echo_string = previous_help_echo_string;
6615 } 6546 }
6616 else 6547 else
6617 { 6548 {
@@ -6720,6 +6651,7 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit)
6720 int tool_bar_p = 0; 6651 int tool_bar_p = 0;
6721 6652
6722 bzero (&compose_status, sizeof (compose_status)); 6653 bzero (&compose_status, sizeof (compose_status));
6654 bzero (&last_mouse_glyph, sizeof (last_mouse_glyph));
6723 6655
6724 if (dpyinfo->grabbed 6656 if (dpyinfo->grabbed
6725 && last_mouse_frame 6657 && last_mouse_frame