2025-02-09 23:09:13 +01:00
|
|
|
/**
|
2025-02-09 23:13:53 +01:00
|
|
|
* V-Shell (Vertical Workspaces)
|
2025-02-09 23:09:13 +01:00
|
|
|
* swipeTracker.js
|
2025-02-09 23:13:53 +01:00
|
|
|
*
|
2025-02-09 23:09:13 +01:00
|
|
|
* @author GdH <G-dH@github.com>
|
|
|
|
* @copyright 2022 - 2023
|
|
|
|
* @license GPL-3.0
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
2025-02-09 23:16:18 +01:00
|
|
|
const Clutter = imports.gi.Clutter;
|
|
|
|
const GObject = imports.gi.GObject;
|
|
|
|
|
2025-02-09 23:09:13 +01:00
|
|
|
const Main = imports.ui.main;
|
|
|
|
const SwipeTracker = imports.ui.swipeTracker;
|
|
|
|
|
2025-02-09 23:16:18 +01:00
|
|
|
let Me;
|
2025-02-09 23:09:13 +01:00
|
|
|
let opt;
|
|
|
|
|
2025-02-09 23:16:18 +01:00
|
|
|
var SwipeTrackerModule = class {
|
|
|
|
constructor(me) {
|
|
|
|
Me = me;
|
|
|
|
opt = Me.opt;
|
2025-02-09 23:09:13 +01:00
|
|
|
|
2025-02-09 23:16:18 +01:00
|
|
|
this._firstActivation = true;
|
|
|
|
this.moduleEnabled = false;
|
|
|
|
}
|
2025-02-09 23:13:53 +01:00
|
|
|
|
2025-02-09 23:16:18 +01:00
|
|
|
cleanGlobals() {
|
|
|
|
Me = null;
|
|
|
|
opt = null;
|
|
|
|
}
|
2025-02-09 23:13:53 +01:00
|
|
|
|
2025-02-09 23:16:18 +01:00
|
|
|
update(reset) {
|
|
|
|
this.moduleEnabled = opt.get('swipeTrackerModule');
|
|
|
|
const conflict = false;
|
2025-02-09 23:09:13 +01:00
|
|
|
|
2025-02-09 23:16:18 +01:00
|
|
|
reset = reset || !this.moduleEnabled || conflict;
|
|
|
|
|
|
|
|
// don't touch the original code if module disabled
|
|
|
|
if (reset && !this._firstActivation) {
|
|
|
|
this._disableModule();
|
|
|
|
} else if (!reset) {
|
|
|
|
this._firstActivation = false;
|
|
|
|
this._activateModule();
|
2025-02-09 23:09:13 +01:00
|
|
|
}
|
2025-02-09 23:16:18 +01:00
|
|
|
if (reset && this._firstActivation)
|
|
|
|
console.debug(' SwipeTrackerModule - Keeping untouched');
|
|
|
|
}
|
|
|
|
|
|
|
|
_activateModule() {
|
|
|
|
if (opt.ORIENTATION) { // 1-VERTICAL, 0-HORIZONTAL
|
|
|
|
this._setVertical();
|
|
|
|
} else {
|
|
|
|
this._setHorizontal();
|
2025-02-09 23:09:13 +01:00
|
|
|
}
|
2025-02-09 23:16:18 +01:00
|
|
|
console.debug(' SwipeTrackerModule - Activated');
|
|
|
|
}
|
2025-02-09 23:09:13 +01:00
|
|
|
|
2025-02-09 23:16:18 +01:00
|
|
|
_disableModule() {
|
|
|
|
this._setHorizontal();
|
|
|
|
|
|
|
|
console.debug(' SwipeTrackerModule - Disabled');
|
2025-02-09 23:09:13 +01:00
|
|
|
}
|
|
|
|
|
2025-02-09 23:16:18 +01:00
|
|
|
_setVertical() {
|
2025-02-09 23:09:13 +01:00
|
|
|
// reverse swipe gestures for enter/leave overview and ws switching
|
|
|
|
Main.overview._swipeTracker.orientation = Clutter.Orientation.HORIZONTAL;
|
|
|
|
Main.wm._workspaceAnimation._swipeTracker.orientation = Clutter.Orientation.VERTICAL;
|
|
|
|
// overview's updateGesture() function should reflect ws tmb position to match appGrid/ws animation direction
|
|
|
|
// function in connection cannot be overridden in prototype of its class because connected is actually another copy of the original function
|
2025-02-09 23:16:18 +01:00
|
|
|
if (!this._originalGestureUpdateId) {
|
|
|
|
this._originalGestureUpdateId = GObject.signal_handler_find(Main.overview._swipeTracker._touchpadGesture, { signalId: 'update' });
|
|
|
|
Main.overview._swipeTracker._touchpadGesture.block_signal_handler(this._originalGestureUpdateId);
|
2025-02-09 23:09:13 +01:00
|
|
|
Main.overview._swipeTracker._updateGesture = SwipeTrackerVertical._updateGesture;
|
2025-02-09 23:16:18 +01:00
|
|
|
this._vwGestureUpdateId = Main.overview._swipeTracker._touchpadGesture.connect('update', SwipeTrackerVertical._updateGesture.bind(Main.overview._swipeTracker));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
_setHorizontal() {
|
|
|
|
// original swipeTrackers' orientation and updateGesture function
|
|
|
|
Main.overview._swipeTracker.orientation = Clutter.Orientation.VERTICAL;
|
|
|
|
Main.wm._workspaceAnimation._swipeTracker.orientation = Clutter.Orientation.HORIZONTAL;
|
|
|
|
Main.overview._swipeTracker._updateGesture = SwipeTracker.SwipeTracker.prototype._updateGesture;
|
|
|
|
if (this._vwGestureUpdateId) {
|
|
|
|
Main.overview._swipeTracker._touchpadGesture.disconnect(this._vwGestureUpdateId);
|
|
|
|
this._vwGestureUpdateId = 0;
|
|
|
|
}
|
|
|
|
if (this._originalGestureUpdateId) {
|
|
|
|
Main.overview._swipeTracker._touchpadGesture.unblock_signal_handler(this._originalGestureUpdateId);
|
|
|
|
this._originalGestureUpdateId = 0;
|
2025-02-09 23:09:13 +01:00
|
|
|
}
|
|
|
|
}
|
2025-02-09 23:16:18 +01:00
|
|
|
};
|
2025-02-09 23:09:13 +01:00
|
|
|
|
2025-02-09 23:13:53 +01:00
|
|
|
const SwipeTrackerVertical = {
|
|
|
|
_updateGesture(gesture, time, delta, distance) {
|
|
|
|
if (this._state !== 1) // State.SCROLLING)
|
2025-02-09 23:09:13 +01:00
|
|
|
return;
|
|
|
|
|
|
|
|
if ((this._allowedModes & Main.actionMode) === 0 || !this.enabled) {
|
|
|
|
this._interrupt();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (opt.WS_TMB_RIGHT)
|
|
|
|
delta = -delta;
|
|
|
|
this._progress += delta / distance;
|
|
|
|
this._history.append(time, delta);
|
|
|
|
|
|
|
|
this._progress = Math.clamp(this._progress, ...this._getBounds(this._initialProgress));
|
|
|
|
this.emit('update', this._progress);
|
2025-02-09 23:13:53 +01:00
|
|
|
},
|
|
|
|
};
|