Subject: Re: bug#71763: [PATCH] Inconsistency in bitmap overlay drawing for macOS

From: Gerd Möllmann <[email-masked]>
Date: Sun, 27 Oct 2024 15:03:32 +0100

Eli Zaretskii <[email-masked]> writes:

>> Didn't even know until a few minutes ago that the cursor can land in
>> the fringe.
>
> See overflow-newline-into-fringe.  It was added in Emacs 22 (and is ON
> by default, as you can see by typing enough characters on a line and
> ending the line with a newline, such that the last character before
> the newline fits completely on the screen line).

Indeed, never noticed, thanks!

>
>> And I'm wondering if that ever happens in the left fringe,
>
> It can, if the window shows RTL text, which starts at the right edge
> of the window.
>
>> and/or if the overlay arrow appears only on the left.
>
> In an RTL buffer, the arrow should appear on the right.

Yeah, of course :-).

>
>> Anyway. Assuming that I read the code correctly, that we are drawing a
>> cursor and overlay arrow on top of each other, then I think Daniel's
>> patch makes sense, because drawing the overlay arrow should not clear
>> under it and erase what was drawn for the cursor before.
>> 
>> That's about what I could find out. NS should do something different if
>> overlay_p is set or not, I think that's for sure. And if Daniel says it
>> works, that's goog enough for me I guess.
>
> Thanks.  If possible, can you also tell what the current code does
> wrong, that this patch fixes?

diff --git a/src/nsterm.m b/src/nsterm.m
index 794630de1c1..fc9133071ed 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -2961,24 +2961,28 @@ Hide the window (X11 semantics)
   NSTRACE_MSG ("which:%d cursor:%d overlay:%d width:%d height:%d period:%d",
                p->which, p->cursor_p, p->overlay_p, p->wd, p->h, p->dh);
 
-  /* Work out the rectangle we will need to clear.  */
-  clearRect = NSMakeRect (p->x, p->y, p->wd, p->h);
+  /* Clear screen unless overlay.  */
+  if ( !p->overlay_p )
+    {
+      /* Work out the rectangle we will need to clear.  */
+      clearRect = NSMakeRect (p->x, p->y, p->wd, p->h);

If I read the diff correctly, this puts the clearing under the bitmap in
an if-statement so that it is only done if we do not draw intentionally
on top something drawn before.

Right, Daniel?