forked from icedman/anino-dock
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.js
54 lines (44 loc) · 1.12 KB
/
utils.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
'use strict';
const GLib = imports.gi.GLib;
const Gdk = imports.gi.Gdk;
const dummy_pointer = {
get_position: () => {
return [{}, 0, 0];
},
warp: (screen, x, y) => {},
};
var getPointer = () => {
let display = Gdk.Display.get_default();
// wayland?
if (!display) {
return dummy_pointer;
}
let deviceManager = display.get_device_manager();
if (!deviceManager) {
return dummy_pointer;
}
let pointer = deviceManager.get_client_pointer() || dummy_pointer;
return pointer;
};
var warpPointer = (pointer, x, y) => {
let [screen, pointerX, pointerY] = pointer.get_position();
pointer.warp(screen, x, y);
};
var setTimeout = (func, delay, ...args) => {
const wrappedFunc = () => {
func.apply(this, args);
};
return GLib.timeout_add(GLib.PRIORITY_DEFAULT, delay, wrappedFunc);
};
var setInterval = (func, delay, ...args) => {
const wrappedFunc = () => {
return func.apply(this, args) || true;
};
return GLib.timeout_add(GLib.PRIORITY_DEFAULT, delay, wrappedFunc);
};
var clearTimeout = (id) => {
GLib.source_remove(id);
};
var clearInterval = (id) => {
GLib.source_remove(id);
};