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: Thu, 06 Apr 2023 12:12:04 +0200 Message-ID: References: <83edp420lx.fsf@gnu.org> <83bkk817rr.fsf@gnu.org> <87mt3rru3q.fsf@yahoo.com> <87ttxxrfpf.fsf@yahoo.com> Reply-To: Daniel =?UTF-8?Q?Mart=C3=ADn?= Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="27889"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (darwin) Cc: Al Haji-Ali , Eli Zaretskii , 62573@debbugs.gnu.org To: Po Lu Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Apr 06 12:13:14 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 1pkMcE-00075v-2L for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 06 Apr 2023 12:13:14 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pkMc3-0000Um-Ql; Thu, 06 Apr 2023 06:13:03 -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 1pkMc2-0000Uc-J8 for bug-gnu-emacs@gnu.org; Thu, 06 Apr 2023 06:13:02 -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 1pkMc2-00021j-AV for bug-gnu-emacs@gnu.org; Thu, 06 Apr 2023 06:13:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pkMc2-0007jm-0V for bug-gnu-emacs@gnu.org; Thu, 06 Apr 2023 06:13: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: Thu, 06 Apr 2023 10:13:01 +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.168077593629670 (code B ref 62573); Thu, 06 Apr 2023 10:13:01 +0000 Original-Received: (at 62573) by debbugs.gnu.org; 6 Apr 2023 10:12:16 +0000 Original-Received: from localhost ([127.0.0.1]:53484 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pkMbI-0007iU-9i for submit@debbugs.gnu.org; Thu, 06 Apr 2023 06:12:16 -0400 Original-Received: from sonic301-21.consmr.mail.ir2.yahoo.com ([77.238.176.98]:38484) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pkMbG-0007iH-Pg for 62573@debbugs.gnu.org; Thu, 06 Apr 2023 06:12:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.es; s=s2048; t=1680775929; bh=EvMuDYzJoWRxxSxLkHQmophsWDGpNjKFKlb0CcBzTJI=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From:Subject:Reply-To; b=ZBJZg2RM995lfqNrNpjApdONOw+NHs9fMB4HVX4UxbaQ3C03nDu+RS0u42fJm9eLUhEFsijMmpa5IsgyTHF1htnXm6l5FuF0CPB9cN75DeaVrUJWXfhx3bMqxDJLZnlZBBUXNXxa9Nk3ld/Whh7HsZHDE+UnB0risihFns2roJ5Nn/pYZgCprzscqjGWOBSClQS9IrAeRY1C6xgtqqYhUY3aixMupunfoXeGHOZMDopqTimakISUHiz/iGHcr+hDLEZHfOXk95LnHTNC8thwgFnUeFucA+BQGArTA270g24waeM1jcBiIMraOfPjfAmBoXfp5Tvg7misiCjz5+zXwA== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1680775929; bh=X6nGdqeSPrfNrnHsbXjkHsoVXbq9fL/gSmYtWsHcLp3=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=SA/jGhLiTnaCDOjBFf62XzFlaf5i2eKt3z75zdzIY8a32Wyu7o6hGSN8BDILz/aQ3EsaRDe3Woo2ceo4MUIkPNWge7TLGWViQgps8M5c4gPfl9RqBDT+GO26YWnwvEvoxIeVpJj7LdjvaCHNRyDl9eBA7VxYKRM+hrpmXMdrWKAFyoNxjrX67AefuD0litN+5DGJNh9NmwL6dlQ5HcK7Dj+8ZFHuwNSxoh6aDD4hTrtg0N+mGMOv8AgEDJGeshN/r+ptOkSaiqkjtr2OmKuYdcMrB/fz/esatIpG/pcQsgIBnbzagGPzOUlsqkEjsnrU7GdSmOfpRFZLc4dpJd5y/w== X-YMail-OSG: TyW1ULYVM1nzrcBzv_bMKKR4oCvLMiTlyI6q2kk0lLCVMXxnMW2DSbjIeMoHyed TjBQE8B28kcHGGfEnNe2nGyLiN1Hz3ayYUWsHCb7nizr9GrJKavnDvukKomX8Na5vL8ImV8KYsRj EjliBeMBfnxFtqxodYNkv9fPUJtC5NooaNatMs2XcPi5XLqDlzNQD0EvCWxka7cJVmNBuqShekKD UmKRWIOOFVP_zVB.Pkg6MvDpNFVlKRJhbTrAAeb3W_kCIPBqhG7jscYKMihNbOkmDSY1X5KUot5j nP7fIH7cd9m3OgTtAdANzngm0RBwuHHklI6he9TbUC5e_MQHD0j2IHb_zEZ3iB31EzNngpqy7lm9 sVqZg2PYW8xduUk34iSRYHbnWYY_9EJfbX5jX3PJ69EeN8Jh7wpP4.7BUYJghZtLhyNKET28MQ8m m9atwUk.IRDK1zJUdRcF3uDuaVWNnuRqxYbLknJAo_kncCY_0WlNKvjZvLhbwx1o8f__PaOIjwhM GHa5kpcGtPjYEadHwu5I5Bh4xomvwxYcUU._bDyDIDju7mq4SBw1rl1xues2UlPUd9.zyRQNwGdb iX9zKBJVtoFbXfvv.jCedg3GL5c4irmNXaaoEtXP5i_SMl0oGGk_fBtmCJi73LtbBMJlmFmoJ48U BhmzyNDs_VHVa.Kl.LcL4eoFdGs_pNW3jkkSQe847t11ENX7bMUZqjX.FF37w4UPCJ.9862usDMH y6PnQV9kgS2ZJcqqfObPczmZVN5uEJTAhXMyIdE7TV95Wpqi9tTbXHChWTY1ouae9o8to3cNDli2 uUwBgRAp1BS4dddOf6caO3xS93CO9OY58e83XXeR2T X-Sonic-MF: X-Sonic-ID: 51c4d936-c0a9-4b62-a7ef-cb7031465158 Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic301.consmr.mail.ir2.yahoo.com with HTTP; Thu, 6 Apr 2023 10:12:09 +0000 Original-Received: by hermes--production-ir2-74cd8fc864-b5cqd (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 6ee514815d0610f4ab50da0a4ef9c754; Thu, 06 Apr 2023 10:12:05 +0000 (UTC) In-Reply-To: <87ttxxrfpf.fsf@yahoo.com> (Po Lu's message of "Mon, 03 Apr 2023 08:07:24 +0800") X-Mailer: WebService/1.1.21365 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:259306 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Po Lu writes: > Daniel Mart=C3=ADn writes: > >> +#define CG_SET_FILL_COLOR_WITH_FRAME_CURSOR(context, frame) = \ >> + do { = \ >> + CGColorRef refcol_ =3D = \ >> + get_cgcolor_from_nscolor (FRAME_CURSOR_COLOR (frame), frame); = \ >> + CGContextSetFillColorWithColor (context, refcol_); = \ >> + CGColorRelease (refcol_); = \ >> + } while (0) >> +#define CG_SET_FILL_COLOR_WITH_FRAME_BACKGROUND(context, frame) = \ >> + do { = \ >> + CGColorRef refcol_ =3D = \ >> + get_cgcolor_from_nscolor (FRAME_BACKGROUND_COLOR (frame), frame);= \ >> + CGContextSetFillColorWithColor (context, refcol_); = \ >> + CGColorRelease (refcol_); = \ >> + } while (0) > > Thanks. The GNU Coding Standards split expressions, before operators. > So this should read: > > do { > CGColorRef refcol > =3D ... > > also, since you put this in a separate block, you don't have to worry > about shadowing, so there's no need to use names with a trailing > underscore. > OK, I've removed the trailing underscore in the other macros as well. Here's a new patch with the requested changes. If everything looks good, could someone install the patch for me? (I don't have push access to the repository.) Thanks. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Change-cursor-color-on-NS-port-when-it-matches-the-f.patch >From bbce06787debc564353ffc09ad74566e1fa254a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=ADn?= Date: Sun, 2 Apr 2023 22:39:44 +0200 Subject: [PATCH] Change cursor color on NS port when it matches the face background * src/macfont.m (CG_SET_FILL_COLOR_WITH_FRAME_CURSOR): New macro. (CG_SET_FILL_COLOR_WITH_FRAME_BACKGROUND): New macro. (macfont_draw): When the cursor's color matches the face background, set the fill color of the cursor to the face foreground. * src/nsterm.m (ns_maybe_dumpglyphs_background): When dumping the background of a glyph string, apply the logic mentioned above. (Bug#62573) --- src/macfont.m | 50 +++++++++++++++++++++++++++++++++++--------------- src/nsterm.m | 20 ++++++++++++-------- 2 files changed, 47 insertions(+), 23 deletions(-) diff --git a/src/macfont.m b/src/macfont.m index d0cdbcd08c7..9f9f6f4efaf 100644 --- a/src/macfont.m +++ b/src/macfont.m @@ -632,21 +632,35 @@ static void mac_font_get_glyphs_for_variants (CFDataRef, UTF32Char, #define CG_SET_FILL_COLOR_WITH_FACE_FOREGROUND(context, face) \ do { \ - CGColorRef refcol_ = get_cgcolor (NS_FACE_FOREGROUND (face)); \ - CGContextSetFillColorWithColor (context, refcol_) ; \ - CGColorRelease (refcol_); \ + CGColorRef refcol = get_cgcolor (NS_FACE_FOREGROUND (face)); \ + CGContextSetFillColorWithColor (context, refcol); \ + CGColorRelease (refcol); \ } while (0) #define CG_SET_FILL_COLOR_WITH_FACE_BACKGROUND(context, face) \ do { \ - CGColorRef refcol_ = get_cgcolor (NS_FACE_BACKGROUND (face)); \ - CGContextSetFillColorWithColor (context, refcol_); \ - CGColorRelease (refcol_); \ + CGColorRef refcol = get_cgcolor (NS_FACE_BACKGROUND (face)); \ + CGContextSetFillColorWithColor (context, refcol); \ + CGColorRelease (refcol); \ + } while (0) +#define CG_SET_FILL_COLOR_WITH_FRAME_CURSOR(context, frame) \ + do { \ + CGColorRef refcol \ + = get_cgcolor_from_nscolor (FRAME_CURSOR_COLOR (frame), frame); \ + CGContextSetFillColorWithColor (context, refcol); \ + CGColorRelease (refcol); \ + } while (0) +#define CG_SET_FILL_COLOR_WITH_FRAME_BACKGROUND(context, frame) \ + do { \ + CGColorRef refcol \ + = get_cgcolor_from_nscolor (FRAME_BACKGROUND_COLOR (frame), frame); \ + CGContextSetFillColorWithColor (context, refcol); \ + CGColorRelease (refcol); \ } while (0) #define CG_SET_STROKE_COLOR_WITH_FACE_FOREGROUND(context, face) \ do { \ - CGColorRef refcol_ = get_cgcolor (NS_FACE_FOREGROUND (face)); \ - CGContextSetStrokeColorWithColor (context, refcol_); \ - CGColorRelease (refcol_); \ + CGColorRef refcol = get_cgcolor (NS_FACE_FOREGROUND (face)); \ + CGContextSetStrokeColorWithColor (context, refcol); \ + CGColorRelease (refcol); \ } while (0) @@ -2933,9 +2947,12 @@ 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 + CG_SET_FILL_COLOR_WITH_FRAME_CURSOR (context, f); } else CG_SET_FILL_COLOR_WITH_FACE_BACKGROUND (context, face); @@ -2949,9 +2966,12 @@ 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 + CG_SET_FILL_COLOR_WITH_FRAME_BACKGROUND (context, f); } else CG_SET_FILL_COLOR_WITH_FACE_FOREGROUND (context, face); diff --git a/src/nsterm.m b/src/nsterm.m index c9f955000ac..37462cf49e2 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -3750,14 +3750,18 @@ 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); -- 2.34.1 --=-=-=--