summaryrefslogtreecommitdiffstats
path: root/extensions/44/vertical-workspaces/lib/swipeTracker.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-08 16:02:51 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-08 16:02:51 +0000
commit38dd2e23d9e4d0c4e4ccae2e1f261dd19861c331 (patch)
treece0a90ded587c944b91104ca6aeaae96cfaa9f7b /extensions/44/vertical-workspaces/lib/swipeTracker.js
parentReleasing version 20230618. (diff)
downloadgnome-shell-extensions-extra-38dd2e23d9e4d0c4e4ccae2e1f261dd19861c331.tar.xz
gnome-shell-extensions-extra-38dd2e23d9e4d0c4e4ccae2e1f261dd19861c331.zip
Moving current extensions to subdirectory for GNOME 44 as GNOME Shell 45 is backwards incompatible (see Debian #1052112).
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'extensions/44/vertical-workspaces/lib/swipeTracker.js')
-rw-r--r--extensions/44/vertical-workspaces/lib/swipeTracker.js87
1 files changed, 87 insertions, 0 deletions
diff --git a/extensions/44/vertical-workspaces/lib/swipeTracker.js b/extensions/44/vertical-workspaces/lib/swipeTracker.js
new file mode 100644
index 0000000..d9c3407
--- /dev/null
+++ b/extensions/44/vertical-workspaces/lib/swipeTracker.js
@@ -0,0 +1,87 @@
+/**
+ * V-Shell (Vertical Workspaces)
+ * swipeTracker.js
+ *
+ * @author GdH <G-dH@github.com>
+ * @copyright 2022 - 2023
+ * @license GPL-3.0
+ *
+ */
+
+'use strict';
+
+const { Clutter, GObject } = imports.gi;
+const Main = imports.ui.main;
+const SwipeTracker = imports.ui.swipeTracker;
+
+const Me = imports.misc.extensionUtils.getCurrentExtension();
+
+let opt;
+let _firstRun = true;
+
+let _vwGestureUpdateId;
+let _originalGestureUpdateId;
+
+function update(reset = false) {
+ opt = Me.imports.lib.settings.opt;
+ const moduleEnabled = opt.get('swipeTrackerModule', true);
+ reset = reset || !moduleEnabled;
+
+ // don't even touch this module if disabled
+ if (_firstRun && reset)
+ return;
+
+ _firstRun = 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;
+ }
+ if (_originalGestureUpdateId) {
+ Main.overview._swipeTracker._touchpadGesture.unblock_signal_handler(_originalGestureUpdateId);
+ _originalGestureUpdateId = 0;
+ }
+
+ opt = null;
+ return;
+ }
+
+ if (opt.ORIENTATION) { // 1-VERTICAL, 0-HORIZONTAL
+ // 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);
+ Main.overview._swipeTracker._updateGesture = SwipeTrackerVertical._updateGesture;
+ _vwGestureUpdateId = Main.overview._swipeTracker._touchpadGesture.connect('update', SwipeTrackerVertical._updateGesture.bind(Main.overview._swipeTracker));
+ }
+ }
+}
+
+const SwipeTrackerVertical = {
+ _updateGesture(gesture, time, delta, distance) {
+ if (this._state !== 1) // State.SCROLLING)
+ 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);
+ },
+};