RFR: 8341514: Add reducedMotion and reducedTransparency preferences [v2]
Kevin Rushforth
kcr at openjdk.org
Mon Oct 7 14:48:46 UTC 2024
On Mon, 7 Oct 2024 03:43:26 GMT, Michael Strauß <mstrauss at openjdk.org> wrote:
>> This PR adds the `Platform.Preferences.reducedMotion` and `Platform.Preferences.reducedTransparency` accessibility preferences:
>>
>> interface Preferences {
>> /**
>> * Specifies whether applications should minimize the amount of non-essential animations,
>> * reducing discomfort for users who experience motion sickness or vertigo.
>> * <p>
>> * If the platform does not report this preference, this property defaults to {@code false}.
>> *
>> * @return the {@code reducedMotion} property
>> * @defaultValue {@code false}
>> * @since 24
>> */
>> ReadOnlyBooleanProperty reducedMotionProperty();
>>
>> /**
>> * Specifies whether applications should minimize the amount of transparent or translucent
>> * layer effects, which can help to increase contrast and readability for some users.
>> * <p>
>> * If the platform does not report this preference, this property defaults to {@code false}.
>> *
>> * @return the {@code reducedTransparency} property
>> * @defaultValue {@code false}
>> * @since 24
>> */
>> ReadOnlyBooleanProperty reducedTransparencyProperty();
>>
>> ...
>> }
>>
>>
>> On Windows, these preferences correspond to "Transparency effects" and "Animation effects" in the system settings:
>> <img src="https://github.com/user-attachments/assets/b286850d-ebbc-444c-9c09-5380f97d0e91" width="400" >
>>
>> On macOS, these preferences correspond to "Reduce motion" and "Reduce transparency" in the system settings:
>> <img src="https://github.com/user-attachments/assets/4c7b92f8-0cd9-4d1f-91df-40cb449f91ff" width="400" >
>>
>> On Linux, the `reducedMotion` preference corresponds to `gtk-enable-animations`. On my Ubuntu 24.04 system, GTK3 does not pick up the "Settings / Accessibility / Reduce Animations" system setting, and therefore GTK always reports `gtk-enable-animations == true`. Changing the preference requires manually editing `etc/gtk-3.0/settings.ini`. The `reducedTransparency` preference has no corresponding GTK setting.
>
> Michael Strauß has updated the pull request incrementally with one additional commit since the last revision:
>
> small changes
This seems like a reasonable enhancement. Since this adds new interface methods, it is (technically) an incompatible change. I recommend either documenting that applications should not implement the interface, or else make it a sealed class so that they can't.
modules/javafx.graphics/src/main/java/javafx/application/Platform.java line 598:
> 596: * @since 24
> 597: */
> 598: ReadOnlyBooleanProperty reducedMotionProperty();
Adding a new method without a default implementation to an interface is an incompatible change. Since we do not expect that an application would ever implement this interface, this seems OK to me.
We should either add an `@implSpec` to the class docs indicating that applications should not implement `Platform.Preferences` or make it a sealed interface.
-------------
PR Review: https://git.openjdk.org/jfx/pull/1592#pullrequestreview-2352168072
PR Review Comment: https://git.openjdk.org/jfx/pull/1592#discussion_r1790364314
More information about the openjfx-dev
mailing list