Subject: bug#51404: Support system dark mode on Windows 10

From: Eli Zaretskii <[email-masked]>
Date: Sat, 30 Oct 2021 13:34:12 +0300

> Date: Thu, 28 Oct 2021 10:15:40 +0300
> From: Eli Zaretskii <[email-masked]>
> Cc: [email-masked]
> 
> > From: Vince Salvino <[email-masked]>
> > CC: "[email-masked]" <[email-masked]>
> > Date: Wed, 27 Oct 2021 21:41:05 +0000
> > 
> > Update: I managed to get my hands on an 1809 system and was able to get dark mode working there as well. As far as I can tell 1809 is the absolute minimum as that is when this setting and dark mode Explorer were introduced into Windows.
> > 
> > The advantage is that this will now work on Windows Server 2019 and Windows LTSC 2019, which some folks may be limited to as those are the latest Server and LTSC releases.
> > 
> > Attached patch includes the complete change, with relevant notes etc.
> 
> Thanks.  Your legal paperwork also came through, so I will be
> installing this soon.

Now done, with a few minor adaptations to our style conventions.

Please in the future accompany your changes with ChangeLog-style
commit log messages, as described in CONTRIBUTE.  (I added those for
you in this case.)

Can we now please implement the Emacs-specific user setting that will
allow users to opt in or out of this feature?  Here's what I suggest:

  . define a variable exposed to Lisp using DEFVAR_BOOL; let's call it
    w32-follow-system-theme
  . move the determination of w32_darkmode from globals_of_w32fns to
    w32_term_init, and make it depend on the value of
    w32-follow-system-theme: only set w32_darkmode if the variable is
    non-zero
  . document that users can customize w32-follow-system-theme in their
    early-init file (which is processed before window-system
    initialization that calls x-open-connection)

WDYT?

(Let me know if you need help in making any of the above happen.)

Thanks.