2019-02-20 09:12:36 +00:00
|
|
|
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
|
|
|
|
2023-07-10 09:53:00 +00:00
|
|
|
import Gio from 'gi://Gio';
|
|
|
|
import * as Ripples from './ripples.js';
|
|
|
|
import * as Main from './main.js';
|
2019-02-20 09:12:36 +00:00
|
|
|
|
2023-07-10 09:53:00 +00:00
|
|
|
const LOCATE_POINTER_KEY = 'locate-pointer';
|
|
|
|
const LOCATE_POINTER_SCHEMA = 'org.gnome.desktop.interface';
|
2019-02-20 09:12:36 +00:00
|
|
|
|
2023-07-10 09:53:00 +00:00
|
|
|
export class LocatePointer {
|
2019-02-20 09:12:36 +00:00
|
|
|
constructor() {
|
2019-01-29 01:27:05 +00:00
|
|
|
this._settings = new Gio.Settings({ schema_id: LOCATE_POINTER_SCHEMA });
|
2019-08-30 23:57:12 +00:00
|
|
|
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;
|
|
|
|
}
|
2019-02-20 09:12:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
show() {
|
2019-08-30 23:57:12 +00:00
|
|
|
if (!this._ripples)
|
2019-02-20 09:12:36 +00:00
|
|
|
return;
|
|
|
|
|
2019-02-01 13:41:55 +00:00
|
|
|
let [x, y] = global.get_pointer();
|
2019-02-20 09:12:36 +00:00
|
|
|
this._ripples.playAnimation(x, y);
|
|
|
|
}
|
2023-07-10 09:53:00 +00:00
|
|
|
}
|