forked from RensAlthuis/vertical-overview
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gestures.js
85 lines (70 loc) · 3.94 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
84
85
import Clutter from 'gi://Clutter';
import Shell from 'gi://Shell';
import GObject from 'gi://GObject';
import * as Main from 'resource:///org/gnome/shell/ui/main.js';
import * as SwipeTracker from './swipeTracker.js';
const USE_3_FINGER_SWIPES = false;
export 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.connectObject('begin', Main.overview._gestureBegin.bind(Main.overview));
swipeTracker.connectObject('update', Main.overview._gestureUpdate.bind(Main.overview));
swipeTracker.connectObject('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.connectObject('begin', workspacesDisplay._switchWorkspaceBegin.bind(workspacesDisplay));
swipeTracker.connectObject('update', workspacesDisplay._switchWorkspaceUpdate.bind(workspacesDisplay));
swipeTracker.connectObject('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.connectObject('begin', workspaceAnimation._switchWorkspaceBegin.bind(workspaceAnimation));
swipeTrackerAnimation.connectObject('update', workspaceAnimation._switchWorkspaceUpdate.bind(workspaceAnimation));
swipeTrackerAnimation.connectObject('end', workspaceAnimation._switchWorkspaceEnd.bind(workspaceAnimation));
workspaceAnimation._swipeTracker = swipeTrackerAnimation;
global.display.bind_property('compositor-modifiers',
workspaceAnimation._swipeTracker, 'scroll-modifiers',
GObject.BindingFlags.SYNC_CREATE);
}
}
export function reset() {
let withProperties = {}
if (USE_3_FINGER_SWIPES) {
withProperties.swipeTracker = Main.overview._swipeTracker;
Main.overview._swipeTracker = global.vertical_overview.swipeTracker;
swipeTracker.destroy();
delete withProperties.swipeTracker;
Main.overview._swipeTracker.enabled = true;
} else {
let workspacesDisplay = Main.overview._overview._controls._workspacesDisplay;
withProperties.swipeTracker = workspacesDisplay._swipeTracker;
workspacesDisplay._swipeTracker = global.vertical_overview.swipeTracker;
swipeTracker.destroy();
delete withProperties.swipeTracker;
let workspaceAnimation = Main.wm._workspaceAnimation;
withProperties.animationSwipeTracker = workspaceAnimation._swipeTracker;
animationSwipeTracker.destroy();
delete withProperties.animationSwipeTracker;
workspaceAnimation._swipeTracker = global.vertical_overview.animationSwipeTracker;
workspaceAnimation._swipeTracker.enabled = true;
}
}