From d5dd23f5ce7bcd79cdde768735cda86ebc1718c0 Mon Sep 17 00:00:00 2001 From: Anurag Dhadse Date: Sat, 2 Jul 2022 21:17:04 +0530 Subject: [PATCH] Draft: new UI to customize gestures --- extension/common/settings.ts | 34 +++-- extension/constants.ts | 15 ++- extension/extension.ts | 74 +++++++---- ...extensions.gestureImprovements.gschema.xml | 63 ++++++---- extension/src/gestures.ts | 111 +++++++++++++++- extension/src/{ => swipeGestures}/altTab.ts | 9 +- .../src/{ => swipeGestures}/forwardBack.ts | 34 +++-- .../{ => swipeGestures}/overviewRoundTrip.ts | 14 ++- .../src/{ => swipeGestures}/snapWindow.ts | 15 +-- extension/src/{ => trackers}/swipeTracker.ts | 6 +- extension/ui/gestures.ui | 119 ++++++++---------- metadata.json | 2 +- 12 files changed, 337 insertions(+), 159 deletions(-) rename extension/src/{ => swipeGestures}/altTab.ts (95%) rename extension/src/{ => swipeGestures}/forwardBack.ts (84%) rename extension/src/{ => swipeGestures}/overviewRoundTrip.ts (94%) rename extension/src/{ => swipeGestures}/snapWindow.ts (96%) rename extension/src/{ => trackers}/swipeTracker.ts (98%) diff --git a/extension/common/settings.ts b/extension/common/settings.ts index d3791c1..4c52056 100644 --- a/extension/common/settings.ts +++ b/extension/common/settings.ts @@ -1,7 +1,21 @@ import Gio from '@gi-types/gio2'; import GLib from '@gi-types/glib2'; -// define enum +// define enum for Horizontal motion Gesture +export enum SwipeHorizontalGestureType { + WINDOW_SWITCHING = 0, + APP_NAVIGATION = 1, + WORKSPACE_SWITCHING = 2 +} + +// define enum for Vertical motion Gestures +export enum SwipeVerticalGestureType { + OVERVIEW_NAVIGATION = 0, + APP_NAVIGATION = 1, + WINDOW_MANIPULATION = 2 +} + +// define enum for Pinch Gesture export enum PinchGestureType { NONE = 0, SHOW_DESKTOP = 1, @@ -26,13 +40,13 @@ export enum ForwardBackKeyBinds { } export type BooleanSettingsKeys = - 'default-session-workspace' | - 'default-overview' | - 'allow-minimize-window' | + // 'default-session-workspace' | + // 'default-overview' | + // 'allow-minimize-window' | + // 'enable-window-manipulation-gesture' | 'follow-natural-scroll' | 'enable-alttab-gesture' | 'enable-forward-back-gesture' | - 'enable-window-manipulation-gesture' | 'default-overview-gesture-direction' ; @@ -46,9 +60,13 @@ export type DoubleSettingsKeys = ; export type EnumSettingsKeys = + 'swipe-horizontal-3-finger-gesture' | + 'swipe-vertical-3-finger-gesture' | 'pinch-3-finger-gesture' | + 'swipe-horizontal-4-finger-gesture' | + 'swipe-vertical-4-finger-gesture' | 'pinch-4-finger-gesture' | - 'overview-navifation-states' + 'overview-navigation-states' ; export type MiscSettingsKeys = @@ -81,8 +99,10 @@ type Enum_Functions = { } type SettingsEnumFunctions = + Enum_Functions<'swipe-horizontal-3-finger-gesture' | 'swipe-horizontal-4-finger-gesture', SwipeHorizontalGestureType> & + Enum_Functions<'swipe-vertical-3-finger-gesture' | 'swipe-vertical-4-finger-gesture', SwipeVerticalGestureType> & Enum_Functions<'pinch-3-finger-gesture' | 'pinch-4-finger-gesture', PinchGestureType> & - Enum_Functions<'overview-navifation-states', OverviewNavigationState> + Enum_Functions<'overview-navigation-states', OverviewNavigationState> ; type Misc_Functions = { diff --git a/extension/constants.ts b/extension/constants.ts index 258c56e..ab4c622 100644 --- a/extension/constants.ts +++ b/extension/constants.ts @@ -29,10 +29,21 @@ export const OverviewControlsState = { HIDDEN_N: 3, }; +// export const ExtSettings = { +// DEFAULT_SESSION_WORKSPACE_GESTURE: false, +// DEFAULT_OVERVIEW_GESTURE: false, +// ALLOW_MINIMIZE_WINDOW: false, +// FOLLOW_NATURAL_SCROLL: true, +// APP_GESTURES: false, +// DEFAULT_OVERVIEW_GESTURE_DIRECTION: true, +// }; + export const ExtSettings = { - DEFAULT_SESSION_WORKSPACE_GESTURE: false, - DEFAULT_OVERVIEW_GESTURE: false, + // DEFAULT_SESSION_WORKSPACE_GESTURE: false, + // DEFAULT_OVERVIEW_GESTURE: false, // TODO: remove ALLOW_MINIMIZE_WINDOW: false, + + FOLLOW_NATURAL_SCROLL: true, APP_GESTURES: false, DEFAULT_OVERVIEW_GESTURE_DIRECTION: true, diff --git a/extension/extension.ts b/extension/extension.ts index 24f3fb0..b6ccb7e 100644 --- a/extension/extension.ts +++ b/extension/extension.ts @@ -1,15 +1,12 @@ +import Clutter from '@gi-types/clutter'; import GLib from '@gi-types/glib2'; import { imports } from 'gnome-shell'; -import { AllSettingsKeys, GioSettings, PinchGestureType } from './common/settings'; +import { AllSettingsKeys, GioSettings, PinchGestureType, SwipeHorizontalGestureType, SwipeVerticalGestureType } from './common/settings'; import * as Constants from './constants'; +import { SwipeGestureInfo, SwipeGestureToExtensionMapper } from './src/gestures'; import { AltTabConstants, ExtSettings, TouchpadConstants } from './constants'; -import { AltTabGestureExtension } from './src/altTab'; -import { ForwardBackGestureExtension } from './src/forwardBack'; -import { GestureExtension } from './src/gestures'; -import { OverviewRoundTripGestureExtension } from './src/overviewRoundTrip'; import { CloseWindowExtension } from './src/pinchGestures/closeWindow'; import { ShowDesktopExtension } from './src/pinchGestures/showDesktop'; -import { SnapWindowExtension } from './src/snapWindow'; import * as DBusUtils from './src/utils/dbus'; import * as VKeyboard from './src/utils/keyboard'; @@ -73,23 +70,12 @@ class Extension { this._initializeSettings(); this._extensions = []; if (this.settings === undefined) - return; - + return; + if (this.settings.get_boolean('enable-alttab-gesture')) - this._extensions.push(new AltTabGestureExtension()); + // this._extensions.push(new AltTabGestureExtension()); - if (this.settings.get_boolean('enable-forward-back-gesture')) { - const appForwardBackKeyBinds = this.settings.get_value('forward-back-application-keyboard-shortcuts').deepUnpack(); - this._extensions.push(new ForwardBackGestureExtension(appForwardBackKeyBinds)); - } - - this._extensions.push( - new OverviewRoundTripGestureExtension(this.settings.get_enum('overview-navifation-states')), - new GestureExtension(), - ); - - if (this.settings.get_boolean('enable-window-manipulation-gesture')) - this._extensions.push(new SnapWindowExtension()); + this._setSwipeGestures() // pinch to show desktop const pinchToFingersMap = this._getPinchGestureTypeAndFingers(); @@ -119,13 +105,14 @@ class Extension { _initializeSettings() { if (this.settings) { - ExtSettings.DEFAULT_SESSION_WORKSPACE_GESTURE = this.settings.get_boolean('default-session-workspace'); - ExtSettings.DEFAULT_OVERVIEW_GESTURE = this.settings.get_boolean('default-overview'); - ExtSettings.ALLOW_MINIMIZE_WINDOW = this.settings.get_boolean('allow-minimize-window'); + // TODO: fix this somewhere, somehow + // ExtSettings.ALLOW_MINIMIZE_WINDOW = this.settings.get_boolean('allow-minimize-window'); + ExtSettings.FOLLOW_NATURAL_SCROLL = this.settings.get_boolean('follow-natural-scroll'); ExtSettings.DEFAULT_OVERVIEW_GESTURE_DIRECTION = this.settings.get_boolean('default-overview-gesture-direction'); ExtSettings.APP_GESTURES = this.settings.get_boolean('enable-forward-back-gesture'); + TouchpadConstants.SWIPE_MULTIPLIER = Constants.TouchpadConstants.DEFAULT_SWIPE_MULTIPLIER * this.settings.get_double('touchpad-speed-scale'); TouchpadConstants.PINCH_MULTIPLIER = Constants.TouchpadConstants.DEFAULT_PINCH_MULTIPLIER * this.settings.get_double('touchpad-pinch-speed'); AltTabConstants.DELAY_DURATION = this.settings.get_int('alttab-delay'); @@ -133,6 +120,45 @@ class Extension { } } + private _setSwipeGestures() { + if (this.settings) { + const swipeHorizontal3FingerGesture = this.settings.get_enum('swipe-horizontal-3-finger-gesture'); + const swipeVertical3FingerGesture = this.settings.get_enum('swipe-vertical-3-finger-gesture'); + const swipeHorizontal4FingerGesture = this.settings.get_enum('swipe-horizontal-4-finger-gesture'); + const swipeVertical4FingerGesture = this.settings.get_enum('swipe-vertical-4-finger-gesture'); + + const swipeGestureToExtension = new SwipeGestureToExtensionMapper(this.settings) + + const swipeHorizontal3FingerGestureInfo = new SwipeGestureInfo( + Clutter.Orientation.HORIZONTAL, + [3], swipeHorizontal3FingerGesture + ) + const extension_1 = swipeGestureToExtension.get_extension(swipeHorizontal3FingerGestureInfo) + + const swipeVertical3FingerGestureInfo = new SwipeGestureInfo( + Clutter.Orientation.VERTICAL, + [3], swipeVertical3FingerGesture + ) + const extension_2 = swipeGestureToExtension.get_extension(swipeVertical3FingerGestureInfo) + + const swipeHorizontal4FingerGestureInfo = new SwipeGestureInfo( + Clutter.Orientation.HORIZONTAL, + [4], swipeHorizontal4FingerGesture + ) + const extension_3 = swipeGestureToExtension.get_extension(swipeHorizontal4FingerGestureInfo) + + const swipeVertical4FingerGestureInfo = new SwipeGestureInfo( + Clutter.Orientation.VERTICAL, + [4], swipeVertical4FingerGesture + ) + const extension_4 = swipeGestureToExtension.get_extension(swipeVertical4FingerGestureInfo) + + this._extensions.push( + extension_1, extension_2, extension_3, extension_4 + ); + } + } + private _getPinchGestureTypeAndFingers(): Map { if (!this.settings) return new Map(); diff --git a/extension/schemas/org.gnome.shell.extensions.gestureImprovements.gschema.xml b/extension/schemas/org.gnome.shell.extensions.gestureImprovements.gschema.xml index dc613ab..d02dd05 100644 --- a/extension/schemas/org.gnome.shell.extensions.gestureImprovements.gschema.xml +++ b/extension/schemas/org.gnome.shell.extensions.gestureImprovements.gschema.xml @@ -1,5 +1,17 @@ + + + + + + + + + + + + @@ -12,6 +24,7 @@ + @@ -26,18 +39,36 @@ 100 - - false - If true, use 3-fingers to switch workspace, 4 for windows + + + + 'WINDOW_SWITCHING' + Gesture for 3 finger Left/Right Swipe + + + 'OVERVIEW_NAVIGATION' + Gesture for 3 finger Top/Down Swipe - - false - If true, use 3-fingers for overview gesture, 4 for snapping/tiling + + 'NONE' + Gesture for 3 finger pinch - - false - If true, when swipe down on non-maximized window minimizes it + + + + 'WORKSPACE_SWITCHING' + Gesture for 4 finger Left/Right Swipe + + + 'APP_NAVIGATION' + Gesture for 4 finger Top/Down Swipe + + + 'SHOW_DESKTOP' + Gesture for 4 finger pinch + + true Whether to follow natural scroll for swipe @@ -51,20 +82,8 @@ Enable alttab gesture - false - Enable forward/back keybinding gesture - - true - Enable Window manipulation gesture - - - 'NONE' - Gesture for 3 finger pinch - - - 'SHOW_DESKTOP' - Gesture for 4 finger pinch + Enable forward/back keybinding gesture 'CYCLIC' diff --git a/extension/src/gestures.ts b/extension/src/gestures.ts index d5069c4..0b0ec34 100644 --- a/extension/src/gestures.ts +++ b/extension/src/gestures.ts @@ -3,7 +3,13 @@ import GObject from '@gi-types/gobject2'; import Shell from '@gi-types/shell'; import { CustomEventType, global, imports, __shell_private_types } from 'gnome-shell'; import { ExtSettings, OverviewControlsState } from '../constants'; -import { createSwipeTracker, TouchpadSwipeGesture } from './swipeTracker'; +import { createSwipeTracker, TouchpadSwipeGesture } from './trackers/swipeTracker'; + +import { SnapWindowExtension } from '../src/swipeGestures/snapWindow'; +import { AltTabGestureExtension } from '../src/swipeGestures/altTab'; +import { ForwardBackGestureExtension } from '../src/swipeGestures/forwardBack'; +import { OverviewRoundTripGestureExtension } from '../src/swipeGestures/overviewRoundTrip'; +import { GioSettings } from '../common/settings'; const Main = imports.ui.main; @@ -79,12 +85,13 @@ class WorkspaceAnimationModifier extends SwipeTrackerEndPointsModifer { private _workspaceAnimation: imports.ui.workspaceAnimation.WorkspaceAnimationController; protected _swipeTracker: SwipeTrackerT; - constructor(wm: typeof imports.ui.main.wm) { + constructor(wm: typeof imports.ui.main.wm, n_fingers: number[]) { super(); this._workspaceAnimation = wm._workspaceAnimation; this._swipeTracker = createSwipeTracker( global.stage, - (ExtSettings.DEFAULT_SESSION_WORKSPACE_GESTURE ? [3] : [4]), + // (ExtSettings.DEFAULT_SESSION_WORKSPACE_GESTURE ? [3] : [4]), + n_fingers, Shell.ActionMode.NORMAL, Clutter.Orientation.HORIZONTAL, ExtSettings.FOLLOW_NATURAL_SCROLL, @@ -138,7 +145,7 @@ export class GestureExtension implements ISubExtension { private _swipeTrackers: ShellSwipeTracker[]; private _workspaceAnimationModifier: WorkspaceAnimationModifier; - constructor() { + constructor(n_fingers: number[]) { this._stateAdjustment = Main.overview._overview._controls._stateAdjustment; this._swipeTrackers = [ { @@ -174,7 +181,7 @@ export class GestureExtension implements ISubExtension { }, ]; - this._workspaceAnimationModifier = new WorkspaceAnimationModifier(Main.wm); + this._workspaceAnimationModifier = new WorkspaceAnimationModifier(Main.wm, n_fingers); } apply(): void { @@ -239,4 +246,96 @@ export class GestureExtension implements ISubExtension { GObject.BindingFlags.SYNC_CREATE, ); } -} \ No newline at end of file +} + +export class SwipeGestureInfo { + orientation: Clutter.Orientation; + n_fingers: number[]; + enum_id: number; + + constructor(orientation: Clutter.Orientation, + n_fingers: number[], + enum_id: number) { + this.orientation = orientation; + this.n_fingers = n_fingers; + this.enum_id = enum_id; + } +} + +export class SwipeGestureToExtensionMapper { + private settings: GioSettings; + private extensionInUse = { + "WINDOW_SWITCHING": false, + "APP_NAVIGATION": false, + "WORKSPACE_SWITCHING": false, + "OVERVIEW_NAVIGATION": false, + "WINDOW_MANIPULATION": false + }; + + constructor(settings: GioSettings) { + this.settings = settings; + } + + get_extension(gesture: SwipeGestureInfo) { + if (gesture.orientation === Clutter.Orientation.HORIZONTAL) { + switch (gesture.enum_id) { + case 0: { + if (this.extensionInUse["WORKSPACE_SWITCHING"] === false) { + this.extensionInUse["WORKSPACE_SWITCHING"] = true; + return new AltTabGestureExtension(gesture.n_fingers); + } + } + case 1: { + if (this.settings.get_boolean('enable-forward-back-gesture') && + this.extensionInUse["APP_NAVIGATION"] === false) { + this.extensionInUse["APP_NAVIGATION"] = true + const appForwardBackKeyBinds = this.settings.get_value('forward-back-application-keyboard-shortcuts').deepUnpack(); + return new ForwardBackGestureExtension( + appForwardBackKeyBinds, + gesture.n_fingers, + gesture.orientation, + false + ); + } + } + case 2: { + if (this.extensionInUse["WORKSPACE_SWITCHING"] === false) { + this.extensionInUse["WORKSPACE_SWITCHING"] = true; + return new GestureExtension(gesture.n_fingers); + } + } + } + } else if (gesture.orientation == Clutter.Orientation.VERTICAL) { + switch (gesture.enum_id) { + case 0: { + if (this.extensionInUse["OVERVIEW_NAVIGATION"] === false) { + this.extensionInUse["OVERVIEW_NAVIGATION"] = true + return new OverviewRoundTripGestureExtension( + this.settings.get_enum('overview-navigation-states'), + gesture.n_fingers + ); + } + } + case 1: { + if (this.settings.get_boolean('enable-forward-back-gesture') && + this.extensionInUse["APP_NAVIGATION"] === false) { + this.extensionInUse["APP_NAVIGATION"] = true + const appForwardBackKeyBinds = this.settings.get_value('forward-back-application-keyboard-shortcuts').deepUnpack(); + return new ForwardBackGestureExtension( + appForwardBackKeyBinds, + gesture.n_fingers, + gesture.orientation, + true + ); + } + } + case 2: { + if (this.extensionInUse["WINDOW_MANIPULATION"] == false){ + this.extensionInUse["WINDOW_MANIPULATION"] = true; + return new SnapWindowExtension(gesture.n_fingers); + } + } + } + } + } +} diff --git a/extension/src/altTab.ts b/extension/src/swipeGestures/altTab.ts similarity index 95% rename from extension/src/altTab.ts rename to extension/src/swipeGestures/altTab.ts index eb51187..aa8cec8 100644 --- a/extension/src/altTab.ts +++ b/extension/src/swipeGestures/altTab.ts @@ -3,8 +3,8 @@ import GLib from '@gi-types/glib2'; import Shell from '@gi-types/shell'; import St from '@gi-types/st'; import { imports } from 'gnome-shell'; -import { AltTabConstants, ExtSettings } from '../constants'; -import { TouchpadSwipeGesture } from './swipeTracker'; +import { AltTabConstants, ExtSettings } from '../../constants'; +import { TouchpadSwipeGesture } from '../trackers/swipeTracker'; const Main = imports.ui.main; const { WindowSwitcherPopup } = imports.ui.altTab; @@ -41,11 +41,12 @@ export class AltTabGestureExtension implements ISubExtension { private _progress = 0; private _altTabTimeoutId = 0; - constructor() { + constructor(n_fingers: number[]) { this._connectHandlers = []; this._touchpadSwipeTracker = new TouchpadSwipeGesture( - (ExtSettings.DEFAULT_SESSION_WORKSPACE_GESTURE ? [4] : [3]), + // (ExtSettings.DEFAULT_SESSION_WORKSPACE_GESTURE ? [4] : [3]), + n_fingers, Shell.ActionMode.ALL, Clutter.Orientation.HORIZONTAL, false, diff --git a/extension/src/forwardBack.ts b/extension/src/swipeGestures/forwardBack.ts similarity index 84% rename from extension/src/forwardBack.ts rename to extension/src/swipeGestures/forwardBack.ts index e00d6c3..7dcc6d1 100644 --- a/extension/src/forwardBack.ts +++ b/extension/src/swipeGestures/forwardBack.ts @@ -4,11 +4,11 @@ import Meta from '@gi-types/meta'; import { imports, global } from 'gnome-shell'; -import { ExtSettings } from '../constants'; -import { ArrowIconAnimation } from './animations/arrow'; -import { createSwipeTracker } from './swipeTracker'; -import { getVirtualKeyboard, IVirtualKeyboard } from './utils/keyboard'; -import { ForwardBackKeyBinds } from '../common/settings'; +import { ExtSettings } from '../../constants'; +import { ArrowIconAnimation } from '../animations/arrow'; +import { createSwipeTracker } from '../trackers/swipeTracker'; +import { getVirtualKeyboard, IVirtualKeyboard } from '../utils/keyboard'; +import { ForwardBackKeyBinds } from '../../common/settings'; const Main = imports.ui.main; declare type SwipeTrackerT = imports.ui.swipeTracker.SwipeTracker; @@ -41,21 +41,35 @@ export class ForwardBackGestureExtension implements ISubExtension { private _windowTracker: Shell.WindowTracker; private _focusWindow?: Meta.Window | null; - constructor(appForwardBackKeyBinds: AppForwardBackKeyBinds) { + constructor(appForwardBackKeyBinds: AppForwardBackKeyBinds, + n_fingers: number[], + orientation: Clutter.Orientation, + natural_scroll_direction: boolean) { this._appForwardBackKeyBinds = appForwardBackKeyBinds; this._windowTracker = Shell.WindowTracker.get_default(); this._keyboard = getVirtualKeyboard(); + // TODO: fix it with settings + // this._swipeTracker = createSwipeTracker( + // global.stage, + // ExtSettings.DEFAULT_OVERVIEW_GESTURE ? [4] : [3], // n fingers + // Shell.ActionMode.NORMAL, + // ExtSettings.DEFAULT_OVERVIEW_GESTURE ? Clutter.Orientation.VERTICAL : Clutter.Orientation.HORIZONTAL, // direction + // ExtSettings.DEFAULT_OVERVIEW_GESTURE ? true : false, // Natural scroll direction (scroll down in moving up) + // 1, + // { allowTouch: false }, + // ); this._swipeTracker = createSwipeTracker( global.stage, - ExtSettings.DEFAULT_OVERVIEW_GESTURE ? [4] : [3], - Shell.ActionMode.NORMAL, - ExtSettings.DEFAULT_OVERVIEW_GESTURE ? Clutter.Orientation.VERTICAL : Clutter.Orientation.HORIZONTAL, - ExtSettings.DEFAULT_OVERVIEW_GESTURE ? true : false, + n_fingers, // n fingers + Shell.ActionMode.NORMAL, + orientation, // direction + natural_scroll_direction, // Natural scroll direction (scroll down in moving up) 1, { allowTouch: false }, ); + this._connectHandlers = [ this._swipeTracker.connect('begin', this._gestureBegin.bind(this)), this._swipeTracker.connect('update', this._gestureUpdate.bind(this)), diff --git a/extension/src/overviewRoundTrip.ts b/extension/src/swipeGestures/overviewRoundTrip.ts similarity index 94% rename from extension/src/overviewRoundTrip.ts rename to extension/src/swipeGestures/overviewRoundTrip.ts index a7aa0d0..2f53279 100644 --- a/extension/src/overviewRoundTrip.ts +++ b/extension/src/swipeGestures/overviewRoundTrip.ts @@ -1,9 +1,9 @@ import Clutter from '@gi-types/clutter'; import Shell from '@gi-types/shell'; import { global, imports } from 'gnome-shell'; -import { OverviewNavigationState } from '../common/settings'; -import { ExtSettings, OverviewControlsState } from '../constants'; -import { createSwipeTracker } from './swipeTracker'; +import { OverviewNavigationState } from '../../common/settings'; +import { ExtSettings, OverviewControlsState } from '../../constants'; +import { createSwipeTracker } from '../trackers/swipeTracker'; const Main = imports.ui.main; const { SwipeTracker } = imports.ui.swipeTracker; @@ -26,9 +26,12 @@ export class OverviewRoundTripGestureExtension implements ISubExtension { private _shownEventId = 0; private _hiddenEventId = 0; private _navigationStates: OverviewNavigationState; + private n_fingers: number[] - constructor(navigationStates: OverviewNavigationState) { + constructor(navigationStates: OverviewNavigationState, + n_fingers: number[]) { this._navigationStates = navigationStates; + this.n_fingers = n_fingers; this._overviewControls = Main.overview._overview._controls; this._stateAdjustment = this._overviewControls._stateAdjustment; this._oldGetStateTransitionParams = this._overviewControls._stateAdjustment.getStateTransitionParams; @@ -63,7 +66,8 @@ export class OverviewRoundTripGestureExtension implements ISubExtension { this._swipeTracker = createSwipeTracker( global.stage, - (ExtSettings.DEFAULT_OVERVIEW_GESTURE ? [3] : [4]), + // (ExtSettings.DEFAULT_OVERVIEW_GESTURE ? [3] : [4]), + this.n_fingers, Shell.ActionMode.NORMAL | Shell.ActionMode.OVERVIEW, Clutter.Orientation.VERTICAL, ExtSettings.DEFAULT_OVERVIEW_GESTURE_DIRECTION, diff --git a/extension/src/snapWindow.ts b/extension/src/swipeGestures/snapWindow.ts similarity index 96% rename from extension/src/snapWindow.ts rename to extension/src/swipeGestures/snapWindow.ts index bb079f2..df9d3b9 100644 --- a/extension/src/snapWindow.ts +++ b/extension/src/swipeGestures/snapWindow.ts @@ -3,11 +3,11 @@ import Meta from '@gi-types/meta'; import Shell from '@gi-types/shell'; import St from '@gi-types/st'; import { global, imports } from 'gnome-shell'; -import { registerClass } from '../common/utils/gobject'; -import { ExtSettings } from '../constants'; -import { createSwipeTracker, TouchpadSwipeGesture } from './swipeTracker'; -import { easeActor, easeAdjustment } from './utils/environment'; -import { getVirtualKeyboard, IVirtualKeyboard } from './utils/keyboard'; +import { registerClass } from '../../common/utils/gobject'; +import { ExtSettings } from '../../constants'; +import { createSwipeTracker, TouchpadSwipeGesture } from '../trackers/swipeTracker'; +import { easeActor, easeAdjustment } from '../utils/environment'; +import { getVirtualKeyboard, IVirtualKeyboard } from '../utils/keyboard'; const Main = imports.ui.main; @@ -281,10 +281,11 @@ export class SnapWindowExtension implements ISubExtension { private _allowChangeDirection = false; private _uiGroupAddedActorId: number; - constructor() { + constructor(n_fingers: number[]) { this._swipeTracker = createSwipeTracker( global.stage, - (ExtSettings.DEFAULT_OVERVIEW_GESTURE ? [4] : [3]), + // (ExtSettings.DEFAULT_OVERVIEW_GESTURE ? [4] : [3]), + n_fingers, Shell.ActionMode.NORMAL, Clutter.Orientation.VERTICAL, true, diff --git a/extension/src/swipeTracker.ts b/extension/src/trackers/swipeTracker.ts similarity index 98% rename from extension/src/swipeTracker.ts rename to extension/src/trackers/swipeTracker.ts index c0b4d4c..ac298f8 100644 --- a/extension/src/swipeTracker.ts +++ b/extension/src/trackers/swipeTracker.ts @@ -3,9 +3,9 @@ import GObject from '@gi-types/gobject2'; import Meta from '@gi-types/meta'; import Shell from '@gi-types/shell'; import { CustomEventType, global, imports } from 'gnome-shell'; -import { registerClass } from '../common/utils/gobject'; -import { TouchpadConstants } from '../constants'; -import * as DBusUtils from './utils/dbus'; +import { registerClass } from '../../common/utils/gobject'; +import { TouchpadConstants } from '../../constants'; +import * as DBusUtils from '../utils/dbus'; const Main = imports.ui.main; const { SwipeTracker } = imports.ui.swipeTracker; diff --git a/extension/ui/gestures.ui b/extension/ui/gestures.ui index b2d722f..b2eba55 100644 --- a/extension/ui/gestures.ui +++ b/extension/ui/gestures.ui @@ -3,6 +3,22 @@ + + + Window Switching + App Navigation + Workspace Switching + + + + + + Overview Navigation + App Navigation + Window Manipulation + + + None @@ -12,110 +28,77 @@ + Gestures gesture-swipe-right-symbolic - + + - Swipe Gestures + 3 Finger Gestures - + - - 4-finger gestures for overview navigation - For navigating between desktop, activities and appgrid - - - center - True - - + + 3 finger Left/Right Swipe + horizontal_swipe_gestures_model - + - - 4-finger gestures for workspace switching - - - center - True - - + + 3 finger Up/Down Swipe + vertical_swipe_gestures_model - - - - Window switching - - - center - True - - - - - - - - - Window manipulation - Tile, unmaximize, maximize or fullscreen a window - - - center - True - - - - - - + - - Minimize window - This will disable tiling gesture - - - - center - True - - + + 3 finger pinch + pinch_gestures_model + - - + - Pinch Gestures + 4 Finger Gestures - + - - 3 finger pinch - pinch_gestures_model + + 4 finger Left/Right Swipe + horizontal_swipe_gestures_model - + + + + 4 finger Up/Down Swipe + vertical_swipe_gestures_model + + + + 4 finger pinch pinch_gestures_model - + + + \ No newline at end of file diff --git a/metadata.json b/metadata.json index 93b774b..b4a238e 100644 --- a/metadata.json +++ b/metadata.json @@ -7,5 +7,5 @@ "settings-schema": "org.gnome.shell.extensions.gestureImprovements", "url": "https://github.com/harshadgavali/gnome-gesture-improvements", "uuid": "gestureImprovements@gestures", - "version": 22.5 + "version": 23 }