RFR: 8301302: Platform preferences API [v42]
Jose Pereda
jpereda at openjdk.org
Wed Dec 6 19:50:22 UTC 2023
On Wed, 6 Dec 2023 19:23:38 GMT, Michael Strauß <mstrauss at openjdk.org> wrote:
>> Please read [this document](https://gist.github.com/mstr2/9f46f92c98d3c86aa6a0b4224a9a6548) for an introduction to the Platform Preferences API, and how it interacts with the proposed style theme and stage appearance features.
>
> Michael Strauß has updated the pull request incrementally with one additional commit since the last revision:
>
> consistently use NULL
I am testing `PlatformPreferencesChangedTest` on Windows 11 22H2 22621.2715 (English setup).
I run the app, with no contrast theme, and I see the default colours:
preferences = {
Windows.SPI.HighContrastOn=false
Windows.SysColor.COLOR_3DFACE=0xf0f0f0ff
...
Windows.UIColor.Foreground=0x000000ff
}
Note I get the preference `Windows.SPI.HighContrastOn`, which is not listed in the javadoc of `javafx.application.Platform.Preferences`, but I don't get these two preferences which are listed:
Windows.SPI.HighContrast
Windows.SPI.HighContrastColorScheme
I take that `PlatformPreferences` doesn't list those if the high contrast mode is off.
Then I go to Settings->Accessibility->Contrast themes, select Aquatic, and I see the change:
changed = {
Windows.SysColor.COLOR_3DFACE=0x202020ff
...
Windows.UIColor.Foreground=0xffffffff
}
(still no SPI preferences).
The app only changes the window frame (to yellow), and I see this exception:
Exception in thread "JavaFX Application Thread" java.lang.IllegalArgumentException: No enum constant com.sun.javafx.application.PlatformImpl.HighContrastScheme.High Contrast Black
at java.base/java.lang.Enum.valueOf(Enum.java:273)
at javafx.graphics at 22-internal/com.sun.javafx.application.PlatformImpl$HighContrastScheme.valueOf(PlatformImpl.java:738)
at javafx.graphics at 22-internal/com.sun.javafx.application.PlatformImpl._setAccessibilityTheme(PlatformImpl.java:826)
at javafx.graphics at 22-internal/com.sun.javafx.application.PlatformImpl.setAccessibilityTheme(PlatformImpl.java:786)
at javafx.graphics at 22-internal/com.sun.javafx.application.PlatformImpl.checkHighContrastThemeChanged(PlatformImpl.java:1097)
at javafx.graphics at 22-internal/com.sun.javafx.application.PlatformImpl.updatePreferences(PlatformImpl.java:1083)
at javafx.graphics at 22-internal/com.sun.javafx.tk.quantum.QuantumToolkit$2.handlePreferencesChanged(QuantumToolkit.java:375)
at javafx.graphics at 22-internal/com.sun.glass.ui.Application.notifyPreferencesChanged(Application.java:264)
```
With some debugging, I can see that the new Preferences map passed to `PlatformImpl::checkHighContrastThemeChanged` does have `Windows.SPI.HighContrastColorScheme -> High Contrast Black` and therefore `High Contrast Black` is passed now, instead of the existing key `high.contrast.black.theme` in `PlatformImpl::HighContrastScheme`, which causes the above exception.
The same happens applying the `desert` contrast theme: error finding `PlatformImpl.HighContrastScheme.High Contrast White` instead of `high.contrast.white.theme`,
the `dusk` contrast theme -> `PlatformImpl.HighContrastScheme.High Contrast #1` instead of `high.contrast.1.theme` and
or the `night sky` contrast theme -> `PlatformImpl.HighContrastScheme.High Contrast #2` instead of `high.contrast.2.theme`.
So I guess we'll need to review this `HighContrastScheme` enum.
-------------
PR Comment: https://git.openjdk.org/jfx/pull/1014#issuecomment-1843583231
More information about the openjfx-dev
mailing list