diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 15:07:22 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 15:07:22 +0000 |
commit | f9d480cfe50ca1d7a0f0b5a2b8bb9932962bfbe7 (patch) | |
tree | ce9e8db2d4e8799780fa72ae8f1953039373e2ee /js/ui/locatePointer.js | |
parent | Initial commit. (diff) | |
download | gnome-shell-upstream.tar.xz gnome-shell-upstream.zip |
Adding upstream version 3.38.6.upstream/3.38.6upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | js/ui/locatePointer.js | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/js/ui/locatePointer.js b/js/ui/locatePointer.js new file mode 100644 index 0000000..6ae2941 --- /dev/null +++ b/js/ui/locatePointer.js @@ -0,0 +1,39 @@ +// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- +/* exported LocatePointer */ + +const { Gio } = imports.gi; +const Ripples = imports.ui.ripples; +const Main = imports.ui.main; + +const LOCATE_POINTER_KEY = "locate-pointer"; +const LOCATE_POINTER_SCHEMA = "org.gnome.desktop.interface"; + +var LocatePointer = class { + 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'); + 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); + } +}; |