forked from mechtifs/wiggle
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcursor.js
More file actions
47 lines (37 loc) · 1.11 KB
/
cursor.js
File metadata and controls
47 lines (37 loc) · 1.11 KB
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
'use strict';
import Clutter from 'gi://Clutter';
export default class Cursor {
constructor() {
this._tracker = global.backend.get_cursor_tracker(global.display);
}
get hot() {
return this._tracker.get_hot();
}
get sprite() {
return this._tracker.get_sprite();
}
show() {
const seat = Clutter.get_default_backend().get_default_seat();
if (seat.is_unfocus_inhibited()) {
seat.uninhibit_unfocus();
}
this._tracker.disconnectObject(this);
this._tracker.set_pointer_visible(true);
}
hide() {
const seat = Clutter.get_default_backend().get_default_seat();
if (!seat.is_unfocus_inhibited()) {
seat.inhibit_unfocus();
}
this._tracker.set_pointer_visible(false);
this._tracker.disconnectObject(this);
this._tracker.connectObject(
'visibility-changed', () => {
if (this._tracker.get_pointer_visible()) {
this._tracker.set_pointer_visible(false);
}
},
this
);
}
}