SDL accessibility events: should SDL synthesize focus changes, or should the app map them?
0 reputation · 01 Jan 2021, 03:45 UTC
0 reputation · 01 Jan 2021, 03:45 UTC
I'm building an SDL2-based UI layer that must work with screen readers on Windows, macOS, and X11. SDL_PollEvent gives me raw input and window events, but no accessibility metadata, so I currently translate SDL_WINDOWEVENT_FOCUS_GAINED and my own widget focus model into platform accessibility API calls (UI Automation, NSAccessibility, AT-SPI) myself.
SDL 2.0.9 added SDL_HINT_ACCESSIBILITY_FOCUS for focus tracking, but its behavior appears to differ per platform, and I'm unsure how much of the focus-change story SDL is expected to own. I see two documented approaches:
A complicating constraint: on Windows with high-DPI scaling, event coordinates can be compressed or expanded, so any hit-testing for focus rectangles seems to require SDL_GetWindowDisplayDPI before computing accessible bounds.
A thoughtful contribution can make all the difference. Be the first to share one.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.