Subject: [macOS] `ns-transparent-titlebar` gives black-on-black text with dark themes

From: Stefan Kangas <[email-masked]>
Date: Sat, 14 Sep 2024 05:58:55 -0700

Severity: minor

When using (some?) dark themes with `ns-transparent-titlebar` set to t
on macOS, you get black-on-black text in the titlebar.

To reproduce the bug, evaluate this in emacs -Q:

   (progn (load-theme 'modus-vivendi)
          (modify-frame-parameters
           nil '((ns-transparent-titlebar . t))))

The black-on-black text disappear when evaluating this:

    (modify-frame-parameters
     nil `((ns-transparent-titlebar . t)
           (ns-appearance . ,(frame-parameter nil 'background-mode))))

However, this now gives white-on-white text when you switch to a light
theme (for example `M-x load-theme RET modus-operandi RET`).

There is a package that attempts to solve this by updating
`ns-appearance` dynamically depending on the theme:

    https://github.com/purcell/ns-auto-titlebar

However, this just seems like a work-around for a plain bug.

I wonder if there is any reason why `ns-transparent-titlebar` set to t
can't just make it work as if `ns-appearance` was set to something like
this:

    (ns-appearance . ,(frame-parameter nil 'background-mode))

FWIW, here's a recipe to try the `ns-auto-titlebar` package:

    emacs -Q --eval "(progn (package-initialize) \
        (use-package ns-auto-titlebar :ensure t \
            :config (ns-auto-titlebar-mode)) \
        (load-theme 'modus-vivendi))"