1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-15 10:30:25 -08:00

Allow users to opt out of following Windows Dark mode

* 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'.
This commit is contained in:
Eli Zaretskii 2024-01-27 19:11:22 +02:00
parent 3c4b6823c3
commit 58f0603d40
4 changed files with 38 additions and 7 deletions

View 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

View file

@ -1880,6 +1880,16 @@ always omitted, and ignored if present when the object is read back in.
* 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.
----------------------------------------------------------------------
This file is part of GNU Emacs.

View 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)

View 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