Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions gestures.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,15 @@ const DIRECTIONS = {

let vy, time, vState, navigator, direction, signals;
let handoffToOverview = false;
// true between BEGIN and END/CANCEL of a PaperWM-managed swipe. Used to defer
// any tracker disabling that would otherwise interrupt a live overview gesture.
let inGesture = false;
// 1 is natural scrolling, -1 is unnatural
let natural = 1;

export function isInGesture() {
return inGesture;
}
export let gliding = false; // exported

let touchpadSettings;
Expand All @@ -42,9 +49,19 @@ export function enable(extension) {
* ensure swipe trackers are reset.
*/
signals.connect(Main.overview, 'hidden', () => {
if (gestureEnabled()) {
swipeTrackersEnable(false);
if (!gestureEnabled()) {
return;
}
// Defer to idle so any in-flight overview swipe animation settles
// (tracker -> State.NONE) before we disable. On GNOME 50 disabling a
// SCROLLING tracker calls _interrupt() -> synthetic 'end' -> illegal
// overview state transition -> stuck/hang.
GLib.idle_add(GLib.PRIORITY_DEFAULT, () => {
if (!inGesture && gestureEnabled()) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using the isInGesture() accessor even within the module

swipeTrackersEnable(false);
}
return GLib.SOURCE_REMOVE;
});
});

/**
Expand Down Expand Up @@ -88,6 +105,7 @@ export function enable(extension) {
natural = touchpadSettings.get_boolean("natural-scroll") ? 1 : -1;
direction = undefined;
handoffToOverview = false;
inGesture = true;
navigator = Navigator.getNavigator();
navigator.connect('destroy', () => {
vState = -1;
Expand Down Expand Up @@ -147,6 +165,7 @@ export function enable(extension) {
return Clutter.EVENT_PROPAGATE;
case Clutter.TouchpadGesturePhase.CANCEL:
case Clutter.TouchpadGesturePhase.END:
inGesture = false;
// If this finger count should be handled by GNOME, never consume
// completion here (prevents overview from getting stuck in 4-finger mode).
if (shouldPropagate(fingers)) {
Expand Down
9 changes: 8 additions & 1 deletion patches.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import * as WindowManager from 'resource:///org/gnome/shell/ui/windowManager.js'
import * as WindowPreview from 'resource:///org/gnome/shell/ui/windowPreview.js';
import * as Screenshot from 'resource:///org/gnome/shell/ui/screenshot.js';

import { Utils, Tiling, Scratch, Settings, OverviewLayout } from './imports.js';
import { Utils, Tiling, Scratch, Settings, OverviewLayout, Gestures } from './imports.js';

/**
Some of Gnome Shell's default behavior is really sub-optimal when using
Expand Down Expand Up @@ -153,6 +153,13 @@ export function setupOverrides() {
const reset = () => {
// gnome windows switch animation time = 250, do that plus a little more
pillSwipeTimer = GLib.timeout_add(GLib.PRIORITY_DEFAULT, 300, () => {
// Don't disable mid-gesture: on GNOME 50 disabling a
// SCROLLING tracker fires _interrupt() -> synthetic 'end'
// -> illegal overview transition -> hang.
if (Gestures.isInGesture?.()) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is there a null-check? This is our own module, the symbol should always exist

pillSwipeTimer = null;
return false;
}
swipeTrackers.forEach(t => {
t.enabled = false;
});
Expand Down