From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Steve Purcell Newsgroups: gmane.emacs.devel Subject: Re: sRGB color support in NS port [PATCH] Date: Sat, 21 Dec 2013 14:10:18 +0000 Message-ID: <933E75DF-F665-46C0-8D82-111186A809B1@sanityinc.com> References: <23825B39C60F460E80B59C5ADF04F637@gmail.com> <83zjnv9yrp.fsf@gnu.org> <16B838CD-13DC-468E-94D1-108EBFE68F6D@swipnet.se> <7FA1C0353EC248D28B9E7242BA7BDFCC@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 (Mac OS X Mail 7.1 \(1827\)) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1387635044 3742 80.91.229.3 (21 Dec 2013 14:10:44 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 21 Dec 2013 14:10:44 +0000 (UTC) Cc: Eli Zaretskii , =?iso-8859-1?Q?Jan_Dj=E4rv?= , Bozhidar Batsov To: emacs-devel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Dec 21 15:10:46 2013 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1VuNGQ-0004bT-Hh for ged-emacs-devel@m.gmane.org; Sat, 21 Dec 2013 15:10:46 +0100 Original-Received: from localhost ([::1]:54331 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VuNGP-0007BN-Pc for ged-emacs-devel@m.gmane.org; Sat, 21 Dec 2013 09:10:45 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:58675) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VuNGH-0007BB-AY for emacs-devel@gnu.org; Sat, 21 Dec 2013 09:10:43 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VuNGB-0006gd-AS for emacs-devel@gnu.org; Sat, 21 Dec 2013 09:10:37 -0500 Original-Received: from h1189701.stratoserver.net ([85.214.32.38]:43171) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VuNG4-0006eV-Fy; Sat, 21 Dec 2013 09:10:24 -0500 Original-Received: from [192.168.1.112] (host109-158-248-123.range109-158.btcentralplus.com [109.158.248.123]) by h1189701.stratoserver.net (Postfix) with ESMTPSA id 73C08820018; Sat, 21 Dec 2013 15:10:21 +0100 (CET) In-Reply-To: <7FA1C0353EC248D28B9E7242BA7BDFCC@gmail.com> X-Mailer: Apple Mail (2.1827) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 85.214.32.38 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:166700 Archived-At: commit 3b63b2c6e9e93adab09eace60750ed981a8e528f Author: Steve Purcell Date: Sat Dec 21 11:44:12 2013 +0000 Treat hex colors as sRGB under OS X >=3D 10.7 diff --git a/src/nsterm.m b/src/nsterm.m index 733c05a..0c79186 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -1373,6 +1373,13 @@ ns_fullscreen_hook (struct frame *f) Color management =20 = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D = */ +#if defined(NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >=3D = MAC_OS_X_VERSION_10_7 +#define NS_COLOR_FROM_RGB(r, g, b) [NSColor colorWithSRGBRed: r green: = g blue: b alpha: 1.0] +#define NS_COLOR_AS_RGB(c) [c colorUsingColorSpace: [NSColorSpace = sRGBColorSpace]] +#else +#define NS_COLOR_FROM_RGB(r, g, b) [NSColor colorWithCalibratedRed: r = green: g blue: b alpha: 1.0] +#define NS_COLOR_AS_RGB(c) [c colorUsingColorSpaceName: = NSCalibratedRGBColorSpace] +#endif =20 =20 NSColor * @@ -1551,7 +1558,7 @@ ns_get_color (const char *name, NSColor **col) =20 if (r >=3D 0.0F) { - *col =3D [NSColor colorWithCalibratedRed: r green: g blue: b = alpha: 1.0]; + *col =3D NS_COLOR_FROM_RGB(r, g, b); unblock_input (); return 0; } @@ -1583,7 +1590,7 @@ ns_get_color (const char *name, NSColor **col) } =20 if (new) - *col =3D [new colorUsingColorSpaceName: NSCalibratedRGBColorSpace]; + *col =3D NS_COLOR_AS_RGB(new); unblock_input (); return new ? 0 : 1; } @@ -1624,7 +1631,7 @@ ns_color_to_lisp (NSColor *col) return build_string ((char *)str); } =20 - [[col colorUsingColorSpaceName: NSCalibratedRGBColorSpace] + [NS_COLOR_AS_RGB(col) getRed: &red green: &green blue: &blue alpha: &alpha]; if (red =3D=3Dgreen && red =3D=3Dblue) { @@ -4252,10 +4259,9 @@ ns_term_init (Lisp_Object display_name) name =3D SSDATA (XCAR (color)); c =3D XINT (XCDR (color)); [cl setColor: - [NSColor colorWithCalibratedRed: RED_FROM_ULONG (c) / = 255.0 - green: GREEN_FROM_ULONG (c) = / 255.0 - blue: BLUE_FROM_ULONG (c) = / 255.0 - alpha: 1.0] + NS_COLOR_FROM_RGB(RED_FROM_ULONG (c) / 255.0, + GREEN_FROM_ULONG (c) / 255.0, + BLUE_FROM_ULONG (c) / 255.0) forKey: [NSString stringWithUTF8String: name]]; } [cl writeToFile: nil];