RFR: 8291087: Wrong position of focus of screen reader on Windows with screen scale > 1

Kevin Rushforth kcr at openjdk.org
Fri Jul 29 12:30:45 UTC 2022


On Fri, 29 Jul 2022 05:46:35 GMT, Ajit Ghaisas <aghaisas at openjdk.org> wrote:

>> When using the Windows Narrator screen reader on a Hi-DPI screen, the visible focus is drawn in the wrong location and with the wrong size. This happens because the the JavaFX Windows accessibility code that returns the screen bounds of the requested UI element does not take the screen scale into account.
>> 
>> The fix is to adjust the bounds by the screen scale before returning it.
>> 
>> You can test it on a Windows machine with scaling set to >= 125% as follows:
>> 1. Turn on Windows Narrator
>> 2. Run any JavaFX program with at least UI controls, for example, `hello.HelloTextField` in `apps/toys/Hello`
>> 3. TAB between the controls
>> 
>> Without the fix, Narrator shows the focus indicator in the wrong position and is too small. With the fix, it is correct. While testing this, I discovered an unrelated (and preexisting) bug where the focus indicator for a TextField or TextArea whose content is larger that the control (and is displayed with scroll bars) is not clipped to the visible area. This happens regardless of screen scale. I will file a follow-up bug for this.
>> 
>> Note that this bug is specific to Windows. It does not occur on macOS, which works correctly on a retina or non-retina display.
>
> modules/javafx.graphics/src/main/java/com/sun/glass/ui/win/WinAccessible.java line 902:
> 
>> 900:         if (getView() != null) return null;
>> 901: 
>> 902:         Bounds bounds = (Bounds)getAttribute(BOUNDS);
> 
> There is another instance where `(Bounds)getAttribute(BOUNDS)` is used in this File (in method `get_HorizontalViewSize()`)
> Please check whether we need to apply scale there as well?

That's a good question to ask. Both `get_HorizontalViewSize()` and `get_VerticalViewSize()` take the ratio of two bounds to compute a percentage between 0 and 100. Since the only use of the bounds in these methods is to divide two widths or heights, it doesn't matter whether or not the ratio is computed using unscaled or scaled values. Further, if I were to scale those values, I'd also need to scale the hard-coded `24` pixel estimate for the cell height. It seemed better to leave them alone.

-------------

PR: https://git.openjdk.org/jfx/pull/853


More information about the openjfx-dev mailing list