blob: 815abaa09c3f876a0b3f8d7174d01be9e299e90b (
plain)
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
|
/**
* V-Shell (Vertical Workspaces)
* overlayKey.js
*
* @author GdH <G-dH@github.com>
* @copyright 2022 - 2023
* @license GPL-3.0
*
*/
'use strict';
const GLib = imports.gi.GLib;
const GObject = imports.gi.GObject;
const Meta = imports.gi.Meta;
const St = imports.gi.St;
const Main = imports.ui.main;
const Overview = imports.ui.overview;
let Me;
let opt;
var OverlayKeyModule = class {
constructor(me) {
Me = me;
opt = Me.opt;
this._firstActivation = true;
this.moduleEnabled = false;
this._originalOverlayKeyHandlerId = 0;
this._overlayKeyHandlerId = 0;
}
cleanGlobals() {
Me = null;
opt = null;
}
update(reset) {
this.moduleEnabled = opt.get('overlayKeyModule');
const conflict = false;
reset = reset || !this.moduleEnabled || conflict;
if (reset && !this._firstActivation) {
this._disableModule();
} else if (!reset) {
this._firstActivation = false;
this._activateModule();
}
if (reset && this._firstActivation)
console.debug(' OverlayKeyModule - Keeping untouched');
}
_activateModule() {
if (!this._originalOverlayKeyHandlerId) {
this._originalOverlayKeyHandlerId = GObject.signal_handler_find(global.display, { signalId: 'overlay-key' });
if (this._originalOverlayKeyHandlerId !== null) {
global.display.block_signal_handler(this._originalOverlayKeyHandlerId);
this._connectOverlayKey();
}
}
console.debug(' OverlayKeyModule - Activated');
}
_disableModule() {
this._restoreOverlayKeyHandler();
console.debug(' OverlayKeyModule - Disabled');
}
_restoreOverlayKeyHandler() {
// Disconnect modified overlay key handler
if (this._overlayKeyHandlerId) {
global.display.disconnect(this._overlayKeyHandlerId);
this._overlayKeyHandlerId = 0;
}
// Unblock original overlay key handler
if (this._originalOverlayKeyHandlerId) {
global.display.unblock_signal_handler(this._originalOverlayKeyHandlerId);
this._originalOverlayKeyHandlerId = 0;
}
}
_connectOverlayKey() {
if (this._overlayKeyHandlerId)
return;
this._overlayKeyHandlerId = global.display.connect('overlay-key', this._onOverlayKeyPressed.bind(Main.overview._overview.controls));
}
_onOverlayKeyPressed() {
if (this._a11ySettings.get_boolean('stickykeys-enable'))
return;
const { initialState, finalState, transitioning } =
this._stateAdjustment.getStateTransitionParams();
const time = GLib.get_monotonic_time() / 1000;
const timeDiff = time - this._lastOverlayKeyTime;
this._lastOverlayKeyTime = time;
const shouldShift = St.Settings.get().enable_animations
? transitioning && finalState > initialState
: Main.overview.visible && timeDiff < Overview.ANIMATION_TIME;
const mode = opt.OVERLAY_KEY_SECONDARY;
if (shouldShift) {
Me.Util.activateSearchProvider('');
if (mode === 1) {
this._shiftState(Meta.MotionDirection.UP);
} else if (mode === 2) {
Me.Util.activateSearchProvider(Me.WSP_PREFIX);
} else if (mode === 3) {
// Changing the overview mode automatically changes the overview transition
opt.OVERVIEW_MODE = 0;
opt.OVERVIEW_MODE2 = false;
opt.WORKSPACE_MODE = 1;
}
} else {
if (Main.overview._shown) {
Main.overview.hide();
return;
}
switch (opt.OVERLAY_KEY_PRIMARY) {
case 0: // Disabled
return;
case 1: // Follow global overview mode
Main.overview.resetOverviewMode();
break;
case 2: // Default overview
opt.OVERVIEW_MODE = 0;
opt.OVERVIEW_MODE2 = false;
opt.WORKSPACE_MODE = 1;
break;
case 3: // Default overview
if (Main.overview._shown)
Main.overview.hide();
else
Main.overview.show(2);
return;
case 4: // Static WS preview
opt.OVERVIEW_MODE = 1;
opt.OVERVIEW_MODE2 = false;
if (!Main.overview._shown)
opt.WORKSPACE_MODE = 0;
break;
case 5: // Static WS
opt.OVERVIEW_MODE = 2;
opt.OVERVIEW_MODE2 = true;
opt.WORKSPACE_MODE = 0;
break;
case 6: // Window Search
opt.OVERVIEW_MODE = 2;
opt.OVERVIEW_MODE2 = true;
if (!Main.overview._shown)
opt.WORKSPACE_MODE = 0;
break;
}
const customOverviewMode = !Main.overview._shown;
Main.overview.toggle(customOverviewMode);
if (opt.OVERLAY_KEY_PRIMARY === 6)
Me.Util.activateSearchProvider(Me.WSP_PREFIX);
}
}
};
|