unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Po Lu <luangruo@yahoo.com>
Cc: emacs-devel@gnu.org
Subject: Re: master 77c3d41adc: Prevent text decorations from overwriting surrounding areas on X
Date: Tue, 11 Jan 2022 14:42:47 +0200	[thread overview]
Message-ID: <837db68muw.fsf@gnu.org> (raw)
In-Reply-To: <87k0f7p0p4.fsf@yahoo.com> (message from Po Lu on Tue, 11 Jan 2022 08:37:11 +0800)

> From: Po Lu <luangruo@yahoo.com>
> 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.



  reply	other threads:[~2022-01-11 12:42 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <164181573002.27254.10999604516337949526@vcs2.savannah.gnu.org>
     [not found] ` <20220110115530.E4B34C0DA1D@vcs2.savannah.gnu.org>
2022-01-10 11:58   ` master 77c3d41adc: Prevent text decorations from overwriting surrounding areas on X Po Lu
2022-01-10 17:47     ` Eli Zaretskii
2022-01-11  0:37       ` Po Lu
2022-01-11 12:42         ` Eli Zaretskii [this message]
2022-01-11 13:18           ` Po Lu
2022-01-11 13:35             ` Eli Zaretskii
2022-01-12  1:56               ` Po Lu
2022-01-12  2:30                 ` Jose Antonio Ortega Ruiz
2022-01-12  3:05                   ` Po Lu
2022-01-12  3:48                     ` Jose Antonio Ortega Ruiz
2022-01-12  3:29                 ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=837db68muw.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=luangruo@yahoo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).