Subject: Re: bug#62573: 29.0.60; Cursor color not being inverted in emacs-29

From: Po Lu <[email-masked]>
Date: Sun, 02 Apr 2023 08:44:09 +0800

Daniel Martín <[email-masked]> writes:

> I've solved the bug by replicating that logic in the appropriate places,
> nsterm.m and macfont.m:

Nice, thanks.

> +              CGColorRef colorref = get_cgcolor_from_nscolor (FRAME_CURSOR_COLOR (f), f);

This row is now wider than 80 columns.  Please wrap it.

>            struct face *face = s->face;
>            if (!face->stipple)
> -	    {
> -	      if (s->hl != DRAW_CURSOR)
> -		[(NS_FACE_BACKGROUND (face) != 0
> -		  ? [NSColor colorWithUnsignedLong:NS_FACE_BACKGROUND (face)]
> -		  : FRAME_BACKGROUND_COLOR (s->f)) set];
> -	      else
> -		[FRAME_CURSOR_COLOR (s->f) set];
> -	    }
> +            {
> +              if (s->hl != DRAW_CURSOR)
> +                [(NS_FACE_BACKGROUND (face) != 0
> +                  ? [NSColor colorWithUnsignedLong:NS_FACE_BACKGROUND (face)]
> +                  : FRAME_BACKGROUND_COLOR (s->f)) set];
> +              else if (face && NS_FACE_BACKGROUND (face)
> +                       == [(NSColor*)FRAME_CURSOR_COLOR (s->f) unsignedLong])
> +                [[NSColor colorWithUnsignedLong:NS_FACE_FOREGROUND (face)] set];
> +              else
> +                [FRAME_CURSOR_COLOR (s->f) set];
> +            }
>            else
>              {
>                struct ns_display_info *dpyinfo = FRAME_DISPLAY_INFO (s->f);
>

Please write:

  (face && (NS_FACE_BACKGROUND (face)
  	    == [(NSColor *) FRAME_CURSOR_COLOR (s->f)
                  unsignedLong]))

instead.

> Could you give it a try on macOS and GNUstep?  Thank you.

Works for me, thanks.

P.S. I think what needs to be done is to make the NS port keep track of
glyph string colors through GCs, so that the relevant code can be easily
synchronized with X.