From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: master 77c3d41adc: Prevent text decorations from overwriting surrounding areas on X Date: Tue, 11 Jan 2022 14:42:47 +0200 Message-ID: <837db68muw.fsf@gnu.org> References: <164181573002.27254.10999604516337949526@vcs2.savannah.gnu.org> <20220110115530.E4B34C0DA1D@vcs2.savannah.gnu.org> <87zgo3pzu3.fsf@yahoo.com> <8335lva3ev.fsf@gnu.org> <87k0f7p0p4.fsf@yahoo.com> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="31028"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Po Lu Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Jan 11 13:50:34 2022 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1n7Gbi-0007wv-Hr for ged-emacs-devel@m.gmane-mx.org; Tue, 11 Jan 2022 13:50:34 +0100 Original-Received: from localhost ([::1]:57436 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n7Gbh-00081F-Jw for ged-emacs-devel@m.gmane-mx.org; Tue, 11 Jan 2022 07:50:33 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:46166) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n7GUK-0003sr-3Z for emacs-devel@gnu.org; Tue, 11 Jan 2022 07:42:57 -0500 Original-Received: from [2001:470:142:3::e] (port=44774 helo=fencepost.gnu.org) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n7GUJ-0002Pb-KC; Tue, 11 Jan 2022 07:42:55 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=q9jf8kk0ONAM0nU7cM+Xiw+i+jmACHJ4f4LTQFg0DNQ=; b=ppbx1yyyd/Fq yQN5EkKeyJd2WuzpjmmY+jm+jYhNDxJSKLEk56sFKgMfp4xGwGejxABgFhR+fWoWsj0gxA2MNkt8+ Y8ZMlYIkWfg+vzKjdUISh6I6U7sLTFVnpOz5CaepX9JH2Z0l28hmQNwjQE95UQWaVeKzr3GAXyyOl kQpgBiax30qzU8KJ6k6YZJLvl0qwWldwktAr8DWOVQH96vsCnh42nWVO+3b3pZ2kFFg9nX2XWo5ws 51DO8OSJZmCEWDRs6Bo0OBMb4VONldZuQnG4QRZOX1e4SDYXDmuOxOJTIuueIve4K7R/B6NuIyxWv O99SvYkmg66Ui3smbPVfDQ==; Original-Received: from [87.69.77.57] (port=4182 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n7GUJ-00012d-Fr; Tue, 11 Jan 2022 07:42:55 -0500 In-Reply-To: <87k0f7p0p4.fsf@yahoo.com> (message from Po Lu on Tue, 11 Jan 2022 08:37:11 +0800) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 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-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:284597 Archived-At: > From: Po Lu > Cc: emacs-devel@gnu.org > Date: Tue, 11 Jan 2022 08:37:11 +0800 > > > wave_clip.x = x0; > > wave_clip.y = y0; > > wave_clip.width = width; > > wave_clip.height = wave_height; > > get_glyph_string_clip_rect (s, &string_clip); > > > > if (!gui_intersect_rectangles (&wave_clip, &string_clip, &final_clip)) > > return; > > > > XSetClipRectangles (display, s->gc, 0, 0, &final_clip, 1, Unsorted); > > > > Isn't this the clipping? Or what am I missing? > > That's only done in x_draw_underwave, and nowhere else where text > decorations (underlines and overlines) are drawn. For underline, we have this: /* Check the sanity of thickness and position. We should avoid drawing underline out of the current line area. */ if (s->y + s->height <= s->ybase + position) position = (s->height - 1) - (s->ybase - s->y); if (s->y + s->height < s->ybase + position + thickness) thickness = (s->y + s->height) - (s->ybase + position); s->underline_thickness = thickness; s->underline_position = position; y = s->ybase + position; if (s->face->underline_defaulted_p) x_fill_rectangle (s->f, s->gc, s->x, y, decoration_width, thickness); else { Display *display = FRAME_X_DISPLAY (s->f); XGCValues xgcv; XGetGCValues (display, s->gc, GCForeground, &xgcv); XSetForeground (display, s->gc, s->face->underline_color); x_fill_rectangle (s->f, s->gc, s->x, y, decoration_width, thickness); XSetForeground (display, s->gc, xgcv.foreground); } The call to x_fill_rectangle was with s->width, which you now replaced with decoration_width, computed as follows: decoration_width = s->width; if (area_max_x < (s->x + decoration_width - 1)) decoration_width -= (s->x + decoration_width - 1) - area_max_x; I have a problem with this correction, because I don't understand the need for it. s->width is the width of the glyph string, which is computed from the glyphs that comprise the glyph string. Those glyphs were laid out by display_line, which should never add a glyph to a glyph row if that glyph doesn't fit on the screen. So how come s->width in your case was too large? Or maybe it's s->x that was wrong (does the underline start exactly under the first glyph)? So I suspect that your fix hides a much more serious problem elsewhere. Please investigate the problem you saw before the change. > > Please show some actual Lisp to try this, so we wouldn't need to guess > > whether the problem doesn't exist or we failed to reproduce correctly. > > After loading the definition of widget-field, just do this in an empty > buffer: > > (set-face-attribute 'default nil :underline t) > (save-excursion > (insert (propertize "foo\n" 'face 'widget-field))) > (redisplay) > (insert "a") > > The underline of the first line will then overwrite the right fringe. It doesn't overwrite the fringe here on MS-Windows. Which is what I'd expect, given the above rationale. There's something else at work here, and we shouldn't so easily decide that no one thought about the need for clipping in this case. Thanks.