Repository navigation
feat(x11): Support OS accent color via the Settings portal - #24424
MartinZikmund merged 2 commits into
Conversation
|
This pull request is merged. |
morning4coffe-dev
left a comment
There was a problem hiding this comment.
Reviewed only the Linux delta over the declared #22851 parent (7933da57fc32), without rebasing or retargeting the stack.
The portal namespace/signature, version >= 2 handling and finite RGB range checks match the Settings specification. The exact conversion also produced (128,64,191) for (0.5,0.25,0.75), and rejected out-of-range, NaN and infinity inputs in the controlled probe.
The startup ordering still has a stale-read race. Installing the watch before ReadOne prevents a missed-subscription window, but an older pending ReadOne response can arrive after a newer accent SettingChanged signal. The initializer publishes both unconditionally, so the older snapshot overwrites the newer live value and remains until another signal arrives.
I executed the source initializer, conversion and dispatcher-publication logic with controlled DBus/dispatcher stand-ins: a pending red read followed by a green signal and then the red reply yielded notifications green -> red and a final red palette. A diagnostic generation check when applying the initial snapshot on the dispatcher kept green.
Please prevent the initial snapshot from superseding a newer signal and add a deterministic overlapping-read/signal regression case. Evidence is from exact source with stand-ins, not a live GNOME/KDE session or a new full SamplesApp runtime run.
| try | ||
| { | ||
| var result = await settings.ReadOneAsync(AppearanceNamespace, AccentColorKey).ConfigureAwait(false); | ||
| CurrentPalette = ToPalette(result); |
There was a problem hiding this comment.
[P2] Do not let the initial read overwrite a newer accent signal
The watch is already active while this read is pending. If it reports a new green accent and the older ReadOne request then completes with red, both updates are queued and this assignment restores red after green. The UISettings value and theme resources can therefore stay stale until the user changes the accent again, despite the watch-before-read ordering.
The exact initializer/publication logic reproduces green -> red with controlled DBus and dispatcher stand-ins; a version check at dispatcher application time keeps green. Track whether an accent signal superseded the initial snapshot (including changes while its UI callback is queued), and add an overlapping-read/signal test.
7933da5 to
ff91a72
Compare
bf3298d to
23bc5ad
Compare
a6dcb43 to
8d0fcf4
Compare
8d0fcf4 to
918edea
Compare
23bc5ad to
d479e59
Compare
918edea to
b2b181f
Compare
6f3d929 to
4a9bb52
Compare
d479e59 to
8bb9dbb
Compare
8bb9dbb
into
unoplatform:dev/mazi/accentcolor
GitHub Issue: related to #4444 (Linux part; closed by the parent PR #22851)
PR Type:
✨ Feature
What changed? 🚀
#22851 introduces
IAccentColorExtensionfor Skia hosts and implements it for Win32 (registry) and macOS (NSColor.controlAccentColor). On Linux the X11 host had no implementation, soUISettings.GetColorValue(UIColorType.Accent*)and theSystemAccentColor*resources stayed on the default blue palette.This PR adds
LinuxAccentColorExtensiontoUno.UI.Runtime.Skia.X11, reading the accent from the XDG Settings portal (org.freedesktop.portal.Settings, version 2,org.freedesktop.appearance/accent-color), the same portal the existingLinuxSystemThemeHelperalready uses forcolor-schemeandcontrast:ReadOne; the value is a(ddd)struct of sRGB components in[0,1], converted to aColorand expanded withAccentColorPalette.FromAccentColor(Linux exposes a single accent color, like macOS).SettingChangedsignal; the change is marshalled to the UI thread and raised throughAccentColorChanged, so the sharedAccentColorHelper→Application.OnAccentColorChangedpath refreshes the resources and raisesUISettings.ColorValuesChanged.accent-colorkey (DBusErrorReplyException), and out-of-range components, which the portal spec defines as "no accent color set".X11ApplicationHostnext toISystemThemeHelperExtension. The framebuffer host is not covered (no session bus / portal in that scenario).SystemAccentColorSampledescription now mentions Linux (GNOME Settings → Appearance, KDE System Settings → Colors & Themes).Supported desktops are those whose portal backend implements
accent-color: GNOME 47+ (xdg-desktop-portal-gnome), KDE Plasma 6 (xdg-desktop-portal-kde), and others following the version 2 spec. Older backends fall back to the default palette.Validation
Compile:
Uno.UI.Runtime.Skia.X11andSamplesApp.Skia.Generic(net10.0, Release) build clean on Windows.Runtime (WSL2 Ubuntu 24.04 / WSLg, .NET 10):
SamplesApp.Skia.Genericrun against a mockorg.freedesktop.portal.Settingsv2 service on a private session bus, with a temporary runtime test (not committed) assertingUISettings.GetColorValue(Accent), the resolvedSystemColorControlAccentBrush, andUISettings.ColorValuesChanged:(1, 0, 0)→GetColorValue(Accent)=#FFFF0000, brush redSettingChanged→ green on both,ColorValuesChangedraised(-1, -1, -1)(out of range) → default#FF0078D7, brush follows(0.5, 0.25, 0.75)→(128, 64, 191)roundingcolor-schemechange leaves the accent untouchedaccent-colorkey → debug log, default palette, no crashNot verified on a real GNOME/KDE portal backend or under Wayland: I do not have a Linux desktop at hand, so a manual pass with
SystemAccentColorSampleon GNOME 47+ / Plasma 6 would be welcome.Behaviour worth knowing
AccentColorChangeda few dispatcher turns later, exactly like the system theme on X11 today.{ThemeResource}consumers update;{StaticResource SystemAccentColor}consumers resolved duringOnLaunchedkeep the default (WinUI parity: static resources never re-resolve). A bounded synchronous first read (Task.Run+ shortWait) would remove the flash at the cost of blocking startup on DBus; I kept the async design to match the theme helper and avoid a UI-thread wait. Happy to switch if reviewers prefer no flash.accent-colorkey); only unexpected exceptions log at Error.Follow-ups (not in this PR)
LinuxSystemThemeHelper,X11TextScaleFactorExtension, this one). A shared Settings-portal client fanning out oneSettingChangedwatch would remove the duplication and the duplicated "no session bus" logs; also align the siblings'version != 2gate with the forward-compatibleversion < 2used here.(ddd)→ palette conversion is pure and could be exposedinternal staticwith anInternalsVisibleTofor a unit test; today the X11 runtime has no test project reference.PR Checklist ✅
SystemAccentColorSample; the portal cannot be driven from CI, see Validation above.Screenshots Compare Test Runresults.