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

window.systemColorTheme conflicts with window.autoDetectColorScheme #210902

Closed
aeschli opened this issue Apr 22, 2024 · 6 comments · Fixed by #210923
Closed

window.systemColorTheme conflicts with window.autoDetectColorScheme #210902

aeschli opened this issue Apr 22, 2024 · 6 comments · Fixed by #210923
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug themes Color theme issues verified Verification succeeded
Milestone

Comments

@aeschli
Copy link
Contributor

aeschli commented Apr 22, 2024

Setting 'window.systemColorTheme' to anything else than default, will cause window.autoDetectColorScheme to no longer work.

Internally it sets nativeTheme.themeSource which hard codenativeTheme.shouldUseDarkColors and prefers-color-scheme and disable the update event which we use to detect the current OS scheme event.

Solutions:
a. we disable window.systemColorTheme if window.autoDetectColorScheme is enabled. Disadvantage: This will no longer allow to redefine the color of context menus / menus and frames when window.autoDetectColorScheme is on
b. we no longer use the Electron API to detect light/dark color schemes but use CSS (`(prefers-color-scheme: light)``.
The problem here is that this will cause some rewrite. We can only get the value when we have a window, while before we could access that value in main and already initialize some window colors

@aeschli
Copy link
Contributor Author

aeschli commented Apr 22, 2024

@bpasero FYI

@aeschli aeschli self-assigned this Apr 22, 2024
@aeschli aeschli changed the title 'window.systemColorTheme' conflicts with window.autoDetectColorScheme window.systemColorTheme conflicts with window.autoDetectColorScheme Apr 22, 2024
@aeschli
Copy link
Contributor Author

aeschli commented Apr 22, 2024

Looks like b is not an option as setting nativeTheme.themeSourc will define what
window.matchMedia((prefers-color-scheme: light)).matches returns

@aeschli
Copy link
Contributor Author

aeschli commented Apr 22, 2024

Ideally Electron would untangle the API that allows to detect the OS color scheme (mode) from the configuration of the Windows color mode. @deepak1556

@aeschli
Copy link
Contributor Author

aeschli commented Apr 22, 2024

Maybe we just rename window.systemColorTheme: auto to 'match theme'

@aeschli
Copy link
Contributor Author

aeschli commented Apr 22, 2024

The problem with window.systemColorTheme: auto is that we can configure a theme per window.

@aeschli
Copy link
Contributor Author

aeschli commented Apr 22, 2024

I now clarified in the settings descriptions that window.autoDetectColorScheme is ignored if window.systemColorTheme hardcodes a system color.

Also I renamed window.systemColorTheme: auto to window.systemColorTheme: matchColorTheme
(PR: #210923)

@aeschli aeschli added themes Color theme issues bug Issue identified by VS Code Team member as probable bug labels Apr 22, 2024
@aeschli aeschli added this to the April 2024 milestone Apr 22, 2024
@aeschli aeschli closed this as completed Apr 22, 2024
@justschen justschen added the verified Verification succeeded label Apr 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue identified by VS Code Team member as probable bug themes Color theme issues verified Verification succeeded
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants