Subject: Re: bug#51251: 29.0.50; Moving cursor on top of raised box leaves artifacts around in NS port

From: Alan Third <[email-masked]>
Date: Sun, 17 Oct 2021 19:37:22 +0100

On Sun, Oct 17, 2021 at 09:14:39PM +0800, Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors wrote:
> 
> Move the cursor over a raised box, like the buttons in a customize
> buffer.  Parts of the cursor will remain in the box even after the
> cursor is moved out of the button.
> 
> I was told that this also occurs on macOS.
> 
> I've attached a patch that fixes the problem for me, but it hasn't been
> tested on macOS.

Hmm, your patch effectively undoes the change in

    Fix NS inset rectangle corners
    9ce3fdc461c9ec799ccbdc9281e392b0b77efd2b

I've attached my attempt to fix it. (Also not tested on macOS, but I
can't see why it wouldn't work there.)
-- 
Alan Third
>From 2317d81c7060a3b2826b76b064502006ddb84f98 Mon Sep 17 00:00:00 2001
From: Alan Third <[email-masked]>
Date: Sun, 17 Oct 2021 19:30:59 +0100
Subject: [PATCH] Fix inset rectangle corners when sides aren't drawn
 (bug#51251)

* src/nsterm.m (ns_draw_relief): Make the inner rectangle line up with
the outer rectangle's edges where the edges aren't drawn.
---
 src/nsterm.m | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/nsterm.m b/src/nsterm.m
index c6f80f8035..aa29c13eb2 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -3512,7 +3512,12 @@ larger if there are taller display elements (e.g., characters
     }
 
   /* Calculate the inner rectangle.  */
-  inner = NSInsetRect (outer, hthickness, vthickness);
+  inner = NSMakeRect (NSMinX (outer) + (left_p ? hthickness : 0),
+                      NSMinY (outer) + (top_p ? vthickness : 0),
+                      NSWidth (outer) - (left_p ? hthickness : 0)
+                                      - (right_p ? hthickness : 0),
+                      NSHeight (outer) - (top_p ? vthickness : 0)
+                                       - (bottom_p ? vthickness : 0));
 
   [(raised_p ? lightCol : darkCol) set];
 
-- 
2.33.0