gnome-shell/js/ui/locatePointer.js
Alessandro Bono 31509e55ca locatePointer: Mark the animation as required
When the accessibility option "Reduce Animation" is turned on, the
accessibility option "Locate Pointer" stops to work. This is because
the animation is not marked as required. Mark it as such.

Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/7472
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2986>
2024-09-06 13:01:39 +00:00

37 lines
1.0 KiB
JavaScript

import Gio from 'gi://Gio';
import * as Ripples from './ripples.js';
import * as Main from './main.js';
const LOCATE_POINTER_KEY = 'locate-pointer';
const LOCATE_POINTER_SCHEMA = 'org.gnome.desktop.interface';
export class LocatePointer {
constructor() {
this._settings = new Gio.Settings({schema_id: LOCATE_POINTER_SCHEMA});
this._settings.connect(`changed::${LOCATE_POINTER_KEY}`, () => this._syncEnabled());
this._syncEnabled();
}
_syncEnabled() {
let enabled = this._settings.get_boolean(LOCATE_POINTER_KEY);
if (enabled === !!this._ripples)
return;
if (enabled) {
this._ripples = new Ripples.Ripples(0.5, 0.5, 'ripple-pointer-location', true);
this._ripples.addTo(Main.uiGroup);
} else {
this._ripples.destroy();
this._ripples = null;
}
}
show() {
if (!this._ripples)
return;
let [x, y] = global.get_pointer();
this._ripples.playAnimation(x, y);
}
}