-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathextension.js
94 lines (80 loc) · 2.72 KB
/
extension.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
const { Clutter, Meta } = imports.gi;
const KeyboardUI = imports.ui.keyboard;
const Main = imports.ui.main;
var disableGestures = true;
var disableOnscreenKeyboard = true;
var disableTopBar = true;
var enableEventCapture = false
// **************************************************
// * https://github.com/lxylxy123456/cariboublocker
// **************************************************
let _originalLastDeviceIsTouchscreen;
function _modifiedLastDeviceIsTouchscreen() {
return false;
}
// **************************************************
// * Event capture
// **************************************************
let eventCaptureId = 0;
function onCapturedEvent(actor, event) {
if (event.type() === Clutter.EventType.TOUCH_BEGIN || event.type() === Clutter.EventType.TOUCH_UPDATE || event.type() === Clutter.EventType.TOUCH_END) {
const [x, y] = event.get_coords();
log(`event type: ${event.type()} x: ${x} y: ${y}`)
} else {
log(`event type: ${event.type()}`)
}
return Clutter.EVENT_PROPAGATE;
}
// **************************************************
// * Extension
// **************************************************
function init() {
// Extension initialization
}
function enable() {
// Disable gestures
if (disableGestures) {
global.stage.get_actions().forEach(action => {
action.enabled = false;
});
print('disabled gestures');
}
// Disable onscreen keyboard
if (disableOnscreenKeyboard) {
_originalLastDeviceIsTouchscreen = KeyboardUI.KeyboardManager.prototype._lastDeviceIsTouchscreen;
KeyboardUI.KeyboardManager.prototype._lastDeviceIsTouchscreen = _modifiedLastDeviceIsTouchscreen;
print('disabled onscreen keyboard');
}
// Disable top bar
if (disableTopBar) {
Main.panel.add_style_class_name('hide-top-bar');
Main.panel._hideIndicators()
}
// Enable event capture
if (enableEventCapture) {
eventCaptureId = global.stage.connect('event', onCapturedEvent);
}
}
function disable() {
// Enable gestures
if (disableGestures) {
global.stage.get_actions().forEach(action => {
action.enabled = true;
});
print('enabled gestures');
}
// Enable onscreen keyboard
if (disableOnscreenKeyboard) {
KeyboardUI.KeyboardManager.prototype._lastDeviceIsTouchscreen = _originalLastDeviceIsTouchscreen;
_originalLastDeviceIsTouchscreen = null;
print('enabled onscreen keyboard');
}
// Enable top bar
if (disableTopBar) {
Main.panel.remove_style_class_name('hide-top-bar');
}
// Disable event capture
if (enableEventCapture) {
global.stage.disconnect(eventCaptureId);
}
}