Skip to content

Commit

Permalink
snapWindow: disable touch gestures
Browse files Browse the repository at this point in the history
  • Loading branch information
harshadgavali committed Aug 17, 2021
1 parent eea32ca commit 9e2fec6
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 10 deletions.
3 changes: 3 additions & 0 deletions extension/src/snapWindow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,10 @@ export class SnapWindowExtension implements ISubExtension {
(ExtSettings.DEFAULT_OVERVIEW_GESTURE ? [4] : [3]),
Shell.ActionMode.NORMAL,
Clutter.Orientation.VERTICAL,
1,
{ allowTouch: false },
);

this._swipeTracker.allowLongSwipes = true;
this._touchpadSwipeGesture = this._swipeTracker._touchpadGesture as typeof TouchpadSwipeGesture.prototype;
this._tilePreview = new TilePreview();
Expand Down
38 changes: 28 additions & 10 deletions extension/src/swipeTracker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,25 @@ import { TouchpadConstants } from '../constants';
enum TouchpadState {
NONE = 0,
PENDING = 1,
HANDLING = 2,
HANDLING = 2,
IGNORED = 3,
}

export const TouchpadSwipeGesture = GObject.registerClass({
Properties: {
'enabled': GObject.ParamSpec.boolean(
'enabled',
'enabled',
'enabled',
'enabled',
'enabled',
GObject.ParamFlags.READWRITE,
true,
),
'orientation': GObject.ParamSpec.enum(
'orientation',
'orientation',
'orientation',
'orientation',
'orientation',
GObject.ParamFlags.READWRITE,
Clutter.Orientation,
Clutter.Orientation,
Clutter.Orientation.HORIZONTAL,
),
},
Expand Down Expand Up @@ -205,23 +205,41 @@ export const TouchpadSwipeGesture = GObject.registerClass({
}
});

declare type _SwipeTrackerOptionalParams = {
allowTouch?: boolean,
allowDrag?: boolean,
allowScroll?: boolean,
}

export function createSwipeTracker(
actor: Clutter.Actor,
nfingers: number[],
allowedModes: Shell.ActionMode,
orientation: Clutter.Orientation,
gestureSpeed = 1,
params?: _SwipeTrackerOptionalParams,
): typeof SwipeTracker.prototype {

params = params ?? {};
params.allowDrag = params.allowDrag ?? false;
params.allowScroll = params.allowScroll ?? false;
const allowTouch = params.allowTouch ?? true;
delete params.allowTouch;

// create swipeTracker
const swipeTracker = new SwipeTracker(
actor,
orientation,
allowedModes,
{ allowDrag: false, allowScroll: false },

params,
);

// remove touch gestures
if (!allowTouch && swipeTracker._touchGesture) {
global.stage.remove_action(swipeTracker._touchGesture);
delete swipeTracker._touchGesture;
}

// remove old touchpad gesture from swipeTracker
if (swipeTracker._touchpadGesture) {
swipeTracker._touchpadGesture.destroy();
Expand All @@ -242,8 +260,8 @@ export function createSwipeTracker(
swipeTracker._touchpadGesture.connect('end', swipeTracker._endTouchpadGesture.bind(swipeTracker));
swipeTracker.bind_property('enabled', swipeTracker._touchpadGesture, 'enabled', 0);
swipeTracker.bind_property(
'orientation',
swipeTracker._touchpadGesture,
'orientation',
swipeTracker._touchpadGesture,
'orientation',
GObject.BindingFlags.SYNC_CREATE,
);
Expand Down
1 change: 1 addition & 0 deletions gnome-shell/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ declare namespace imports {
confirmSwipe(distance: number, snapPoints: number[], currentProgress: number, cancelProgress: number): void;
destroy(): void;

_touchGesture?: Clutter.GestureAction;
_touchpadGesture?: __shell_private_types.TouchpadGesture;
// custom
__oldTouchpadGesture?: __shell_private_types.TouchpadGesture;
Expand Down

0 comments on commit 9e2fec6

Please sign in to comment.