-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
eframe: Automatically change theme when system dark/light mode changes #2750
Merged
Merged
Changes from 12 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
095c384
React to ThemeChanged event from winit
bash 53b67be
React to theme change using media query change event in WASM
bash d4bf614
Share conversion from bool -> Theme
bash e38348d
Suppress too_many_arguments warning
bash 062ec1b
Document limitations of automatically following the dark vs light mod…
bash bcf4db9
Simplify expression
bash 9105b26
Conditionally compile code to prevent unused item warnings
bash cfa295d
Remove needless borrow
bash 1d1e8f8
Remove another needless borrow
bash 166da0f
Make associated functions to standalone
bash aabb1a4
Request repaint after theme has changed
bash 7930deb
Only install event listener when `follow_system_theme` is enabled
bash 1ecb65c
Remove dark-light feature gate
bash 2c449e5
Detect system theme using winit
bash b5f4548
Update documentation
bash 6c1c8df
Fix typos
bash 0c49a3d
fix warning about unused argument
emilk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see any reason to limit this on the
dark-light
feature.dark-light
pulls in a specific dependency for detecting the system theme on start-up. Maybe we can do that viawinit
instead?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have removed
#[cfg(feature = "dark-light")]
from all places where it's not necessary.Detecting the theme via winit's
theme
function works for Windows and macOS—I have tested the latest change on both my Windows 11 and my macOS devices.The theme is read from the system preferences when the window is created.
The
theme
function always returnsNone
on Linux though (for both X11 and Wayland), so there we still have to rely ondark-light
.The
NativeOptions::system_theme
function has become a bit of a liar, since it no longer corresponds with the effectively used system theme on Windows and macOS.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting! Sounds like we maybe don't need
dark-light
at all then? (since it already doesn't work well on Linux)