Skip to main content

accessibility_preferences

Function accessibility_preferences 

Source
pub fn accessibility_preferences() -> AccessibilityPreferences
Expand description

The OS accessibility preferences (cached): what AccessibilityPreferences::from_system reads, without running the platform reader again.

The cache holds the accessibility block of the last platform reader run: SystemTheme::from_system and from_system_async fill it, and where neither has run since the last invalidate_caches(), the first call runs the reader itself. invalidate_caches() clears it. A reader that fails is not reported: the preferences used without a reader (the defaults, with the platform’s detect_reduced_motion()) stay cached until the next invalidation, as a failure to detect the icon theme does.

For a preset switch, where the OS preferences apply under the preset and the reader has usually just run. The theme watcher (watch::on_theme_change) reports a change of every accessibility setting the reader reads but one, Windows’ high contrast, which Windows announces only to top-level windows, as it does the non-client fonts; nothing clears the cache when it changes. That holds from Windows 10 2004: before it the watcher has no AnimationsEnabledChanged, so a reduced-motion change is not reported either (and before 1703, with no AdvancedEffectsEnabledChanged, a transparency change). Where the current setting matters more than the cost, read AccessibilityPreferences::from_system, which runs the reader every time.