aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/dispextern.h3
-rw-r--r--src/xdisp.c1
-rw-r--r--src/xfont.c19
-rw-r--r--src/xterm.c141
4 files changed, 90 insertions, 74 deletions
diff --git a/src/dispextern.h b/src/dispextern.h
index bb981f83fca..619f4c07675 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -1281,9 +1281,6 @@ struct glyph_string
1281 /* The window on which the glyph string is drawn. */ 1281 /* The window on which the glyph string is drawn. */
1282 struct window *w; 1282 struct window *w;
1283 1283
1284 /* X display and window for convenience. */
1285 Display *display;
1286
1287 /* The glyph row for which this string was built. It determines the 1284 /* The glyph row for which this string was built. It determines the
1288 y-origin and height of the string. */ 1285 y-origin and height of the string. */
1289 struct glyph_row *row; 1286 struct glyph_row *row;
diff --git a/src/xdisp.c b/src/xdisp.c
index d380645c849..1aa677fcc78 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -25953,7 +25953,6 @@ init_glyph_string (struct glyph_string *s,
25953#ifdef HAVE_NTGUI 25953#ifdef HAVE_NTGUI
25954 s->hdc = hdc; 25954 s->hdc = hdc;
25955#endif 25955#endif
25956 s->display = FRAME_X_DISPLAY (s->f);
25957 s->char2b = char2b; 25956 s->char2b = char2b;
25958 s->hl = hl; 25957 s->hl = hl;
25959 s->row = row; 25958 s->row = row;
diff --git a/src/xfont.c b/src/xfont.c
index 5ecbd6de33b..ff80df407d7 100644
--- a/src/xfont.c
+++ b/src/xfont.c
@@ -1000,6 +1000,7 @@ xfont_draw (struct glyph_string *s, int from, int to, int x, int y,
1000 bool with_background) 1000 bool with_background)
1001{ 1001{
1002 XFontStruct *xfont = ((struct xfont_info *) s->font)->xfont; 1002 XFontStruct *xfont = ((struct xfont_info *) s->font)->xfont;
1003 Display *display = FRAME_X_DISPLAY (s->f);
1003 int len = to - from; 1004 int len = to - from;
1004 GC gc = s->gc; 1005 GC gc = s->gc;
1005 int i; 1006 int i;
@@ -1007,7 +1008,7 @@ xfont_draw (struct glyph_string *s, int from, int to, int x, int y,
1007 if (s->gc != s->face->gc) 1008 if (s->gc != s->face->gc)
1008 { 1009 {
1009 block_input (); 1010 block_input ();
1010 XSetFont (s->display, gc, xfont->fid); 1011 XSetFont (display, gc, xfont->fid);
1011 unblock_input (); 1012 unblock_input ();
1012 } 1013 }
1013 1014
@@ -1022,20 +1023,20 @@ xfont_draw (struct glyph_string *s, int from, int to, int x, int y,
1022 { 1023 {
1023 if (s->padding_p) 1024 if (s->padding_p)
1024 for (i = 0; i < len; i++) 1025 for (i = 0; i < len; i++)
1025 XDrawImageString (FRAME_X_DISPLAY (s->f), FRAME_X_DRAWABLE (s->f), 1026 XDrawImageString (display, FRAME_X_DRAWABLE (s->f),
1026 gc, x + i, y, str + i, 1); 1027 gc, x + i, y, str + i, 1);
1027 else 1028 else
1028 XDrawImageString (FRAME_X_DISPLAY (s->f), FRAME_X_DRAWABLE (s->f), 1029 XDrawImageString (display, FRAME_X_DRAWABLE (s->f),
1029 gc, x, y, str, len); 1030 gc, x, y, str, len);
1030 } 1031 }
1031 else 1032 else
1032 { 1033 {
1033 if (s->padding_p) 1034 if (s->padding_p)
1034 for (i = 0; i < len; i++) 1035 for (i = 0; i < len; i++)
1035 XDrawString (FRAME_X_DISPLAY (s->f), FRAME_X_DRAWABLE (s->f), 1036 XDrawString (display, FRAME_X_DRAWABLE (s->f),
1036 gc, x + i, y, str + i, 1); 1037 gc, x + i, y, str + i, 1);
1037 else 1038 else
1038 XDrawString (FRAME_X_DISPLAY (s->f), FRAME_X_DRAWABLE (s->f), 1039 XDrawString (display, FRAME_X_DRAWABLE (s->f),
1039 gc, x, y, str, len); 1040 gc, x, y, str, len);
1040 } 1041 }
1041 unblock_input (); 1042 unblock_input ();
@@ -1048,20 +1049,20 @@ xfont_draw (struct glyph_string *s, int from, int to, int x, int y,
1048 { 1049 {
1049 if (s->padding_p) 1050 if (s->padding_p)
1050 for (i = 0; i < len; i++) 1051 for (i = 0; i < len; i++)
1051 XDrawImageString16 (FRAME_X_DISPLAY (s->f), FRAME_X_DRAWABLE (s->f), 1052 XDrawImageString16 (display, FRAME_X_DRAWABLE (s->f),
1052 gc, x + i, y, s->char2b + from + i, 1); 1053 gc, x + i, y, s->char2b + from + i, 1);
1053 else 1054 else
1054 XDrawImageString16 (FRAME_X_DISPLAY (s->f), FRAME_X_DRAWABLE (s->f), 1055 XDrawImageString16 (display, FRAME_X_DRAWABLE (s->f),
1055 gc, x, y, s->char2b + from, len); 1056 gc, x, y, s->char2b + from, len);
1056 } 1057 }
1057 else 1058 else
1058 { 1059 {
1059 if (s->padding_p) 1060 if (s->padding_p)
1060 for (i = 0; i < len; i++) 1061 for (i = 0; i < len; i++)
1061 XDrawString16 (FRAME_X_DISPLAY (s->f), FRAME_X_DRAWABLE (s->f), 1062 XDrawString16 (display, FRAME_X_DRAWABLE (s->f),
1062 gc, x + i, y, s->char2b + from + i, 1); 1063 gc, x + i, y, s->char2b + from + i, 1);
1063 else 1064 else
1064 XDrawString16 (FRAME_X_DISPLAY (s->f), FRAME_X_DRAWABLE (s->f), 1065 XDrawString16 (display, FRAME_X_DRAWABLE (s->f),
1065 gc, x, y, s->char2b + from, len); 1066 gc, x, y, s->char2b + from, len);
1066 } 1067 }
1067 unblock_input (); 1068 unblock_input ();
diff --git a/src/xterm.c b/src/xterm.c
index 26f74cde91d..bd69e6c7a82 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -1454,6 +1454,7 @@ x_set_cursor_gc (struct glyph_string *s)
1454 /* Cursor on non-default face: must merge. */ 1454 /* Cursor on non-default face: must merge. */
1455 XGCValues xgcv; 1455 XGCValues xgcv;
1456 unsigned long mask; 1456 unsigned long mask;
1457 Display *display = FRAME_X_DISPLAY (s->f);
1457 1458
1458 xgcv.background = s->f->output_data.x->cursor_pixel; 1459 xgcv.background = s->f->output_data.x->cursor_pixel;
1459 xgcv.foreground = s->face->background; 1460 xgcv.foreground = s->face->background;
@@ -1479,11 +1480,11 @@ x_set_cursor_gc (struct glyph_string *s)
1479 mask = GCForeground | GCBackground | GCGraphicsExposures; 1480 mask = GCForeground | GCBackground | GCGraphicsExposures;
1480 1481
1481 if (FRAME_DISPLAY_INFO (s->f)->scratch_cursor_gc) 1482 if (FRAME_DISPLAY_INFO (s->f)->scratch_cursor_gc)
1482 XChangeGC (s->display, FRAME_DISPLAY_INFO (s->f)->scratch_cursor_gc, 1483 XChangeGC (display, FRAME_DISPLAY_INFO (s->f)->scratch_cursor_gc,
1483 mask, &xgcv); 1484 mask, &xgcv);
1484 else 1485 else
1485 FRAME_DISPLAY_INFO (s->f)->scratch_cursor_gc 1486 FRAME_DISPLAY_INFO (s->f)->scratch_cursor_gc
1486 = XCreateGC (s->display, FRAME_X_DRAWABLE (s->f), mask, &xgcv); 1487 = XCreateGC (display, FRAME_X_DRAWABLE (s->f), mask, &xgcv);
1487 1488
1488 s->gc = FRAME_DISPLAY_INFO (s->f)->scratch_cursor_gc; 1489 s->gc = FRAME_DISPLAY_INFO (s->f)->scratch_cursor_gc;
1489 } 1490 }
@@ -1519,6 +1520,7 @@ x_set_mouse_face_gc (struct glyph_string *s)
1519 except for FONT. */ 1520 except for FONT. */
1520 XGCValues xgcv; 1521 XGCValues xgcv;
1521 unsigned long mask; 1522 unsigned long mask;
1523 Display *display = FRAME_X_DISPLAY (s->f);
1522 1524
1523 xgcv.background = s->face->background; 1525 xgcv.background = s->face->background;
1524 xgcv.foreground = s->face->foreground; 1526 xgcv.foreground = s->face->foreground;
@@ -1526,11 +1528,11 @@ x_set_mouse_face_gc (struct glyph_string *s)
1526 mask = GCForeground | GCBackground | GCGraphicsExposures; 1528 mask = GCForeground | GCBackground | GCGraphicsExposures;
1527 1529
1528 if (FRAME_DISPLAY_INFO (s->f)->scratch_cursor_gc) 1530 if (FRAME_DISPLAY_INFO (s->f)->scratch_cursor_gc)
1529 XChangeGC (s->display, FRAME_DISPLAY_INFO (s->f)->scratch_cursor_gc, 1531 XChangeGC (display, FRAME_DISPLAY_INFO (s->f)->scratch_cursor_gc,
1530 mask, &xgcv); 1532 mask, &xgcv);
1531 else 1533 else
1532 FRAME_DISPLAY_INFO (s->f)->scratch_cursor_gc 1534 FRAME_DISPLAY_INFO (s->f)->scratch_cursor_gc
1533 = XCreateGC (s->display, FRAME_X_DRAWABLE (s->f), mask, &xgcv); 1535 = XCreateGC (display, FRAME_X_DRAWABLE (s->f), mask, &xgcv);
1534 1536
1535 s->gc = FRAME_DISPLAY_INFO (s->f)->scratch_cursor_gc; 1537 s->gc = FRAME_DISPLAY_INFO (s->f)->scratch_cursor_gc;
1536 1538
@@ -1672,11 +1674,12 @@ x_compute_glyph_string_overhangs (struct glyph_string *s)
1672static void 1674static void
1673x_clear_glyph_string_rect (struct glyph_string *s, int x, int y, int w, int h) 1675x_clear_glyph_string_rect (struct glyph_string *s, int x, int y, int w, int h)
1674{ 1676{
1677 Display *display = FRAME_X_DISPLAY (s->f);
1675 XGCValues xgcv; 1678 XGCValues xgcv;
1676 XGetGCValues (s->display, s->gc, GCForeground | GCBackground, &xgcv); 1679 XGetGCValues (display, s->gc, GCForeground | GCBackground, &xgcv);
1677 XSetForeground (s->display, s->gc, xgcv.background); 1680 XSetForeground (display, s->gc, xgcv.background);
1678 x_fill_rectangle (s->f, s->gc, x, y, w, h); 1681 x_fill_rectangle (s->f, s->gc, x, y, w, h);
1679 XSetForeground (s->display, s->gc, xgcv.foreground); 1682 XSetForeground (display, s->gc, xgcv.foreground);
1680} 1683}
1681 1684
1682 1685
@@ -1697,13 +1700,15 @@ x_draw_glyph_string_background (struct glyph_string *s, bool force_p)
1697 1700
1698 if (s->stippled_p) 1701 if (s->stippled_p)
1699 { 1702 {
1703 Display *display = FRAME_X_DISPLAY (s->f);
1704
1700 /* Fill background with a stipple pattern. */ 1705 /* Fill background with a stipple pattern. */
1701 XSetFillStyle (s->display, s->gc, FillOpaqueStippled); 1706 XSetFillStyle (display, s->gc, FillOpaqueStippled);
1702 x_fill_rectangle (s->f, s->gc, s->x, 1707 x_fill_rectangle (s->f, s->gc, s->x,
1703 s->y + box_line_width, 1708 s->y + box_line_width,
1704 s->background_width, 1709 s->background_width,
1705 s->height - 2 * box_line_width); 1710 s->height - 2 * box_line_width);
1706 XSetFillStyle (s->display, s->gc, FillSolid); 1711 XSetFillStyle (display, s->gc, FillSolid);
1707 s->background_filled_p = true; 1712 s->background_filled_p = true;
1708 } 1713 }
1709 else if (FONT_HEIGHT (s->font) < s->height - 2 * box_line_width 1714 else if (FONT_HEIGHT (s->font) < s->height - 2 * box_line_width
@@ -2591,7 +2596,7 @@ x_setup_relief_colors (struct glyph_string *s)
2591 XGCValues xgcv; 2596 XGCValues xgcv;
2592 2597
2593 /* Get the background color of the face. */ 2598 /* Get the background color of the face. */
2594 XGetGCValues (s->display, s->gc, GCBackground, &xgcv); 2599 XGetGCValues (FRAME_X_DISPLAY (s->f), s->gc, GCBackground, &xgcv);
2595 color = xgcv.background; 2600 color = xgcv.background;
2596 } 2601 }
2597 2602
@@ -2801,10 +2806,11 @@ x_draw_box_rect (struct glyph_string *s,
2801 int left_x, int top_y, int right_x, int bottom_y, int width, 2806 int left_x, int top_y, int right_x, int bottom_y, int width,
2802 bool left_p, bool right_p, XRectangle *clip_rect) 2807 bool left_p, bool right_p, XRectangle *clip_rect)
2803{ 2808{
2809 Display *display = FRAME_X_DISPLAY (s->f);
2804 XGCValues xgcv; 2810 XGCValues xgcv;
2805 2811
2806 XGetGCValues (s->display, s->gc, GCForeground, &xgcv); 2812 XGetGCValues (display, s->gc, GCForeground, &xgcv);
2807 XSetForeground (s->display, s->gc, s->face->box_color); 2813 XSetForeground (display, s->gc, s->face->box_color);
2808 x_set_clip_rectangles (s->f, s->gc, clip_rect, 1); 2814 x_set_clip_rectangles (s->f, s->gc, clip_rect, 1);
2809 2815
2810 /* Top. */ 2816 /* Top. */
@@ -2825,7 +2831,7 @@ x_draw_box_rect (struct glyph_string *s,
2825 x_fill_rectangle (s->f, s->gc, 2831 x_fill_rectangle (s->f, s->gc,
2826 right_x - width + 1, top_y, width, bottom_y - top_y + 1); 2832 right_x - width + 1, top_y, width, bottom_y - top_y + 1);
2827 2833
2828 XSetForeground (s->display, s->gc, xgcv.foreground); 2834 XSetForeground (display, s->gc, xgcv.foreground);
2829 x_reset_clip_rectangles (s->f, s->gc); 2835 x_reset_clip_rectangles (s->f, s->gc);
2830} 2836}
2831 2837
@@ -2888,6 +2894,7 @@ x_composite_image (struct glyph_string *s, Pixmap dest,
2888 int srcX, int srcY, int dstX, int dstY, 2894 int srcX, int srcY, int dstX, int dstY,
2889 int width, int height) 2895 int width, int height)
2890{ 2896{
2897 Display *display = FRAME_X_DISPLAY (s->f);
2891#ifdef HAVE_XRENDER 2898#ifdef HAVE_XRENDER
2892 if (s->img->picture) 2899 if (s->img->picture)
2893 { 2900 {
@@ -2897,27 +2904,27 @@ x_composite_image (struct glyph_string *s, Pixmap dest,
2897 2904
2898 /* FIXME: Should we do this each time or would it make sense to 2905 /* FIXME: Should we do this each time or would it make sense to
2899 store destination in the frame struct? */ 2906 store destination in the frame struct? */
2900 default_format = XRenderFindVisualFormat (s->display, 2907 default_format = XRenderFindVisualFormat (display,
2901 DefaultVisual (s->display, 0)); 2908 DefaultVisual (display, 0));
2902 destination = XRenderCreatePicture (s->display, dest, 2909 destination = XRenderCreatePicture (display, dest,
2903 default_format, 0, &attr); 2910 default_format, 0, &attr);
2904 2911
2905 /* FIXME: It may make sense to use PictOpSrc instead of 2912 /* FIXME: It may make sense to use PictOpSrc instead of
2906 PictOpOver, as I don't know if we care about alpha values too 2913 PictOpOver, as I don't know if we care about alpha values too
2907 much here. */ 2914 much here. */
2908 XRenderComposite (s->display, PictOpOver, 2915 XRenderComposite (display, PictOpOver,
2909 s->img->picture, s->img->mask_picture, destination, 2916 s->img->picture, s->img->mask_picture, destination,
2910 srcX, srcY, 2917 srcX, srcY,
2911 srcX, srcY, 2918 srcX, srcY,
2912 dstX, dstY, 2919 dstX, dstY,
2913 width, height); 2920 width, height);
2914 2921
2915 XRenderFreePicture (s->display, destination); 2922 XRenderFreePicture (display, destination);
2916 return; 2923 return;
2917 } 2924 }
2918#endif 2925#endif
2919 2926
2920 XCopyArea (s->display, s->img->pixmap, 2927 XCopyArea (display, s->img->pixmap,
2921 dest, s->gc, 2928 dest, s->gc,
2922 srcX, srcY, 2929 srcX, srcY,
2923 width, height, dstX, dstY); 2930 width, height, dstX, dstY);
@@ -2992,7 +2999,7 @@ x_draw_image_foreground (struct glyph_string *s)
2992 xgcv.clip_x_origin = x; 2999 xgcv.clip_x_origin = x;
2993 xgcv.clip_y_origin = y; 3000 xgcv.clip_y_origin = y;
2994 xgcv.function = GXcopy; 3001 xgcv.function = GXcopy;
2995 XChangeGC (s->display, s->gc, mask, &xgcv); 3002 XChangeGC (FRAME_X_DISPLAY (s->f), s->gc, mask, &xgcv);
2996 3003
2997 get_glyph_string_clip_rect (s, &clip_rect); 3004 get_glyph_string_clip_rect (s, &clip_rect);
2998 image_rect.x = x; 3005 image_rect.x = x;
@@ -3141,6 +3148,8 @@ x_draw_image_foreground_1 (struct glyph_string *s, Pixmap pixmap)
3141 3148
3142 if (s->img->pixmap) 3149 if (s->img->pixmap)
3143 { 3150 {
3151 Display *display = FRAME_X_DISPLAY (s->f);
3152
3144 if (s->img->mask) 3153 if (s->img->mask)
3145 { 3154 {
3146 /* We can't set both a clip mask and use XSetClipRectangles 3155 /* We can't set both a clip mask and use XSetClipRectangles
@@ -3156,16 +3165,16 @@ x_draw_image_foreground_1 (struct glyph_string *s, Pixmap pixmap)
3156 xgcv.clip_x_origin = x - s->slice.x; 3165 xgcv.clip_x_origin = x - s->slice.x;
3157 xgcv.clip_y_origin = y - s->slice.y; 3166 xgcv.clip_y_origin = y - s->slice.y;
3158 xgcv.function = GXcopy; 3167 xgcv.function = GXcopy;
3159 XChangeGC (s->display, s->gc, mask, &xgcv); 3168 XChangeGC (display, s->gc, mask, &xgcv);
3160 3169
3161 XCopyArea (s->display, s->img->pixmap, pixmap, s->gc, 3170 XCopyArea (display, s->img->pixmap, pixmap, s->gc,
3162 s->slice.x, s->slice.y, 3171 s->slice.x, s->slice.y,
3163 s->slice.width, s->slice.height, x, y); 3172 s->slice.width, s->slice.height, x, y);
3164 XSetClipMask (s->display, s->gc, None); 3173 XSetClipMask (display, s->gc, None);
3165 } 3174 }
3166 else 3175 else
3167 { 3176 {
3168 XCopyArea (s->display, s->img->pixmap, pixmap, s->gc, 3177 XCopyArea (display, s->img->pixmap, pixmap, s->gc,
3169 s->slice.x, s->slice.y, 3178 s->slice.x, s->slice.y,
3170 s->slice.width, s->slice.height, x, y); 3179 s->slice.width, s->slice.height, x, y);
3171 3180
@@ -3200,10 +3209,12 @@ x_draw_glyph_string_bg_rect (struct glyph_string *s, int x, int y, int w, int h)
3200{ 3209{
3201 if (s->stippled_p) 3210 if (s->stippled_p)
3202 { 3211 {
3212 Display *display = FRAME_X_DISPLAY (s->f);
3213
3203 /* Fill background with a stipple pattern. */ 3214 /* Fill background with a stipple pattern. */
3204 XSetFillStyle (s->display, s->gc, FillOpaqueStippled); 3215 XSetFillStyle (display, s->gc, FillOpaqueStippled);
3205 x_fill_rectangle (s->f, s->gc, x, y, w, h); 3216 x_fill_rectangle (s->f, s->gc, x, y, w, h);
3206 XSetFillStyle (s->display, s->gc, FillSolid); 3217 XSetFillStyle (display, s->gc, FillSolid);
3207 } 3218 }
3208 else 3219 else
3209 x_clear_glyph_string_rect (s, x, y, w, h); 3220 x_clear_glyph_string_rect (s, x, y, w, h);
@@ -3231,6 +3242,7 @@ x_draw_image_glyph_string (struct glyph_string *s)
3231 int box_line_vwidth = max (s->face->box_line_width, 0); 3242 int box_line_vwidth = max (s->face->box_line_width, 0);
3232 int height; 3243 int height;
3233#ifndef USE_CAIRO 3244#ifndef USE_CAIRO
3245 Display *display = FRAME_X_DISPLAY (s->f);
3234 Pixmap pixmap = None; 3246 Pixmap pixmap = None;
3235#endif 3247#endif
3236 3248
@@ -3261,34 +3273,34 @@ x_draw_image_glyph_string (struct glyph_string *s)
3261 int depth = DefaultDepthOfScreen (screen); 3273 int depth = DefaultDepthOfScreen (screen);
3262 3274
3263 /* Create a pixmap as large as the glyph string. */ 3275 /* Create a pixmap as large as the glyph string. */
3264 pixmap = XCreatePixmap (s->display, FRAME_X_DRAWABLE (s->f), 3276 pixmap = XCreatePixmap (display, FRAME_X_DRAWABLE (s->f),
3265 s->background_width, 3277 s->background_width,
3266 s->height, depth); 3278 s->height, depth);
3267 3279
3268 /* Don't clip in the following because we're working on the 3280 /* Don't clip in the following because we're working on the
3269 pixmap. */ 3281 pixmap. */
3270 XSetClipMask (s->display, s->gc, None); 3282 XSetClipMask (display, s->gc, None);
3271 3283
3272 /* Fill the pixmap with the background color/stipple. */ 3284 /* Fill the pixmap with the background color/stipple. */
3273 if (s->stippled_p) 3285 if (s->stippled_p)
3274 { 3286 {
3275 /* Fill background with a stipple pattern. */ 3287 /* Fill background with a stipple pattern. */
3276 XSetFillStyle (s->display, s->gc, FillOpaqueStippled); 3288 XSetFillStyle (display, s->gc, FillOpaqueStippled);
3277 XSetTSOrigin (s->display, s->gc, - s->x, - s->y); 3289 XSetTSOrigin (display, s->gc, - s->x, - s->y);
3278 XFillRectangle (s->display, pixmap, s->gc, 3290 XFillRectangle (display, pixmap, s->gc,
3279 0, 0, s->background_width, s->height); 3291 0, 0, s->background_width, s->height);
3280 XSetFillStyle (s->display, s->gc, FillSolid); 3292 XSetFillStyle (display, s->gc, FillSolid);
3281 XSetTSOrigin (s->display, s->gc, 0, 0); 3293 XSetTSOrigin (display, s->gc, 0, 0);
3282 } 3294 }
3283 else 3295 else
3284 { 3296 {
3285 XGCValues xgcv; 3297 XGCValues xgcv;
3286 XGetGCValues (s->display, s->gc, GCForeground | GCBackground, 3298 XGetGCValues (display, s->gc, GCForeground | GCBackground,
3287 &xgcv); 3299 &xgcv);
3288 XSetForeground (s->display, s->gc, xgcv.background); 3300 XSetForeground (display, s->gc, xgcv.background);
3289 XFillRectangle (s->display, pixmap, s->gc, 3301 XFillRectangle (display, pixmap, s->gc,
3290 0, 0, s->background_width, s->height); 3302 0, 0, s->background_width, s->height);
3291 XSetForeground (s->display, s->gc, xgcv.foreground); 3303 XSetForeground (display, s->gc, xgcv.foreground);
3292 } 3304 }
3293 } 3305 }
3294 else 3306 else
@@ -3320,9 +3332,9 @@ x_draw_image_glyph_string (struct glyph_string *s)
3320 { 3332 {
3321 x_draw_image_foreground_1 (s, pixmap); 3333 x_draw_image_foreground_1 (s, pixmap);
3322 x_set_glyph_string_clipping (s); 3334 x_set_glyph_string_clipping (s);
3323 XCopyArea (s->display, pixmap, FRAME_X_DRAWABLE (s->f), s->gc, 3335 XCopyArea (display, pixmap, FRAME_X_DRAWABLE (s->f), s->gc,
3324 0, 0, s->background_width, s->height, s->x, s->y); 3336 0, 0, s->background_width, s->height, s->x, s->y);
3325 XFreePixmap (s->display, pixmap); 3337 XFreePixmap (display, pixmap);
3326 } 3338 }
3327 else 3339 else
3328#endif /* ! USE_CAIRO */ 3340#endif /* ! USE_CAIRO */
@@ -3383,6 +3395,7 @@ x_draw_stretch_glyph_string (struct glyph_string *s)
3383 { 3395 {
3384 int y = s->y; 3396 int y = s->y;
3385 int w = background_width - width, h = s->height; 3397 int w = background_width - width, h = s->height;
3398 Display *display = FRAME_X_DISPLAY (s->f);
3386 XRectangle r; 3399 XRectangle r;
3387 GC gc; 3400 GC gc;
3388 3401
@@ -3405,17 +3418,17 @@ x_draw_stretch_glyph_string (struct glyph_string *s)
3405 if (s->face->stipple) 3418 if (s->face->stipple)
3406 { 3419 {
3407 /* Fill background with a stipple pattern. */ 3420 /* Fill background with a stipple pattern. */
3408 XSetFillStyle (s->display, gc, FillOpaqueStippled); 3421 XSetFillStyle (display, gc, FillOpaqueStippled);
3409 x_fill_rectangle (s->f, gc, x, y, w, h); 3422 x_fill_rectangle (s->f, gc, x, y, w, h);
3410 XSetFillStyle (s->display, gc, FillSolid); 3423 XSetFillStyle (display, gc, FillSolid);
3411 } 3424 }
3412 else 3425 else
3413 { 3426 {
3414 XGCValues xgcv; 3427 XGCValues xgcv;
3415 XGetGCValues (s->display, gc, GCForeground | GCBackground, &xgcv); 3428 XGetGCValues (display, gc, GCForeground | GCBackground, &xgcv);
3416 XSetForeground (s->display, gc, xgcv.background); 3429 XSetForeground (display, gc, xgcv.background);
3417 x_fill_rectangle (s->f, gc, x, y, w, h); 3430 x_fill_rectangle (s->f, gc, x, y, w, h);
3418 XSetForeground (s->display, gc, xgcv.foreground); 3431 XSetForeground (display, gc, xgcv.foreground);
3419 } 3432 }
3420 3433
3421 x_reset_clip_rectangles (s->f, gc); 3434 x_reset_clip_rectangles (s->f, gc);
@@ -3470,10 +3483,12 @@ x_get_scale_factor(Display *disp, int *scale_x, int *scale_y)
3470static void 3483static void
3471x_draw_underwave (struct glyph_string *s) 3484x_draw_underwave (struct glyph_string *s)
3472{ 3485{
3486 Display *display = FRAME_X_DISPLAY (s->f);
3487
3473 /* Adjust for scale/HiDPI. */ 3488 /* Adjust for scale/HiDPI. */
3474 int scale_x, scale_y; 3489 int scale_x, scale_y;
3475 3490
3476 x_get_scale_factor (s->display, &scale_x, &scale_y); 3491 x_get_scale_factor (display, &scale_x, &scale_y);
3477 3492
3478 int wave_height = 3 * scale_y, wave_length = 2 * scale_x; 3493 int wave_height = 3 * scale_y, wave_length = 2 * scale_x;
3479 3494
@@ -3503,7 +3518,7 @@ x_draw_underwave (struct glyph_string *s)
3503 if (!gui_intersect_rectangles (&wave_clip, &string_clip, &final_clip)) 3518 if (!gui_intersect_rectangles (&wave_clip, &string_clip, &final_clip))
3504 return; 3519 return;
3505 3520
3506 XSetClipRectangles (s->display, s->gc, 0, 0, &final_clip, 1, Unsorted); 3521 XSetClipRectangles (display, s->gc, 0, 0, &final_clip, 1, Unsorted);
3507 3522
3508 /* Draw the waves */ 3523 /* Draw the waves */
3509 3524
@@ -3522,16 +3537,16 @@ x_draw_underwave (struct glyph_string *s)
3522 3537
3523 while (x1 <= xmax) 3538 while (x1 <= xmax)
3524 { 3539 {
3525 XSetLineAttributes (s->display, s->gc, thickness, LineSolid, CapButt, 3540 XSetLineAttributes (display, s->gc, thickness, LineSolid, CapButt,
3526 JoinRound); 3541 JoinRound);
3527 XDrawLine (s->display, FRAME_X_DRAWABLE (s->f), s->gc, x1, y1, x2, y2); 3542 XDrawLine (display, FRAME_X_DRAWABLE (s->f), s->gc, x1, y1, x2, y2);
3528 x1 = x2, y1 = y2; 3543 x1 = x2, y1 = y2;
3529 x2 += dx, y2 = y0 + odd*dy; 3544 x2 += dx, y2 = y0 + odd*dy;
3530 odd = !odd; 3545 odd = !odd;
3531 } 3546 }
3532 3547
3533 /* Restore previous clipping rectangle(s) */ 3548 /* Restore previous clipping rectangle(s) */
3534 XSetClipRectangles (s->display, s->gc, 0, 0, s->clip, s->num_clips, Unsorted); 3549 XSetClipRectangles (display, s->gc, 0, 0, s->clip, s->num_clips, Unsorted);
3535#endif /* not USE_CAIRO */ 3550#endif /* not USE_CAIRO */
3536} 3551}
3537 3552
@@ -3648,11 +3663,12 @@ x_draw_glyph_string (struct glyph_string *s)
3648 x_draw_underwave (s); 3663 x_draw_underwave (s);
3649 else 3664 else
3650 { 3665 {
3666 Display *display = FRAME_X_DISPLAY (s->f);
3651 XGCValues xgcv; 3667 XGCValues xgcv;
3652 XGetGCValues (s->display, s->gc, GCForeground, &xgcv); 3668 XGetGCValues (display, s->gc, GCForeground, &xgcv);
3653 XSetForeground (s->display, s->gc, s->face->underline_color); 3669 XSetForeground (display, s->gc, s->face->underline_color);
3654 x_draw_underwave (s); 3670 x_draw_underwave (s);
3655 XSetForeground (s->display, s->gc, xgcv.foreground); 3671 XSetForeground (display, s->gc, xgcv.foreground);
3656 } 3672 }
3657 } 3673 }
3658 else if (s->face->underline_type == FACE_UNDER_LINE) 3674 else if (s->face->underline_type == FACE_UNDER_LINE)
@@ -3732,12 +3748,13 @@ x_draw_glyph_string (struct glyph_string *s)
3732 s->x, y, s->width, thickness); 3748 s->x, y, s->width, thickness);
3733 else 3749 else
3734 { 3750 {
3751 Display *display = FRAME_X_DISPLAY (s->f);
3735 XGCValues xgcv; 3752 XGCValues xgcv;
3736 XGetGCValues (s->display, s->gc, GCForeground, &xgcv); 3753 XGetGCValues (display, s->gc, GCForeground, &xgcv);
3737 XSetForeground (s->display, s->gc, s->face->underline_color); 3754 XSetForeground (display, s->gc, s->face->underline_color);
3738 x_fill_rectangle (s->f, s->gc, 3755 x_fill_rectangle (s->f, s->gc,
3739 s->x, y, s->width, thickness); 3756 s->x, y, s->width, thickness);
3740 XSetForeground (s->display, s->gc, xgcv.foreground); 3757 XSetForeground (display, s->gc, xgcv.foreground);
3741 } 3758 }
3742 } 3759 }
3743 } 3760 }
@@ -3751,12 +3768,13 @@ x_draw_glyph_string (struct glyph_string *s)
3751 s->width, h); 3768 s->width, h);
3752 else 3769 else
3753 { 3770 {
3771 Display *display = FRAME_X_DISPLAY (s->f);
3754 XGCValues xgcv; 3772 XGCValues xgcv;
3755 XGetGCValues (s->display, s->gc, GCForeground, &xgcv); 3773 XGetGCValues (display, s->gc, GCForeground, &xgcv);
3756 XSetForeground (s->display, s->gc, s->face->overline_color); 3774 XSetForeground (display, s->gc, s->face->overline_color);
3757 x_fill_rectangle (s->f, s->gc, s->x, s->y + dy, 3775 x_fill_rectangle (s->f, s->gc, s->x, s->y + dy,
3758 s->width, h); 3776 s->width, h);
3759 XSetForeground (s->display, s->gc, xgcv.foreground); 3777 XSetForeground (display, s->gc, xgcv.foreground);
3760 } 3778 }
3761 } 3779 }
3762 3780
@@ -3780,12 +3798,13 @@ x_draw_glyph_string (struct glyph_string *s)
3780 s->width, h); 3798 s->width, h);
3781 else 3799 else
3782 { 3800 {
3801 Display *display = FRAME_X_DISPLAY (s->f);
3783 XGCValues xgcv; 3802 XGCValues xgcv;
3784 XGetGCValues (s->display, s->gc, GCForeground, &xgcv); 3803 XGetGCValues (display, s->gc, GCForeground, &xgcv);
3785 XSetForeground (s->display, s->gc, s->face->strike_through_color); 3804 XSetForeground (display, s->gc, s->face->strike_through_color);
3786 x_fill_rectangle (s->f, s->gc, s->x, glyph_y + dy, 3805 x_fill_rectangle (s->f, s->gc, s->x, glyph_y + dy,
3787 s->width, h); 3806 s->width, h);
3788 XSetForeground (s->display, s->gc, xgcv.foreground); 3807 XSetForeground (display, s->gc, xgcv.foreground);
3789 } 3808 }
3790 } 3809 }
3791 3810