Subject: bug#42452: 27.0.91; hollow box cursor sometimes leaves artifacts

From: Eli Zaretskii <[email-masked]>
Date: Mon, 29 Mar 2021 08:06:45 +0300

> From: Radon Rosborough <[email-masked]>
> Date: Sun, 28 Mar 2021 15:21:47 -0700
> 
> I've attached a patch that appears to resolve the problem for me.
> 
> What we are doing in this patch is overriding the graphics context
> configuration so that line_width is set to 1, rather than the default
> of 0. There is somewhat detailed documentation from xlib on the
> meaning of the line_width argument, and how to set it via XChangeGC,
> here: https://tronche.com/gui/x/xlib/GC/manipulating.html
> 
> In short, a line_width of 0 means "draw a line of width 1 pixel, but
> use a device-dependent algorithm to do so, which may have higher
> performance". Unlike setting line_width to 1, setting it to 0 does not
> make any guarantees about the exact pixels that are rendered as part
> of the line. Apparently, there is a bug in the X server's
> device-dependent graphics code, or perhaps the graphics driver, which
> causes the "device-dependent algorithm" to be buggy under some
> circumstances, and draw a line of width 2 when a line of width 1 is
> requested.

Since this happens for unknown reasons, most probably some misfeature
of the X server, the change to use an explicit line thickness is a
debugging device.  As such, it shouldn't be the default; instead,
let's have a Lisp variable that gives the thickness, by default zero,
and let users affected by this issue set the variable to whatever
value that fixes the problem.

> Other interesting behavior: If I set line_width explicitly to 2 rather
> than to 1, then the graphical artifacts mentioned in the initial bug
> report occur unconditionally, every time a hollow box cursor is
> rendered.

I cannot see anything when I go to the URL you posted, just a blank
screen (a frequent problem with imgur.com), so I don't think I
understand what "artifacts" are you alluding to.  Does Emacs leave
traces of the hollow cursor when it moves it to another location?  Or
are you alluding to the different thickness of some of the borders of
the cursor?

Thanks.