From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Alex Gramiak Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] Remove display member of glyph_string Date: Thu, 09 May 2019 12:21:07 -0600 Message-ID: <87o94bcwvg.fsf@gmail.com> References: <87a7fwe12f.fsf@gmail.com> <83ef58goru.fsf@gnu.org> <871s17ehmq.fsf@gmail.com> <834l63h87x.fsf@gnu.org> <87sgtnczvt.fsf@gmail.com> <831s17h5lf.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="66229"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux) Cc: emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu May 09 20:22:27 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hOngY-000H4x-Du for ged-emacs-devel@m.gmane.org; Thu, 09 May 2019 20:22:26 +0200 Original-Received: from localhost ([127.0.0.1]:59207 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hOngX-000764-A6 for ged-emacs-devel@m.gmane.org; Thu, 09 May 2019 14:22:25 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:41820) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hOnfT-00073Y-FJ for emacs-devel@gnu.org; Thu, 09 May 2019 14:21:21 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hOnfR-00081R-6k for emacs-devel@gnu.org; Thu, 09 May 2019 14:21:19 -0400 Original-Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]:40774) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hOnfQ-000816-Ol; Thu, 09 May 2019 14:21:17 -0400 Original-Received: by mail-pf1-x441.google.com with SMTP id u17so1735279pfn.7; Thu, 09 May 2019 11:21:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=/1T3+XDHWzTuSMqZjrgw1Iv1WmvDop74qZIPjlgRAEE=; b=hxDl+rk0qADlWXXDqBWx6lFEIjK1fRlTMzOz1aWE5bK60aLmyCDTtVdonQu+V76dsT IE0f+LYgq1zYCIdgPFNVxKknBCYLmb5tKTAxR9FshT14qO6TfQbi0QkAmlyyOZ1diCqG TGw+fikmLp8H8J4glGRFDkFQsTJdS+ndgRw3Y0gea9o+8WDC198OIBVnPuDv7KCve+9o XbAhvPHyfbLyoDI5ZP9AFa+mxZGMzk7nF7HbHrR1+yyq7qgRZHC7DKdl598KZmaNcO+I i6Y9jzCRV7eR2epHWo9W4B21KzkK0RKjdGs3Hv8x/cI/FCamaGhZgM2aL66nG++kPLFv iyAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=/1T3+XDHWzTuSMqZjrgw1Iv1WmvDop74qZIPjlgRAEE=; b=AfnIdC59Vwjl/QeMRvw9QjmUZAuM+QtH0wb/WjhAoFEfh1hqdLNmsnVJKMsnEcwgD0 gw2znWmr1OK6/L8JR+dqAX1RjTmgW8EQ5vp1SxMWHImYDYp+SAomBxljRvje0+28mPtq xGqA3EXbs0YU6cDF6axYYwkwxnI/G8oK9UhfJ9y8cTxBUeT/XkG/Z2Wy3IN+bSCiNMr3 hP5cAmRRY0mXCNrkBMNJz0MnESXrM1MYCibsNLDUg4zKHTSKMHsJGHaPEIf1SUXuKYRQ DNVlMYIhUFis2D69X0eS2O+YSa57eXgS0zK20AoB9um8++a1USf4+0lRYiuAxCKuGISq X8uA== X-Gm-Message-State: APjAAAU6TaQPlivrj9pTY+BKD96xH3ciT6XSCxKzPYtuMw3VnseUwQh6 kolVgYEknEpVm8VKZyDQt1b37fA6 X-Google-Smtp-Source: APXvYqwQOUw6Kj6P+zuVQ3ErCZ0Y3wQRGFQ3Qe/lFyT7y5pEtDN2OT9jMOLHq7dh5GD6NWpMi3fFyg== X-Received: by 2002:a62:14d6:: with SMTP id 205mr7409913pfu.4.1557426075033; Thu, 09 May 2019 11:21:15 -0700 (PDT) Original-Received: from lylat ([2604:3d09:e37f:1500:1a72:4878:e793:7302]) by smtp.gmail.com with ESMTPSA id b20sm6138024pff.118.2019.05.09.11.21.12 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 09 May 2019 11:21:13 -0700 (PDT) In-Reply-To: <831s17h5lf.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 09 May 2019 20:59:08 +0300") X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::441 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:236344 Archived-At: --=-=-= Content-Type: text/plain Eli Zaretskii writes: >> From: Alex Gramiak >> Cc: emacs-devel@gnu.org >> Date: Thu, 09 May 2019 11:16:06 -0600 >> >> > There's one more instance of FRAME_X_DISPLAY in xdisp.c which was >> > left, and it will fail compilation on non-X platforms. >> > >> > Otherwise, this LGTM, thanks. >> >> I only see one such instance, and it's surrounded by: >> >> #if false && defined HAVE_X_WINDOWS >> >> So it should be good, no? > > That one, yes. But there's one more, and it isn't conditioned by > HAVE_X_WINDOWS. Are you maybe looking on a wrong branch? I'm on > master. You mean the one in init_glyph_string, right? That was removed in my first patch, which I've attached again below: --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Remove-display-member-of-glyph_string.patch >From d6f7b845573bcdd81552851f9d87cfd5179c7d70 Mon Sep 17 00:00:00 2001 From: Alexander Gramiak Date: Wed, 8 May 2019 21:40:24 -0600 Subject: [PATCH] Remove display member of glyph_string This member has little value even on X, and it leaks internal backend details to the glyph_string struct. * src/dispextern.h (glyph_string): Remove X display member. * src/xdisp.c (init_glyph_string): Remove initialization of display. * src/xfont.c (xfont_draw): * src/xterm.c: Use FRAME_X_DISPLAY (s->f) instead of display member. --- src/dispextern.h | 3 - src/xdisp.c | 1 - src/xfont.c | 19 ++++--- src/xterm.c | 141 +++++++++++++++++++++++++++-------------------- 4 files changed, 90 insertions(+), 74 deletions(-) diff --git a/src/dispextern.h b/src/dispextern.h index bb981f83fc..619f4c0767 100644 --- a/src/dispextern.h +++ b/src/dispextern.h @@ -1281,9 +1281,6 @@ struct glyph_string /* The window on which the glyph string is drawn. */ struct window *w; - /* X display and window for convenience. */ - Display *display; - /* The glyph row for which this string was built. It determines the y-origin and height of the string. */ struct glyph_row *row; diff --git a/src/xdisp.c b/src/xdisp.c index d380645c84..1aa677fcc7 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -25953,7 +25953,6 @@ init_glyph_string (struct glyph_string *s, #ifdef HAVE_NTGUI s->hdc = hdc; #endif - s->display = FRAME_X_DISPLAY (s->f); s->char2b = char2b; s->hl = hl; s->row = row; diff --git a/src/xfont.c b/src/xfont.c index 5ecbd6de33..ff80df407d 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, bool with_background) { XFontStruct *xfont = ((struct xfont_info *) s->font)->xfont; + Display *display = FRAME_X_DISPLAY (s->f); int len = to - from; GC gc = s->gc; int i; @@ -1007,7 +1008,7 @@ xfont_draw (struct glyph_string *s, int from, int to, int x, int y, if (s->gc != s->face->gc) { block_input (); - XSetFont (s->display, gc, xfont->fid); + XSetFont (display, gc, xfont->fid); unblock_input (); } @@ -1022,20 +1023,20 @@ xfont_draw (struct glyph_string *s, int from, int to, int x, int y, { if (s->padding_p) for (i = 0; i < len; i++) - XDrawImageString (FRAME_X_DISPLAY (s->f), FRAME_X_DRAWABLE (s->f), + XDrawImageString (display, FRAME_X_DRAWABLE (s->f), gc, x + i, y, str + i, 1); else - XDrawImageString (FRAME_X_DISPLAY (s->f), FRAME_X_DRAWABLE (s->f), + XDrawImageString (display, FRAME_X_DRAWABLE (s->f), gc, x, y, str, len); } else { if (s->padding_p) for (i = 0; i < len; i++) - XDrawString (FRAME_X_DISPLAY (s->f), FRAME_X_DRAWABLE (s->f), + XDrawString (display, FRAME_X_DRAWABLE (s->f), gc, x + i, y, str + i, 1); else - XDrawString (FRAME_X_DISPLAY (s->f), FRAME_X_DRAWABLE (s->f), + XDrawString (display, FRAME_X_DRAWABLE (s->f), gc, x, y, str, len); } unblock_input (); @@ -1048,20 +1049,20 @@ xfont_draw (struct glyph_string *s, int from, int to, int x, int y, { if (s->padding_p) for (i = 0; i < len; i++) - XDrawImageString16 (FRAME_X_DISPLAY (s->f), FRAME_X_DRAWABLE (s->f), + XDrawImageString16 (display, FRAME_X_DRAWABLE (s->f), gc, x + i, y, s->char2b + from + i, 1); else - XDrawImageString16 (FRAME_X_DISPLAY (s->f), FRAME_X_DRAWABLE (s->f), + XDrawImageString16 (display, FRAME_X_DRAWABLE (s->f), gc, x, y, s->char2b + from, len); } else { if (s->padding_p) for (i = 0; i < len; i++) - XDrawString16 (FRAME_X_DISPLAY (s->f), FRAME_X_DRAWABLE (s->f), + XDrawString16 (display, FRAME_X_DRAWABLE (s->f), gc, x + i, y, s->char2b + from + i, 1); else - XDrawString16 (FRAME_X_DISPLAY (s->f), FRAME_X_DRAWABLE (s->f), + XDrawString16 (display, FRAME_X_DRAWABLE (s->f), gc, x, y, s->char2b + from, len); } unblock_input (); diff --git a/src/xterm.c b/src/xterm.c index 26f74cde91..7bedcabe98 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -1454,6 +1454,7 @@ x_set_cursor_gc (struct glyph_string *s) /* Cursor on non-default face: must merge. */ XGCValues xgcv; unsigned long mask; + Display *display = FRAME_X_DISPLAY (s->f); xgcv.background = s->f->output_data.x->cursor_pixel; xgcv.foreground = s->face->background; @@ -1479,11 +1480,11 @@ x_set_cursor_gc (struct glyph_string *s) mask = GCForeground | GCBackground | GCGraphicsExposures; if (FRAME_DISPLAY_INFO (s->f)->scratch_cursor_gc) - XChangeGC (s->display, FRAME_DISPLAY_INFO (s->f)->scratch_cursor_gc, + XChangeGC (display, FRAME_DISPLAY_INFO (s->f)->scratch_cursor_gc, mask, &xgcv); else FRAME_DISPLAY_INFO (s->f)->scratch_cursor_gc - = XCreateGC (s->display, FRAME_X_DRAWABLE (s->f), mask, &xgcv); + = XCreateGC (display, FRAME_X_DRAWABLE (s->f), mask, &xgcv); s->gc = FRAME_DISPLAY_INFO (s->f)->scratch_cursor_gc; } @@ -1519,6 +1520,7 @@ x_set_mouse_face_gc (struct glyph_string *s) except for FONT. */ XGCValues xgcv; unsigned long mask; + Display *display = FRAME_X_DISPLAY (s->f); xgcv.background = s->face->background; xgcv.foreground = s->face->foreground; @@ -1526,11 +1528,11 @@ x_set_mouse_face_gc (struct glyph_string *s) mask = GCForeground | GCBackground | GCGraphicsExposures; if (FRAME_DISPLAY_INFO (s->f)->scratch_cursor_gc) - XChangeGC (s->display, FRAME_DISPLAY_INFO (s->f)->scratch_cursor_gc, + XChangeGC (display, FRAME_DISPLAY_INFO (s->f)->scratch_cursor_gc, mask, &xgcv); else FRAME_DISPLAY_INFO (s->f)->scratch_cursor_gc - = XCreateGC (s->display, FRAME_X_DRAWABLE (s->f), mask, &xgcv); + = XCreateGC (display, FRAME_X_DRAWABLE (s->f), mask, &xgcv); s->gc = FRAME_DISPLAY_INFO (s->f)->scratch_cursor_gc; @@ -1672,11 +1674,12 @@ x_compute_glyph_string_overhangs (struct glyph_string *s) static void x_clear_glyph_string_rect (struct glyph_string *s, int x, int y, int w, int h) { + Display *display = FRAME_X_DISPLAY (s->f); XGCValues xgcv; - XGetGCValues (s->display, s->gc, GCForeground | GCBackground, &xgcv); - XSetForeground (s->display, s->gc, xgcv.background); + XGetGCValues (display, s->gc, GCForeground | GCBackground, &xgcv); + XSetForeground (display, s->gc, xgcv.background); x_fill_rectangle (s->f, s->gc, x, y, w, h); - XSetForeground (s->display, s->gc, xgcv.foreground); + XSetForeground (display, s->gc, xgcv.foreground); } @@ -1697,13 +1700,15 @@ x_draw_glyph_string_background (struct glyph_string *s, bool force_p) if (s->stippled_p) { + Display *display = FRAME_X_DISPLAY (s->f); + /* Fill background with a stipple pattern. */ - XSetFillStyle (s->display, s->gc, FillOpaqueStippled); + XSetFillStyle (display, s->gc, FillOpaqueStippled); x_fill_rectangle (s->f, s->gc, s->x, s->y + box_line_width, s->background_width, s->height - 2 * box_line_width); - XSetFillStyle (s->display, s->gc, FillSolid); + XSetFillStyle (display, s->gc, FillSolid); s->background_filled_p = true; } else if (FONT_HEIGHT (s->font) < s->height - 2 * box_line_width @@ -2591,7 +2596,7 @@ x_setup_relief_colors (struct glyph_string *s) XGCValues xgcv; /* Get the background color of the face. */ - XGetGCValues (s->display, s->gc, GCBackground, &xgcv); + XGetGCValues (FRAME_X_DISPLAY (s->f), s->gc, GCBackground, &xgcv); color = xgcv.background; } @@ -2801,10 +2806,11 @@ x_draw_box_rect (struct glyph_string *s, int left_x, int top_y, int right_x, int bottom_y, int width, bool left_p, bool right_p, XRectangle *clip_rect) { + Display *display = FRAME_X_DISPLAY (s->f); XGCValues xgcv; - XGetGCValues (s->display, s->gc, GCForeground, &xgcv); - XSetForeground (s->display, s->gc, s->face->box_color); + XGetGCValues (display, s->gc, GCForeground, &xgcv); + XSetForeground (display, s->gc, s->face->box_color); x_set_clip_rectangles (s->f, s->gc, clip_rect, 1); /* Top. */ @@ -2825,7 +2831,7 @@ x_draw_box_rect (struct glyph_string *s, x_fill_rectangle (s->f, s->gc, right_x - width + 1, top_y, width, bottom_y - top_y + 1); - XSetForeground (s->display, s->gc, xgcv.foreground); + XSetForeground (display, s->gc, xgcv.foreground); x_reset_clip_rectangles (s->f, s->gc); } @@ -2888,6 +2894,7 @@ x_composite_image (struct glyph_string *s, Pixmap dest, int srcX, int srcY, int dstX, int dstY, int width, int height) { + Display *display = FRAME_X_DISPLAY (s->f); #ifdef HAVE_XRENDER if (s->img->picture) { @@ -2897,27 +2904,27 @@ x_composite_image (struct glyph_string *s, Pixmap dest, /* FIXME: Should we do this each time or would it make sense to store destination in the frame struct? */ - default_format = XRenderFindVisualFormat (s->display, - DefaultVisual (s->display, 0)); - destination = XRenderCreatePicture (s->display, dest, + default_format = XRenderFindVisualFormat (display, + DefaultVisual (display, 0)); + destination = XRenderCreatePicture (display, dest, default_format, 0, &attr); /* FIXME: It may make sense to use PictOpSrc instead of PictOpOver, as I don't know if we care about alpha values too much here. */ - XRenderComposite (s->display, PictOpOver, + XRenderComposite (display, PictOpOver, s->img->picture, s->img->mask_picture, destination, srcX, srcY, srcX, srcY, dstX, dstY, width, height); - XRenderFreePicture (s->display, destination); + XRenderFreePicture (display, destination); return; } #endif - XCopyArea (s->display, s->img->pixmap, + XCopyArea (display, s->img->pixmap, dest, s->gc, srcX, srcY, width, height, dstX, dstY); @@ -2992,7 +2999,7 @@ x_draw_image_foreground (struct glyph_string *s) xgcv.clip_x_origin = x; xgcv.clip_y_origin = y; xgcv.function = GXcopy; - XChangeGC (s->display, s->gc, mask, &xgcv); + XChangeGC (FRAME_X_DISPLAY (s->f), s->gc, mask, &xgcv); get_glyph_string_clip_rect (s, &clip_rect); image_rect.x = x; @@ -3141,6 +3148,8 @@ x_draw_image_foreground_1 (struct glyph_string *s, Pixmap pixmap) if (s->img->pixmap) { + Display *display = FRAME_X_DISPLAY (s->f); + if (s->img->mask) { /* 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) xgcv.clip_x_origin = x - s->slice.x; xgcv.clip_y_origin = y - s->slice.y; xgcv.function = GXcopy; - XChangeGC (s->display, s->gc, mask, &xgcv); + XChangeGC (display, s->gc, mask, &xgcv); - XCopyArea (s->display, s->img->pixmap, pixmap, s->gc, + XCopyArea (display, s->img->pixmap, pixmap, s->gc, s->slice.x, s->slice.y, s->slice.width, s->slice.height, x, y); - XSetClipMask (s->display, s->gc, None); + XSetClipMask (display, s->gc, None); } else { - XCopyArea (s->display, s->img->pixmap, pixmap, s->gc, + XCopyArea (display, s->img->pixmap, pixmap, s->gc, s->slice.x, s->slice.y, s->slice.width, s->slice.height, x, y); @@ -3200,10 +3209,12 @@ x_draw_glyph_string_bg_rect (struct glyph_string *s, int x, int y, int w, int h) { if (s->stippled_p) { + Display *display = FRAME_X_DISPLAY (s->f); + /* Fill background with a stipple pattern. */ - XSetFillStyle (s->display, s->gc, FillOpaqueStippled); + XSetFillStyle (display, s->gc, FillOpaqueStippled); x_fill_rectangle (s->f, s->gc, x, y, w, h); - XSetFillStyle (s->display, s->gc, FillSolid); + XSetFillStyle (display, s->gc, FillSolid); } else x_clear_glyph_string_rect (s, x, y, w, h); @@ -3230,6 +3241,7 @@ x_draw_image_glyph_string (struct glyph_string *s) int box_line_hwidth = eabs (s->face->box_line_width); int box_line_vwidth = max (s->face->box_line_width, 0); int height; + Display *display = FRAME_X_DISPLAY (s->f); #ifndef USE_CAIRO Pixmap pixmap = None; #endif @@ -3261,34 +3273,34 @@ x_draw_image_glyph_string (struct glyph_string *s) int depth = DefaultDepthOfScreen (screen); /* Create a pixmap as large as the glyph string. */ - pixmap = XCreatePixmap (s->display, FRAME_X_DRAWABLE (s->f), + pixmap = XCreatePixmap (display, FRAME_X_DRAWABLE (s->f), s->background_width, s->height, depth); /* Don't clip in the following because we're working on the pixmap. */ - XSetClipMask (s->display, s->gc, None); + XSetClipMask (display, s->gc, None); /* Fill the pixmap with the background color/stipple. */ if (s->stippled_p) { /* Fill background with a stipple pattern. */ - XSetFillStyle (s->display, s->gc, FillOpaqueStippled); - XSetTSOrigin (s->display, s->gc, - s->x, - s->y); - XFillRectangle (s->display, pixmap, s->gc, + XSetFillStyle (display, s->gc, FillOpaqueStippled); + XSetTSOrigin (display, s->gc, - s->x, - s->y); + XFillRectangle (display, pixmap, s->gc, 0, 0, s->background_width, s->height); - XSetFillStyle (s->display, s->gc, FillSolid); - XSetTSOrigin (s->display, s->gc, 0, 0); + XSetFillStyle (display, s->gc, FillSolid); + XSetTSOrigin (display, s->gc, 0, 0); } else { XGCValues xgcv; - XGetGCValues (s->display, s->gc, GCForeground | GCBackground, + XGetGCValues (display, s->gc, GCForeground | GCBackground, &xgcv); - XSetForeground (s->display, s->gc, xgcv.background); - XFillRectangle (s->display, pixmap, s->gc, + XSetForeground (display, s->gc, xgcv.background); + XFillRectangle (display, pixmap, s->gc, 0, 0, s->background_width, s->height); - XSetForeground (s->display, s->gc, xgcv.foreground); + XSetForeground (display, s->gc, xgcv.foreground); } } else @@ -3320,9 +3332,9 @@ x_draw_image_glyph_string (struct glyph_string *s) { x_draw_image_foreground_1 (s, pixmap); x_set_glyph_string_clipping (s); - XCopyArea (s->display, pixmap, FRAME_X_DRAWABLE (s->f), s->gc, + XCopyArea (display, pixmap, FRAME_X_DRAWABLE (s->f), s->gc, 0, 0, s->background_width, s->height, s->x, s->y); - XFreePixmap (s->display, pixmap); + XFreePixmap (display, pixmap); } else #endif /* ! USE_CAIRO */ @@ -3383,6 +3395,7 @@ x_draw_stretch_glyph_string (struct glyph_string *s) { int y = s->y; int w = background_width - width, h = s->height; + Display *display = FRAME_X_DISPLAY (s->f); XRectangle r; GC gc; @@ -3405,17 +3418,17 @@ x_draw_stretch_glyph_string (struct glyph_string *s) if (s->face->stipple) { /* Fill background with a stipple pattern. */ - XSetFillStyle (s->display, gc, FillOpaqueStippled); + XSetFillStyle (display, gc, FillOpaqueStippled); x_fill_rectangle (s->f, gc, x, y, w, h); - XSetFillStyle (s->display, gc, FillSolid); + XSetFillStyle (display, gc, FillSolid); } else { XGCValues xgcv; - XGetGCValues (s->display, gc, GCForeground | GCBackground, &xgcv); - XSetForeground (s->display, gc, xgcv.background); + XGetGCValues (display, gc, GCForeground | GCBackground, &xgcv); + XSetForeground (display, gc, xgcv.background); x_fill_rectangle (s->f, gc, x, y, w, h); - XSetForeground (s->display, gc, xgcv.foreground); + XSetForeground (display, gc, xgcv.foreground); } x_reset_clip_rectangles (s->f, gc); @@ -3470,10 +3483,12 @@ x_get_scale_factor(Display *disp, int *scale_x, int *scale_y) static void x_draw_underwave (struct glyph_string *s) { + Display *display = FRAME_X_DISPLAY (s->f); + /* Adjust for scale/HiDPI. */ int scale_x, scale_y; - x_get_scale_factor (s->display, &scale_x, &scale_y); + x_get_scale_factor (display, &scale_x, &scale_y); int wave_height = 3 * scale_y, wave_length = 2 * scale_x; @@ -3503,7 +3518,7 @@ x_draw_underwave (struct glyph_string *s) if (!gui_intersect_rectangles (&wave_clip, &string_clip, &final_clip)) return; - XSetClipRectangles (s->display, s->gc, 0, 0, &final_clip, 1, Unsorted); + XSetClipRectangles (display, s->gc, 0, 0, &final_clip, 1, Unsorted); /* Draw the waves */ @@ -3522,16 +3537,16 @@ x_draw_underwave (struct glyph_string *s) while (x1 <= xmax) { - XSetLineAttributes (s->display, s->gc, thickness, LineSolid, CapButt, + XSetLineAttributes (display, s->gc, thickness, LineSolid, CapButt, JoinRound); - XDrawLine (s->display, FRAME_X_DRAWABLE (s->f), s->gc, x1, y1, x2, y2); + XDrawLine (display, FRAME_X_DRAWABLE (s->f), s->gc, x1, y1, x2, y2); x1 = x2, y1 = y2; x2 += dx, y2 = y0 + odd*dy; odd = !odd; } /* Restore previous clipping rectangle(s) */ - XSetClipRectangles (s->display, s->gc, 0, 0, s->clip, s->num_clips, Unsorted); + XSetClipRectangles (display, s->gc, 0, 0, s->clip, s->num_clips, Unsorted); #endif /* not USE_CAIRO */ } @@ -3648,11 +3663,12 @@ x_draw_glyph_string (struct glyph_string *s) x_draw_underwave (s); else { + Display *display = FRAME_X_DISPLAY (s->f); XGCValues xgcv; - XGetGCValues (s->display, s->gc, GCForeground, &xgcv); - XSetForeground (s->display, s->gc, s->face->underline_color); + XGetGCValues (display, s->gc, GCForeground, &xgcv); + XSetForeground (display, s->gc, s->face->underline_color); x_draw_underwave (s); - XSetForeground (s->display, s->gc, xgcv.foreground); + XSetForeground (display, s->gc, xgcv.foreground); } } else if (s->face->underline_type == FACE_UNDER_LINE) @@ -3732,12 +3748,13 @@ x_draw_glyph_string (struct glyph_string *s) s->x, y, s->width, thickness); else { + Display *display = FRAME_X_DISPLAY (s->f); XGCValues xgcv; - XGetGCValues (s->display, s->gc, GCForeground, &xgcv); - XSetForeground (s->display, s->gc, s->face->underline_color); + XGetGCValues (display, s->gc, GCForeground, &xgcv); + XSetForeground (display, s->gc, s->face->underline_color); x_fill_rectangle (s->f, s->gc, s->x, y, s->width, thickness); - XSetForeground (s->display, s->gc, xgcv.foreground); + XSetForeground (display, s->gc, xgcv.foreground); } } } @@ -3751,12 +3768,13 @@ x_draw_glyph_string (struct glyph_string *s) s->width, h); else { + Display *display = FRAME_X_DISPLAY (s->f); XGCValues xgcv; - XGetGCValues (s->display, s->gc, GCForeground, &xgcv); - XSetForeground (s->display, s->gc, s->face->overline_color); + XGetGCValues (display, s->gc, GCForeground, &xgcv); + XSetForeground (display, s->gc, s->face->overline_color); x_fill_rectangle (s->f, s->gc, s->x, s->y + dy, s->width, h); - XSetForeground (s->display, s->gc, xgcv.foreground); + XSetForeground (display, s->gc, xgcv.foreground); } } @@ -3780,12 +3798,13 @@ x_draw_glyph_string (struct glyph_string *s) s->width, h); else { + Display *display = FRAME_X_DISPLAY (s->f); XGCValues xgcv; - XGetGCValues (s->display, s->gc, GCForeground, &xgcv); - XSetForeground (s->display, s->gc, s->face->strike_through_color); + XGetGCValues (display, s->gc, GCForeground, &xgcv); + XSetForeground (display, s->gc, s->face->strike_through_color); x_fill_rectangle (s->f, s->gc, s->x, glyph_y + dy, s->width, h); - XSetForeground (s->display, s->gc, xgcv.foreground); + XSetForeground (display, s->gc, xgcv.foreground); } } -- 2.21.0 --=-=-=--