js: Port to modules

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1499>
This commit is contained in:
Evan Welsh
2023-07-10 02:53:00 -07:00
committed by Florian Müllner
parent d9198317ae
commit a751e213f6
162 changed files with 2183 additions and 2336 deletions

View File

@ -1,10 +1,9 @@
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
/* exported getPointerWatcher */
const GLib = imports.gi.GLib;
import GLib from 'gi://GLib';
// We stop polling if the user is idle for more than this amount of time
var IDLE_TIME = 1000;
const IDLE_TIME = 1000;
// This file implements a reasonably efficient system for tracking the position
// of the mouse pointer. We simply query the pointer from the X server in a loop,
@ -15,14 +14,14 @@ let _pointerWatcher = null;
/**
* @returns {PointerWatcher}
*/
function getPointerWatcher() {
export function getPointerWatcher() {
if (_pointerWatcher == null)
_pointerWatcher = new PointerWatcher();
return _pointerWatcher;
}
var PointerWatch = class {
class PointerWatch {
constructor(watcher, interval, callback) {
this.watcher = watcher;
this.interval = interval;
@ -35,9 +34,9 @@ var PointerWatch = class {
remove() {
this.watcher._removeWatch(this);
}
};
}
var PointerWatcher = class {
class PointerWatcher {
constructor() {
this._idleMonitor = global.backend.get_core_idle_monitor();
this._idleMonitor.add_idle_watch(IDLE_TIME, this._onIdleMonitorBecameIdle.bind(this));
@ -126,4 +125,4 @@ var PointerWatcher = class {
i++;
}
}
};
}