animationUtils: Allow marking animations as required

There are cases when we want to mark an animation as required. For
example, we want the "Locate Pointer" animation to work even when
the animation is marked as disabled. Take this into account when
adjusting the animation time.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2986>
This commit is contained in:
Alessandro Bono 2023-10-20 22:00:40 +02:00 committed by Marge Bot
parent a52a931fb1
commit 27878aa096

View File

@ -13,14 +13,20 @@ const N_WIGGLES = 3;
* adjustAnimationTime:
*
* @param {number} msecs - time in milliseconds
* @param {object} params - optional parameters
* @param {boolean=} params.animationRequired - whether to ignore the enable-animations setting
*
* Adjust `msecs` to account for St's enable-animations
* and slow-down-factor settings
*/
export function adjustAnimationTime(msecs) {
export function adjustAnimationTime(msecs, params) {
params = Params.parse(params, {
animationRequired: false,
});
const settings = St.Settings.get();
if (!settings.enable_animations)
if (!settings.enable_animations && !params.animationRequired)
return 0;
return settings.slow_down_factor * msecs;
}