animationUtils: Group together various animation helpers

The environment module is used to initialize the environment, yet it
currently also defines the adjustAnimationTime() function.

Ideally it should not export any utility functions, in particular
once converted to ESM.

The function cannot be moved to the existing Utils module, as that
depends on an initialized environment, and can therefore not be
imported from environment.js, so use that opportunity to group
together several animation helpers in a new animationUtils module.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2822>
This commit is contained in:
Evan Welsh
2023-07-09 21:58:21 -07:00
parent 3c9857abad
commit 87d1248dc1
11 changed files with 136 additions and 112 deletions

View File

@ -44,6 +44,7 @@ const Shell = imports.gi.Shell;
const St = imports.gi.St;
const Gettext = imports.gettext;
const SignalTracker = imports.misc.signalTracker;
const {adjustAnimationTime} = imports.misc.animationUtils;
Gio._promisify(Gio.DataInputStream.prototype, 'fill_async');
Gio._promisify(Gio.DataInputStream.prototype, 'read_line_async');
@ -389,17 +390,3 @@ function init() {
// Prevent extensions from opening a display connection to ourselves
Gdk.set_allowed_backends('');
}
// adjustAnimationTime:
// @msecs: time in milliseconds
//
// Adjust @msecs to account for St's enable-animations
// and slow-down-factor settings
function adjustAnimationTime(msecs) {
let settings = St.Settings.get();
if (!settings.enable_animations)
return 0;
return settings.slow_down_factor * msecs;
}