|
| 1 | +import Clutter from '@gi-types/clutter'; |
1 | 2 | import GLib from '@gi-types/glib2'; |
2 | 3 | import { imports } from 'gnome-shell'; |
3 | 4 | import { AllSettingsKeys, GioSettings, PinchGestureType } from './common/settings'; |
4 | 5 | import * as Constants from './constants'; |
| 6 | +import { SwipeGestureInfo, SwipeGestureToExtensionMapper } from './src/gestures'; |
5 | 7 | import { AltTabConstants, ExtSettings, TouchpadConstants } from './constants'; |
6 | | -import { AltTabGestureExtension } from './src/altTab'; |
7 | | -import { ForwardBackGestureExtension } from './src/forwardBack'; |
8 | | -import { GestureExtension } from './src/gestures'; |
9 | | -import { OverviewRoundTripGestureExtension } from './src/overviewRoundTrip'; |
10 | 8 | import { CloseWindowExtension } from './src/pinchGestures/closeWindow'; |
11 | 9 | import { ShowDesktopExtension } from './src/pinchGestures/showDesktop'; |
12 | | -import { SnapWindowExtension } from './src/snapWindow'; |
13 | 10 | import * as DBusUtils from './src/utils/dbus'; |
14 | 11 | import * as VKeyboard from './src/utils/keyboard'; |
15 | 12 |
|
@@ -73,23 +70,13 @@ class Extension { |
73 | 70 | this._initializeSettings(); |
74 | 71 | this._extensions = []; |
75 | 72 | if (this.settings === undefined) |
76 | | - return; |
77 | | - |
78 | | - if (this.settings.get_boolean('enable-alttab-gesture')) |
79 | | - this._extensions.push(new AltTabGestureExtension()); |
| 73 | + return; |
80 | 74 |
|
81 | | - if (this.settings.get_boolean('enable-forward-back-gesture')) { |
82 | | - const appForwardBackKeyBinds = this.settings.get_value('forward-back-application-keyboard-shortcuts').deepUnpack(); |
83 | | - this._extensions.push(new ForwardBackGestureExtension(appForwardBackKeyBinds)); |
84 | | - } |
85 | | - |
86 | | - this._extensions.push( |
87 | | - new OverviewRoundTripGestureExtension(this.settings.get_enum('overview-navifation-states')), |
88 | | - new GestureExtension(), |
89 | | - ); |
90 | | - |
91 | | - if (this.settings.get_boolean('enable-window-manipulation-gesture')) |
92 | | - this._extensions.push(new SnapWindowExtension()); |
| 75 | + // TODO: remove it |
| 76 | + // if (this.settings.get_boolean('enable-alttab-gesture')) |
| 77 | + // this._extensions.push(new AltTabGestureExtension()); |
| 78 | + |
| 79 | + this._setSwipeGestures() |
93 | 80 |
|
94 | 81 | // pinch to show desktop |
95 | 82 | const pinchToFingersMap = this._getPinchGestureTypeAndFingers(); |
@@ -119,20 +106,62 @@ class Extension { |
119 | 106 |
|
120 | 107 | _initializeSettings() { |
121 | 108 | if (this.settings) { |
122 | | - ExtSettings.DEFAULT_SESSION_WORKSPACE_GESTURE = this.settings.get_boolean('default-session-workspace'); |
123 | | - ExtSettings.DEFAULT_OVERVIEW_GESTURE = this.settings.get_boolean('default-overview'); |
124 | | - ExtSettings.ALLOW_MINIMIZE_WINDOW = this.settings.get_boolean('allow-minimize-window'); |
| 109 | + // TODO: fix this somewhere, somehow |
| 110 | + // ExtSettings.ALLOW_MINIMIZE_WINDOW = this.settings.get_boolean('allow-minimize-window'); |
| 111 | + |
125 | 112 | ExtSettings.FOLLOW_NATURAL_SCROLL = this.settings.get_boolean('follow-natural-scroll'); |
126 | 113 | ExtSettings.DEFAULT_OVERVIEW_GESTURE_DIRECTION = this.settings.get_boolean('default-overview-gesture-direction'); |
127 | 114 | ExtSettings.APP_GESTURES = this.settings.get_boolean('enable-forward-back-gesture'); |
128 | 115 |
|
| 116 | + |
129 | 117 | TouchpadConstants.SWIPE_MULTIPLIER = Constants.TouchpadConstants.DEFAULT_SWIPE_MULTIPLIER * this.settings.get_double('touchpad-speed-scale'); |
130 | 118 | TouchpadConstants.PINCH_MULTIPLIER = Constants.TouchpadConstants.DEFAULT_PINCH_MULTIPLIER * this.settings.get_double('touchpad-pinch-speed'); |
131 | 119 | AltTabConstants.DELAY_DURATION = this.settings.get_int('alttab-delay'); |
132 | 120 | TouchpadConstants.HOLD_SWIPE_DELAY_DURATION = this.settings.get_int('hold-swipe-delay-duration'); |
133 | 121 | } |
134 | 122 | } |
135 | 123 |
|
| 124 | + private _setSwipeGestures() { |
| 125 | + if (this.settings) { |
| 126 | + const swipeHorizontal3FingerGesture = this.settings.get_enum('swipe-horizontal-3-finger-gesture'); |
| 127 | + const swipeVertical3FingerGesture = this.settings.get_enum('swipe-vertical-3-finger-gesture'); |
| 128 | + const swipeHorizontal4FingerGesture = this.settings.get_enum('swipe-horizontal-4-finger-gesture'); |
| 129 | + const swipeVertical4FingerGesture = this.settings.get_enum('swipe-vertical-4-finger-gesture'); |
| 130 | + |
| 131 | + const swipeGestureToExtension = new SwipeGestureToExtensionMapper(this.settings) |
| 132 | + |
| 133 | + const swipeHorizontal3FingerGestureInfo = new SwipeGestureInfo( |
| 134 | + Clutter.Orientation.HORIZONTAL, |
| 135 | + [3], swipeHorizontal3FingerGesture |
| 136 | + ) |
| 137 | + const extension_1 = swipeGestureToExtension.get_extension(swipeHorizontal3FingerGestureInfo) |
| 138 | + |
| 139 | + const swipeVertical3FingerGestureInfo = new SwipeGestureInfo( |
| 140 | + Clutter.Orientation.VERTICAL, |
| 141 | + [3], swipeVertical3FingerGesture |
| 142 | + ) |
| 143 | + const extension_2 = swipeGestureToExtension.get_extension(swipeVertical3FingerGestureInfo) |
| 144 | + |
| 145 | + const swipeHorizontal4FingerGestureInfo = new SwipeGestureInfo( |
| 146 | + Clutter.Orientation.HORIZONTAL, |
| 147 | + [4], swipeHorizontal4FingerGesture |
| 148 | + ) |
| 149 | + const extension_3 = swipeGestureToExtension.get_extension(swipeHorizontal4FingerGestureInfo) |
| 150 | + |
| 151 | + const swipeVertical4FingerGestureInfo = new SwipeGestureInfo( |
| 152 | + Clutter.Orientation.VERTICAL, |
| 153 | + [4], swipeVertical4FingerGesture |
| 154 | + ) |
| 155 | + const extension_4 = swipeGestureToExtension.get_extension(swipeVertical4FingerGestureInfo); |
| 156 | + |
| 157 | + [extension_1, extension_2, extension_3, extension_4].forEach(function(this:Extension, elem) { |
| 158 | + if (elem !== undefined) { |
| 159 | + this._extensions.push(elem); |
| 160 | + } |
| 161 | + }); |
| 162 | + } |
| 163 | + } |
| 164 | + |
136 | 165 | private _getPinchGestureTypeAndFingers(): Map<PinchGestureType, number[]> { |
137 | 166 | if (!this.settings) return new Map(); |
138 | 167 |
|
|
0 commit comments