aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGerd Moellmann1999-08-06 13:59:59 +0000
committerGerd Moellmann1999-08-06 13:59:59 +0000
commit66ac4b0e5fa32071fa60c7d4956786cc1d161245 (patch)
treef4b879a13edd6dbd864d8f63df5a04037127ba9d /src
parent312246d12fbaafcd86316d2acc05ace59e1341ce (diff)
downloademacs-66ac4b0e5fa32071fa60c7d4956786cc1d161245.tar.gz
emacs-66ac4b0e5fa32071fa60c7d4956786cc1d161245.zip
(x_draw_phys_cursor_glyph): Redraw overlaps.
(x_fix_overlapping_area): New. (x_redisplay_interface): Add x_fix_overlapping_area. (x_draw_glyphs): Add parameter overlaps_p. (struct glyph_string): Add member for_overlaps_p. (x_get_glyph_string_clip_rect): If glyph string draws foreground of overlapping rows, clip to window bottom. (x_fill_glyph_string): Add parameter overlaps_p. (x_fill_composite_glyph_string): Ditto. (BUILD_GLYPH_STRINGS): Ditto. (BUILD_CHAR_GLYPH_STRINGS): Ditto. (x_draw_glyph_string): Don't draw anything but the foreground if glyph string draws row overlaps. (x_append_glyph): Set glyph flag overlaps_vertically_p. (x_produce_image_glyph): Compute iterator's physical ascent and descent. (x_produce_stretch_glyph): Ditto. (x_produce_glyphs): Ditto.
Diffstat (limited to 'src')
-rw-r--r--src/xterm.c324
1 files changed, 224 insertions, 100 deletions
diff --git a/src/xterm.c b/src/xterm.c
index a8e5c974d15..15f2ccfa6d8 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -1440,6 +1440,8 @@ x_append_glyph (it)
1440 glyph->right_box_line_p = it->end_of_box_run_p; 1440 glyph->right_box_line_p = it->end_of_box_run_p;
1441 glyph->voffset = it->voffset; 1441 glyph->voffset = it->voffset;
1442 glyph->multibyte_p = it->multibyte_p; 1442 glyph->multibyte_p = it->multibyte_p;
1443 glyph->overlaps_vertically_p = (it->phys_ascent > it->ascent
1444 || it->phys_descent > it->descent);
1443 ++it->glyph_row->used[area]; 1445 ++it->glyph_row->used[area];
1444 } 1446 }
1445} 1447}
@@ -1487,8 +1489,8 @@ x_produce_image_glyph (it)
1487 PREPARE_FACE_FOR_DISPLAY (it->f, face); 1489 PREPARE_FACE_FOR_DISPLAY (it->f, face);
1488 prepare_image_for_display (it->f, img); 1490 prepare_image_for_display (it->f, img);
1489 1491
1490 it->ascent = IMAGE_ASCENT (img); 1492 it->ascent = it->phys_ascent = IMAGE_ASCENT (img);
1491 it->descent = img->height + 2 * img->margin - it->ascent; 1493 it->descent = it->phys_descent = img->height + 2 * img->margin - it->ascent;
1492 it->pixel_width = img->width + 2 * img->margin; 1494 it->pixel_width = img->width + 2 * img->margin;
1493 1495
1494 it->nglyphs = 1; 1496 it->nglyphs = 1;
@@ -1691,8 +1693,8 @@ x_produce_stretch_glyph (it)
1691 } 1693 }
1692 1694
1693 it->pixel_width = width; 1695 it->pixel_width = width;
1694 it->ascent = height * ascent; 1696 it->ascent = it->phys_ascent = height * ascent;
1695 it->descent = height - it->ascent; 1697 it->descent = it->phys_descent = height - it->ascent;
1696 it->nglyphs = 1; 1698 it->nglyphs = 1;
1697 1699
1698 if (face->box != FACE_NO_BOX) 1700 if (face->box != FACE_NO_BOX)
@@ -1758,10 +1760,12 @@ x_produce_glyphs (it)
1758 int stretched_p; 1760 int stretched_p;
1759 1761
1760 it->nglyphs = 1; 1762 it->nglyphs = 1;
1761 it->ascent = font->ascent;
1762 it->descent = font->descent;
1763 1763
1764 pcm = x_per_char_metric (font, &char2b); 1764 pcm = x_per_char_metric (font, &char2b);
1765 it->ascent = font->ascent;
1766 it->descent = font->descent;
1767 it->phys_ascent = pcm->ascent;
1768 it->phys_descent = pcm->descent;
1765 it->pixel_width = pcm->width; 1769 it->pixel_width = pcm->width;
1766 1770
1767 /* If this is a space inside a region of text with 1771 /* If this is a space inside a region of text with
@@ -1820,8 +1824,8 @@ x_produce_glyphs (it)
1820 /* A newline has no width but we need the height of the line. */ 1824 /* A newline has no width but we need the height of the line. */
1821 it->pixel_width = 0; 1825 it->pixel_width = 0;
1822 it->nglyphs = 0; 1826 it->nglyphs = 0;
1823 it->ascent = font->ascent; 1827 it->ascent = it->phys_ascent = font->ascent;
1824 it->descent = font->descent; 1828 it->descent = it->phys_descent = font->descent;
1825 1829
1826 if (face->box != FACE_NO_BOX) 1830 if (face->box != FACE_NO_BOX)
1827 { 1831 {
@@ -1840,8 +1844,8 @@ x_produce_glyphs (it)
1840 1844
1841 it->pixel_width = next_tab_x - x; 1845 it->pixel_width = next_tab_x - x;
1842 it->nglyphs = 1; 1846 it->nglyphs = 1;
1843 it->ascent = font->ascent; 1847 it->ascent = it->phys_ascent = font->ascent;
1844 it->descent = font->descent; 1848 it->descent = it->phys_descent = font->descent;
1845 1849
1846 if (it->glyph_row) 1850 if (it->glyph_row)
1847 { 1851 {
@@ -1879,6 +1883,8 @@ x_produce_glyphs (it)
1879 information in cmpcharp to do the correct setting. */ 1883 information in cmpcharp to do the correct setting. */
1880 it->ascent = font->ascent; 1884 it->ascent = font->ascent;
1881 it->descent = font->descent; 1885 it->descent = font->descent;
1886 it->phys_ascent = font->max_bounds.ascent;
1887 it->phys_descent = font->max_bounds.descent;
1882 } 1888 }
1883 else 1889 else
1884 { 1890 {
@@ -1894,6 +1900,8 @@ x_produce_glyphs (it)
1894 it->nglyphs = 1; 1900 it->nglyphs = 1;
1895 it->ascent = font->ascent; 1901 it->ascent = font->ascent;
1896 it->descent = font->descent; 1902 it->descent = font->descent;
1903 it->phys_ascent = pcm->ascent;
1904 it->phys_descent = pcm->descent;
1897 if (it->glyph_row 1905 if (it->glyph_row
1898 && (pcm->lbearing < 0 1906 && (pcm->lbearing < 0
1899 || pcm->rbearing > pcm->width)) 1907 || pcm->rbearing > pcm->width))
@@ -1932,8 +1940,11 @@ x_produce_glyphs (it)
1932 xassert (it->ascent >= 0 && it->descent > 0); 1940 xassert (it->ascent >= 0 && it->descent > 0);
1933 if (it->area == TEXT_AREA) 1941 if (it->area == TEXT_AREA)
1934 it->current_x += it->pixel_width; 1942 it->current_x += it->pixel_width;
1943
1935 it->max_ascent = max (it->max_ascent, it->ascent); 1944 it->max_ascent = max (it->max_ascent, it->ascent);
1936 it->max_descent = max (it->max_descent, it->descent); 1945 it->max_descent = max (it->max_descent, it->descent);
1946 it->max_phys_ascent = max (it->max_phys_ascent, it->phys_ascent);
1947 it->max_phys_descent = max (it->max_phys_descent, it->phys_descent);
1937} 1948}
1938 1949
1939 1950
@@ -2065,6 +2076,11 @@ struct glyph_string
2065 stipple pattern. */ 2076 stipple pattern. */
2066 unsigned stippled_p : 1; 2077 unsigned stippled_p : 1;
2067 2078
2079 /* 1 means only the foreground of this glyph string must be drawn,
2080 and we should use the physical height of the line this glyph
2081 string appears in as clip rect. */
2082 unsigned for_overlaps_p : 1;
2083
2068 /* The GC to use for drawing this glyph string. */ 2084 /* The GC to use for drawing this glyph string. */
2069 GC gc; 2085 GC gc;
2070 2086
@@ -2119,7 +2135,8 @@ static int x_left_overwritten P_ ((struct glyph_string *));
2119static int x_left_overwriting P_ ((struct glyph_string *)); 2135static int x_left_overwriting P_ ((struct glyph_string *));
2120static int x_right_overwritten P_ ((struct glyph_string *)); 2136static int x_right_overwritten P_ ((struct glyph_string *));
2121static int x_right_overwriting P_ ((struct glyph_string *)); 2137static int x_right_overwriting P_ ((struct glyph_string *));
2122static int x_fill_glyph_string P_ ((struct glyph_string *, int, int, int)); 2138static int x_fill_glyph_string P_ ((struct glyph_string *, int, int, int,
2139 int));
2123static void x_init_glyph_string P_ ((struct glyph_string *, 2140static void x_init_glyph_string P_ ((struct glyph_string *,
2124 XChar2b *, struct window *, 2141 XChar2b *, struct window *,
2125 struct glyph_row *, 2142 struct glyph_row *,
@@ -2127,7 +2144,7 @@ static void x_init_glyph_string P_ ((struct glyph_string *,
2127 enum draw_glyphs_face)); 2144 enum draw_glyphs_face));
2128static int x_draw_glyphs P_ ((struct window *, int , struct glyph_row *, 2145static int x_draw_glyphs P_ ((struct window *, int , struct glyph_row *,
2129 enum glyph_row_area, int, int, 2146 enum glyph_row_area, int, int,
2130 enum draw_glyphs_face, int *, int *)); 2147 enum draw_glyphs_face, int *, int *, int));
2131static void x_set_glyph_string_clipping P_ ((struct glyph_string *)); 2148static void x_set_glyph_string_clipping P_ ((struct glyph_string *));
2132static void x_set_glyph_string_gc P_ ((struct glyph_string *)); 2149static void x_set_glyph_string_gc P_ ((struct glyph_string *));
2133static void x_draw_glyph_string_background P_ ((struct glyph_string *, 2150static void x_draw_glyph_string_background P_ ((struct glyph_string *,
@@ -2159,9 +2176,10 @@ static void x_draw_relief_rect P_ ((struct frame *, int, int, int, int,
2159 int, int, int, int, XRectangle *)); 2176 int, int, int, int, XRectangle *));
2160static void x_draw_box_rect P_ ((struct glyph_string *, int, int, int, int, 2177static void x_draw_box_rect P_ ((struct glyph_string *, int, int, int, int,
2161 int, int, int, XRectangle *)); 2178 int, int, int, XRectangle *));
2179static void x_fix_overlapping_area P_ ((struct window *, struct glyph_row *,
2180 enum glyph_row_area));
2162 2181
2163 2182
2164
2165/* Append the list of glyph strings with head H and tail T to the list 2183/* Append the list of glyph strings with head H and tail T to the list
2166 with head *HEAD and tail *TAIL. Set *HEAD and *TAIL to the result. */ 2184 with head *HEAD and tail *TAIL. Set *HEAD and *TAIL to the result. */
2167 2185
@@ -2420,12 +2438,22 @@ x_get_glyph_string_clip_rect (s, r)
2420 r->y = WINDOW_DISPLAY_TOP_LINE_HEIGHT (s->w); 2438 r->y = WINDOW_DISPLAY_TOP_LINE_HEIGHT (s->w);
2421 else 2439 else
2422 r->y = max (0, s->row->y); 2440 r->y = max (0, s->row->y);
2423 r->y = WINDOW_TO_FRAME_PIXEL_Y (s->w, r->y);
2424 2441
2425 /* If drawing a toolbar window, draw it over the internal border 2442 /* If drawing a toolbar window, draw it over the internal border
2426 at the top of the window. */ 2443 at the top of the window. */
2427 if (s->w == XWINDOW (s->f->toolbar_window)) 2444 if (s->w == XWINDOW (s->f->toolbar_window))
2428 r->y -= s->f->output_data.x->internal_border_width; 2445 r->y -= s->f->output_data.x->internal_border_width;
2446
2447 /* If S draws overlapping rows, it's sufficient to use the top and
2448 bottom of the window for clipping because this glyph string
2449 intentionally draws over other lines. */
2450 if (s->for_overlaps_p)
2451 {
2452 r->y = WINDOW_DISPLAY_TOP_LINE_HEIGHT (s->w);
2453 r->height = window_text_bottom_y (s->w) - r->y;
2454 }
2455
2456 r->y = WINDOW_TO_FRAME_PIXEL_Y (s->w, r->y);
2429} 2457}
2430 2458
2431 2459
@@ -2754,7 +2782,8 @@ x_draw_glyph_string_foreground (s)
2754 Always use XDrawImageString when drawing the cursor so 2782 Always use XDrawImageString when drawing the cursor so
2755 that there is no chance that characters under a box 2783 that there is no chance that characters under a box
2756 cursor are invisible. */ 2784 cursor are invisible. */
2757 if (s->background_filled_p && s->hl != DRAW_CURSOR) 2785 if (s->for_overlaps_p
2786 || (s->background_filled_p && s->hl != DRAW_CURSOR))
2758 { 2787 {
2759 /* Draw characters with 16-bit or 8-bit functions. */ 2788 /* Draw characters with 16-bit or 8-bit functions. */
2760 if (s->two_byte_p) 2789 if (s->two_byte_p)
@@ -3675,7 +3704,7 @@ x_draw_glyph_string (s)
3675 /* If S draws into the background of its successor, draw the 3704 /* If S draws into the background of its successor, draw the
3676 background of the successor first so that S can draw into it. 3705 background of the successor first so that S can draw into it.
3677 This makes S->next use XDrawString instead of XDrawImageString. */ 3706 This makes S->next use XDrawString instead of XDrawImageString. */
3678 if (s->next && s->right_overhang) 3707 if (s->next && s->right_overhang && !s->for_overlaps_p)
3679 { 3708 {
3680 xassert (s->next->img == NULL); 3709 xassert (s->next->img == NULL);
3681 x_set_glyph_string_gc (s->next); 3710 x_set_glyph_string_gc (s->next);
@@ -3698,7 +3727,10 @@ x_draw_glyph_string (s)
3698 break; 3727 break;
3699 3728
3700 case CHAR_GLYPH: 3729 case CHAR_GLYPH:
3701 x_draw_glyph_string_background (s, 0); 3730 if (s->for_overlaps_p)
3731 s->background_filled_p = 1;
3732 else
3733 x_draw_glyph_string_background (s, 0);
3702 x_draw_glyph_string_foreground (s); 3734 x_draw_glyph_string_foreground (s);
3703 break; 3735 break;
3704 3736
@@ -3706,72 +3738,75 @@ x_draw_glyph_string (s)
3706 abort (); 3738 abort ();
3707 } 3739 }
3708 3740
3709 /* Draw underline. */ 3741 if (!s->for_overlaps_p)
3710 if (s->face->underline_p)
3711 { 3742 {
3712 unsigned long dy, h; 3743 /* Draw underline. */
3744 if (s->face->underline_p)
3745 {
3746 unsigned long dy, h;
3713 3747
3714 if (!XGetFontProperty (s->font, XA_UNDERLINE_THICKNESS, &h)) 3748 if (!XGetFontProperty (s->font, XA_UNDERLINE_THICKNESS, &h))
3715 h = 1; 3749 h = 1;
3716 if (!XGetFontProperty (s->font, XA_UNDERLINE_POSITION, &dy)) 3750 if (!XGetFontProperty (s->font, XA_UNDERLINE_POSITION, &dy))
3717 dy = s->height - h; 3751 dy = s->height - h;
3718 3752
3719 if (s->face->underline_defaulted_p) 3753 if (s->face->underline_defaulted_p)
3720 XFillRectangle (s->display, s->window, s->gc, s->x, s->y + dy, 3754 XFillRectangle (s->display, s->window, s->gc, s->x, s->y + dy,
3721 s->width, h); 3755 s->width, h);
3722 else 3756 else
3723 { 3757 {
3724 XGCValues xgcv; 3758 XGCValues xgcv;
3725 XGetGCValues (s->display, s->gc, GCForeground, &xgcv); 3759 XGetGCValues (s->display, s->gc, GCForeground, &xgcv);
3726 XSetForeground (s->display, s->gc, s->face->underline_color); 3760 XSetForeground (s->display, s->gc, s->face->underline_color);
3727 XFillRectangle (s->display, s->window, s->gc, s->x, s->y + dy, 3761 XFillRectangle (s->display, s->window, s->gc, s->x, s->y + dy,
3728 s->width, h); 3762 s->width, h);
3729 XSetForeground (s->display, s->gc, xgcv.foreground); 3763 XSetForeground (s->display, s->gc, xgcv.foreground);
3764 }
3730 } 3765 }
3731 }
3732 3766
3733 /* Draw overline. */ 3767 /* Draw overline. */
3734 if (s->face->overline_p) 3768 if (s->face->overline_p)
3735 {
3736 unsigned long dy = 0, h = 1;
3737
3738 if (s->face->overline_color_defaulted_p)
3739 XFillRectangle (s->display, s->window, s->gc, s->x, s->y + dy,
3740 s->width, h);
3741 else
3742 { 3769 {
3743 XGCValues xgcv; 3770 unsigned long dy = 0, h = 1;
3744 XGetGCValues (s->display, s->gc, GCForeground, &xgcv); 3771
3745 XSetForeground (s->display, s->gc, s->face->overline_color); 3772 if (s->face->overline_color_defaulted_p)
3746 XFillRectangle (s->display, s->window, s->gc, s->x, s->y + dy, 3773 XFillRectangle (s->display, s->window, s->gc, s->x, s->y + dy,
3747 s->width, h); 3774 s->width, h);
3748 XSetForeground (s->display, s->gc, xgcv.foreground); 3775 else
3776 {
3777 XGCValues xgcv;
3778 XGetGCValues (s->display, s->gc, GCForeground, &xgcv);
3779 XSetForeground (s->display, s->gc, s->face->overline_color);
3780 XFillRectangle (s->display, s->window, s->gc, s->x, s->y + dy,
3781 s->width, h);
3782 XSetForeground (s->display, s->gc, xgcv.foreground);
3783 }
3749 } 3784 }
3750 }
3751 3785
3752 /* Draw strike-through. */ 3786 /* Draw strike-through. */
3753 if (s->face->strike_through_p) 3787 if (s->face->strike_through_p)
3754 {
3755 unsigned long h = 1;
3756 unsigned long dy = (s->height - h) / 2;
3757
3758 if (s->face->strike_through_color_defaulted_p)
3759 XFillRectangle (s->display, s->window, s->gc, s->x, s->y + dy,
3760 s->width, h);
3761 else
3762 { 3788 {
3763 XGCValues xgcv; 3789 unsigned long h = 1;
3764 XGetGCValues (s->display, s->gc, GCForeground, &xgcv); 3790 unsigned long dy = (s->height - h) / 2;
3765 XSetForeground (s->display, s->gc, s->face->strike_through_color); 3791
3766 XFillRectangle (s->display, s->window, s->gc, s->x, s->y + dy, 3792 if (s->face->strike_through_color_defaulted_p)
3767 s->width, h); 3793 XFillRectangle (s->display, s->window, s->gc, s->x, s->y + dy,
3768 XSetForeground (s->display, s->gc, xgcv.foreground); 3794 s->width, h);
3795 else
3796 {
3797 XGCValues xgcv;
3798 XGetGCValues (s->display, s->gc, GCForeground, &xgcv);
3799 XSetForeground (s->display, s->gc, s->face->strike_through_color);
3800 XFillRectangle (s->display, s->window, s->gc, s->x, s->y + dy,
3801 s->width, h);
3802 XSetForeground (s->display, s->gc, xgcv.foreground);
3803 }
3769 } 3804 }
3770 }
3771 3805
3772 /* Draw relief. */ 3806 /* Draw relief. */
3773 if (s->face->box != FACE_NO_BOX) 3807 if (s->face->box != FACE_NO_BOX)
3774 x_draw_glyph_string_box (s); 3808 x_draw_glyph_string_box (s);
3809 }
3775 3810
3776 /* Reset clipping. */ 3811 /* Reset clipping. */
3777 XSetClipMask (s->display, s->gc, None); 3812 XSetClipMask (s->display, s->gc, None);
@@ -3797,26 +3832,31 @@ struct work
3797 3832
3798static void x_fill_composite_glyph_string P_ ((struct glyph_string *, 3833static void x_fill_composite_glyph_string P_ ((struct glyph_string *,
3799 int, struct work **, 3834 int, struct work **,
3800 struct work **)); 3835 struct work **, int));
3801 3836
3802 3837
3803/* Load glyph string S with information from the top of *STACK for a 3838/* Load glyph string S with information from the top of *STACK for a
3804 composite character. FACE_ID is the id of the face in which S is 3839 composite character. FACE_ID is the id of the face in which S is
3805 drawn. *NEW is a pointer to a struct work not on the stack, that 3840 drawn. *NEW is a pointer to a struct work not on the stack, that
3806 can be used if this function needs to push a new structure on the 3841 can be used if this function needs to push a new structure on the
3807 stack. If it uses it, *NEW is set to null. */ 3842 stack. If it uses it, *NEW is set to null. OVERLAPS_P non-zero
3843 means S should draw the foreground only, and use its lines physical
3844 height for clipping. */
3808 3845
3809static void 3846static void
3810x_fill_composite_glyph_string (s, face_id, stack, new) 3847x_fill_composite_glyph_string (s, face_id, stack, new, overlaps_p)
3811 struct glyph_string *s; 3848 struct glyph_string *s;
3812 int face_id; 3849 int face_id;
3813 struct work **stack, **new; 3850 struct work **stack, **new;
3851 int overlaps_p;
3814{ 3852{
3815 int i, c; 3853 int i, c;
3816 struct work *work; 3854 struct work *work;
3817 3855
3818 xassert (s && *new && *stack); 3856 xassert (s && *new && *stack);
3819 3857
3858 s->for_overlaps_p = 1;
3859
3820 /* Pop the work stack. */ 3860 /* Pop the work stack. */
3821 work = *stack; 3861 work = *stack;
3822 *stack = work->next; 3862 *stack = work->next;
@@ -3885,14 +3925,17 @@ x_fill_composite_glyph_string (s, face_id, stack, new)
3885 3925
3886/* Load glyph string S with a sequence of non-composite characters. 3926/* Load glyph string S with a sequence of non-composite characters.
3887 FACE_ID is the face id of the string. START is the index of the 3927 FACE_ID is the face id of the string. START is the index of the
3888 first glyph to consider, END is the index of the last + 1. Value 3928 first glyph to consider, END is the index of the last + 1.
3889 is the index of the first glyph not in S. */ 3929 OVERLAPS_P non-zero means S should draw the foreground only, and
3930 use its lines physical height for clipping.
3931
3932 Value is the index of the first glyph not in S. */
3890 3933
3891static int 3934static int
3892x_fill_glyph_string (s, face_id, start, end) 3935x_fill_glyph_string (s, face_id, start, end, overlaps_p)
3893 struct glyph_string *s; 3936 struct glyph_string *s;
3894 int face_id; 3937 int face_id;
3895 int start, end; 3938 int start, end, overlaps_p;
3896{ 3939{
3897 struct glyph *glyph, *last; 3940 struct glyph *glyph, *last;
3898 int voffset; 3941 int voffset;
@@ -3902,6 +3945,7 @@ x_fill_glyph_string (s, face_id, start, end)
3902 xassert (s->nchars == 0); 3945 xassert (s->nchars == 0);
3903 xassert (start >= 0 && end > start); 3946 xassert (start >= 0 && end > start);
3904 3947
3948 s->for_overlaps_p = overlaps_p,
3905 glyph = s->row->glyphs[s->area] + start; 3949 glyph = s->row->glyphs[s->area] + start;
3906 last = s->row->glyphs[s->area] + end; 3950 last = s->row->glyphs[s->area] + end;
3907 voffset = glyph->voffset; 3951 voffset = glyph->voffset;
@@ -3938,7 +3982,7 @@ x_fill_glyph_string (s, face_id, start, end)
3938 3982
3939 /* Adjust base line for subscript/superscript text. */ 3983 /* Adjust base line for subscript/superscript text. */
3940 s->ybase += voffset; 3984 s->ybase += voffset;
3941 3985
3942 xassert (s->face && s->face->gc); 3986 xassert (s->face && s->face->gc);
3943 return glyph - s->row->glyphs[s->area]; 3987 return glyph - s->row->glyphs[s->area];
3944} 3988}
@@ -4102,7 +4146,7 @@ x_set_glyph_string_background_width (s, start, last_x)
4102 right-most x-position of the drawing area. */ 4146 right-most x-position of the drawing area. */
4103 4147
4104#define BUILD_CHAR_GLYPH_STRINGS(W, ROW, AREA, START, END, HEAD, TAIL, HL, \ 4148#define BUILD_CHAR_GLYPH_STRINGS(W, ROW, AREA, START, END, HEAD, TAIL, HL, \
4105 X, LAST_X) \ 4149 X, LAST_X, OVERLAPS_P) \
4106 do \ 4150 do \
4107 { \ 4151 { \
4108 int c, charset, face_id; \ 4152 int c, charset, face_id; \
@@ -4152,7 +4196,7 @@ x_set_glyph_string_background_width (s, start, last_x)
4152 if (new == NULL) \ 4196 if (new == NULL) \
4153 new = (struct work *) alloca (sizeof *new); \ 4197 new = (struct work *) alloca (sizeof *new); \
4154 x_fill_composite_glyph_string (s, face_id, &stack, \ 4198 x_fill_composite_glyph_string (s, face_id, &stack, \
4155 &new); \ 4199 &new, OVERLAPS_P); \
4156 } \ 4200 } \
4157 \ 4201 \
4158 ++START; \ 4202 ++START; \
@@ -4166,7 +4210,8 @@ x_set_glyph_string_background_width (s, start, last_x)
4166 x_append_glyph_string (&HEAD, &TAIL, s); \ 4210 x_append_glyph_string (&HEAD, &TAIL, s); \
4167 s->charset = charset; \ 4211 s->charset = charset; \
4168 s->x = (X); \ 4212 s->x = (X); \
4169 START = x_fill_glyph_string (s, face_id, START, END); \ 4213 START = x_fill_glyph_string (s, face_id, START, END, \
4214 OVERLAPS_P); \
4170 } \ 4215 } \
4171 } \ 4216 } \
4172 while (0) 4217 while (0)
@@ -4183,7 +4228,7 @@ x_set_glyph_string_background_width (s, start, last_x)
4183 asynchronously). */ 4228 asynchronously). */
4184 4229
4185#define BUILD_GLYPH_STRINGS(W, ROW, AREA, START, END, HEAD, TAIL, HL, \ 4230#define BUILD_GLYPH_STRINGS(W, ROW, AREA, START, END, HEAD, TAIL, HL, \
4186 X, LAST_X) \ 4231 X, LAST_X, OVERLAPS_P) \
4187 do \ 4232 do \
4188 { \ 4233 { \
4189 HEAD = TAIL = NULL; \ 4234 HEAD = TAIL = NULL; \
@@ -4194,7 +4239,8 @@ x_set_glyph_string_background_width (s, start, last_x)
4194 { \ 4239 { \
4195 case CHAR_GLYPH: \ 4240 case CHAR_GLYPH: \
4196 BUILD_CHAR_GLYPH_STRINGS (W, ROW, AREA, START, END, HEAD, \ 4241 BUILD_CHAR_GLYPH_STRINGS (W, ROW, AREA, START, END, HEAD, \
4197 TAIL, HL, X, LAST_X); \ 4242 TAIL, HL, X, LAST_X, \
4243 OVERLAPS_P); \
4198 break; \ 4244 break; \
4199 \ 4245 \
4200 case STRETCH_GLYPH: \ 4246 case STRETCH_GLYPH: \
@@ -4235,10 +4281,14 @@ x_set_glyph_string_background_width (s, start, last_x)
4235 return in *REAL_END the real end position for display. This can be 4281 return in *REAL_END the real end position for display. This can be
4236 different from END in case overlapping glyphs must be displayed. 4282 different from END in case overlapping glyphs must be displayed.
4237 4283
4284 If OVERLAPS_P is non-zero, draw only the foreground of characters
4285 and clip to the physical height of ROW.
4286
4238 Value is the x-position reached, relative to AREA of W. */ 4287 Value is the x-position reached, relative to AREA of W. */
4239 4288
4240static int 4289static int
4241x_draw_glyphs (w, x, row, area, start, end, hl, real_start, real_end) 4290x_draw_glyphs (w, x, row, area, start, end, hl, real_start, real_end,
4291 overlaps_p)
4242 struct window *w; 4292 struct window *w;
4243 int x; 4293 int x;
4244 struct glyph_row *row; 4294 struct glyph_row *row;
@@ -4246,6 +4296,7 @@ x_draw_glyphs (w, x, row, area, start, end, hl, real_start, real_end)
4246 int start, end; 4296 int start, end;
4247 enum draw_glyphs_face hl; 4297 enum draw_glyphs_face hl;
4248 int *real_start, *real_end; 4298 int *real_start, *real_end;
4299 int overlaps_p;
4249{ 4300{
4250 struct glyph_string *head, *tail; 4301 struct glyph_string *head, *tail;
4251 struct glyph_string *s; 4302 struct glyph_string *s;
@@ -4299,7 +4350,8 @@ x_draw_glyphs (w, x, row, area, start, end, hl, real_start, real_end)
4299 BUILD_GLYPH_STRINGS will modify its start parameter. That's 4350 BUILD_GLYPH_STRINGS will modify its start parameter. That's
4300 the reason we use a separate variable `i'. */ 4351 the reason we use a separate variable `i'. */
4301 i = start; 4352 i = start;
4302 BUILD_GLYPH_STRINGS (w, row, area, i, end, head, tail, hl, x, last_x); 4353 BUILD_GLYPH_STRINGS (w, row, area, i, end, head, tail, hl, x, last_x,
4354 overlaps_p);
4303 if (tail) 4355 if (tail)
4304 x_reached = tail->x + tail->background_width; 4356 x_reached = tail->x + tail->background_width;
4305 else 4357 else
@@ -4308,7 +4360,7 @@ x_draw_glyphs (w, x, row, area, start, end, hl, real_start, real_end)
4308 /* If there are any glyphs with lbearing < 0 or rbearing > width in 4360 /* If there are any glyphs with lbearing < 0 or rbearing > width in
4309 the row, redraw some glyphs in front or following the glyph 4361 the row, redraw some glyphs in front or following the glyph
4310 strings built above. */ 4362 strings built above. */
4311 if (row->contains_overlapping_glyphs_p) 4363 if (!overlaps_p && row->contains_overlapping_glyphs_p)
4312 { 4364 {
4313 int dummy_x = 0; 4365 int dummy_x = 0;
4314 struct glyph_string *h, *t; 4366 struct glyph_string *h, *t;
@@ -4327,7 +4379,8 @@ x_draw_glyphs (w, x, row, area, start, end, hl, real_start, real_end)
4327 { 4379 {
4328 j = i; 4380 j = i;
4329 BUILD_GLYPH_STRINGS (w, row, area, j, start, h, t, 4381 BUILD_GLYPH_STRINGS (w, row, area, j, start, h, t,
4330 DRAW_NORMAL_TEXT, dummy_x, last_x); 4382 DRAW_NORMAL_TEXT, dummy_x, last_x,
4383 overlaps_p);
4331 start = i; 4384 start = i;
4332 if (real_start) 4385 if (real_start)
4333 *real_start = start; 4386 *real_start = start;
@@ -4346,7 +4399,8 @@ x_draw_glyphs (w, x, row, area, start, end, hl, real_start, real_end)
4346 if (i >= 0) 4399 if (i >= 0)
4347 { 4400 {
4348 BUILD_GLYPH_STRINGS (w, row, area, i, start, h, t, 4401 BUILD_GLYPH_STRINGS (w, row, area, i, start, h, t,
4349 DRAW_NORMAL_TEXT, dummy_x, last_x); 4402 DRAW_NORMAL_TEXT, dummy_x, last_x,
4403 overlaps_p);
4350 for (s = h; s; s = s->next) 4404 for (s = h; s; s = s->next)
4351 s->background_filled_p = 1; 4405 s->background_filled_p = 1;
4352 if (real_start) 4406 if (real_start)
@@ -4363,7 +4417,8 @@ x_draw_glyphs (w, x, row, area, start, end, hl, real_start, real_end)
4363 if (i >= 0) 4417 if (i >= 0)
4364 { 4418 {
4365 BUILD_GLYPH_STRINGS (w, row, area, end, i, h, t, 4419 BUILD_GLYPH_STRINGS (w, row, area, end, i, h, t,
4366 DRAW_NORMAL_TEXT, x, last_x); 4420 DRAW_NORMAL_TEXT, x, last_x,
4421 overlaps_p);
4367 x_compute_overhangs_and_x (h, tail->x + tail->width, 0); 4422 x_compute_overhangs_and_x (h, tail->x + tail->width, 0);
4368 x_append_glyph_string_lists (&head, &tail, h, t); 4423 x_append_glyph_string_lists (&head, &tail, h, t);
4369 if (real_end) 4424 if (real_end)
@@ -4379,7 +4434,8 @@ x_draw_glyphs (w, x, row, area, start, end, hl, real_start, real_end)
4379 if (i >= 0) 4434 if (i >= 0)
4380 { 4435 {
4381 BUILD_GLYPH_STRINGS (w, row, area, end, i, h, t, 4436 BUILD_GLYPH_STRINGS (w, row, area, end, i, h, t,
4382 DRAW_NORMAL_TEXT, x, last_x); 4437 DRAW_NORMAL_TEXT, x, last_x,
4438 overlaps_p);
4383 for (s = h; s; s = s->next) 4439 for (s = h; s; s = s->next)
4384 s->background_filled_p = 1; 4440 s->background_filled_p = 1;
4385 x_compute_overhangs_and_x (h, tail->x + tail->width, 0); 4441 x_compute_overhangs_and_x (h, tail->x + tail->width, 0);
@@ -4407,6 +4463,56 @@ x_draw_glyphs (w, x, row, area, start, end, hl, real_start, real_end)
4407} 4463}
4408 4464
4409 4465
4466/* Fix the display of area AREA of overlapping row ROW in window W. */
4467
4468static void
4469x_fix_overlapping_area (w, row, area)
4470 struct window *w;
4471 struct glyph_row *row;
4472 enum glyph_row_area area;
4473{
4474 int i, x;
4475
4476 BLOCK_INPUT;
4477
4478 if (area == LEFT_MARGIN_AREA)
4479 x = 0;
4480 else if (area == TEXT_AREA)
4481 x = row->x + window_box_width (w, LEFT_MARGIN_AREA);
4482 else
4483 x = (window_box_width (w, LEFT_MARGIN_AREA)
4484 + window_box_width (w, TEXT_AREA));
4485
4486 for (i = 0; i < row->used[area];)
4487 {
4488 if (row->glyphs[area][i].overlaps_vertically_p)
4489 {
4490 int start = i, start_x = x;
4491
4492 do
4493 {
4494 x += row->glyphs[area][i].pixel_width;
4495 ++i;
4496 }
4497 while (i < row->used[area]
4498 && row->glyphs[area][i].overlaps_vertically_p);
4499
4500 x_draw_glyphs (w, start_x, row, area, start, i,
4501 (row->inverse_p
4502 ? DRAW_INVERSE_VIDEO : DRAW_NORMAL_TEXT),
4503 NULL, NULL, 1);
4504 }
4505 else
4506 {
4507 x += row->glyphs[area][i].pixel_width;
4508 ++i;
4509 }
4510 }
4511
4512 UNBLOCK_INPUT;
4513}
4514
4515
4410/* Output LEN glyphs starting at START at the nominal cursor position. 4516/* Output LEN glyphs starting at START at the nominal cursor position.
4411 Advance the nominal cursor over the text. The global variable 4517 Advance the nominal cursor over the text. The global variable
4412 updated_window contains the window being updated, updated_row is 4518 updated_window contains the window being updated, updated_row is
@@ -4431,7 +4537,7 @@ x_write_glyphs (start, len)
4431 hpos, hpos + len, 4537 hpos, hpos + len,
4432 (updated_row->inverse_p 4538 (updated_row->inverse_p
4433 ? DRAW_INVERSE_VIDEO : DRAW_NORMAL_TEXT), 4539 ? DRAW_INVERSE_VIDEO : DRAW_NORMAL_TEXT),
4434 &real_start, &real_end); 4540 &real_start, &real_end, 0);
4435 4541
4436 /* If we drew over the cursor, note that it is not visible any more. */ 4542 /* If we drew over the cursor, note that it is not visible any more. */
4437 note_overwritten_text_cursor (updated_window, real_start, 4543 note_overwritten_text_cursor (updated_window, real_start,
@@ -4490,7 +4596,7 @@ x_insert_glyphs (start, len)
4490 /* Write the glyphs. */ 4596 /* Write the glyphs. */
4491 hpos = start - row->glyphs[updated_area]; 4597 hpos = start - row->glyphs[updated_area];
4492 x_draw_glyphs (w, output_cursor.x, row, updated_area, hpos, hpos + len, 4598 x_draw_glyphs (w, output_cursor.x, row, updated_area, hpos, hpos + len,
4493 DRAW_NORMAL_TEXT, &real_start, &real_end); 4599 DRAW_NORMAL_TEXT, &real_start, &real_end, 0);
4494 note_overwritten_text_cursor (w, real_start, real_end - real_start); 4600 note_overwritten_text_cursor (w, real_start, real_end - real_start);
4495 4601
4496 /* Advance the output cursor. */ 4602 /* Advance the output cursor. */
@@ -5091,7 +5197,7 @@ expose_area (w, row, r, area)
5091 first - row->glyphs[area], 5197 first - row->glyphs[area],
5092 last - row->glyphs[area], 5198 last - row->glyphs[area],
5093 row->inverse_p ? DRAW_INVERSE_VIDEO : DRAW_NORMAL_TEXT, 5199 row->inverse_p ? DRAW_INVERSE_VIDEO : DRAW_NORMAL_TEXT,
5094 NULL, NULL); 5200 NULL, NULL, 0);
5095} 5201}
5096 5202
5097 5203
@@ -5109,7 +5215,7 @@ expose_line (w, row, r)
5109 if (row->mode_line_p || w->pseudo_window_p) 5215 if (row->mode_line_p || w->pseudo_window_p)
5110 x_draw_glyphs (w, 0, row, TEXT_AREA, 0, row->used[TEXT_AREA], 5216 x_draw_glyphs (w, 0, row, TEXT_AREA, 0, row->used[TEXT_AREA],
5111 row->inverse_p ? DRAW_INVERSE_VIDEO : DRAW_NORMAL_TEXT, 5217 row->inverse_p ? DRAW_INVERSE_VIDEO : DRAW_NORMAL_TEXT,
5112 NULL, NULL); 5218 NULL, NULL, 0);
5113 else 5219 else
5114 { 5220 {
5115 if (row->used[LEFT_MARGIN_AREA]) 5221 if (row->used[LEFT_MARGIN_AREA])
@@ -6583,7 +6689,7 @@ show_mouse_face (dpyinfo, draw)
6583 6689
6584 if (end_hpos > start_hpos) 6690 if (end_hpos > start_hpos)
6585 x_draw_glyphs (w, start_x, row, updated_area, 6691 x_draw_glyphs (w, start_x, row, updated_area,
6586 start_hpos, end_hpos, draw, NULL, NULL); 6692 start_hpos, end_hpos, draw, NULL, NULL, 0);
6587 } 6693 }
6588 6694
6589 /* If we turned the cursor off, turn it back on. */ 6695 /* If we turned the cursor off, turn it back on. */
@@ -9771,8 +9877,25 @@ x_draw_phys_cursor_glyph (w, row, hl)
9771 happen in mini-buffer windows when switching between echo area 9877 happen in mini-buffer windows when switching between echo area
9772 glyphs and mini-buffer. */ 9878 glyphs and mini-buffer. */
9773 if (w->phys_cursor.hpos < row->used[TEXT_AREA]) 9879 if (w->phys_cursor.hpos < row->used[TEXT_AREA])
9774 x_draw_glyphs (w, w->phys_cursor.x, row, TEXT_AREA, 9880 {
9775 w->phys_cursor.hpos, w->phys_cursor.hpos + 1, hl, 0, 0); 9881 x_draw_glyphs (w, w->phys_cursor.x, row, TEXT_AREA,
9882 w->phys_cursor.hpos, w->phys_cursor.hpos + 1,
9883 hl, 0, 0, 0);
9884
9885 /* When we erase the cursor, and ROW is overlapped by other
9886 rows, make sure that these overlapping parts of other rows
9887 are redrawn. */
9888 if (hl == DRAW_NORMAL_TEXT && row->overlapped_p)
9889 {
9890 if (row > w->current_matrix->rows
9891 && MATRIX_ROW_OVERLAPS_SUCC_P (row - 1))
9892 x_fix_overlapping_area (w, row - 1, TEXT_AREA);
9893
9894 if (MATRIX_ROW_BOTTOM_Y (row) < window_text_bottom_y (w)
9895 && MATRIX_ROW_OVERLAPS_PRED_P (row + 1))
9896 x_fix_overlapping_area (w, row + 1, TEXT_AREA);
9897 }
9898 }
9776} 9899}
9777 9900
9778 9901
@@ -12619,7 +12742,8 @@ static struct redisplay_interface x_redisplay_interface =
12619 x_update_window_end, 12742 x_update_window_end,
12620 XTcursor_to, 12743 XTcursor_to,
12621 x_flush, 12744 x_flush,
12622 x_get_glyph_overhangs 12745 x_get_glyph_overhangs,
12746 x_fix_overlapping_area
12623}; 12747};
12624 12748
12625void 12749void