summaryrefslogtreecommitdiffstats
path: root/extensions/44/vertical-workspaces/lib/swipeTracker.js
diff options
context:
space:
mode:
Diffstat (limited to 'extensions/44/vertical-workspaces/lib/swipeTracker.js')
-rw-r--r--extensions/44/vertical-workspaces/lib/swipeTracker.js95
1 files changed, 62 insertions, 33 deletions
diff --git a/extensions/44/vertical-workspaces/lib/swipeTracker.js b/extensions/44/vertical-workspaces/lib/swipeTracker.js
index d9c3407..7122ead 100644
--- a/extensions/44/vertical-workspaces/lib/swipeTracker.js
+++ b/extensions/44/vertical-workspaces/lib/swipeTracker.js
@@ -10,61 +10,90 @@
'use strict';
-const { Clutter, GObject } = imports.gi;
+const Clutter = imports.gi.Clutter;
+const GObject = imports.gi.GObject;
+
const Main = imports.ui.main;
const SwipeTracker = imports.ui.swipeTracker;
-const Me = imports.misc.extensionUtils.getCurrentExtension();
-
+let Me;
let opt;
-let _firstRun = true;
-let _vwGestureUpdateId;
-let _originalGestureUpdateId;
+var SwipeTrackerModule = class {
+ constructor(me) {
+ Me = me;
+ opt = Me.opt;
-function update(reset = false) {
- opt = Me.imports.lib.settings.opt;
- const moduleEnabled = opt.get('swipeTrackerModule', true);
- reset = reset || !moduleEnabled;
+ this._firstActivation = true;
+ this.moduleEnabled = false;
+ }
- // don't even touch this module if disabled
- if (_firstRun && reset)
- return;
+ cleanGlobals() {
+ Me = null;
+ opt = null;
+ }
- _firstRun = false;
+ update(reset) {
+ this.moduleEnabled = opt.get('swipeTrackerModule');
+ const conflict = false;
- if (reset || !opt.ORIENTATION) { // 1-VERTICAL, 0-HORIZONTAL
- // 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 (_vwGestureUpdateId) {
- Main.overview._swipeTracker._touchpadGesture.disconnect(_vwGestureUpdateId);
- _vwGestureUpdateId = 0;
+ 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();
}
- if (_originalGestureUpdateId) {
- Main.overview._swipeTracker._touchpadGesture.unblock_signal_handler(_originalGestureUpdateId);
- _originalGestureUpdateId = 0;
+ if (reset && this._firstActivation)
+ console.debug(' SwipeTrackerModule - Keeping untouched');
+ }
+
+ _activateModule() {
+ if (opt.ORIENTATION) { // 1-VERTICAL, 0-HORIZONTAL
+ this._setVertical();
+ } else {
+ this._setHorizontal();
}
+ console.debug(' SwipeTrackerModule - Activated');
+ }
- opt = null;
- return;
+ _disableModule() {
+ this._setHorizontal();
+
+ console.debug(' SwipeTrackerModule - Disabled');
}
- if (opt.ORIENTATION) { // 1-VERTICAL, 0-HORIZONTAL
+ _setVertical() {
// 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
- if (!_originalGestureUpdateId) {
- _originalGestureUpdateId = GObject.signal_handler_find(Main.overview._swipeTracker._touchpadGesture, { signalId: 'update' });
- Main.overview._swipeTracker._touchpadGesture.block_signal_handler(_originalGestureUpdateId);
+ if (!this._originalGestureUpdateId) {
+ this._originalGestureUpdateId = GObject.signal_handler_find(Main.overview._swipeTracker._touchpadGesture, { signalId: 'update' });
+ Main.overview._swipeTracker._touchpadGesture.block_signal_handler(this._originalGestureUpdateId);
Main.overview._swipeTracker._updateGesture = SwipeTrackerVertical._updateGesture;
- _vwGestureUpdateId = Main.overview._swipeTracker._touchpadGesture.connect('update', SwipeTrackerVertical._updateGesture.bind(Main.overview._swipeTracker));
+ 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;
}
}
-}
+};
const SwipeTrackerVertical = {
_updateGesture(gesture, time, delta, distance) {