Vixen
dd8b0a81
csharp
public readonly record struct SystemAccessibility

The accessibility settings an operating system will tell an application about.

No guide page documents this yet — the page shows what the code says about itself.

Remarks

The platform half of prefers-reduced-motion and forced-colors, and the reason it exists is that both queries already worked and neither had a source. MediaPreferences has carried these axes since the media features landed, and every writer of it in the tree was a test — so an application shipped its animations to a user who had switched them off and nothing anywhere reported it. That is the same shape of hole PlatformInput.ApplyColorScheme was written to close one axis over.

⚠ null is a real answer and is not false. A headless run has no user to have a preference, and a Linux session with no settings daemon has nowhere to keep one. Flattening either to "no, they did not ask for reduced motion" is how an application ends up animating at a user who has already said not to — the honest translation of "unknown" is CSS's no-preference, and the difference is that a host can tell the two apart and log the first.

⚠ Two nullable flags rather than two tri-state enums, unlike SystemColorScheme one axis over. A colour scheme has three genuine values and its unknown is a fourth; these are yes-or-no settings whose third state is only ever "nobody could be asked", which is exactly what a nullable means and is one type rather than three.

⚠ TextScale is a multiplier and not a font size, which is what lets one number mean the same thing on three platforms. Windows keeps a percentage from 100 to 225, GNOME a factor around one; both are a scale of whatever the application's own base is, and neither is a point size. A host multiplies UiDocument.RootFontSize by it, so an application that chose a fourteen-pixel root keeps its own proportions.

⚠ macOS has no source for it and that is the honest answer rather than a gap. Dynamic Type is an iOS API; the Mac has no system-wide text scale to read, so MacOSAccessibility leaves this null — the same null-is-not-no reading the two flags above already carry.

What is deliberately not here: the system accent colour and the platform's semantic palette (AppKit's labelColor and friends). Both need a platform read this type cannot make on its own terms — see SystemPalette, which is where they would land.

Fields and properties (4)

  • public bool? ReduceMotion

    Whether the user has asked for less animation, or null where the platform cannot say.

  • public bool? HighContrast

    Whether the user has asked for a forced high-contrast palette, or null where the platform cannot say.

  • public float? TextScale

    How much larger than normal the user wants text, as a multiplier — 1.5 for fifty per cent larger — or null where the platform cannot say.

  • public static SystemAccessibility Unknown

    What a platform that cannot read any of this reports.

Methods (1)

  • public SystemAccessibility(bool? ReduceMotion = null, bool? HighContrast = null, float? TextScale = null)

    The accessibility settings an operating system will tell an application about.

Used by (14)

  • AccessibilityWiringTestsVixen.Platform.Ui.Tests
  • DesktopAccessibilityVixen.Platform.Desktop
  • DesktopAccessibilityTestsVixen.Platform.Desktop.Tests
  • DesktopPlatformVixen.Platform.Desktop
  • HeadlessPlatformVixen.Platform.Headless
  • IPlatformVixen.Platform
  • LinuxAccessibilityVixen.Platform.Linux
  • MacOSAccessibilityVixen.Platform.MacOS
  • PlatformInputVixen.Platform.Ui
  • SystemPaletteWiringTestsVixen.Platform.Ui.Tests
  • TextScaleWiringTestsVixen.Platform.Ui.Tests
  • WindowsAccessibilityVixen.Platform.Windows
  • PinningPlatformVixen.App.Tests
  • PresentingPlatformVixen.App.Tests