8000 feat: support `systemPreferences.isDarkMode()` on Windows by deermichel · Pull Request #19217 · electron/electron · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat: support systemPreferences.isDarkMode() on Windows #19217

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

Merged
merged 2 commits into from
Jul 15, 2019

Conversation

deermichel
Copy link
Contributor
@deermichel deermichel commented Jul 12, 2019

Description of Change

Closes #18696. Closes #15316. Adds support for the systemPreferences.isDarkMode() API on Windows using Chromium's NativeTheme API.

Outdated (not-actually-used) approach

Whether the system uses dark or light theme is derived from following registry key:

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize\AppsUseLightTheme 
  | value 0  == dark
  | value 1+ == light

cc @MarshallOfSound @erickzhao @codebytere

Checklist

Release Notes

Notes: Added support for systemPreferences.isDarkMode() API on Windows.

@deermichel deermichel requested a review from erickzhao July 12, 2019 01:07
@electron-cation electron-cation bot added the new-pr 🌱 PR opened recently label Jul 12, 2019
@deepak1556
Copy link
Member

I want to reiterate on this again #18666 (comment), why aren't we reusing the api from ui::NativeTheme ?

/cc @codebytere @MarshallOfSound

@deermichel
Copy link
Contributor Author

Huh... probs bc that would've been too easy 😄. I'll take a closer look at it tmw - looks promising... and even offers an event emitter for theme changes.

Maybe we can get Linux support as well and upstream it to Chromium?

@MarshallOfSound
Copy link
Member

Yeah macOS is the issue there. We could use that api just for Windows support though?

8000

@deepak1556
Copy link
Member

@codebytere I don't see the reason to patch even if thats the case we could return ui::NativeTheme result for if (@available(macOS 10.14, *)) { else return result from our implementation..

@codebytere
Copy link
Member

oops my comment somehow deleted but in response to the above, yeah it might just be fine to gate it on mac and use for windows in totality

@electron-cation electron-cation bot removed the new-pr 🌱 PR opened recently label Jul 13, 2019
@deermichel deermichel force-pushed the intern/win-darkmode branch from 494b9b1 to 06cbf62 Compare July 13, 2019 16:39
@deermichel
Copy link
Contributor Author
deermichel commented Jul 15, 2019

Before merging, should I also add a dark-mode-changed (or sth like that) event or better do so in an additional PR? (And i might migrate the other methods to NativeTheme as well)

@MarshallOfSound
Copy link
Member

@deermichel If we do do a first-party dark-mode-changed event we should probs do it for macOS as well and that requires some consideration as we support < 10.14. Let's land isDarkMode for windows and think about the event separately

@deermichel
Copy link
Contributor Author

You're right, I totally forgot about macOS. Then this PR is ready to get merged 👍

@codebytere codebytere merged commit da672a3 into master Jul 15, 2019
@release-clerk
Copy link
release-clerk bot commented Jul 15, 2019

Release Notes Persisted

Added support for systemPreferences.isDarkMode() API on Windows.

@codebytere codebytere deleted the intern/win-darkmode branch July 15, 2019 21:37
@caesar
Copy link
Contributor
caesar commented Jul 20, 2019

Will this make it into Electron 6.0.0?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add method for getting Windows 10 Shell Color Windows support for systemPreferences.isDarkMode() API
6 participants
0