Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
153 changes: 153 additions & 0 deletions Settings.ui
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@
<property name="step_increment">0.1</property>
<property name="page_increment">10</property>
</object>
<object class="GtkAdjustment" id="touch-gesture-sensitivity-adjustment">
<property name="lower">0.5</property>
<property name="upper">5</property>
<property name="step_increment">0.1</property>
<property name="page_increment">1</property>
</object>
<object class="GtkAdjustment" id="vertical_margin">
<property name="upper">100</property>
<property name="step_increment">1</property>
Expand Down Expand Up @@ -510,6 +516,153 @@
</child>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="halign">start</property>
<property name="hexpand">True</property>
<property name="label" translatable="yes">Touchscreen Gestures</property>
<attributes>
<attribute name="weight" value="bold" />
</attributes>
</object>
</child>
<child>
<object class="GtkListBox">
<property name="focusable">False</property>
<property name="selection_mode">none</property>
<property name="margin-bottom">16</property>
<style>
<class name="frame" />
</style>
<child>
<object class="GtkListBoxRow">
<property name="activatable">False</property>
<property name="focusable">False</property>
<child>
<object class="GtkGrid">
<property name="focusable">False</property>
<property name="tooltip_text" translatable="yes">Enables / disables the PaperWM touchscreen swipe gesture for moving the tiling left/right.</property>
<property name="margin_start">12</property>
<property name="margin_end">12</property>
<property name="margin_top">6</property>
<property name="margin_bottom">6</property>
<property name="column_spacing">32</property>
<child>
<object class="GtkLabel">
<property name="focusable">False</property>
<property name="hexpand">1</property>
<property name="label" translatable="yes">Enable Touchscreen Gestures</property>
<property name="use_markup">1</property>
<property name="xalign">0</property>
<layout>
<property name="column">0</property>
<property name="row">0</property>
</layout>
</object>
</child>
<child>
<object class="GtkSwitch" id="touch-gesture-enabled">
<layout>
<property name="column">1</property>
<property name="row">0</property>
</layout>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkListBoxRow">
<property name="activatable">False</property>
<property name="focusable">False</property>
<child>
<object class="GtkGrid">
<property name="focusable">False</property>
<property name="tooltip_text" translatable="yes">Number of fingers for the touchscreen tiling swipe. 3 fingers conflicts with GNOME's workspace gesture.</property>
<property name="margin_start">12</property>
<property name="margin_end">12</property>
<property name="margin_top">6</property>
<property name="margin_bottom">6</property>
<property name="column_spacing">32</property>
<child>
<object class="GtkLabel">
<property name="focusable">False</property>
<property name="hexpand">1</property>
<property name="label" translatable="yes">Swipe tiling windows &lt;i&gt;(swipe left/right)&lt;/i&gt;</property>
<property name="use_markup">1</property>
<property name="xalign">0</property>
<layout>
<property name="column">0</property>
<property name="row">0</property>
</layout>
</object>
</child>
<child>
<object class="GtkComboBoxText" id="touch-gesture-fingers">
<property name="focusable">False</property>
<property name="hexpand">0</property>
<property name="width-request">106</property>
<items>
<item id="four-fingers" translatable="yes">4 Fingers</item>
<item id="five-fingers" translatable="yes">5 Fingers</item>
</items>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkListBoxRow">
<property name="activatable">False</property>
<property name="focusable">False</property>
<child>
<object class="GtkGrid">
<property name="focusable">False</property>
<property name="tooltip_text" translatable="yes">How far the tiling moves per unit of finger travel. Higher means a shorter swipe switches window.</property>
<property name="margin_start">12</property>
<property name="margin_end">12</property>
<property name="margin_top">6</property>
<property name="margin_bottom">6</property>
<property name="column_spacing">32</property>
<child>
<object class="GtkLabel">
<property name="focusable">False</property>
<property name="hexpand">1</property>
<property name="label" translatable="yes">Swipe sensitivity</property>
<property name="use_markup">1</property>
<property name="xalign">0</property>
<layout>
<property name="column">0</property>
<property name="row">0</property>
</layout>
</object>
</child>
<child>
<object class="GtkSpinButton" id="touch-gesture-sensitivity">
<property name="can_focus">True</property>
<property name="editable">True</property>
<property name="width_chars">2</property>
<property name="max_width_chars">2</property>
<property name="text" translatable="yes">0</property>
<property name="adjustment">touch-gesture-sensitivity-adjustment</property>
<property name="digits">1</property>
<property name="snap_to_ticks">1</property>
<property name="numeric">1</property>
<property name="update_policy">always</property>
<layout>
<property name="column">1</property>
<property name="row">0</property>
</layout>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="halign">start</property>
Expand Down
75 changes: 75 additions & 0 deletions gestures.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const DIRECTIONS = {
};

let vy, time, vState, navigator, direction, signals;
let touchPanGesture; // touchscreen 4-finger pan gesture (local addition)
let handoffToOverview = false;
// 1 is natural scrolling, -1 is unnatural
let natural = 1;
Expand Down Expand Up @@ -172,6 +173,76 @@ export function enable(extension) {
}
return Clutter.EVENT_PROPAGATE;
});

