-
Notifications
You must be signed in to change notification settings - Fork 6
/
gestures.js
83 lines (68 loc) · 3.75 KB
/
gestures.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
const { Gio, Meta, Shell, Clutter, GObject } = imports.gi;
const Main = imports.ui.main;
const Self = imports.misc.extensionUtils.getCurrentExtension();
const SwipeTracker = Self.imports.swipeTracker;
const USE_3_FINGER_SWIPES = false;
function override() {
if (USE_3_FINGER_SWIPES) {
global.vertical_overview.swipeTracker = Main.overview._swipeTracker;
global.vertical_overview.swipeTracker.enabled = false;
const swipeTracker = new SwipeTracker.SwipeTracker(global.stage,
Clutter.Orientation.VERTICAL,
Shell.ActionMode.NORMAL | Shell.ActionMode.OVERVIEW,
{ allowDrag: false, allowScroll: false });
swipeTracker.connect('begin', Main.overview._gestureBegin.bind(Main.overview));
swipeTracker.connect('update', Main.overview._gestureUpdate.bind(Main.overview));
swipeTracker.connect('end', Main.overview._gestureEnd.bind(Main.overview));
Main.overview._swipeTracker = swipeTracker;
} else {
let workspacesDisplay = Main.overview._overview._controls._workspacesDisplay;
global.vertical_overview.swipeTracker = workspacesDisplay._swipeTracker;
global.vertical_overview.swipeTracker.enabled = false;
const swipeTracker = new SwipeTracker.SwipeTracker(
Main.layoutManager.overviewGroup,
Clutter.Orientation.VERTICAL,
Shell.ActionMode.OVERVIEW,
{ allowDrag: false });
swipeTracker.allowLongSwipes = true;
swipeTracker.connect('begin', workspacesDisplay._switchWorkspaceBegin.bind(workspacesDisplay));
swipeTracker.connect('update', workspacesDisplay._switchWorkspaceUpdate.bind(workspacesDisplay));
swipeTracker.connect('end', workspacesDisplay._switchWorkspaceEnd.bind(workspacesDisplay));
workspacesDisplay._swipeTracker = swipeTracker;
let workspaceAnimation = Main.wm._workspaceAnimation;
global.vertical_overview.animationSwipeTracker = workspaceAnimation._swipeTracker;
global.vertical_overview.animationSwipeTracker.enabled = false;
const swipeTrackerAnimation = new SwipeTracker.SwipeTracker(global.stage,
Clutter.Orientation.VERTICAL,
Shell.ActionMode.NORMAL,
{ allowDrag: false });
swipeTrackerAnimation.connect('begin', workspaceAnimation._switchWorkspaceBegin.bind(workspaceAnimation));
swipeTrackerAnimation.connect('update', workspaceAnimation._switchWorkspaceUpdate.bind(workspaceAnimation));
swipeTrackerAnimation.connect('end', workspaceAnimation._switchWorkspaceEnd.bind(workspaceAnimation));
workspaceAnimation._swipeTracker = swipeTrackerAnimation;
global.display.bind_property('compositor-modifiers',
workspaceAnimation._swipeTracker, 'scroll-modifiers',
GObject.BindingFlags.SYNC_CREATE);
}
}
function reset() {
if (USE_3_FINGER_SWIPES) {
var swipeTracker = Main.overview._swipeTracker;
Main.overview._swipeTracker = global.vertical_overview.swipeTracker;
swipeTracker.destroy();
delete swipeTracker;
Main.overview._swipeTracker.enabled = true;
} else {
let workspacesDisplay = Main.overview._overview._controls._workspacesDisplay;
var swipeTracker = workspacesDisplay._swipeTracker;
workspacesDisplay._swipeTracker = global.vertical_overview.swipeTracker;
swipeTracker.destroy();
delete swipeTracker;
let workspaceAnimation = Main.wm._workspaceAnimation;
let animationSwipeTracker = workspaceAnimation._swipeTracker;
animationSwipeTracker.destroy();
delete animationSwipeTracker;
workspaceAnimation._swipeTracker = global.vertical_overview.animationSwipeTracker;
workspaceAnimation._swipeTracker.enabled = true;
}
}