]> git.eshelyaron.com Git - emacs.git/commitdiff
Allow users to opt out of following Windows Dark mode
authorEli Zaretskii <eliz@gnu.org>
Sat, 27 Jan 2024 17:11:22 +0000 (19:11 +0200)
committerEshel Yaron <me@eshelyaron.com>
Wed, 31 Jan 2024 20:09:19 +0000 (21:09 +0100)
* src/w32fns.c (globals_of_w32fns) <w32-follow-system-dark-mode>:
New variable.
(w32_applytheme): Disable application of Dark mode if
'w32-follow-system-dark-mode' is nil.

* etc/NEWS:
* doc/emacs/msdos.texi (Windows Misc): Document
'w32-follow-system-dark-mode'.

(cherry picked from commit 58f0603d40d238383aaa911eb09b3e2809177bfa)

doc/emacs/msdos.texi
etc/NEWS
lisp/cus-start.el
src/w32fns.c

index b00f116ee4efdffa7cbde029b03e3dd31b32883e..861c0d90dc6b807e005875cef3cea5ae375d7b72 100644 (file)
@@ -1182,12 +1182,23 @@ click-to-focus policy.
 @end ifnottex
 
   On Windows 10 (version 1809 and higher) and Windows 11, Emacs title
-bars and scroll bars will follow the system's Light or Dark mode,
-similar to other programs such as Explorer and Command Prompt.  To
-change the color mode, select @code{Personalization} from
-@w{@code{Windows Settings}}, then
-@w{@code{Colors->Choose your color}} (or @w{@code{Choose your default
-app mode}}); then restart Emacs.
+bars and scroll bars by default follow the system's Light or Dark
+mode, similar to other programs such as Explorer and Command Prompt.
+To change the color mode, select @code{Personalization} from
+@w{@code{Windows Settings}}, then @w{@code{Colors->Choose your color}}
+(or @w{@code{Choose your default app mode}} or @w{@code{Choose your
+mode}}); then restart Emacs.  On Windows 11, you can select separate
+default modes for Windows and for applications.
+
+@vindex w32-follow-system-dark-mode
+  If you don't want Emacs to follow the system's Dark mode setting,
+customize the variable @code{w32-follow-system-dark-mode} to a
+@code{nil} value; then Emacs will use the default Light mode
+regardless of system-wide settings.  Changing the value of this
+variable affects only the Emacs frames created after the change, so
+you should set its value in your init file (@pxref{Init File}), either
+directly or via @kbd{M-x customize-variable}, which lets you save the
+customized value, see @ref{Saving Customizations}.
 
 @ifnottex
 @include msdos-xtra.texi
index a2ce782af174ed14acc18739e958d8c75ee6646a..8b7d445b39b171fd6b662427e0dd87cec9a64ec4 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -2012,6 +2012,16 @@ always omitted, and ignored if present when the object is read back in.
 \f
 * Changes in Emacs 30.1 on Non-Free Operating Systems
 
+** MS-Windows
+
++++
+*** You can now opt out of following the system's Dark mode.
+By default, Emacs on MS-Windows follows the system's Dark mode for its
+title bars' and scroll bars' appearance.  If the new user option
+'w32-follow-system-dark-mode' is customized to the nil value, Emacs
+will disregard the system's Dark mode and will always use the default
+Light mode.
+
 \f
 ----------------------------------------------------------------------
 This file is part of GNU Emacs.
index 3687902928259605becfa42be71e153c9e461177..7e0b64e906715ac87740bced24d41dead090db1a 100644 (file)
@@ -606,6 +606,8 @@ This should only be chosen under exceptional circumstances,
 since it could result in memory overflow and make Emacs crash."
                                              nil))
                               "27.1")
+             ;; w32fns.c
+             (w32-follow-system-dark-mode display boolean "30.1")
             ;; window.c
             (temp-buffer-show-function windows (choice (const nil) function))
             (next-screen-context-lines windows integer)
index f44460e52c01bbc74ab5805bb4e2ad79bf8e9858..8d4bd00b91c3856e2e962f6bedbc87672a71881f 100644 (file)
@@ -2376,7 +2376,7 @@ w32_init_class (HINSTANCE hinst)
 static void
 w32_applytheme (HWND hwnd)
 {
-  if (w32_darkmode)
+  if (w32_darkmode && w32_follow_system_dark_mode)
     {
       /* Set window theme to that of a built-in Windows app (Explorer),
         because it has dark scroll bars and other UI elements.  */
@@ -11393,6 +11393,14 @@ This variable is used for debugging, and takes precedence over any
 value of the `inhibit-double-buffering' frame parameter.  */);
   w32_disable_double_buffering = false;
 
+  DEFVAR_BOOL ("w32-follow-system-dark-mode", w32_follow_system_dark_mode,
+              doc: /* Whether to follow the system's Dark mode on MS-Windows.
+If this is nil, Emacs on MS-Windows will not follow the system's Dark
+mode as far as the appearance of title bars and scroll bars is
+concerned, it will always use the default Light mode instead.
+Changing the value takes effect only for frames created after the change.  */);
+  w32_follow_system_dark_mode = true;
+
   if (os_subtype == OS_SUBTYPE_NT)
     w32_unicode_gui = 1;
   else