ui/main: Allow not inhibiting animations sometimes
When we're running in e.g. CI, or in a virtual machine without hardware acceleration, and we actually want to enable animations despite the potential performance implications, change the AnimationsSettings to only inhibit if we're a XVNC instance or not hardware accelerated if --force-animations wasn't passed. Still inhibit animations if there is a remote desktop session that explicitly disables animations. Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2560>
This commit is contained in:
parent
08d4addeef
commit
33d3a65646
@ -919,43 +919,62 @@ function showRestartMessage(message) {
|
|||||||
|
|
||||||
var AnimationsSettings = class {
|
var AnimationsSettings = class {
|
||||||
constructor() {
|
constructor() {
|
||||||
let backend = global.backend;
|
this._animationsEnabled = true;
|
||||||
if (!backend.is_rendering_hardware_accelerated()) {
|
|
||||||
St.Settings.get().inhibit_animations();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let isXvnc = Shell.util_has_x11_display_extension(
|
|
||||||
global.display, 'VNC-EXTENSION');
|
|
||||||
if (isXvnc) {
|
|
||||||
St.Settings.get().inhibit_animations();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let remoteAccessController = backend.get_remote_access_controller();
|
|
||||||
if (!remoteAccessController)
|
|
||||||
return;
|
|
||||||
|
|
||||||
this._handles = new Set();
|
this._handles = new Set();
|
||||||
|
|
||||||
|
global.connect('notify::force-animations',
|
||||||
|
this._syncAnimationsEnabled.bind(this));
|
||||||
|
this._syncAnimationsEnabled();
|
||||||
|
|
||||||
|
const backend = global.backend;
|
||||||
|
const remoteAccessController = backend.get_remote_access_controller();
|
||||||
|
if (remoteAccessController) {
|
||||||
remoteAccessController.connect('new-handle',
|
remoteAccessController.connect('new-handle',
|
||||||
(_, handle) => this._onNewRemoteAccessHandle(handle));
|
(_, handle) => this._onNewRemoteAccessHandle(handle));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_shouldEnableAnimations() {
|
||||||
|
if (this._handles.size > 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (global.force_animations)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
const backend = global.backend;
|
||||||
|
if (!backend.is_rendering_hardware_accelerated())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (Shell.util_has_x11_display_extension(
|
||||||
|
global.display, 'VNC-EXTENSION'))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
_syncAnimationsEnabled() {
|
||||||
|
const shouldEnableAnimations = this._shouldEnableAnimations();
|
||||||
|
if (this._animationsEnabled === shouldEnableAnimations)
|
||||||
|
return;
|
||||||
|
|
||||||
|
const settings = St.Settings.get();
|
||||||
|
if (shouldEnableAnimations)
|
||||||
|
settings.uninhibit_animations();
|
||||||
|
else
|
||||||
|
settings.inhibit_animations();
|
||||||
|
}
|
||||||
|
|
||||||
_onRemoteAccessHandleStopped(handle) {
|
_onRemoteAccessHandleStopped(handle) {
|
||||||
let settings = St.Settings.get();
|
|
||||||
|
|
||||||
settings.uninhibit_animations();
|
|
||||||
this._handles.delete(handle);
|
this._handles.delete(handle);
|
||||||
|
this._syncAnimationsEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
_onNewRemoteAccessHandle(handle) {
|
_onNewRemoteAccessHandle(handle) {
|
||||||
if (!handle.get_disable_animations())
|
if (!handle.get_disable_animations())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
let settings = St.Settings.get();
|
|
||||||
|
|
||||||
settings.inhibit_animations();
|
|
||||||
this._handles.add(handle);
|
this._handles.add(handle);
|
||||||
|
this._syncAnimationsEnabled();
|
||||||
handle.connect('stopped', this._onRemoteAccessHandleStopped.bind(this));
|
handle.connect('stopped', this._onRemoteAccessHandleStopped.bind(this));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user