Repository navigation
fix(linux): portal color-scheme 0 (no preference) resolves to light, matching Chromium - #1743
Merged
Merged
Conversation
…matching Chromium
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #285
Root cause
crates/rune/src/platform/portal_appearance.rs,SCHEMEused0for both "no portal has answered yet" and "portal answeredcolor-scheme = 0(no preference)", andscheme_darkreturnedNonefor0.crates/rune/src/platform/preferences.rs(window_dark) turnsNoneinto dark, andHost::paintignoresNone. On desktops whose light/default style reports0(GNOME's Default style, DankMaterialShell in light mode),Cx::system_dark()stayedtrueand switching from dark (1) back to default (0) could not leave dark mode.Outside answer
Once the XDG desktop portal answers
org.freedesktop.appearancecolor-scheme,1is dark and0(no preference),2(prefer light), and unknown values resolve to light;Noneis reserved for "the portal never answered":color-schemeui/linux/portal_settings_linux.cc(SetColorScheme) &portal_settings_linux_unittest.cc(UsePortalSettingNoPreference,crbug.com/462191707)1toprefer_dark = trueand0/2/ unknown to explicitprefer_dark = false(light); reservesstd::nulloptstrictly for an unanswered portal.widget/gtk/nsLookAndFeel.cpp(RecomputeDBusAppearanceSetting)1toSome(ColorScheme::Dark)and0/2toSome(ColorScheme::Light).src/adw-style-manager.c(get_is_dark)ADW_COLOR_SCHEME_DEFAULTisPREFER_LIGHT(system_scheme == PREFER_DARK), so0draws light.src/gui/platform/unix/qdbussettings.cpp&qplatformtheme.cpp0toUnknown;qt_fusionPalettetreats onlyDarkas dark.prefers-color-scheme)Changes
crates/rune/src/platform/portal_appearance.rs: separateUNKNOWN = 0(portal has not answered) from answered statesDARK = 1(1) andLIGHT = 2(0,2, or unknown values per the XDG Settings portal spec), and extract pureencode_scheme,stored_dark, andrecord_schemehelpers so transitions out ofUNKNOWNand1 -> 0both request a redraw.crates/rune/src/platform.rs: enableportal_appearanceundercfg(test)so its mapping and state-transition tests run on all targets while keeping D-Bus code gated behindcfg(all(target_os = "linux", feature = "dbus")).crates/rune/src/platform/portal_appearance_tests.rs: test unansweredNone,0/1/2/unknown mapping, andUNKNOWN -> 0 -> 2 -> 1 -> 0redraw transitions.changelog/unreleased/2026-11-24-linux-portal-color-scheme-default.md: record the behaviour change.Verification
cargo test -p rune -p rune-mermaid -p rune-kit --features rune-kit/markdown,rune-kit/mermaid platform::portal(failed before fix on0andUNKNOWN -> 0; 7/7 passed after fix).cargo check -p rune -p rune-kit --testspassed (exit 0;reads_the_scheme_however_deeply_the_portal_wraps_itcompiled, not run in container).scripts/file-size.shpassed (0 errors).xdg-desktop-portal.