-
-
Notifications
You must be signed in to change notification settings - Fork 50
Expand file tree
/
Copy pathutils.js
More file actions
42 lines (34 loc) · 987 Bytes
/
utils.js
File metadata and controls
42 lines (34 loc) · 987 Bytes
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
import GLib from 'gi://GLib';
// todo.. recompute ... seems to length the debounce hold out period
const DEBOUNCE_PRECISION = 1;
const dummy_pointer = {
get_position: () => {
return [{}, 0, 0];
},
warp: (screen, x, y) => {},
};
export const getPointer = () => {
return global.get_pointer();
};
export const warpPointer = (pointer, x, y) => {
let [screen, pointerX, pointerY] = pointer.get_position();
pointer.warp(screen, x, y);
};
export const setTimeout = (func, delay, ...args) => {
const wrappedFunc = () => {
func.apply(this, args);
};
return GLib.timeout_add(GLib.PRIORITY_DEFAULT, delay, wrappedFunc);
};
export const setInterval = (func, delay, ...args) => {
const wrappedFunc = () => {
return func.apply(this, args) || true;
};
return GLib.timeout_add(GLib.PRIORITY_DEFAULT, delay, wrappedFunc);
};
export const clearTimeout = (id) => {
GLib.source_remove(id);
};
export const clearInterval = (id) => {
GLib.source_remove(id);
};