Skip to content
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

Add functions to fetch various system preferences and accessibility options #11720

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Semphriss
Copy link
Contributor

Description

Currently supported (as of opening the PR, will probably be updated):

Feature Windows macOS GNU/Linux
Reduce motion / disable animations X X GNOME only*
Reduce transparency X X
High contrast X X X
Colorblind-friendly mode / shape-based distinction (replacing color-based distinction) X GNOME only*
Scrollbars always visible X * GNOME only*
Screen reader X* X *
System accent color * X *
Text scaling * * GNOME only*
Cursor scaling * * GNOME only*

*The platform supports that option, but I haven't found how to fetch it (no X) or I could support it only partially (X). I would need help to find how I can access them. I've written more details in the "Platform support" section below.

Detecting changes dynamically is also supported across all platforms.

As of opening the PR, not everything is supported. I'm opening the PR early for two reasons:

  • I would need feedback on the API to make sure I'm going in the right direction.
  • I would need advice from platform experts to counsel me about the standards of each platform. I used what I believed to be the best, but I'm missing information about many platforms and I have limited resources and knowledge to test each platform.

API design and code organisation

In short, I pretty much copied what I saw about the system theme support. I most likely have made many suboptimal choices in the process.

Currently, I've provided one function that provides each of the boolean options (everything except accent color, font scaling and cursor scaling) and one function to fetch each of the remaining ones.

Is this the best way to organise the code? Some other possibilities I've though about are using an SDL_Properties object (abstracts the types which allows using one function for all, but is more complex to use) and using one function for each (way too many options, which poses a problem for event IDs).

I've also added event types and structures to detect when each option changed. I've split them similarly to their function counterparts: one event type for all boolean values (with a field to carry over which exact setting changed) and one type for each of the other options.

I've organised the code in a similar way to how SDL_SystemTheme was organised, with the only exception that preferences aren't bound to the video driver. Should I bind them to the video driver, or should I organise them differently?

Platform support

As of opening the PR, I support fetching most of the options on Windows, macOS and GNOME.

  • Windows has an accent color, a text scaling factor and a cursor scaling factor, but I haven't yet found which registries hold each one of them. If someone has an activated Windows available and could tell me, it would help me a lot.
  • Windows allows detecting the presence of a screen reader that isn't Windows' built-in Narrator screen reader. I'm not sure why there is this distinction, but if there was a separate way to detect Narrator, it would be useful to support it.
  • macOS can detect a modified setting with NSWorkspaceAccessibilityDisplayOptionsDidChangeNotification. However, this does not say which exact setting changed; only that one of them has changed. I'm not sure how to proceed with this.
  • Due to a lack of standardisation with DBus Settings, each option except "High contrast" will need to be implemented for each desktop environment. I've seen about accent-color, but it's not available on my Ubuntu 24.04. If someone has a non-GNOME DE and would like to help, please let me know that the signal namespace and keys are for your DE.
  • For the other missing option/platform pairs, I simply haven't yet found how to support them.

Existing Issue(s)

Closes #11636

@slouken slouken added this to the 3.x milestone Dec 26, 2024
@expikr
Copy link
Contributor

expikr commented Dec 27, 2024

potentially relevant: https://devblogs.microsoft.com/oldnewthing/20210820-00/?p=105593

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Expose OS accessibility preferences?
3 participants