Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not change Windows border colors #43

Open
riceissa opened this issue Jan 2, 2024 · 12 comments
Open

Does not change Windows border colors #43

riceissa opened this issue Jan 2, 2024 · 12 comments
Labels
help wanted Extra attention is needed windows

Comments

@riceissa
Copy link

riceissa commented Jan 2, 2024

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
Copy link
Owner

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?

@LionyxML LionyxML added the help wanted Extra attention is needed label Jan 13, 2024
@riceissa
Copy link
Author

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
Copy link
Author

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
Copy link
Owner

LionyxML commented Jan 28, 2024

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
Copy link
Author

Thank you for looking into this!

Is there a link to the Emacs bug report?

@LionyxML
Copy link
Owner

Sure!

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

@11xx
Copy link

11xx commented Mar 1, 2024

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
Copy link
Author

riceissa commented Mar 1, 2024

@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
Copy link

11xx commented Mar 2, 2024

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

emacs-mica-titlebar.git.mp4

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
Copy link
Author

@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
Copy link

11xx commented Mar 14, 2024

@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
Copy link
Owner

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed windows
Projects
None yet
Development

No branches or pull requests

3 participants