diff options
| author | YAMAMOTO Mitsuharu | 2005-10-07 07:39:17 +0000 |
|---|---|---|
| committer | YAMAMOTO Mitsuharu | 2005-10-07 07:39:17 +0000 |
| commit | a66678fd3c23322bdebbe285086e9a6d9db1593d (patch) | |
| tree | 77ea2e261128e80a60f7bedf856b30d8ff72f643 /src | |
| parent | 41124e0631d5db6b8702a1cf0797ba4622308c98 (diff) | |
| download | emacs-a66678fd3c23322bdebbe285086e9a6d9db1593d.tar.gz emacs-a66678fd3c23322bdebbe285086e9a6d9db1593d.zip | |
Rename member for_overlaps_p in struct glyph_string to
for_overlaps.
(get_glyph_string_clip_rects): New function created from
get_glyph_string_clip_rect. Set clipping rectangles according to
the value of for_overlaps. Enable to store multiple clipping
rectangles.
(get_glyph_string_clip_rect): Use get_glyph_string_clip_rects.
(fill_composite_glyph_string, fill_glyph_string, draw_glyphs):
Rename argument OVERLAPS_P to OVERLAPS. All uses in macros changed.
(x_fix_overlapping_area): Add OVERLAPS arg. Pass it to draw_glyphs.
(draw_phys_cursor_glyph): Set width of erased cursor to use it for
calculating clipping rectangles later. Call
x_fix_overlapping_area with new OVERLAPS arg to draw only erased
cursor area.
(expose_overlaps): Call x_fix_overlapping_area with new
OVERLAPS arg to draw overlaps in both preceding and succeeding rows.
Diffstat (limited to 'src')
| -rw-r--r-- | src/xdisp.c | 161 |
1 files changed, 128 insertions, 33 deletions
diff --git a/src/xdisp.c b/src/xdisp.c index 2dd48757470..9e29bfa0e46 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -1768,15 +1768,20 @@ frame_to_window_pixel_xy (w, x, y) | |||
| 1768 | } | 1768 | } |
| 1769 | 1769 | ||
| 1770 | /* EXPORT: | 1770 | /* EXPORT: |
| 1771 | Return in *R the clipping rectangle for glyph string S. */ | 1771 | Return in RECTS[] at most N clipping rectangles for glyph string S. |
| 1772 | Return the number of stored rectangles. */ | ||
| 1772 | 1773 | ||
| 1773 | void | 1774 | int |
| 1774 | get_glyph_string_clip_rect (s, nr) | 1775 | get_glyph_string_clip_rects (s, rects, n) |
| 1775 | struct glyph_string *s; | 1776 | struct glyph_string *s; |
| 1776 | NativeRectangle *nr; | 1777 | NativeRectangle *rects; |
| 1778 | int n; | ||
| 1777 | { | 1779 | { |
| 1778 | XRectangle r; | 1780 | XRectangle r; |
| 1779 | 1781 | ||
| 1782 | if (n <= 0) | ||
| 1783 | return 0; | ||
| 1784 | |||
| 1780 | if (s->row->full_width_p) | 1785 | if (s->row->full_width_p) |
| 1781 | { | 1786 | { |
| 1782 | /* Draw full-width. X coordinates are relative to S->w->left_col. */ | 1787 | /* Draw full-width. X coordinates are relative to S->w->left_col. */ |
| @@ -1819,10 +1824,27 @@ get_glyph_string_clip_rect (s, nr) | |||
| 1819 | /* If S draws overlapping rows, it's sufficient to use the top and | 1824 | /* If S draws overlapping rows, it's sufficient to use the top and |
| 1820 | bottom of the window for clipping because this glyph string | 1825 | bottom of the window for clipping because this glyph string |
| 1821 | intentionally draws over other lines. */ | 1826 | intentionally draws over other lines. */ |
| 1822 | if (s->for_overlaps_p) | 1827 | if (s->for_overlaps) |
| 1823 | { | 1828 | { |
| 1824 | r.y = WINDOW_HEADER_LINE_HEIGHT (s->w); | 1829 | r.y = WINDOW_HEADER_LINE_HEIGHT (s->w); |
| 1825 | r.height = window_text_bottom_y (s->w) - r.y; | 1830 | r.height = window_text_bottom_y (s->w) - r.y; |
| 1831 | |||
| 1832 | /* Alas, the above simple strategy does not work for the | ||
| 1833 | environments with anti-aliased text: if the same text is | ||
| 1834 | drawn onto the same place multiple times, it gets thicker. | ||
| 1835 | If the overlap we are processing is for the erased cursor, we | ||
| 1836 | take the intersection with the rectagle of the cursor. */ | ||
| 1837 | if (s->for_overlaps & OVERLAPS_ERASED_CURSOR) | ||
| 1838 | { | ||
| 1839 | XRectangle rc, r_save = r; | ||
| 1840 | |||
| 1841 | rc.x = WINDOW_TEXT_TO_FRAME_PIXEL_X (s->w, s->w->phys_cursor.x); | ||
| 1842 | rc.y = s->w->phys_cursor.y; | ||
| 1843 | rc.width = s->w->phys_cursor_width; | ||
| 1844 | rc.height = s->w->phys_cursor_height; | ||
| 1845 | |||
| 1846 | x_intersect_rectangles (&r_save, &rc, &r); | ||
| 1847 | } | ||
| 1826 | } | 1848 | } |
| 1827 | else | 1849 | else |
| 1828 | { | 1850 | { |
| @@ -1881,11 +1903,71 @@ get_glyph_string_clip_rect (s, nr) | |||
| 1881 | } | 1903 | } |
| 1882 | } | 1904 | } |
| 1883 | 1905 | ||
| 1906 | if ((s->for_overlaps & OVERLAPS_BOTH) == 0 | ||
| 1907 | || (s->for_overlaps & OVERLAPS_BOTH) == OVERLAPS_BOTH && n == 1) | ||
| 1908 | { | ||
| 1884 | #ifdef CONVERT_FROM_XRECT | 1909 | #ifdef CONVERT_FROM_XRECT |
| 1885 | CONVERT_FROM_XRECT (r, *nr); | 1910 | CONVERT_FROM_XRECT (r, *rects); |
| 1886 | #else | 1911 | #else |
| 1887 | *nr = r; | 1912 | *rects = r; |
| 1913 | #endif | ||
| 1914 | return 1; | ||
| 1915 | } | ||
| 1916 | else | ||
| 1917 | { | ||
| 1918 | /* If we are processing overlapping and allowed to return | ||
| 1919 | multiple clipping rectangles, we exclude the row of the glyph | ||
| 1920 | string from the clipping rectangle. This is to avoid drawing | ||
| 1921 | the same text on the environment with anti-aliasing. */ | ||
| 1922 | #ifdef CONVERT_FROM_XRECT | ||
| 1923 | XRectangle rs[2]; | ||
| 1924 | #else | ||
| 1925 | XRectangle *rs = rects; | ||
| 1926 | #endif | ||
| 1927 | int i = 0, row_y = WINDOW_TO_FRAME_PIXEL_Y (s->w, s->row->y); | ||
| 1928 | |||
| 1929 | if (s->for_overlaps & OVERLAPS_PRED) | ||
| 1930 | { | ||
| 1931 | rs[i] = r; | ||
| 1932 | if (r.y + r.height > row_y) | ||
| 1933 | if (r.y < row_y) | ||
| 1934 | rs[i].height = row_y - r.y; | ||
| 1935 | else | ||
| 1936 | rs[i].height = 0; | ||
| 1937 | i++; | ||
| 1938 | } | ||
| 1939 | if (s->for_overlaps & OVERLAPS_SUCC) | ||
| 1940 | { | ||
| 1941 | rs[i] = r; | ||
| 1942 | if (r.y < row_y + s->row->visible_height) | ||
| 1943 | if (r.y + r.height > row_y + s->row->visible_height) | ||
| 1944 | { | ||
| 1945 | rs[i].y = row_y + s->row->visible_height; | ||
| 1946 | rs[i].height = r.y + r.height - rs[i].y; | ||
| 1947 | } | ||
| 1948 | else | ||
| 1949 | rs[i].height = 0; | ||
| 1950 | i++; | ||
| 1951 | } | ||
| 1952 | |||
| 1953 | n = i; | ||
| 1954 | #ifdef CONVERT_FROM_XRECT | ||
| 1955 | for (i = 0; i < n; i++) | ||
| 1956 | CONVERT_FROM_XRECT (rs[i], rects[i]); | ||
| 1888 | #endif | 1957 | #endif |
| 1958 | return n; | ||
| 1959 | } | ||
| 1960 | } | ||
| 1961 | |||
| 1962 | /* EXPORT: | ||
| 1963 | Return in *NR the clipping rectangle for glyph string S. */ | ||
| 1964 | |||
| 1965 | void | ||
| 1966 | get_glyph_string_clip_rect (s, nr) | ||
| 1967 | struct glyph_string *s; | ||
| 1968 | NativeRectangle *nr; | ||
| 1969 | { | ||
| 1970 | get_glyph_string_clip_rects (s, nr, 1); | ||
| 1889 | } | 1971 | } |
| 1890 | 1972 | ||
| 1891 | 1973 | ||
| @@ -18023,22 +18105,23 @@ get_glyph_face_and_encoding (f, glyph, char2b, two_byte_p) | |||
| 18023 | 18105 | ||
| 18024 | FACES is an array of faces for all components of this composition. | 18106 | FACES is an array of faces for all components of this composition. |
| 18025 | S->gidx is the index of the first component for S. | 18107 | S->gidx is the index of the first component for S. |
| 18026 | OVERLAPS_P non-zero means S should draw the foreground only, and | 18108 | |
| 18027 | use its physical height for clipping. | 18109 | OVERLAPS non-zero means S should draw the foreground only, and use |
| 18110 | its physical height for clipping. See also draw_glyphs. | ||
| 18028 | 18111 | ||
| 18029 | Value is the index of a component not in S. */ | 18112 | Value is the index of a component not in S. */ |
| 18030 | 18113 | ||
| 18031 | static int | 18114 | static int |
| 18032 | fill_composite_glyph_string (s, faces, overlaps_p) | 18115 | fill_composite_glyph_string (s, faces, overlaps) |
| 18033 | struct glyph_string *s; | 18116 | struct glyph_string *s; |
| 18034 | struct face **faces; | 18117 | struct face **faces; |
| 18035 | int overlaps_p; | 18118 | int overlaps; |
| 18036 | { | 18119 | { |
| 18037 | int i; | 18120 | int i; |
| 18038 | 18121 | ||
| 18039 | xassert (s); | 18122 | xassert (s); |
| 18040 | 18123 | ||
| 18041 | s->for_overlaps_p = overlaps_p; | 18124 | s->for_overlaps = overlaps; |
| 18042 | 18125 | ||
| 18043 | s->face = faces[s->gidx]; | 18126 | s->face = faces[s->gidx]; |
| 18044 | s->font = s->face->font; | 18127 | s->font = s->face->font; |
| @@ -18082,16 +18165,16 @@ fill_composite_glyph_string (s, faces, overlaps_p) | |||
| 18082 | 18165 | ||
| 18083 | FACE_ID is the face id of the string. START is the index of the | 18166 | FACE_ID is the face id of the string. START is the index of the |
| 18084 | first glyph to consider, END is the index of the last + 1. | 18167 | first glyph to consider, END is the index of the last + 1. |
| 18085 | OVERLAPS_P non-zero means S should draw the foreground only, and | 18168 | OVERLAPS non-zero means S should draw the foreground only, and use |
| 18086 | use its physical height for clipping. | 18169 | its physical height for clipping. See also draw_glyphs. |
| 18087 | 18170 | ||
| 18088 | Value is the index of the first glyph not in S. */ | 18171 | Value is the index of the first glyph not in S. */ |
| 18089 | 18172 | ||
| 18090 | static int | 18173 | static int |
| 18091 | fill_glyph_string (s, face_id, start, end, overlaps_p) | 18174 | fill_glyph_string (s, face_id, start, end, overlaps) |
| 18092 | struct glyph_string *s; | 18175 | struct glyph_string *s; |
| 18093 | int face_id; | 18176 | int face_id; |
| 18094 | int start, end, overlaps_p; | 18177 | int start, end, overlaps; |
| 18095 | { | 18178 | { |
| 18096 | struct glyph *glyph, *last; | 18179 | struct glyph *glyph, *last; |
| 18097 | int voffset; | 18180 | int voffset; |
| @@ -18101,7 +18184,7 @@ fill_glyph_string (s, face_id, start, end, overlaps_p) | |||
| 18101 | xassert (s->nchars == 0); | 18184 | xassert (s->nchars == 0); |
| 18102 | xassert (start >= 0 && end > start); | 18185 | xassert (start >= 0 && end > start); |
| 18103 | 18186 | ||
| 18104 | s->for_overlaps_p = overlaps_p, | 18187 | s->for_overlaps = overlaps, |
| 18105 | glyph = s->row->glyphs[s->area] + start; | 18188 | glyph = s->row->glyphs[s->area] + start; |
| 18106 | last = s->row->glyphs[s->area] + end; | 18189 | last = s->row->glyphs[s->area] + end; |
| 18107 | voffset = glyph->voffset; | 18190 | voffset = glyph->voffset; |
| @@ -18578,7 +18661,7 @@ compute_overhangs_and_x (s, x, backward_p) | |||
| 18578 | INIT_GLYPH_STRING (s, char2b, w, row, area, START, HL); \ | 18661 | INIT_GLYPH_STRING (s, char2b, w, row, area, START, HL); \ |
| 18579 | append_glyph_string (&HEAD, &TAIL, s); \ | 18662 | append_glyph_string (&HEAD, &TAIL, s); \ |
| 18580 | s->x = (X); \ | 18663 | s->x = (X); \ |
| 18581 | START = fill_glyph_string (s, face_id, START, END, overlaps_p); \ | 18664 | START = fill_glyph_string (s, face_id, START, END, overlaps); \ |
| 18582 | } \ | 18665 | } \ |
| 18583 | while (0) | 18666 | while (0) |
| 18584 | 18667 | ||
| @@ -18631,7 +18714,7 @@ compute_overhangs_and_x (s, x, backward_p) | |||
| 18631 | if (n == 0) \ | 18714 | if (n == 0) \ |
| 18632 | first_s = s; \ | 18715 | first_s = s; \ |
| 18633 | \ | 18716 | \ |
| 18634 | n = fill_composite_glyph_string (s, faces, overlaps_p); \ | 18717 | n = fill_composite_glyph_string (s, faces, overlaps); \ |
| 18635 | } \ | 18718 | } \ |
| 18636 | \ | 18719 | \ |
| 18637 | ++START; \ | 18720 | ++START; \ |
| @@ -18700,20 +18783,26 @@ compute_overhangs_and_x (s, x, backward_p) | |||
| 18700 | DRAW_IMAGE_SUNKEN draw an image with a sunken relief around it | 18783 | DRAW_IMAGE_SUNKEN draw an image with a sunken relief around it |
| 18701 | DRAW_IMAGE_RAISED draw an image with a raised relief around it | 18784 | DRAW_IMAGE_RAISED draw an image with a raised relief around it |
| 18702 | 18785 | ||
| 18703 | If OVERLAPS_P is non-zero, draw only the foreground of characters | 18786 | If OVERLAPS is non-zero, draw only the foreground of characters and |
| 18704 | and clip to the physical height of ROW. | 18787 | clip to the physical height of ROW. Non-zero value also defines |
| 18788 | the overlapping part to be drawn: | ||
| 18789 | |||
| 18790 | OVERLAPS_PRED overlap with preceding rows | ||
| 18791 | OVERLAPS_SUCC overlap with succeeding rows | ||
| 18792 | OVERLAPS_BOTH overlap with both preceding/succeeding rows | ||
| 18793 | OVERLAPS_ERASED_CURSOR overlap with erased cursor area | ||
| 18705 | 18794 | ||
| 18706 | Value is the x-position reached, relative to AREA of W. */ | 18795 | Value is the x-position reached, relative to AREA of W. */ |
| 18707 | 18796 | ||
| 18708 | static int | 18797 | static int |
| 18709 | draw_glyphs (w, x, row, area, start, end, hl, overlaps_p) | 18798 | draw_glyphs (w, x, row, area, start, end, hl, overlaps) |
| 18710 | struct window *w; | 18799 | struct window *w; |
| 18711 | int x; | 18800 | int x; |
| 18712 | struct glyph_row *row; | 18801 | struct glyph_row *row; |
| 18713 | enum glyph_row_area area; | 18802 | enum glyph_row_area area; |
| 18714 | int start, end; | 18803 | int start, end; |
| 18715 | enum draw_glyphs_face hl; | 18804 | enum draw_glyphs_face hl; |
| 18716 | int overlaps_p; | 18805 | int overlaps; |
| 18717 | { | 18806 | { |
| 18718 | struct glyph_string *head, *tail; | 18807 | struct glyph_string *head, *tail; |
| 18719 | struct glyph_string *s; | 18808 | struct glyph_string *s; |
| @@ -18762,7 +18851,7 @@ draw_glyphs (w, x, row, area, start, end, hl, overlaps_p) | |||
| 18762 | /* If there are any glyphs with lbearing < 0 or rbearing > width in | 18851 | /* If there are any glyphs with lbearing < 0 or rbearing > width in |
| 18763 | the row, redraw some glyphs in front or following the glyph | 18852 | the row, redraw some glyphs in front or following the glyph |
| 18764 | strings built above. */ | 18853 | strings built above. */ |
| 18765 | if (head && !overlaps_p && row->contains_overlapping_glyphs_p) | 18854 | if (head && !overlaps && row->contains_overlapping_glyphs_p) |
| 18766 | { | 18855 | { |
| 18767 | int dummy_x = 0; | 18856 | int dummy_x = 0; |
| 18768 | struct glyph_string *h, *t; | 18857 | struct glyph_string *h, *t; |
| @@ -18855,7 +18944,7 @@ draw_glyphs (w, x, row, area, start, end, hl, overlaps_p) | |||
| 18855 | /* When drawing overlapping rows, only the glyph strings' | 18944 | /* When drawing overlapping rows, only the glyph strings' |
| 18856 | foreground is drawn, which doesn't erase a cursor | 18945 | foreground is drawn, which doesn't erase a cursor |
| 18857 | completely. */ | 18946 | completely. */ |
| 18858 | && !overlaps_p) | 18947 | && !overlaps) |
| 18859 | { | 18948 | { |
| 18860 | int x0 = clip_head ? clip_head->x : (head ? head->x : x); | 18949 | int x0 = clip_head ? clip_head->x : (head ? head->x : x); |
| 18861 | int x1 = (clip_tail ? clip_tail->x + clip_tail->background_width | 18950 | int x1 = (clip_tail ? clip_tail->x + clip_tail->background_width |
| @@ -20588,13 +20677,15 @@ notice_overwritten_cursor (w, area, x0, x1, y0, y1) | |||
| 20588 | #ifdef HAVE_WINDOW_SYSTEM | 20677 | #ifdef HAVE_WINDOW_SYSTEM |
| 20589 | 20678 | ||
| 20590 | /* EXPORT for RIF: | 20679 | /* EXPORT for RIF: |
| 20591 | Fix the display of area AREA of overlapping row ROW in window W. */ | 20680 | Fix the display of area AREA of overlapping row ROW in window W |
| 20681 | with respect to the overlapping part OVERLAPS. */ | ||
| 20592 | 20682 | ||
| 20593 | void | 20683 | void |
| 20594 | x_fix_overlapping_area (w, row, area) | 20684 | x_fix_overlapping_area (w, row, area, overlaps) |
| 20595 | struct window *w; | 20685 | struct window *w; |
| 20596 | struct glyph_row *row; | 20686 | struct glyph_row *row; |
| 20597 | enum glyph_row_area area; | 20687 | enum glyph_row_area area; |
| 20688 | int overlaps; | ||
| 20598 | { | 20689 | { |
| 20599 | int i, x; | 20690 | int i, x; |
| 20600 | 20691 | ||
| @@ -20617,7 +20708,7 @@ x_fix_overlapping_area (w, row, area) | |||
| 20617 | 20708 | ||
| 20618 | draw_glyphs (w, start_x, row, area, | 20709 | draw_glyphs (w, start_x, row, area, |
| 20619 | start, i, | 20710 | start, i, |
| 20620 | DRAW_NORMAL_TEXT, 1); | 20711 | DRAW_NORMAL_TEXT, overlaps); |
| 20621 | } | 20712 | } |
| 20622 | else | 20713 | else |
| 20623 | { | 20714 | { |
| @@ -20659,13 +20750,17 @@ draw_phys_cursor_glyph (w, row, hl) | |||
| 20659 | are redrawn. */ | 20750 | are redrawn. */ |
| 20660 | else if (hl == DRAW_NORMAL_TEXT && row->overlapped_p) | 20751 | else if (hl == DRAW_NORMAL_TEXT && row->overlapped_p) |
| 20661 | { | 20752 | { |
| 20753 | w->phys_cursor_width = x1 - w->phys_cursor.x; | ||
| 20754 | |||
| 20662 | if (row > w->current_matrix->rows | 20755 | if (row > w->current_matrix->rows |
| 20663 | && MATRIX_ROW_OVERLAPS_SUCC_P (row - 1)) | 20756 | && MATRIX_ROW_OVERLAPS_SUCC_P (row - 1)) |
| 20664 | x_fix_overlapping_area (w, row - 1, TEXT_AREA); | 20757 | x_fix_overlapping_area (w, row - 1, TEXT_AREA, |
| 20758 | OVERLAPS_ERASED_CURSOR); | ||
| 20665 | 20759 | ||
| 20666 | if (MATRIX_ROW_BOTTOM_Y (row) < window_text_bottom_y (w) | 20760 | if (MATRIX_ROW_BOTTOM_Y (row) < window_text_bottom_y (w) |
| 20667 | && MATRIX_ROW_OVERLAPS_PRED_P (row + 1)) | 20761 | && MATRIX_ROW_OVERLAPS_PRED_P (row + 1)) |
| 20668 | x_fix_overlapping_area (w, row + 1, TEXT_AREA); | 20762 | x_fix_overlapping_area (w, row + 1, TEXT_AREA, |
| 20763 | OVERLAPS_ERASED_CURSOR); | ||
| 20669 | } | 20764 | } |
| 20670 | } | 20765 | } |
| 20671 | } | 20766 | } |
| @@ -22456,13 +22551,13 @@ expose_overlaps (w, first_overlapping_row, last_overlapping_row) | |||
| 22456 | xassert (row->enabled_p && !row->mode_line_p); | 22551 | xassert (row->enabled_p && !row->mode_line_p); |
| 22457 | 22552 | ||
| 22458 | if (row->used[LEFT_MARGIN_AREA]) | 22553 | if (row->used[LEFT_MARGIN_AREA]) |
| 22459 | x_fix_overlapping_area (w, row, LEFT_MARGIN_AREA); | 22554 | x_fix_overlapping_area (w, row, LEFT_MARGIN_AREA, OVERLAPS_BOTH); |
| 22460 | 22555 | ||
| 22461 | if (row->used[TEXT_AREA]) | 22556 | if (row->used[TEXT_AREA]) |
| 22462 | x_fix_overlapping_area (w, row, TEXT_AREA); | 22557 | x_fix_overlapping_area (w, row, TEXT_AREA, OVERLAPS_BOTH); |
| 22463 | 22558 | ||
| 22464 | if (row->used[RIGHT_MARGIN_AREA]) | 22559 | if (row->used[RIGHT_MARGIN_AREA]) |
| 22465 | x_fix_overlapping_area (w, row, RIGHT_MARGIN_AREA); | 22560 | x_fix_overlapping_area (w, row, RIGHT_MARGIN_AREA, OVERLAPS_BOTH); |
| 22466 | } | 22561 | } |
| 22467 | } | 22562 | } |
| 22468 | 22563 | ||