Subject: Re: bug#33452: Color of tooltip text on macOS with dark mode

From: Alan Third <[email-masked]>
Date: Sat, 24 Nov 2018 09:35:25 +0000

On Fri, Nov 23, 2018 at 11:08:18PM +0200, Eli Zaretskii wrote:
> > Date: Fri, 23 Nov 2018 20:38:51 +0000
> > From: Alan Third <[email-masked]>
> > Cc: [email-masked], [email-masked]
> > 
> > Sorry, I thought you were meaning colours as set by Emacs lisp.
> > 
> > We can set the foreground and background to anything we want in C, but
> > in emacs-26 currently we can’t modify them by Emacs lisp, and only the
> > background colour is being set in C, which leaves the foreground to
> > use whatever the system default is.
> > 
> > The master branch honours the colours set by lisp.
> 
> Thanks.  So what are out alternatives for emacs-26, besides
> backporting from master (which will give control on colors to Lisp)?

We can try to use the system tooltip colours, but I think we’re better
off just setting a foreground colour. Patch attached.
-- 
Alan Third
>From 1caacbf3600302ca3dd7da4371e30857c4b01f51 Mon Sep 17 00:00:00 2001
From: Alan Third <[email-masked]>
Date: Sat, 24 Nov 2018 09:30:17 +0000
Subject: [PATCH] Set tooltip text color (bug#33452)

; Do not merge into master

* src/nsmenu.m: ([EmacsTooltip init]): Set text color to black.
---
 src/nsmenu.m | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/nsmenu.m b/src/nsmenu.m
index 604adcf40b..52a7d52e8e 100644
--- a/src/nsmenu.m
+++ b/src/nsmenu.m
@@ -1318,8 +1318,9 @@ @implementation EmacsTooltip
 
 - (instancetype)init
 {
-  NSColor *col = [NSColor colorWithCalibratedRed: 1.0 green: 1.0
+  NSColor *bgcol = [NSColor colorWithCalibratedRed: 1.0 green: 1.0
                                             blue: 0.792 alpha: 0.95];
+  NSColor *fgcol = [NSColor blackColor];
   NSFont *font = [NSFont toolTipsFontOfSize: 0];
   NSFont *sfont = [font screenFont];
   int height = [sfont ascender] - [sfont descender];
@@ -1328,7 +1329,8 @@ - (instancetype)init
 
   textField = [[NSTextField alloc] initWithFrame: r];
   [textField setFont: font];
-  [textField setBackgroundColor: col];
+  [textField setTextColor: fgcol];
+  [textField setBackgroundColor: bgcol];
 
   [textField setEditable: NO];
   [textField setSelectable: NO];
@@ -1345,7 +1347,7 @@ - (instancetype)init
   [win setReleasedWhenClosed: NO];
   [win setDelegate: self];
   [[win contentView] addSubview: textField];
-/*  [win setBackgroundColor: col]; */
+/*  [win setBackgroundColor: bgcol]; */
   [win setOpaque: NO];
 
   return self;
-- 
2.19.1