LionyxML / auto-dark-emacs

Auto-Dark-Emacs is an auto changer between 2 themes, dark/light, following MacOS, Linux or Windows Dark Mode settings
GNU General Public License v2.0
140 stars 34 forks source link

Does not change Windows border colors #43

Open riceissa opened 7 months ago

riceissa commented 7 months ago

auto-dark does not seem to change the border colors on Windows; the border colors only get set whenever I open Emacs. For example, if I open Emacs at night (when Windows has dark mode) and then wake up in the morning (when I have a program that automatically sets Windows to be in light mode), Emacs will have a light inside with a dark border:

image

(notice how the top bar and scrollbar are black)

If I close Emacs and restart it then the borders turn light (assuming it is daytime).

LionyxML commented 7 months ago

Hello there @riceissa.

Damn Windows.

Is this also a problem when you start Emacs with emacs -Q?

I am not entirely sure how we could "force" from "within Emacs" a change on system window decoration. Also, It's been a while since I've fired up some Windows machine.

Would you please inform your Windows and Emacs versions?

riceissa commented 7 months ago

I appreciate the response!

Yes, the same thing happens when I run emacs.exe -Q or runemacs.exe -Q on the command prompt. Pretty much every other program (command prompt, WSL, Obsidian, Anki, Firefox) automatically changes the title bar color when I change the app theme. Only a few seem to either be unable to do this (Git-Bash, Emacs) or provide their own interface for manually setting the theme (SumatraPDF). This does seem like maybe a bug in Emacs itself, but I was hoping there was some way to run some Elisp code to fix it instead of having to file a bug with the Emacs developers. 😅

Emacs version is: GNU Emacs 29.1 (build 2, x86_64-w64-mingw32) of 2023-07-30.

Windows version is: Windows 10 (Pro) Version 22H2 (OS Build 19045.3930).

riceissa commented 7 months ago

Just wanted to give an update that a new version of Emacs (19.2) came out yesterday and I've upgraded to that version, but the problem is still there.

LionyxML commented 7 months ago

Tonight, I had some time to address this issue, and I encountered almost all the problems you described myself :)

Some screenshots here: https://imgur.com/a/zSSx2tk

This is good; it means the issue is reproducible.

It appears to be beyond the scope of auto-dark-mode, lying somewhere between the Emacs GUI toolkit on Windows and Windows itself.

Having said that, I opened a bug report with Emacs for further exploration of what we could do about it.

If there's something we can do with ELISP (I tried several things with no success), auto-dark provides hooks that can execute extra code whenever a change is detected. This can help in setting what is needed for a 'complete change with titlebar and scrollbar'.

This issue will remain open while we explore possibilities.

riceissa commented 6 months ago

Thank you for looking into this!

Is there a link to the Emacs bug report?

LionyxML commented 6 months ago

Sure!

You can follow the bug report here: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=68766

11xx commented 5 months ago

This is what MicaForEveryone is for. It works very well with Windows Auto Dark Mode.

Emacs on Windows runs as a "Win32" app so it uses the "legacy" tookit.

Live changing Win32 title bar colors (for already open windows) can be done via the registry, though it can only change for all of them, so it wouldn't be possible to change just for Emacs.

riceissa commented 5 months ago

@11xx I would be fine with changing all the title bar colors (not just Emacs); in fact, I would prefer that. I don't know how the registry works; is there a command I can run from the command prompt or Windows PowerShell?

11xx commented 5 months ago

I'd really recommend installing MicaForEveryone, Other than having it running no configuration is required, you can even choose to give the title bar the acrylic look too, here's an example of it working on Windows 11

https://github.com/LionyxML/auto-dark-emacs/assets/89880718/c59c0ca7-3243-4a9d-be71-8744dd244ab9

But traditionally the registry key to change the title bar color would be HKEY_CURRENT_USER\Software\Microsoft\Windows\DWM with a DWORD AccentColor for focused windows' title bars with value in the HEX format of BBGGRR or AABBGGRR. There's also AccentColorInactive for unfocused windows' title bars.

PS example:

New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\DWM" -Name "AccentColor" -Value 0xc4cccccc -PropertyType DWORD -Force

New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\DWM" -Name "AccentColorInactive" -Value 0xc4333333 -PropertyType DWORD -Force

where cccccc is a light grey and 333333 is a dark grey

But again, there's no reason for changing the registry manually like this.

Sorry for the off-topic of the repo, just wanted to point out that this is a non-Emacs thing and it does have a third-party solution.

riceissa commented 5 months ago

@11xx Thank you. That video looks very nice. I tried the PowerShell lines you gave and it didn't change the Emacs windows border for me. I also tried installing MicaForEveryone but it complains about not having .NET Core even though I installed both the latest version and the one linked in their FAQ. So for now, the only approach that works on my computer is to close Emacs and open it again.

11xx commented 5 months ago

@riceissa I remember having to install version 3.1 from that link. Make sure it's the .NET Desktop Runtime currently v3.1.32.

Yeah so apparently the registry approach worked until Windows 10 update 19something so.. :c

LionyxML commented 5 months ago

@11xx no problem going a bit off-site this topic.

@riceissa so apparently we still do not have a solution =(

I was thinking about modifing the README file in order to point to this issue if any Windows user comes along.