Subject: bug#68766: 29.2; Windows dark/light mode changes does not reflect on Emacs Title bar/Scrollbar

From: Eli Zaretskii <[email-masked]>
Date: Sun, 28 Jan 2024 08:38:20 +0200

> From: "Rahul M. Juliato" <[email-masked]>
> Date: Sat, 27 Jan 2024 23:08:45 -0300
> 
> It seems Emacs only sets it's title bar and scrollbar colors during
> initialization, not during run time.

More accurately, the dark/light theme is examined and affected when
Emacs creates a frame.  So in the scenario you described, any frames
created _after_ running the script should obey the new dark/light
setting, but the frames which existed at the time of the change will
retain their appearance.

> I do not know if this is "by design" or "a bug", hence my bug-report.

It's "by design", in the sense that this is how the Dark theme support
is implemented in Emacs.  If someone submits changes to react to theme
change immediately for all the frames, we can consider that for
inclusion.

> I'd also like to mention that ~auto-dark~ has a hook after changing to
> both light/dark modes that could be used to run some extra elisp code if
> needed.
> 
> Is it possible to change the system title bar/scrollbar colors or "theme"
> from inside Emacs with Elisp?

No, it is not currently possible.  The code which determines the
dark/light mode of a frame runs at frame creation time, so exposing it
to Lisp would not be useful.  The development version (what will be
Emacs 30 in due time) has a user option to opt out of following the
system-wide Dark mode, but that option is only useful if set in the
init file.