From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Daniel =?UTF-8?Q?Mart=C3=ADn?= via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#62573: 29.0.60; Cursor color not being inverted in emacs-29 Date: Sat, 01 Apr 2023 21:56:33 +0200 Message-ID: References: <83edp420lx.fsf@gnu.org> <83bkk817rr.fsf@gnu.org> Reply-To: Daniel =?UTF-8?Q?Mart=C3=ADn?= Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="6945"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (darwin) Cc: luangruo@yahoo.com, 62573@debbugs.gnu.org, Al Haji-Ali To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Apr 01 21:57:13 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pihLd-0001d5-6w for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 01 Apr 2023 21:57:13 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pihLV-0000Te-Uc; Sat, 01 Apr 2023 15:57:05 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pihLT-0000Ri-8J for bug-gnu-emacs@gnu.org; Sat, 01 Apr 2023 15:57:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pihLT-0003hq-05 for bug-gnu-emacs@gnu.org; Sat, 01 Apr 2023 15:57:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pihLS-0007eS-C8 for bug-gnu-emacs@gnu.org; Sat, 01 Apr 2023 15:57:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Daniel =?UTF-8?Q?Mart=C3=ADn?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 01 Apr 2023 19:57:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 62573 X-GNU-PR-Package: emacs Original-Received: via spool by 62573-submit@debbugs.gnu.org id=B62573.168037900729388 (code B ref 62573); Sat, 01 Apr 2023 19:57:02 +0000 Original-Received: (at 62573) by debbugs.gnu.org; 1 Apr 2023 19:56:47 +0000 Original-Received: from localhost ([127.0.0.1]:38644 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pihLC-0007dw-Kt for submit@debbugs.gnu.org; Sat, 01 Apr 2023 15:56:47 -0400 Original-Received: from sonic303-21.consmr.mail.ir2.yahoo.com ([77.238.178.202]:43198) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pihLA-0007da-Aw for 62573@debbugs.gnu.org; Sat, 01 Apr 2023 15:56:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.es; s=s2048; t=1680378998; bh=LXtxUU7N3x05arBxth3CnPZIVJuBx9QtUtIS7c2fNS4=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From:Subject:Reply-To; b=SNw0oDlu67+wxGxSfucAG8hVbvgy1cW9/jvMCx0pTchnHBHSfiFo/dSB+PA0Yx8qzvIgsJt9Sq2KW3MardUs01LUGf5Ry5s776Rw8WNtF85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qyPUfR5Lbbx56_qcJHZTGLikLSvfZDoAajknX53q2EC iRbLz8o.q1pKpFH9tUNH5GHUjX0u4NkazLP21HW2T2iQmo7QHXOoWeM64HbWU5kBu6uUNwCAeAhv 0Aw7EvzPM6cwY5RHf73FKzsy8SwQzx.aBWVO9ksR916in2dasyddsaZdvRAqqnjDbmQZ7nweDoZe hIBpZe5NSwinAmXx9JioLZDxQcab0ll3X.kCX6R3C4Cpq4azv0y1Rj3YGlpuX7DqLPtb9Fr.SyNT Vajfpee5duGPzb_D8.RW2sliUvLGo6o.BjcBEsckMF5rKosuH4VYrpCYDvrX4FVptSynjZzZol_s iak7cUIZBmHPMHrpmLZO2cO3zIFUdb9NqpSt9zhTT6N5iYZQ8NtGpeh1bMfHjDrz4FJJGLH0KpOJ Ye99rHoc8eUQLQkPlO7QAYVUXNvLH5vKTI8XOYm62bjb2vYxTsC.wiSn7hG53cACpa5gfm5YzBfi 9qil4CmdteZveRynR8NXG9XAT.ngWw.CEmgZxsMYhS X-Sonic-MF: X-Sonic-ID: fa2006c8-486b-404c-954d-5c11e023753f Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic303.consmr.mail.ir2.yahoo.com with HTTP; Sat, 1 Apr 2023 19:56:38 +0000 Original-Received: by hermes--production-ir2-74cd8fc864-jl5bm (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 525242455118bffb9120b771f33b1d5e; Sat, 01 Apr 2023 19:56:35 +0000 (UTC) In-Reply-To: <83bkk817rr.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 01 Apr 2023 08:38:48 +0300") X-Mailer: WebService/1.1.21284 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:259073 Archived-At: Eli Zaretskii writes: >> From: Al Haji-Ali >> Cc: 62573@debbugs.gnu.org >> Date: Fri, 31 Mar 2023 22:46:00 +0100 >> >> >> On 31/03/2023, Eli Zaretskii wrote: >> > On which platform is that and with what Emacs configuration? (Using >> > "M-x report-emacs-bug" would have collected this information >> > automatically for you.) >> Apologies, below are the details. I can also add the config of emacs 28.2 if that's helpful. >> I am not sure what the issue is or how to debug it, so any hints are appreciated. >> >> --------------------------------------------------------------------------- >> In GNU Emacs 29.0.60 (build 1, aarch64-apple-darwin22.3.0, NS >> appkit-2299.40 Version 13.2.1 (Build 22D68)) of 2023-03-22 built on >> HW-R9XXWKPJ4D >> Windowing system distributor 'Apple', version 10.3.2299 >> System Description: macOS 13.2.1 > > This is macOS, so I suspect the problem is specific to macOS. Can > someone with access to macOS please try reproducing this, and perhaps > debugging the problem? This bug is a regression caused by 07715630ad9df9cb681cbadecbaf73fc9c698061. (Adding Po Lu to the CC.) >From what I see, the font display refactor removed this code from src/nsterm.m: - face = FACE_FROM_ID_OR_NULL (f, phys_cursor_glyph->face_id); - if (face && NS_FACE_BACKGROUND (face) - == ns_index_color (FRAME_CURSOR_COLOR (f), f)) - { - [ns_lookup_indexed_color (NS_FACE_FOREGROUND (face), f) set]; - hollow_color = FRAME_CURSOR_COLOR (f); - } - else which seems to be responsible for the cursor color change when the background face color is the same as the cursor color. I can't find that logic in the current code, so I think we miss it from the refactoring. I've solved the bug by replicating that logic in the appropriate places, nsterm.m and macfont.m: diff --git a/src/macfont.m b/src/macfont.m index d0cdbcd08c7..d14cf5f9c98 100644 --- a/src/macfont.m +++ b/src/macfont.m @@ -2933,9 +2933,15 @@ So we use CTFontDescriptorCreateMatchingFontDescriptor (no { if (s->hl == DRAW_CURSOR) { - CGColorRef colorref = get_cgcolor_from_nscolor (FRAME_CURSOR_COLOR (f), f); - CGContextSetFillColorWithColor (context, colorref); - CGColorRelease (colorref); + if (face && NS_FACE_BACKGROUND (face) + == [(NSColor*)FRAME_CURSOR_COLOR (f) unsignedLong]) + CG_SET_FILL_COLOR_WITH_FACE_FOREGROUND (context, face); + else + { + CGColorRef colorref = get_cgcolor_from_nscolor (FRAME_CURSOR_COLOR (f), f); + CGContextSetFillColorWithColor (context, colorref); + CGColorRelease (colorref); + } } else CG_SET_FILL_COLOR_WITH_FACE_BACKGROUND (context, face); @@ -2949,9 +2955,15 @@ So we use CTFontDescriptorCreateMatchingFontDescriptor (no CGContextScaleCTM (context, 1, -1); if (s->hl == DRAW_CURSOR) { - CGColorRef colorref = get_cgcolor_from_nscolor (FRAME_BACKGROUND_COLOR (f), f); - CGContextSetFillColorWithColor (context, colorref); - CGColorRelease (colorref); + if (face && NS_FACE_BACKGROUND (face) + == [(NSColor*)FRAME_CURSOR_COLOR (f) unsignedLong]) + CG_SET_FILL_COLOR_WITH_FACE_BACKGROUND (context, face); + else + { + CGColorRef colorref = get_cgcolor_from_nscolor (FRAME_BACKGROUND_COLOR (f), f); + CGContextSetFillColorWithColor (context, colorref); + CGColorRelease (colorref); + } } else CG_SET_FILL_COLOR_WITH_FACE_FOREGROUND (context, face); diff --git a/src/nsterm.m b/src/nsterm.m index 46007ec4fcb..2f31a279bfc 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -3750,14 +3750,17 @@ Function modeled after x_draw_glyph_string_box (). { 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); Could you give it a try on macOS and GNUstep? Thank you.