/**
Touchscreen pan -> scroll the window strip.

PaperWM natively only handles touchpad swipes (TOUCHPAD_SWIPE events)
and a single-finger top-bar touch scroll; a touchscreen never emits
TOUCHPAD_SWIPE. This adds a touchscreen equivalent via Clutter's gesture
framework. Unlike a raw captured-event handler, a gesture recognised by
the framework intercepts touch even over windows.

Defaults to 4 fingers: GNOME owns the 3-finger touchscreen swipe
(workspace switching) and wins gesture recognition. Finger count,
sensitivity and enabled state are configurable via the touch-gesture-*
settings.
*/
touchPanGesture = new Clutter.PanGesture();
touchPanGesture.set_pan_axis(Clutter.PanAxis.X);
let panSpace = null;

// Push finger count and enabled state to the gesture; re-apply on change.
// Sensitivity is read live per pan-update (see below).
const applyTouchGestureSettings = () => {
const fingers = Settings.prefs.touch_gesture_fingers;
touchPanGesture.set_min_n_points(fingers);
touchPanGesture.set_max_n_points(fingers);
touchPanGesture.set_enabled(Settings.prefs.touch_gesture_enabled);
};
applyTouchGestureSettings();
signals.connect(gsettings, 'changed::touch-gesture-enabled', applyTouchGestureSettings);
signals.connect(gsettings, 'changed::touch-gesture-fingers', applyTouchGestureSettings);

signals.connect(touchPanGesture, 'recognize', () => {
const space = Tiling.spaces.activeSpace ?? Tiling.spaces.selectedSpace;
panSpace = space ?? null;
if (!panSpace)
return;
panSpace.vx = 0;
dxs = [];
dts = [];
start = panSpace.targetX;
panSpace.hState = Clutter.TouchpadGesturePhase.UPDATE;
direction = DIRECTIONS.Horizontal;
Easer.removeEase(panSpace.cloneContainer);
swipeTrackersEnable(false);
navigator = Navigator.getNavigator();
update(panSpace, 0, GLib.get_monotonic_time() / 1000);
});

signals.connect(touchPanGesture, 'pan-update', gesture => {
if (!panSpace)
return;
const delta = gesture.get_delta();
update(panSpace, -delta.get_x() * Settings.prefs.touch_gesture_sensitivity,
GLib.get_monotonic_time() / 1000);
});

const finishPan = () => {
if (!panSpace)
return;
panSpace.hState = Clutter.TouchpadGesturePhase.END;
done(panSpace);
direction = undefined;
dxs = [];
dts = [];
panSpace = null;
};
signals.connect(touchPanGesture, 'end', finishPan);
signals.connect(touchPanGesture, 'cancel', finishPan);

global.stage.add_action(touchPanGesture);
}

function shouldPropagate(fingers) {
Expand Down Expand Up @@ -206,6 +277,10 @@ export function disable() {
signals = null;
Utils.timeout_remove(endVerticalTimeout);
endVerticalTimeout = null;
if (touchPanGesture) {
global.stage.remove_action(touchPanGesture);
touchPanGesture = null;
}
touchpadSettings = null;
}

Expand Down
9 changes: 9 additions & 0 deletions prefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,15 @@ class SettingsWidget {
const fingerNumberDefault = 0;
enumOptionsChanged('gesture-horizontal-fingers', fingerOptions, fingerOptionDefault, fingerNumberDefault);
enumOptionsChanged('gesture-workspace-fingers', fingerOptions, fingerOptionDefault, fingerNumberDefault);

// Touchscreen gesture settings
booleanStateChanged('touch-gesture-enabled');
enumOptionsChanged(
'touch-gesture-fingers',
{ 'four-fingers': 4, 'five-fingers': 5 },
'four-fingers',
4);
doubleValueChanged('touch-gesture-sensitivity', 'touch-gesture-sensitivity');
enumOptionsChanged(
'default-focus-mode',
{
Expand Down
Binary file modified schemas/gschemas.compiled
Binary file not shown.
15 changes: 15 additions & 0 deletions schemas/org.gnome.shell.extensions.paperwm.gschema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -768,6 +768,21 @@
<summary>Number of fingers for workspace switching. 0:DISABLED 3:THREE_FINGERS 4:FOUR_FINGERS</summary>
</key>

<key type="b" name="touch-gesture-enabled">
<default>true</default>
<summary>Enables the PaperWM touchscreen swipe gesture</summary>
</key>

<key type="i" name="touch-gesture-fingers">
<default>4</default>
<summary>Number of fingers for the touchscreen tiling swipe. 4:FOUR_FINGERS 5:FIVE_FINGERS</summary>
</key>

<key type="d" name="touch-gesture-sensitivity">
<default>1.8</default>
<summary>Touchscreen swipe sensitivity: how far the tiling moves per unit of finger travel</summary>
</key>

<child name="keybindings" schema="org.gnome.shell.extensions.paperwm.keybindings"/>
<child name="workspaces" schema="org.gnome.shell.extensions.paperwm.workspacelist"/>

Expand Down
3 changes: 3 additions & 0 deletions settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ export function enable(extension) {
'gesture-enabled',
'gesture-horizontal-fingers',
'gesture-workspace-fingers',
'touch-gesture-enabled',
'touch-gesture-fingers',
'touch-gesture-sensitivity',
'open-window-position',
'overview-ensure-viewport-animation',
'overview-min-windows-per-row',
Expand Down
Loading