From eb32012306cb5d35be815064f0ae69209449b70f Mon Sep 17 00:00:00 2001 From: Swapnil Devesh Date: Thu, 25 Apr 2024 22:28:07 +0530 Subject: [PATCH 01/16] Initial commit from https://github.com/harshadgavali/gnome-gesture-improvements/issues/206#issuecomment-2023405620 which bumps support for 46 on the transpiled version from @joaophi --- assets/arrow1-left-symbolic.svg | 407 ++++++++++++++++++ assets/arrow1-right-symbolic.svg | 407 ++++++++++++++++++ common/appGestures.js | 344 +++++++++++++++ common/prefs.js | 113 +++++ common/settings.js | 27 ++ common/utils/gobject.js | 18 + common/utils/logging.js | 13 + constants.js | 43 ++ extension.js | 135 ++++++ metadata.json | 12 + prefs.js | 13 + schemas/gschemas.compiled | Bin 0 -> 2133 bytes ...extensions.gestureImprovements.gschema.xml | 104 +++++ src/altTab.js | 185 ++++++++ src/animations/arrow.js | 101 +++++ src/forwardBack.js | 161 +++++++ src/gestures.js | 183 ++++++++ src/overviewRoundTrip.js | 167 +++++++ src/pinchGestures/closeWindow.js | 120 ++++++ src/pinchGestures/showDesktop.js | 375 ++++++++++++++++ src/snapWindow.js | 361 ++++++++++++++++ src/swipeTracker.js | 242 +++++++++++ src/trackers/pinchTracker.js | 287 ++++++++++++ src/utils/dbus.js | 167 +++++++ src/utils/environment.js | 9 + src/utils/keyboard.js | 50 +++ stylesheet.css | 38 ++ ui/customizations.ui | 183 ++++++++ ui/gestures.ui | 121 ++++++ ui/style-dark.css | 7 + ui/style.css | 7 + 31 files changed, 4400 insertions(+) create mode 100644 assets/arrow1-left-symbolic.svg create mode 100644 assets/arrow1-right-symbolic.svg create mode 100644 common/appGestures.js create mode 100644 common/prefs.js create mode 100644 common/settings.js create mode 100644 common/utils/gobject.js create mode 100644 common/utils/logging.js create mode 100644 constants.js create mode 100644 extension.js create mode 100644 metadata.json create mode 100644 prefs.js create mode 100644 schemas/gschemas.compiled create mode 100644 schemas/org.gnome.shell.extensions.gestureImprovements.gschema.xml create mode 100644 src/altTab.js create mode 100644 src/animations/arrow.js create mode 100644 src/forwardBack.js create mode 100644 src/gestures.js create mode 100644 src/overviewRoundTrip.js create mode 100644 src/pinchGestures/closeWindow.js create mode 100644 src/pinchGestures/showDesktop.js create mode 100644 src/snapWindow.js create mode 100644 src/swipeTracker.js create mode 100644 src/trackers/pinchTracker.js create mode 100644 src/utils/dbus.js create mode 100644 src/utils/environment.js create mode 100644 src/utils/keyboard.js create mode 100644 stylesheet.css create mode 100644 ui/customizations.ui create mode 100644 ui/gestures.ui create mode 100644 ui/style-dark.css create mode 100644 ui/style.css diff --git a/assets/arrow1-left-symbolic.svg b/assets/arrow1-left-symbolic.svg new file mode 100644 index 0000000..39eb56d --- /dev/null +++ b/assets/arrow1-left-symbolic.svg @@ -0,0 +1,407 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/arrow1-right-symbolic.svg b/assets/arrow1-right-symbolic.svg new file mode 100644 index 0000000..31973b1 --- /dev/null +++ b/assets/arrow1-right-symbolic.svg @@ -0,0 +1,407 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/common/appGestures.js b/common/appGestures.js new file mode 100644 index 0000000..39d7a82 --- /dev/null +++ b/common/appGestures.js @@ -0,0 +1,344 @@ +/* exported getAppKeybindingGesturePrefsPage */ +import Gtk from 'gi://Gtk'; +import Gio from 'gi://Gio'; +import GLib from 'gi://GLib'; +import GObject from 'gi://GObject'; +import Adw from 'gi://Adw'; +import { ForwardBackKeyBinds } from './settings.js' +import { registerClass } from './utils/gobject.js' +import { printStack } from './utils/logging.js' + +/** return icon image for give app */ +function getAppIconImage(app) { + var _a, _b; + const iconName = (_b = (_a = app.get_icon()) === null || _a === void 0 ? void 0 : _a.to_string()) !== null && _b !== void 0 ? _b : 'icon-missing'; + return new Gtk.Image({ + gicon: Gio.icon_new_for_string(iconName), + iconSize: Gtk.IconSize.LARGE, + }); +} + +/** Returns marked escaped text or empty string if text is nullable */ +function markup_escape_text(text) { + var _a; + text = text !== null && text !== void 0 ? text : ''; + try { + return GLib.markup_escape_text(text, -1); + // eslint-disable-next-line @typescript-eslint/no-explicit-any + } + catch (e) { + // TODO: see what exactly is error and fix it + // probably errors in different language or app name + printStack(`Error: '${(_a = e === null || e === void 0 ? void 0 : e.message) !== null && _a !== void 0 ? _a : e}' while escaping app name for app(${text}))`); + return text; + } +} + +/** Dialog window used for selecting application from given list of apps + * Emits `app-selected` signal with application id + */ +const AppChooserDialog = registerClass({ + Properties: {}, + Signals: { 'app-selected': { param_types: [GObject.TYPE_STRING] } }, +}, class GIE_AppChooserDialog extends Adw.PreferencesWindow { + /** + * @param apps list of apps to display in dialog + * @param parent parent window, dialog will be transient for parent + */ + _init(apps, parent) { + super._init({ + modal: true, + transientFor: parent, + destroyWithParent: false, + title: 'Select application', + }); + + this.set_default_size(0.7 * parent.defaultWidth, 0.7 * parent.defaultHeight); + this._group = new Adw.PreferencesGroup(); + const page = new Adw.PreferencesPage(); + page.add(this._group); + this.add(page); + apps.forEach(app => this._addAppRow(app)); + } + + /** for given app add row to selectable list */ + _addAppRow(app) { + const row = new Adw.ActionRow({ + title: markup_escape_text(app.get_display_name()), + subtitle: markup_escape_text(app.get_description()), + activatable: true, + }); + + row.add_prefix(getAppIconImage(app)); + this._group.add(row); + row.connect('activated', () => { + this.emit('app-selected', app.get_id()); + this.close(); + }); + } +}); + +/** + * Class to create row for application in list to display gesture settings of app + * Emits 'value-updated' when any of settings changes + * Emits 'remove-request' when remove button is clicked + */ +const AppGestureSettingsRow = registerClass({ + Properties: {}, + Signals: { + 'value-updated': { param_types: [GObject.TYPE_UINT, GObject.TYPE_BOOLEAN] }, + 'remove-request': {}, + }, +}, class GIE_AppGestureSettingsRow extends Adw.ExpanderRow { + /** + * @param appGestureSettings value of current settings for app + * @param model list of choices of keybings for setting + */ + _init(app, appGestureSettings, model) { + super._init({ title: markup_escape_text(app.get_display_name()) }); + this.add_prefix(getAppIconImage(app)); + const [keyBind, reverse] = appGestureSettings; + + // keybinding combo row + this._keyBindCombo = new Adw.ComboRow({ + title: 'Keybinding', + subtitle: 'Keyboard shortcut to emit after gesture is completed', + model, + }); + + this._keyBindCombo.set_selected(keyBind); + this.add_row(this._keyBindCombo); + + // reverse switch row + this._reverseButton = new Gtk.Switch({ + active: reverse, + valign: Gtk.Align.CENTER, + }); + + let actionRow = new Adw.ActionRow({ title: 'Reverse gesture direction' }); + actionRow.add_suffix(this._reverseButton); + this.add_row(actionRow); + + // remove setting row + const removeButton = new Gtk.Button({ + label: 'Remove...', + valign: Gtk.Align.CENTER, + halign: Gtk.Align.END, + cssClasses: ['raised'], + }); + + actionRow = new Adw.ActionRow(); + actionRow.add_suffix(removeButton); + this.add_row(actionRow); + + // remove request signal emitted when remove button is clicked + removeButton.connect('clicked', () => this.emit('remove-request')); + this._keyBindCombo.connect('notify::selected', this._onValueUpdated.bind(this)); + this._reverseButton.connect('notify::active', this._onValueUpdated.bind(this)); + } + + /** function called internally whenever some setting is changed, emits external signal */ + _onValueUpdated() { + this.emit('value-updated', this._keyBindCombo.selected, this._reverseButton.active); + } +}); + +/** + * Class to display list of applications and their gesture settings + */ +const AppKeybindingGesturePrefsGroup = registerClass(class GIE_AppKeybindingGesturePrefsGroup extends Adw.PreferencesGroup { + /** + * @param prefsWindow parent preferences window + * @param settings extension settings object + */ + _init(prefsWindow, settings) { + super._init({ + title: 'Enable application specific gestures', + description: 'Hold and then swipe to activate the gesture', + }); + + this._prefsWindow = prefsWindow; + this._settings = settings; + this._appRows = new Map(); + this._cachedSettings = this._settings.get_value('forward-back-application-keyboard-shortcuts').deepUnpack(); + this._appGestureModel = this._getAppGestureModelForComboBox(); + + // build ui widgets + this.add(new Adw.PreferencesRow({ + child: new Gtk.Label({ + label: 'Applications not listed here will have default settings', + halign: Gtk.Align.CENTER, + hexpand: true, + }), + cssClasses: ['custom-information-label-row', 'custom-smaller-card'], + })); + + this._addAppButtonRow = this._buildAddAppButtonRow(); + this.add(this._addAppButtonRow); + Object.keys(this._cachedSettings).sort().reverse().forEach(appId => this._addAppGestureRow(appId)); + + // bind switch to setting value + const toggleSwitch = new Gtk.Switch({ valign: Gtk.Align.CENTER }); + this._settings.bind('enable-forward-back-gesture', toggleSwitch, 'active', Gio.SettingsBindFlags.DEFAULT); + this.set_header_suffix(toggleSwitch); + } + + /** + * Handler function, called when add button is clicked + * Displays dialog to select application to add + */ + _onAddAppButtonClicked() { + // find list of new apps that can be selected + const allApps = Gio.app_info_get_all(); + const selectableApps = allApps + .filter(app => { + const appId = app.get_id(); + return app.should_show() && appId && !this._appRows.has(appId); + }) + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + .sort((a, b) => a.get_id().localeCompare(b.get_id())); + + const appChooserDialog = new AppChooserDialog(selectableApps, this._prefsWindow); + appChooserDialog.connect('app-selected', (_source, appId) => this._addAppGestureRow(appId)); + appChooserDialog.present(); + } + + /** + * @returns row for add app button + */ + _buildAddAppButtonRow() { + const addButton = new Gtk.Button({ + iconName: 'list-add-symbolic', + cssName: 'card', + cssClasses: ['custom-smaller-card'], + }); + + const addButtonRow = new Adw.PreferencesRow({ child: addButton }); + addButton.connect('clicked', this._onAddAppButtonClicked.bind(this)); + return addButtonRow; + } + + /** + * Adds application specific gesture settings row for given app id + * Does nothing if app doesn't exist + */ + _addAppGestureRow(appId) { + const app = Gio.DesktopAppInfo.new(appId); + if (!app) + return; + const appRow = new AppGestureSettingsRow( + app, + this._getAppGestureSetting(appId), // this function updates extension settings + this._appGestureModel + ); + + this._appRows.set(appId, appRow); + this.add(appRow); + + // callbacks for setting updates and remove request + appRow.connect('remove-request', () => this._requestRemoveAppGestureRow(appId)); + appRow.connect('value-updated', (_source, keyBind, reverse) => { + this._setAppGestureSetting(appId, [keyBind, reverse]); + }); + + // re-add add-appbutton at the end + this.remove(this._addAppButtonRow); + this.add(this._addAppButtonRow); + } + + /** + * Removes application specific gesture settings row for given app + * Does nothing if row for app was not added + * Updates extension settings + */ + _removeAppGestureRow(appId) { + const appRow = this._appRows.get(appId); + if (!appRow) + return; + this.remove(appRow); + this._appRows.delete(appId); + delete this._cachedSettings[appId]; + this._updateExtensionSettings(); + } + + /** + * Signal handler called when removal of app gesture settings is requested + * Displays confirmation dialog and removes app row if confirmed + */ + _requestRemoveAppGestureRow(appId) { + const app = Gio.DesktopAppInfo.new(appId); + const dialog = new Gtk.MessageDialog({ + transient_for: this._prefsWindow, + modal: true, + text: `Remove gesture setting for ${app.get_display_name()}?`, + }); + + dialog.add_button('Cancel', Gtk.ResponseType.CANCEL); + dialog + .add_button('Remove', Gtk.ResponseType.ACCEPT) + .get_style_context() + .add_class('destructive-action'); + + dialog.connect('response', (_dlg, response) => { + if (response === Gtk.ResponseType.ACCEPT) { + this._removeAppGestureRow(appId); + } + + dialog.destroy(); + }); + + dialog.present(); + } + + /** + * Returns application specific gesture setting + * if setting is not set, returns default value and saves extension settings + */ + _getAppGestureSetting(appId) { + let val = this._cachedSettings[appId]; + if (!val) { + // this is case when new app was selected for gesture + val = [ForwardBackKeyBinds.Default, false]; + this._setAppGestureSetting(appId, val); + } + + return val; + } + + /** Saves application specific gesture setting into extension settings */ + _setAppGestureSetting(appId, appGestureSettings) { + this._cachedSettings[appId] = appGestureSettings; + this._updateExtensionSettings(); + } + + /** Updates extension settings */ + _updateExtensionSettings() { + const glibVariant = new GLib.Variant('a{s(ib)}', this._cachedSettings); + this._settings.set_value('forward-back-application-keyboard-shortcuts', glibVariant); + } + + /** Returns model which contains all possible choices for keybinding setting for app-gesture */ + _getAppGestureModelForComboBox() { + const appGestureModel = new Gtk.StringList(); + Object.values(ForwardBackKeyBinds).forEach(val => { + if (typeof val !== 'number') + return; + appGestureModel.append(ForwardBackKeyBinds[val]); + }); + + return appGestureModel; + } +}); + +/** + * @returns preference page for application gestures + */ +export function getAppKeybindingGesturePrefsPage(prefsWindow, settings) { + const page = new Adw.PreferencesPage({ + title: 'App Gestures', + iconName: 'org.gnome.Settings-applications-symbolic', + }); + + page.add(new AppKeybindingGesturePrefsGroup(prefsWindow, settings)); + return page; +} diff --git a/common/prefs.js b/common/prefs.js new file mode 100644 index 0000000..4b1e506 --- /dev/null +++ b/common/prefs.js @@ -0,0 +1,113 @@ +/* exported buildPrefsWidget */ +import Gio from 'gi://Gio'; +import Gtk from 'gi://Gtk'; +import Gdk from 'gi://Gdk'; +import Adw from 'gi://Adw'; +// eslint-disable-next-line @typescript-eslint/no-unused-vars +import { getAppKeybindingGesturePrefsPage } from './appGestures.js' + +/** + * Bind value of setting to {@link Gtk.SpinButton} + * @param key key of setting and id of {@link Gtk.SpinButton} object in builder + */ +function bind_int_value(key, settings, builder) { + const button = builder.get_object(key); + settings.bind(key, button, 'value', Gio.SettingsBindFlags.DEFAULT); +} + +/** + * Bind value of setting to {@link Gtk.Swich} + * @param key key of setting and id of {@link Gtk.Switch} object in builder + * @param flags flag used when binding setting's key to switch's {@link Gtk.Switch.active} status + */ +function bind_boolean_value(key, settings, builder, flags) { + const button = builder.get_object(key); + settings.bind(key, button, 'active', flags !== null && flags !== void 0 ? flags : Gio.SettingsBindFlags.DEFAULT); +} + +/** + * Bind value of setting to {@link Adw.ComboRow} + * @param key key of settings and id of {@link Adw.ComboRow} object in builder + */ +function bind_combo_box(key, settings, builder) { + const comboRow = builder.get_object(key); + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const enum_key = key; + comboRow.set_selected(settings.get_enum(enum_key)); + comboRow.connect('notify::selected', () => { + settings.set_enum(enum_key, comboRow.selected); + }); +} + +/** + * Display value of `key` in log scale. + * @param key key of setting and id of {@link Gtk.Scale} object in builder + */ +function display_in_log_scale(key, label_key, settings, builder) { + const scale = builder.get_object(key); + const label = builder.get_object(label_key); + + // display value in log scale + scale.connect('value-changed', () => { + const labelValue = Math.exp(scale.adjustment.value / Math.LOG2E).toFixed(2); + label.set_text(labelValue); + settings.set_double(key, parseFloat(labelValue)); + }); + + const initialValue = Math.log2(settings.get_double(key)); + scale.set_value(initialValue); +} + +/** + * Binds preference widgets and settings keys + * @param builder builder object for preference widgets + * @param settings setting object of extension + */ +function bindPrefsSettings(builder, settings) { + display_in_log_scale('touchpad-speed-scale', 'touchpad-speed-scale_display-value', settings, builder); + display_in_log_scale('touchpad-pinch-speed', 'touchpad-pinch-speed_display-value', settings, builder); + bind_int_value('alttab-delay', settings, builder); + bind_int_value('hold-swipe-delay-duration', settings, builder); + bind_boolean_value('default-session-workspace', settings, builder, Gio.SettingsBindFlags.INVERT_BOOLEAN); + bind_boolean_value('default-overview', settings, builder, Gio.SettingsBindFlags.INVERT_BOOLEAN); + bind_boolean_value('follow-natural-scroll', settings, builder); + bind_boolean_value('default-overview-gesture-direction', settings, builder, Gio.SettingsBindFlags.INVERT_BOOLEAN); + bind_boolean_value('enable-alttab-gesture', settings, builder); + bind_boolean_value('enable-window-manipulation-gesture', settings, builder); + bind_boolean_value('allow-minimize-window', settings, builder); + bind_combo_box('pinch-3-finger-gesture', settings, builder); + bind_combo_box('pinch-4-finger-gesture', settings, builder); + bind_combo_box('overview-navifation-states', settings, builder); +} + +function loadCssProvider(styleManager, uiDir) { + const cssProvider = new Gtk.CssProvider(); + cssProvider.load_from_path(`${uiDir}/${styleManager.dark ? 'style-dark' : 'style'}.css`); + const gtkDefaultDisplay = Gdk.Display.get_default(); + if (gtkDefaultDisplay) { + Gtk.StyleContext.add_provider_for_display(gtkDefaultDisplay, cssProvider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); + } +} + +export function buildPrefsWidget(prefsWindow, settings, uiDir) { + prefsWindow.set_search_enabled(true); + const styleManager = Adw.StyleManager.get_default(); + styleManager.connect('notify::dark', () => loadCssProvider(styleManager, uiDir)); + loadCssProvider(styleManager, uiDir); + const builder = new Gtk.Builder(); + builder.add_from_file(`${uiDir}/gestures.ui`); + builder.add_from_file(`${uiDir}/customizations.ui`); + + // bind to settings + bindPrefsSettings(builder, settings); + + // pinch gesture page + prefsWindow.add(builder.get_object('gestures_page')); + + // application specific gestures + const app_gesture_page = getAppKeybindingGesturePrefsPage(prefsWindow, settings); + prefsWindow.add(app_gesture_page); + + // customize page + prefsWindow.add(builder.get_object('customizations_page')); +} diff --git a/common/settings.js b/common/settings.js new file mode 100644 index 0000000..4dc3e02 --- /dev/null +++ b/common/settings.js @@ -0,0 +1,27 @@ +// define enum +/* exported PinchGestureType, OverviewNavigationState, ForwardBackKeyBinds */ +export var PinchGestureType; +(function (PinchGestureType) { + PinchGestureType[PinchGestureType['NONE'] = 0] = 'NONE'; + PinchGestureType[PinchGestureType['SHOW_DESKTOP'] = 1] = 'SHOW_DESKTOP'; + PinchGestureType[PinchGestureType['CLOSE_WINDOW'] = 2] = 'CLOSE_WINDOW'; + PinchGestureType[PinchGestureType['CLOSE_DOCUMENT'] = 3] = 'CLOSE_DOCUMENT'; +})(PinchGestureType || (PinchGestureType = {})); + +// define enum +export var OverviewNavigationState; +(function (OverviewNavigationState) { + OverviewNavigationState[OverviewNavigationState['CYCLIC'] = 0] = 'CYCLIC'; + OverviewNavigationState[OverviewNavigationState['GNOME'] = 1] = 'GNOME'; + OverviewNavigationState[OverviewNavigationState['WINDOW_PICKER_ONLY'] = 2] = 'WINDOW_PICKER_ONLY'; +})(OverviewNavigationState || (OverviewNavigationState = {})); + +export var ForwardBackKeyBinds; +(function (ForwardBackKeyBinds) { + ForwardBackKeyBinds[ForwardBackKeyBinds['Default'] = 0] = 'Default'; + ForwardBackKeyBinds[ForwardBackKeyBinds['Forward/Backward'] = 1] = 'Forward/Backward'; + ForwardBackKeyBinds[ForwardBackKeyBinds['Page Up/Down'] = 2] = 'Page Up/Down'; + ForwardBackKeyBinds[ForwardBackKeyBinds['Right/Left'] = 3] = 'Right/Left'; + ForwardBackKeyBinds[ForwardBackKeyBinds['Audio Next/Prev'] = 4] = 'Audio Next/Prev'; + ForwardBackKeyBinds[ForwardBackKeyBinds['Tab Next/Prev'] = 5] = 'Tab Next/Prev'; +})(ForwardBackKeyBinds || (ForwardBackKeyBinds = {})); diff --git a/common/utils/gobject.js b/common/utils/gobject.js new file mode 100644 index 0000000..5fa993b --- /dev/null +++ b/common/utils/gobject.js @@ -0,0 +1,18 @@ +/** + * @file This file provides {@link registerClass} function similar to {@link GObject.registerClass} + * Modification provided by {@link registerClass} + * - Add `connect(signal_name, ....)` function to prototype returned + * - Use parameters of constructor of class , instead of `_init` function of class for new method of prototype returned + * - Make `Properties` parameter mandatory @{link https://gitlab.gnome.org/ewlsh/gi.ts/-/issues/6} + */ +/* eslint-disable @typescript-eslint/ban-types */ +/* eslint-disable @typescript-eslint/no-explicit-any */ +/* exported registerClass */ +import GObject from 'gi://GObject'; +const OGRegisterClass = GObject.registerClass; + +export function registerClass(...args) { + if (args.length === 2) + return OGRegisterClass(args[0], args[1]); + return OGRegisterClass(args[0]); +} diff --git a/common/utils/logging.js b/common/utils/logging.js new file mode 100644 index 0000000..6a22b85 --- /dev/null +++ b/common/utils/logging.js @@ -0,0 +1,13 @@ +/* exported printStack */ +export function printStack(message) { + const stack = new Error().stack; + let prefix = ''; + if (stack) { + const lines = stack.split('\n')[1].split('@'); + log(`[DEBUG]:: in function ${lines[0]} at ${lines[2]}`); + prefix = '\t'; + } + + if (message !== undefined) + log(`${prefix}${JSON.stringify(message)}`); +} diff --git a/constants.js b/constants.js new file mode 100644 index 0000000..77766e0 --- /dev/null +++ b/constants.js @@ -0,0 +1,43 @@ +// FIXME: ideally these values matches physical touchpad size. We can get the +// correct values for gnome-shell specifically, since mutter uses libinput +// directly, but GTK apps cannot get it, so use an arbitrary value so that +// it's consistent with apps. +/* exported TouchpadConstants, AltTabConstants, OverviewControlsState, ExtSettings, RELOAD_DELAY, WIGET_SHOWING_DURATION */ +export var TouchpadConstants = { + DEFAULT_SWIPE_MULTIPLIER: 1, + SWIPE_MULTIPLIER: 1, + DEFAULT_PINCH_MULTIPLIER: 1, + PINCH_MULTIPLIER: 1, + DRAG_THRESHOLD_DISTANCE: 16, + TOUCHPAD_BASE_HEIGHT: 300, + TOUCHPAD_BASE_WIDTH: 400, + HOLD_SWIPE_DELAY_DURATION: 100, +}; + +export var AltTabConstants = { + DEFAULT_DELAY_DURATION: 100, + DELAY_DURATION: 100, + POPUP_SCROLL_TIME: 100, + DUMMY_WIN_COUNT: 1, + MIN_WIN_COUNT: 8, +}; + +export var OverviewControlsState = { + APP_GRID_P: -1, + HIDDEN: 0, + WINDOW_PICKER: 1, + APP_GRID: 2, + HIDDEN_N: 3, +}; + +export var 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 var RELOAD_DELAY = 150; // reload extension delay in ms +export var WIGET_SHOWING_DURATION = 100; // animation duration for showing widget diff --git a/extension.js b/extension.js new file mode 100644 index 0000000..19783d0 --- /dev/null +++ b/extension.js @@ -0,0 +1,135 @@ +/* exported init */ +import GLib from 'gi://GLib'; + +import { PinchGestureType } from './common/settings.js' +import * as Constants from './constants.js' +import { AltTabConstants, ExtSettings, TouchpadConstants } from './constants.js' +import { AltTabGestureExtension } from './src/altTab.js' +import { ForwardBackGestureExtension } from './src/forwardBack.js' +import { GestureExtension } from './src/gestures.js' +import { OverviewRoundTripGestureExtension } from './src/overviewRoundTrip.js' +import { CloseWindowExtension } from './src/pinchGestures/closeWindow.js' +import { ShowDesktopExtension } from './src/pinchGestures/showDesktop.js' +import { SnapWindowExtension } from './src/snapWindow.js' +import * as DBusUtils from './src/utils/dbus.js' +import * as VKeyboard from './src/utils/keyboard.js' +import { Extension } from 'resource:///org/gnome/shell/extensions/extension.js'; +export default class MyExtension extends Extension { + constructor(metadata) { + super(metadata); + this._settingChangedId = 0; + this._reloadWaitId = 0; + this._extensions = []; + this._addReloadDelayFor = [ + 'touchpad-speed-scale', + 'alttab-delay', + 'touchpad-pinch-speed', + ]; + } + + enable() { + this.settings = this.getSettings(); + this._settingChangedId = this.settings.connect('changed', this.reload.bind(this)); + this._enable(); + } + + disable() { + if (this.settings) { + this.settings.disconnect(this._settingChangedId); + } + + if (this._reloadWaitId !== 0) { + GLib.source_remove(this._reloadWaitId); + this._reloadWaitId = 0; + } + + this._disable(); + DBusUtils.drop_proxy(); + } + + reload(_settings, key) { + if (this._reloadWaitId !== 0) { + GLib.source_remove(this._reloadWaitId); + this._reloadWaitId = 0; + } + + this._reloadWaitId = GLib.timeout_add(GLib.PRIORITY_DEFAULT, (this._addReloadDelayFor.includes(key) ? Constants.RELOAD_DELAY : 0), () => { + this._disable(); + this._enable(); + this._reloadWaitId = 0; + return GLib.SOURCE_REMOVE; + }); + } + + _enable() { + this._initializeSettings(); + this._extensions = []; + if (this.settings === undefined) + return; + if (this.settings.get_boolean('enable-alttab-gesture')) + 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()); + + // pinch to show desktop + const pinchToFingersMap = this._getPinchGestureTypeAndFingers(); + const showDesktopFingers = pinchToFingersMap.get(PinchGestureType.SHOW_DESKTOP); + if (showDesktopFingers === null || showDesktopFingers === void 0 ? void 0 : showDesktopFingers.length) + this._extensions.push(new ShowDesktopExtension(showDesktopFingers)); + + // pinch to close window + const closeWindowFingers = pinchToFingersMap.get(PinchGestureType.CLOSE_WINDOW); + if (closeWindowFingers === null || closeWindowFingers === void 0 ? void 0 : closeWindowFingers.length) + this._extensions.push(new CloseWindowExtension(closeWindowFingers, PinchGestureType.CLOSE_WINDOW)); + + // pinch to close document + const closeDocumentFingers = pinchToFingersMap.get(PinchGestureType.CLOSE_DOCUMENT); + if (closeDocumentFingers === null || closeDocumentFingers === void 0 ? void 0 : closeDocumentFingers.length) + this._extensions.push(new CloseWindowExtension(closeDocumentFingers, PinchGestureType.CLOSE_DOCUMENT)); + this._extensions.forEach(extension => { var _a; return (_a = extension.apply) === null || _a === void 0 ? void 0 : _a.call(extension); }); + } + + _disable() { + VKeyboard.extensionCleanup(); + DBusUtils.unsubscribeAll(); + this._extensions.reverse().forEach(extension => extension.destroy()); + this._extensions = []; + } + + _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'); + 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'); + TouchpadConstants.HOLD_SWIPE_DELAY_DURATION = this.settings.get_int('hold-swipe-delay-duration'); + } + } + + _getPinchGestureTypeAndFingers() { + if (!this.settings) + return new Map(); + const pinch3FingerGesture = this.settings.get_enum('pinch-3-finger-gesture'); + const pinch4FingerGesture = this.settings.get_enum('pinch-4-finger-gesture'); + const gestureToFingersMap = new Map(); + if (pinch3FingerGesture === pinch4FingerGesture) + gestureToFingersMap.set(pinch3FingerGesture, [3, 4]); + else { + gestureToFingersMap.set(pinch3FingerGesture, [3]); + gestureToFingersMap.set(pinch4FingerGesture, [4]); + } + + return gestureToFingersMap; + } +} diff --git a/metadata.json b/metadata.json new file mode 100644 index 0000000..4727ec3 --- /dev/null +++ b/metadata.json @@ -0,0 +1,12 @@ +{ + "_generated": "Generated by SweetTooth, do not edit", + "description": "Improve touchpad gestures for Wayland/X11\n\nThis extension adds following features:\n\n\u2022 Switch windows from current workspace using 3-finger horizontal swipe\n\u2022 Cyclic gestures between Desktop/Overview/AppGrid using 4 vertical swipe\n\u2022 Switch app-pages using 3-finger swipe gesture on AppGrid\n\u2022 Unmaximize/maximize/fullscreen/half-tiling using 3-finger vertical & horizontal gesture\n\u2022 Optional minimize a window gesture\n\u2022 Override 3-finger gesture with 4-finger for switching workspace\n\u2022 Pinch to show desktop\n\u2022 Application specific keyboard shortcut based hold-swipe gestures (e.g., navigating browser tabs)\n\u2022 Configure speed of gestures\n\u2022 Support for X11\n \nOn X11, you need to install https://github.com/harshadgavali/gnome-x11-gesture-daemon\n\nReport any bugs/requests on GitHub (link directly below)\n", + "name": "Gesture Improvements", + "settings-schema": "org.gnome.shell.extensions.gestureImprovements", + "shell-version": [ + "46" + ], + "url": "https://github.com/harshadgavali/gnome-gesture-improvements", + "uuid": "gestureImprovements@gestures", + "version": 27 +} diff --git a/prefs.js b/prefs.js new file mode 100644 index 0000000..dd6354c --- /dev/null +++ b/prefs.js @@ -0,0 +1,13 @@ +/* exported init, fillPreferencesWindow */ + +import { buildPrefsWidget } from './common/prefs.js' +import { ExtensionPreferences } from 'resource:///org/gnome/Shell/Extensions/js/extensions/prefs.js'; + +export default class MyExtensionPreferences extends ExtensionPreferences { + fillPreferencesWindow(prefsWindow) { + var _a; + const UIDirPath = (_a = this.dir.get_child('ui').get_path()) !== null && _a !== void 0 ? _a : ''; + const settings = this.getSettings(); + buildPrefsWidget(prefsWindow, settings, UIDirPath); + } +} diff --git a/schemas/gschemas.compiled b/schemas/gschemas.compiled new file mode 100644 index 0000000000000000000000000000000000000000..c95fc0ea2bad641741beb3e5bd1621f6911fd67f GIT binary patch literal 2133 zcmb_dO^6&t6t0Pm8{I^sn3y$DGANE!IKE_AS4&{;>|eZ{&XLuxe5VLd~g?u*AOZzesvUr%WDMm8aFgDMF|90mcV@A5oPO%-x9WVt*74__1 zpnPHLzVJL-jAIdKsRC{HgpP-isQY20wuLW(SmOi6N_QBMd`~{eIiUzF0Q-TPfm>26 zLLLNe0}lNI{R{j!aTL!9w#`0+JP%y2{rLj%q#px+8S)3A-|*H3RQ5KlVsyO19MUzI=ln0V4@-HVXl0FPezazH%kOW=Qo`~?`l z|JX_5Nk0sp-H81HlgZ?3;z_?7{C$uC(ERiPpLo&_fqxD14dCLrR~PAwNH2olg}em3 z_u`3%$)5BB;4ed70e=6a^C0o0p9H@jNnS>hk6tLQ5>GnCvj({VJoMqxcf^xU@rRIO zVDa%w#-4P_+b-m9KvpxPGuB{#KrZ6|pZM{M?~Q-x#y{i+;EFCEda;Fyh_mdmjkI{lElmJWr$ufx4;F?Q`qR&sNTBwk}jPFOmhZgV69SB)&62QnObobr%w z$>bwToEDm{mo-w+K!@Bh>meUq<$3TBaNIfWA(RM2vXc3JmhgaY%WkrQj(IFJtDdbk z>eabCWd!zWa<$rQovE=TM@e?J*6P*MwWqgQ&Bj?;WV$fRNfv0fAWb7aJLGYnbjB)Z z8WqztDyC^v@}^PwkET&!Omi=edB<{v$0zJva#E7m@?353F!ZF8>}wz<9Ys~6`znf^ zVcK}QD6y^@+pf@qScRtFkSnTF>SInnQobDeb~RHnOS)^xxEI2gNUm1h*b;6}%-qdv z?t)EEsUFJLxSTVY*&KmQ-aC8k{?PB_o|1k@D=zJ^6RJ07MD7*tzrDn(d4Fw4+>MNxTBCh~@*y za=16%wupQg@VSUGyJQ_756L(bQLOE@^kjZ~vo*;s&t)6cRC8slqCE2a{O(y|H742H z>^!^53WfU%^@1q8RrtJcwNTv0O8jMAlAZFoGB>vgfk|J!B&_6qn%&b6>bb8x)YnLc zBB@Ht#l1`VmupO9+M*u$SBpy8(A<6dpZZd9b_bL9lHN^vM`_#y(D~ARruuXm3knZG1W`jm(qKe-b(N^Oh5S>l7smR literal 0 HcmV?d00001 diff --git a/schemas/org.gnome.shell.extensions.gestureImprovements.gschema.xml b/schemas/org.gnome.shell.extensions.gestureImprovements.gschema.xml new file mode 100644 index 0000000..0032c2b --- /dev/null +++ b/schemas/org.gnome.shell.extensions.gestureImprovements.gschema.xml @@ -0,0 +1,104 @@ + + + + + + + + + + + + + + + + + + 1.0 + + + 1.0 + + + 150 + + + 100 + + + false + If true, use 3-fingers to switch workspace, 4 for windows + + + false + If true, use 3-fingers for overview gesture, 4 for snapping/tiling + + + false + If true, when swipe down on non-maximized window minimizes it + + + true + Whether to follow natural scroll for swipe + + + true + Default direction for overview navigation + + + true + 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 + + + 'CYCLIC' + Gesture for 4 finger pinch + + + + + { + 'firefox.desktop': (5, false), + 'org.chromium.Chromium.desktop': (5, false), + 'microsoft-edge.desktop': (5, false), + 'google-chrome.desktop': (5, false), + 'org.gnome.gThumb.desktop': (2, false), + 'org.gnome.eog.desktop': (3, false), + 'org.gnome.Photos.desktop': (3, false), + 'shotwell.desktop': (3, false), + 'com.spotify.Client.desktop': (4, false), + 'code.desktop': (5, false), + 'code-insiders.desktop': (5, false), + 'org.gnome.Terminal.desktop': (5, false), + 'com.gexperts.Tilix.desktop': (5, false), + 'org.gnome.TextEditor.desktop': (5, false) + } + + Application keyboard shortcuts for forward-back gesture + + + \ No newline at end of file diff --git a/src/altTab.js b/src/altTab.js new file mode 100644 index 0000000..d59aafe --- /dev/null +++ b/src/altTab.js @@ -0,0 +1,185 @@ +/* exported AltTabGestureExtension */ +import Clutter from 'gi://Clutter'; +import GLib from 'gi://GLib'; +import Shell from 'gi://Shell'; +import St from 'gi://St'; + +import { AltTabConstants, ExtSettings } from '../constants.js' +import { TouchpadSwipeGesture } from './swipeTracker.js' +import * as Main from 'resource:///org/gnome/shell/ui/main.js'; +import { WindowSwitcherPopup } from 'resource:///org/gnome/shell/ui/altTab.js'; +let dummyWinCount = AltTabConstants.DUMMY_WIN_COUNT; + +function getIndexForProgress(progress, nelement) { + let index = Math.floor(progress * (nelement + 2 * dummyWinCount)); + index = index - dummyWinCount; + return Math.clamp(index, 0, nelement - 1); +} + +// index -> index + AltTabConstants.DUMMY_WIN_COUNT +function getAvgProgressForIndex(index, nelement) { + index = index + dummyWinCount; + const progress = (index + 0.5) / (nelement + 2 * dummyWinCount); + return progress; +} + +// declare enum +export var AltTabExtState; +(function (AltTabExtState) { + AltTabExtState[AltTabExtState['DISABLED'] = 0] = 'DISABLED'; + AltTabExtState[AltTabExtState['DEFAULT'] = 1] = 'DEFAULT'; + AltTabExtState[AltTabExtState['ALTTABDELAY'] = 2] = 'ALTTABDELAY'; + AltTabExtState[AltTabExtState['ALTTAB'] = 3] = 'ALTTAB'; +})(AltTabExtState || (AltTabExtState = {})); + +export var AltTabGestureExtension = class AltTabGestureExtension { + constructor() { + this._extState = AltTabExtState.DISABLED; + this._progress = 0; + this._altTabTimeoutId = 0; + this._connectHandlers = []; + this._touchpadSwipeTracker = new TouchpadSwipeGesture((ExtSettings.DEFAULT_SESSION_WORKSPACE_GESTURE ? [4] : [3]), Shell.ActionMode.ALL, Clutter.Orientation.HORIZONTAL, false, this._checkAllowedGesture.bind(this)); + this._adjustment = new St.Adjustment({ + value: 0, + lower: 0, + upper: 1, + }); + } + + _checkAllowedGesture() { + return (this._extState <= AltTabExtState.DEFAULT && + Main.actionMode === Shell.ActionMode.NORMAL && + !(ExtSettings.APP_GESTURES && this._touchpadSwipeTracker.isItHoldAndSwipeGesture())); + } + + apply() { + this._adjustment.connect('notify::value', this._onUpdateAdjustmentValue.bind(this)); + this._connectHandlers.push(this._touchpadSwipeTracker.connect('begin', this._gestureBegin.bind(this))); + this._connectHandlers.push(this._touchpadSwipeTracker.connect('update', this._gestureUpdate.bind(this))); + this._connectHandlers.push(this._touchpadSwipeTracker.connect('end', this._gestureEnd.bind(this))); + this._extState = AltTabExtState.DEFAULT; + } + + destroy() { + this._extState = AltTabExtState.DISABLED; + this._connectHandlers.forEach(handle => this._touchpadSwipeTracker.disconnect(handle)); + this._touchpadSwipeTracker.destroy(); + this._connectHandlers = []; + this._adjustment.run_dispose(); + if (this._switcher) { + this._switcher.destroy(); + this._switcher = undefined; + } + } + + _onUpdateAdjustmentValue() { + if (this._extState === AltTabExtState.ALTTAB && this._switcher) { + const nelement = this._switcher._items.length; + if (nelement > 1) { + const n = getIndexForProgress(this._adjustment.value, nelement); + this._switcher._select(n); + const adjustment = this._switcher._switcherList._scrollView.hscroll.adjustment; + const transition = adjustment.get_transition('value'); + if (transition) { + transition.advance(AltTabConstants.POPUP_SCROLL_TIME); + } + } + } + } + + _gestureBegin() { + this._progress = 0; + if (this._extState === AltTabExtState.DEFAULT) { + this._switcher = new WindowSwitcherPopup(); + this._switcher._switcherList.add_style_class_name('gie-alttab-quick-transition'); + this._switcher.connect('destroy', () => { + this._switcher = undefined; + this._reset(); + }); + + // remove timeout entirely + this._switcher._resetNoModsTimeout = function () { + if (this._noModsTimeoutId) { + GLib.source_remove(this._noModsTimeoutId); + this._noModsTimeoutId = 0; + } + }; + + const nelement = this._switcher._items.length; + if (nelement > 0) { + this._switcher.show(false, 'switch-windows', 0); + this._switcher._popModal(); + if (this._switcher._initialDelayTimeoutId !== 0) { + GLib.source_remove(this._switcher._initialDelayTimeoutId); + this._switcher._initialDelayTimeoutId = 0; + } + + const leftOver = AltTabConstants.MIN_WIN_COUNT - nelement; + if (leftOver > 0) { + dummyWinCount = Math.max(AltTabConstants.DUMMY_WIN_COUNT, Math.ceil(leftOver / 2)); + } + else { + dummyWinCount = AltTabConstants.DUMMY_WIN_COUNT; + } + + if (nelement === 1) { + this._switcher._select(0); + this._progress = 0; + } + else { + this._progress = getAvgProgressForIndex(1, nelement); + this._switcher._select(1); + } + + this._adjustment.value = 0; + this._extState = AltTabExtState.ALTTABDELAY; + this._altTabTimeoutId = GLib.timeout_add(GLib.PRIORITY_DEFAULT, AltTabConstants.DELAY_DURATION, () => { + Main.osdWindowManager.hideAll(); + if (this._switcher) + this._switcher.opacity = 255; + this._adjustment.value = this._progress; + this._extState = AltTabExtState.ALTTAB; + this._altTabTimeoutId = 0; + return GLib.SOURCE_REMOVE; + }); + } + else { + this._switcher.destroy(); + this._switcher = undefined; + } + } + } + + _gestureUpdate(_gesture, _time, delta, distance) { + if (this._extState > AltTabExtState.ALTTABDELAY) { + this._progress = Math.clamp(this._progress + delta / distance, 0, 1); + this._adjustment.value = this._progress; + } + } + + _gestureEnd() { + if (this._switcher) { + const win = this._switcher._items[this._switcher._selectedIndex].window; + Main.activateWindow(win); + this._switcher.destroy(); + this._switcher = undefined; + } + + this._reset(); + } + + _reset() { + if (this._extState > AltTabExtState.DEFAULT) { + this._extState = AltTabExtState.DEFAULT; + if (this._altTabTimeoutId) { + GLib.source_remove(this._altTabTimeoutId); + this._altTabTimeoutId = 0; + } + + this._progress = 0; + this._adjustment.value = 0; + } + + this._extState = AltTabExtState.DEFAULT; + } +}; diff --git a/src/animations/arrow.js b/src/animations/arrow.js new file mode 100644 index 0000000..a6fcb6a --- /dev/null +++ b/src/animations/arrow.js @@ -0,0 +1,101 @@ +// import GObject from '@gi-types/gobject2'; +/* exported ArrowIconAnimation */ +import Gio from 'gi://Gio'; +import Clutter from 'gi://Clutter'; +import St from 'gi://St'; + +import { registerClass } from '../../common/utils/gobject.js' +import { easeActor } from '../utils/environment.js' +import { WIGET_SHOWING_DURATION } from '../../constants.js' +// const ExtMe = imports.misc.extensionUtils.getCurrentExtension(); +import * as Util from 'resource:///org/gnome/shell/misc/util.js'; +const Circle = registerClass(class GIE_Circle extends St.Widget { + _init(style_class) { + style_class = `gie-circle ${style_class}`; + super._init({ style_class }); + this.set_pivot_point(0.5, 0.5); + } +}); + +export var ArrowIconAnimation = registerClass(class GIE_ArrowIcon extends St.Widget { + _init() { + super._init(); + this._inner_circle = new Circle('gie-inner-circle'); + this._outer_circle = new Circle('gie-outer-circle'); + this._arrow_icon = new St.Icon({ style_class: 'gie-arrow-icon' }); + this._inner_circle.set_clip_to_allocation(true); + this._inner_circle.add_child(this._arrow_icon); + this.add_child(this._outer_circle); + this.add_child(this._inner_circle); + } + + gestureBegin(icon_name, from_left) { + this._transition = { + arrow: { + from: this._inner_circle.width * (from_left ? -1 : 1), + end: 0, + }, + outer_circle: { + from: 1, + end: 2, + }, + }; + + this._arrow_icon.translation_x = this._transition.arrow.from; + this._outer_circle.scale_x = this._transition.outer_circle.from; + this._outer_circle.scale_y = this._outer_circle.scale_x; + this._arrow_icon.opacity = 255; + + // animating showing widget + this.opacity = 0; + this.show(); + easeActor(this, { + opacity: 255, + mode: Clutter.AnimationMode.EASE_OUT_QUAD, + duration: WIGET_SHOWING_DURATION, + }); + + // this._arrow_icon.set_gicon(Gio.Icon.new_for_string(`${ExtMe.dir.get_uri()}/assets/${icon_name}`)); + } + + gestureUpdate(progress) { + if (this._transition === undefined) + return; + this._arrow_icon.translation_x = Util.lerp(this._transition.arrow.from, this._transition.arrow.end, progress); + this._outer_circle.scale_x = Util.lerp(this._transition.outer_circle.from, this._transition.outer_circle.end, progress); + this._outer_circle.scale_y = this._outer_circle.scale_x; + } + + gestureEnd(duration, progress, callback) { + if (this._transition === undefined) + return; + easeActor(this, { + opacity: 0, + mode: Clutter.AnimationMode.EASE_OUT_QUAD, + duration, + }); + + const translation_x = Util.lerp(this._transition.arrow.from, this._transition.arrow.end, progress); + easeActor(this._arrow_icon, { + translation_x, + duration, + mode: Clutter.AnimationMode.EASE_OUT_EXPO, + onStopped: () => { + callback(); + this.hide(); + this._arrow_icon.opacity = 0; + this._arrow_icon.translation_x = 0; + this._outer_circle.scale_x = 1; + this._outer_circle.scale_y = 1; + }, + }); + + const scale = Util.lerp(this._transition.outer_circle.from, this._transition.outer_circle.end, progress); + easeActor(this._outer_circle, { + scale_x: scale, + scale_y: scale, + duration, + mode: Clutter.AnimationMode.EASE_OUT_EXPO, + }); + } +}); diff --git a/src/forwardBack.js b/src/forwardBack.js new file mode 100644 index 0000000..3ead6fd --- /dev/null +++ b/src/forwardBack.js @@ -0,0 +1,161 @@ +/* exported ForwardBackGestureExtension */ +import Clutter from 'gi://Clutter'; +import Shell from 'gi://Shell'; + +import { ExtSettings } from '../constants.js' +import { ArrowIconAnimation } from './animations/arrow.js' +import { createSwipeTracker } from './swipeTracker.js' +import { getVirtualKeyboard } from './utils/keyboard.js' +import { ForwardBackKeyBinds } from '../common/settings.js' +import * as Main from 'resource:///org/gnome/shell/ui/main.js'; + +// declare enum +export var AnimationState; +(function (AnimationState) { + AnimationState[AnimationState['WAITING'] = 0] = 'WAITING'; + AnimationState[AnimationState['DEFAULT'] = 0] = 'DEFAULT'; + AnimationState[AnimationState['LEFT'] = -1] = 'LEFT'; + AnimationState[AnimationState['RIGHT'] = 1] = 'RIGHT'; +})(AnimationState || (AnimationState = {})); + +// declare enum +export var SwipeGestureDirection; +(function (SwipeGestureDirection) { + SwipeGestureDirection[SwipeGestureDirection['LeftToRight'] = 1] = 'LeftToRight'; + SwipeGestureDirection[SwipeGestureDirection['RightToLeft'] = 2] = 'RightToLeft'; +})(SwipeGestureDirection || (SwipeGestureDirection = {})); + +const SnapPointThreshold = 0.1; + +export var ForwardBackGestureExtension = class ForwardBackGestureExtension { + constructor(appForwardBackKeyBinds) { + this._animationState = AnimationState.WAITING; + this._appForwardBackKeyBinds = appForwardBackKeyBinds; + this._windowTracker = Shell.WindowTracker.get_default(); + this._keyboard = getVirtualKeyboard(); + this._swipeTracker = createSwipeTracker(global.stage, ExtSettings.DEFAULT_SESSION_WORKSPACE_GESTURE ? [4] : [3], Shell.ActionMode.NORMAL, Clutter.Orientation.HORIZONTAL, false, 1, { allowTouch: false }); + this._connectHandlers = [ + this._swipeTracker.connect('begin', this._gestureBegin.bind(this)), + this._swipeTracker.connect('update', this._gestureUpdate.bind(this)), + this._swipeTracker.connect('end', this._gestureEnd.bind(this)), + ]; + + this._arrowIconAnimation = new ArrowIconAnimation(); + this._arrowIconAnimation.hide(); + Main.layoutManager.uiGroup.add_child(this._arrowIconAnimation); + } + + destroy() { + this._connectHandlers.forEach(handle => this._swipeTracker.disconnect(handle)); + this._connectHandlers = []; + this._swipeTracker.destroy(); + this._arrowIconAnimation.destroy(); + } + + _gestureBegin(tracker) { + this._focusWindow = global.display.get_focus_window(); + if (!this._focusWindow) + return; + this._animationState = AnimationState.WAITING; + tracker.confirmSwipe(global.screen_width, [AnimationState.LEFT, AnimationState.DEFAULT, AnimationState.RIGHT], AnimationState.DEFAULT, AnimationState.DEFAULT); + } + + _gestureUpdate(_tracker, progress) { + switch (this._animationState) { + case AnimationState.WAITING: + if (Math.abs(progress - AnimationState.DEFAULT) < SnapPointThreshold) + return; + this._showArrow(progress); + break; + case AnimationState.RIGHT: + progress = (progress - SnapPointThreshold) / (AnimationState.RIGHT - SnapPointThreshold); + this._arrowIconAnimation.gestureUpdate(Math.clamp(progress, 0, 1)); + break; + case AnimationState.LEFT: + progress = (progress + SnapPointThreshold) / (AnimationState.LEFT + SnapPointThreshold); + this._arrowIconAnimation.gestureUpdate(Math.clamp(progress, 0, 1)); + } + } + + _gestureEnd(_tracker, duration, progress) { + if (this._animationState === AnimationState.WAITING) { + if (progress === AnimationState.DEFAULT) + return; + this._showArrow(progress); + } + + switch (this._animationState) { + case AnimationState.RIGHT: + progress = (progress - SnapPointThreshold) / (AnimationState.RIGHT - SnapPointThreshold); + progress = Math.clamp(progress, 0, 1); + this._arrowIconAnimation.gestureEnd(duration, progress, () => { + if (progress !== 0) { + // bring left page to right + const keys = this._getClutterKeyForFocusedApp(SwipeGestureDirection.LeftToRight); + this._keyboard.sendKeys(keys); + } + }); + + break; + case AnimationState.LEFT: + progress = (progress + SnapPointThreshold) / (AnimationState.LEFT + SnapPointThreshold); + progress = Math.clamp(progress, 0, 1); + this._arrowIconAnimation.gestureEnd(duration, progress, () => { + if (progress !== 0) { + // bring right page to left + const keys = this._getClutterKeyForFocusedApp(SwipeGestureDirection.RightToLeft); + this._keyboard.sendKeys(keys); + } + }); + } + } + + _showArrow(progress) { + const [height, width] = [this._arrowIconAnimation.height, this._arrowIconAnimation.width]; + const workArea = this._getWorkArea(); + if (progress > AnimationState.DEFAULT) { + this._animationState = AnimationState.RIGHT; + this._arrowIconAnimation.gestureBegin('arrow1-left-symbolic.svg', true); + this._arrowIconAnimation.set_position(workArea.x + width, workArea.y + Math.round((workArea.height - height) / 2)); + } + else { + this._animationState = AnimationState.LEFT; + this._arrowIconAnimation.gestureBegin('arrow1-right-symbolic.svg', false); + this._arrowIconAnimation.set_position(workArea.x + workArea.width - 2 * width, workArea.y + Math.round((workArea.height - height) / 2)); + } + } + + _getWorkArea() { + const window = this._focusWindow; + if (window) + return window.get_frame_rect(); + return Main.layoutManager.getWorkAreaForMonitor(Main.layoutManager.currentMonitor.index); + } + + /** + * @param gestureDirection direction of swipe gesture left to right or right to left + */ + _getClutterKeyForFocusedApp(gestureDirection) { + const focusApp = this._windowTracker.focus_app; + const keyBind = focusApp ? this._appForwardBackKeyBinds[focusApp.get_id()] : null; + if (keyBind) { + // if keyBind[1] is true => reverse order or keys + const returnBackKey = (gestureDirection === SwipeGestureDirection.LeftToRight) !== keyBind[1]; + switch (keyBind[0]) { + case ForwardBackKeyBinds['Forward/Backward']: + return [returnBackKey ? Clutter.KEY_Back : Clutter.KEY_Forward]; + case ForwardBackKeyBinds['Page Up/Down']: + return [returnBackKey ? Clutter.KEY_Page_Up : Clutter.KEY_Page_Down]; + case ForwardBackKeyBinds['Right/Left']: + return [returnBackKey ? Clutter.KEY_Left : Clutter.KEY_Right]; + case ForwardBackKeyBinds['Audio Next/Prev']: + return [returnBackKey ? Clutter.KEY_AudioPrev : Clutter.KEY_AudioNext]; + case ForwardBackKeyBinds['Tab Next/Prev']: + return [Clutter.KEY_Control_L, returnBackKey ? Clutter.KEY_Page_Up : Clutter.KEY_Page_Down]; + } + } + + // default key bind + return [gestureDirection === SwipeGestureDirection.LeftToRight ? Clutter.KEY_Back : Clutter.KEY_Forward]; + } +}; diff --git a/src/gestures.js b/src/gestures.js new file mode 100644 index 0000000..dfddaf7 --- /dev/null +++ b/src/gestures.js @@ -0,0 +1,183 @@ +/* exported GestureExtension */ +import Clutter from 'gi://Clutter'; +import GObject from 'gi://GObject'; +import Shell from 'gi://Shell'; + +import { ExtSettings, OverviewControlsState } from '../constants.js' +import { createSwipeTracker, TouchpadSwipeGesture } from './swipeTracker.js' +import * as Main from 'resource:///org/gnome/shell/ui/main.js'; + +function connectTouchpadEventToTracker(tracker) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + global.stage.connectObject('captured-event::touchpad', tracker._handleEvent.bind(tracker), tracker); +} + +function disconnectTouchpadEventFromTracker(tracker) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + global.stage.disconnectObject(tracker); +} + +class SwipeTrackerEndPointsModifer { + constructor() { + this._firstVal = 0; + this._lastVal = 0; + } + + apply() { + this._swipeTracker.connect('begin', this._gestureBegin.bind(this)); + this._swipeTracker.connect('update', this._gestureUpdate.bind(this)); + this._swipeTracker.connect('end', this._gestureEnd.bind(this)); + } + + _modifySnapPoints(tracker, callback) { + const _tracker = { + orientation: Clutter.Orientation.HORIZONTAL, + confirmSwipe: (distance, snapPoints, currentProgress, cancelProgress) => { + this._firstVal = snapPoints[0]; + this._lastVal = snapPoints[snapPoints.length - 1]; + snapPoints.unshift(this._firstVal - 1); + snapPoints.push(this._lastVal + 1); + tracker.orientation = _tracker.orientation; + tracker.confirmSwipe(distance, snapPoints, currentProgress, cancelProgress); + }, + }; + + callback(_tracker); + } + + destroy() { + this._swipeTracker.enabled = false; + } +} +class WorkspaceAnimationModifier extends SwipeTrackerEndPointsModifer { + constructor(wm) { + super(); + this._workspaceAnimation = wm._workspaceAnimation; + this._swipeTracker = createSwipeTracker(global.stage, (ExtSettings.DEFAULT_SESSION_WORKSPACE_GESTURE ? [3] : [4]), Shell.ActionMode.NORMAL, Clutter.Orientation.HORIZONTAL, ExtSettings.FOLLOW_NATURAL_SCROLL, 1, { allowTouch: false }); + } + + apply() { + if (this._workspaceAnimation._swipeTracker._touchpadGesture) { + disconnectTouchpadEventFromTracker(this._workspaceAnimation._swipeTracker._touchpadGesture); + } + + super.apply(); + } + + _gestureBegin(tracker, monitor) { + super._modifySnapPoints(tracker, (shallowTracker) => { + this._workspaceAnimation._switchWorkspaceBegin(shallowTracker, monitor); + tracker.orientation = shallowTracker.orientation; + }); + } + + _gestureUpdate(tracker, progress) { + if (progress < this._firstVal) { + progress = this._firstVal - (this._firstVal - progress) * 0.05; + } + else if (progress > this._lastVal) { + progress = this._lastVal + (progress - this._lastVal) * 0.05; + } + + this._workspaceAnimation._switchWorkspaceUpdate(tracker, progress); + } + + _gestureEnd(tracker, duration, progress) { + progress = Math.clamp(progress, this._firstVal, this._lastVal); + this._workspaceAnimation._switchWorkspaceEnd(tracker, duration, progress); + } + + destroy() { + this._swipeTracker.destroy(); + const swipeTracker = this._workspaceAnimation._swipeTracker; + if (swipeTracker._touchpadGesture) { + connectTouchpadEventToTracker(swipeTracker._touchpadGesture); + } + + super.destroy(); + } +} + +export var GestureExtension = class GestureExtension { + constructor() { + this._stateAdjustment = Main.overview._overview._controls._stateAdjustment; + this._swipeTrackers = [ + { + swipeTracker: Main.overview._overview._controls._workspacesDisplay._swipeTracker, + nfingers: [3, 4], + disableOldGesture: true, + followNaturalScroll: ExtSettings.FOLLOW_NATURAL_SCROLL, + modes: Shell.ActionMode.OVERVIEW, + gestureSpeed: 1, + checkAllowedGesture: (event) => { + if (Main.overview._overview._controls._searchController.searchActive) { + return false; + } + + if (event.get_touchpad_gesture_finger_count() === 4) { + return true; + } + else { + return this._stateAdjustment.value === OverviewControlsState.WINDOW_PICKER; + } + }, + }, + { + swipeTracker: Main.overview._overview._controls._appDisplay._swipeTracker, + nfingers: [3], + disableOldGesture: true, + followNaturalScroll: ExtSettings.FOLLOW_NATURAL_SCROLL, + modes: Shell.ActionMode.OVERVIEW, + checkAllowedGesture: () => { + if (Main.overview._overview._controls._searchController.searchActive) { + return false; + } + + return this._stateAdjustment.value === OverviewControlsState.APP_GRID; + }, + }, + ]; + + this._workspaceAnimationModifier = new WorkspaceAnimationModifier(Main.wm); + } + + apply() { + this._workspaceAnimationModifier.apply(); + this._swipeTrackers.forEach(entry => { + var _a; + const { swipeTracker, nfingers, disableOldGesture, followNaturalScroll, modes, checkAllowedGesture, } = entry; + const gestureSpeed = (_a = entry.gestureSpeed) !== null && _a !== void 0 ? _a : 1; + const touchpadGesture = new TouchpadSwipeGesture(nfingers, modes, swipeTracker.orientation, followNaturalScroll, checkAllowedGesture, gestureSpeed); + this._attachGestureToTracker(swipeTracker, touchpadGesture, disableOldGesture); + }); + } + + destroy() { + this._swipeTrackers.reverse().forEach(entry => { + var _a; + const { swipeTracker, disableOldGesture } = entry; + (_a = swipeTracker._touchpadGesture) === null || _a === void 0 ? void 0 : _a.destroy(); + swipeTracker._touchpadGesture = swipeTracker.__oldTouchpadGesture; + swipeTracker.__oldTouchpadGesture = undefined; + if (swipeTracker._touchpadGesture && disableOldGesture) { + connectTouchpadEventToTracker(swipeTracker._touchpadGesture); + } + }); + + this._workspaceAnimationModifier.destroy(); + } + + _attachGestureToTracker(swipeTracker, touchpadSwipeGesture, disablePrevious) { + if (swipeTracker._touchpadGesture && disablePrevious) { + disconnectTouchpadEventFromTracker(swipeTracker._touchpadGesture); + swipeTracker.__oldTouchpadGesture = swipeTracker._touchpadGesture; + } + + swipeTracker._touchpadGesture = touchpadSwipeGesture; + swipeTracker._touchpadGesture.connect('begin', swipeTracker._beginGesture.bind(swipeTracker)); + swipeTracker._touchpadGesture.connect('update', swipeTracker._updateGesture.bind(swipeTracker)); + swipeTracker._touchpadGesture.connect('end', swipeTracker._endTouchpadGesture.bind(swipeTracker)); + swipeTracker.bind_property('enabled', swipeTracker._touchpadGesture, 'enabled', 0); + swipeTracker.bind_property('orientation', swipeTracker._touchpadGesture, 'orientation', GObject.BindingFlags.SYNC_CREATE); + } +}; diff --git a/src/overviewRoundTrip.js b/src/overviewRoundTrip.js new file mode 100644 index 0000000..bf73c59 --- /dev/null +++ b/src/overviewRoundTrip.js @@ -0,0 +1,167 @@ +/* exported OverviewRoundTripGestureExtension */ +import Clutter from 'gi://Clutter'; +import Shell from 'gi://Shell'; + +import { OverviewNavigationState } from '../common/settings.js' +import { ExtSettings, OverviewControlsState } from '../constants.js' +import { createSwipeTracker } from './swipeTracker.js' +import * as Main from 'resource:///org/gnome/shell/ui/main.js'; + +// declare enum +export var ExtensionState; +(function (ExtensionState) { + // DISABLED = 0, + ExtensionState[ExtensionState['DEFAULT'] = 1] = 'DEFAULT'; + ExtensionState[ExtensionState['CUSTOM'] = 2] = 'CUSTOM'; +})(ExtensionState || (ExtensionState = {})); + +export var OverviewRoundTripGestureExtension = class OverviewRoundTripGestureExtension { + constructor(navigationStates) { + this._progress = 0; + this._extensionState = ExtensionState.DEFAULT; + this._shownEventId = 0; + this._hiddenEventId = 0; + this._navigationStates = navigationStates; + this._overviewControls = Main.overview._overview._controls; + this._stateAdjustment = this._overviewControls._stateAdjustment; + this._oldGetStateTransitionParams = this._overviewControls._stateAdjustment.getStateTransitionParams; + this._progress = 0; + this._connectors = []; + } + + _getStateTransitionParams() { + if (this._extensionState <= ExtensionState.DEFAULT) { + return this._oldGetStateTransitionParams.call(this._stateAdjustment); + } + else if (this._extensionState === ExtensionState.CUSTOM) { + const currentState = this._stateAdjustment.value; + const initialState = OverviewControlsState.HIDDEN; + const finalState = OverviewControlsState.APP_GRID; + const length = Math.abs(finalState - initialState); + const progress = Math.abs((currentState - initialState) / length); + return { + transitioning: true, + currentState, + initialState, + finalState, + progress, + }; + } + } + + apply() { + Main.overview._swipeTracker.enabled = false; + this._swipeTracker = createSwipeTracker(global.stage, (ExtSettings.DEFAULT_OVERVIEW_GESTURE ? [3] : [4]), Shell.ActionMode.NORMAL | Shell.ActionMode.OVERVIEW, Clutter.Orientation.VERTICAL, ExtSettings.DEFAULT_OVERVIEW_GESTURE_DIRECTION); + this._swipeTracker.orientation = Clutter.Orientation.VERTICAL; + this._connectors.push(this._swipeTracker.connect('begin', this._gestureBegin.bind(this))); + this._connectors.push(this._swipeTracker.connect('update', this._gestureUpdate.bind(this))); + this._connectors.push(this._swipeTracker.connect('end', this._gestureEnd.bind(this))); + + // override 'getStateTransitionParams' function + this._stateAdjustment.getStateTransitionParams = this._getStateTransitionParams.bind(this); + this._extensionState = ExtensionState.DEFAULT; + this._progress = 0; + + // reset extension state to default, when overview is shown and hidden (not showing/hidding event) + this._shownEventId = Main.overview.connect('shown', () => this._extensionState = ExtensionState.DEFAULT); + this._hiddenEventId = Main.overview.connect('hidden', () => this._extensionState = ExtensionState.DEFAULT); + } + + destroy() { + if (this._swipeTracker) { + this._connectors.forEach(connector => { var _a; return (_a = this._swipeTracker) === null || _a === void 0 ? void 0 : _a.disconnect(connector); }); + this._swipeTracker.destroy(); + this._swipeTracker = undefined; + } + + this._connectors = []; + Main.overview._swipeTracker.enabled = true; + this._stateAdjustment.getStateTransitionParams = this._oldGetStateTransitionParams.bind(this._stateAdjustment); + Main.overview.disconnect(this._shownEventId); + Main.overview.disconnect(this._hiddenEventId); + } + + _gestureBegin(tracker) { + const _tracker = { + confirmSwipe: (distance, _snapPoints, currentProgress, cancelProgress) => { + tracker.confirmSwipe(distance, this._getGestureSnapPoints(), currentProgress, cancelProgress); + }, + }; + + Main.overview._gestureBegin(_tracker); + this._progress = this._stateAdjustment.value; + this._extensionState = ExtensionState.DEFAULT; + } + + _gestureUpdate(tracker, progress) { + if (progress < OverviewControlsState.HIDDEN || + progress > OverviewControlsState.APP_GRID) { + this._extensionState = ExtensionState.CUSTOM; + } + else { + this._extensionState = ExtensionState.DEFAULT; + } + + this._progress = progress; + + // log(`update: progress=${progress}, overview progress=${this._getOverviewProgressValue(progress)}`); + Main.overview._gestureUpdate(tracker, this._getOverviewProgressValue(progress)); + } + + _gestureEnd(tracker, duration, endProgress) { + if (this._progress < OverviewControlsState.HIDDEN) { + this._extensionState = ExtensionState.CUSTOM; + endProgress = endProgress >= OverviewControlsState.HIDDEN ? + OverviewControlsState.HIDDEN : + OverviewControlsState.APP_GRID; + } + else if (this._progress > OverviewControlsState.APP_GRID) { + this._extensionState = ExtensionState.CUSTOM; + endProgress = endProgress <= OverviewControlsState.APP_GRID ? + OverviewControlsState.APP_GRID : + OverviewControlsState.HIDDEN; + } + else { + this._extensionState = ExtensionState.DEFAULT; + endProgress = Math.clamp(endProgress, OverviewControlsState.HIDDEN, OverviewControlsState.APP_GRID); + } + + // log(`end: progress=${this._progress}, endProgress=${endProgress}, overview progress=${this._getOverviewProgressValue(endProgress)}`) + Main.overview._gestureEnd(tracker, duration, endProgress); + } + + _getOverviewProgressValue(progress) { + if (progress < OverviewControlsState.HIDDEN) { + return Math.min(OverviewControlsState.APP_GRID, 2 * Math.abs(OverviewControlsState.HIDDEN - progress)); + } + else if (progress > OverviewControlsState.APP_GRID) { + return Math.min(OverviewControlsState.APP_GRID, 2 * Math.abs(OverviewControlsState.HIDDEN_N - progress)); + } + + return progress; + } + + _getGestureSnapPoints() { + switch (this._navigationStates) { + case OverviewNavigationState.CYCLIC: + return [ + OverviewControlsState.APP_GRID_P, + OverviewControlsState.HIDDEN, + OverviewControlsState.WINDOW_PICKER, + OverviewControlsState.APP_GRID, + OverviewControlsState.HIDDEN_N, + ]; + case OverviewNavigationState.GNOME: + return [ + OverviewControlsState.HIDDEN, + OverviewControlsState.WINDOW_PICKER, + OverviewControlsState.APP_GRID, + ]; + case OverviewNavigationState.WINDOW_PICKER_ONLY: + return [ + OverviewControlsState.HIDDEN, + OverviewControlsState.WINDOW_PICKER, + ]; + } + } +}; diff --git a/src/pinchGestures/closeWindow.js b/src/pinchGestures/closeWindow.js new file mode 100644 index 0000000..5d41bea --- /dev/null +++ b/src/pinchGestures/closeWindow.js @@ -0,0 +1,120 @@ +/* exported CloseWindowExtension */ +import Clutter from 'gi://Clutter'; +import Shell from 'gi://Shell'; +import St from 'gi://St'; + +import { PinchGestureType } from '../../common/settings.js' +import { WIGET_SHOWING_DURATION } from '../../constants.js' +import { TouchpadPinchGesture } from '../trackers/pinchTracker.js' +import { easeActor } from '../utils/environment.js' +import { getVirtualKeyboard } from '../utils/keyboard.js' +import * as Main from 'resource:///org/gnome/shell/ui/main.js'; +import * as Util from 'resource:///org/gnome/shell/misc/util.js'; +const END_OPACITY = 0; +const END_SCALE = 0.5; +export var CloseWindowGestureState; +(function (CloseWindowGestureState) { + CloseWindowGestureState[CloseWindowGestureState['PINCH_IN'] = -1] = 'PINCH_IN'; + CloseWindowGestureState[CloseWindowGestureState['DEFAULT'] = 0] = 'DEFAULT'; +})(CloseWindowGestureState || (CloseWindowGestureState = {})); + +export var CloseWindowExtension = class CloseWindowExtension { + constructor(nfingers, closeType) { + this._closeType = closeType; + this._keyboard = getVirtualKeyboard(); + this._preview = new St.Widget({ + reactive: false, + style_class: 'gie-close-window-preview', + visible: false, + }); + + this._preview.set_pivot_point(0.5, 0.5); + Main.layoutManager.uiGroup.add_child(this._preview); + this._pinchTracker = new TouchpadPinchGesture({ + nfingers: nfingers, + allowedModes: Shell.ActionMode.NORMAL, + pinchSpeed: 0.25, + }); + + this._pinchTracker.connect('begin', this.gestureBegin.bind(this)); + this._pinchTracker.connect('update', this.gestureUpdate.bind(this)); + this._pinchTracker.connect('end', this.gestureEnd.bind(this)); + } + + destroy() { + this._pinchTracker.destroy(); + this._preview.destroy(); + } + + gestureBegin(tracker) { + // if we are currently in middle of animations, ignore this event + if (this._focusWindow) + return; + this._focusWindow = global.display.get_focus_window(); + if (!this._focusWindow) + return; + tracker.confirmPinch(0, [CloseWindowGestureState.PINCH_IN, CloseWindowGestureState.DEFAULT], CloseWindowGestureState.DEFAULT); + const frame = this._focusWindow.get_frame_rect(); + this._preview.set_position(frame.x, frame.y); + this._preview.set_size(frame.width, frame.height); + + // animate showing widget + this._preview.opacity = 0; + this._preview.show(); + easeActor(this._preview, { + opacity: 255, + mode: Clutter.AnimationMode.EASE_OUT_QUAD, + duration: WIGET_SHOWING_DURATION, + }); + } + + gestureUpdate(_tracker, progress) { + progress = CloseWindowGestureState.DEFAULT - progress; + const scale = Util.lerp(1, END_SCALE, progress); + this._preview.set_scale(scale, scale); + this._preview.opacity = Util.lerp(255, END_OPACITY, progress); + } + + gestureEnd(_tracker, duration, progress) { + switch (progress) { + case CloseWindowGestureState.DEFAULT: + this._animatePreview(false, duration); + break; + case CloseWindowGestureState.PINCH_IN: + this._animatePreview(true, duration, this._invokeGestureCompleteAction.bind(this)); + } + } + + _invokeGestureCompleteAction() { + var _a, _b; + switch (this._closeType) { + case PinchGestureType.CLOSE_WINDOW: + (_b = (_a = this._focusWindow) === null || _a === void 0 ? void 0 : _a.delete) === null || _b === void 0 ? void 0 : _b.call(_a, global.get_current_time()); + break; + case PinchGestureType.CLOSE_DOCUMENT: + this._keyboard.sendKeys([Clutter.KEY_Control_L, Clutter.KEY_w]); + } + } + + _animatePreview(gestureCompleted, duration, callback) { + easeActor(this._preview, { + opacity: gestureCompleted ? END_OPACITY : 255, + scaleX: gestureCompleted ? END_SCALE : 1, + scaleY: gestureCompleted ? END_SCALE : 1, + duration, + mode: Clutter.AnimationMode.EASE_OUT_QUAD, + onStopped: () => { + if (callback) + callback(); + this._gestureAnimationDone(); + }, + }); + } + + _gestureAnimationDone() { + this._preview.hide(); + this._preview.opacity = 255; + this._preview.set_scale(1, 1); + this._focusWindow = undefined; + } +}; diff --git a/src/pinchGestures/showDesktop.js b/src/pinchGestures/showDesktop.js new file mode 100644 index 0000000..291221a --- /dev/null +++ b/src/pinchGestures/showDesktop.js @@ -0,0 +1,375 @@ +/* exported ShowDesktopExtension */ +import Clutter from 'gi://Clutter'; +import Meta from 'gi://Meta'; +import Shell from 'gi://Shell'; + +import { TouchpadPinchGesture } from '../trackers/pinchTracker.js' +import { easeActor } from '../utils/environment.js' +import * as Main from 'resource:///org/gnome/shell/ui/main.js'; +import * as Layout from 'resource:///org/gnome/shell/ui/layout.js' +import { lerp } from 'resource:///org/gnome/shell/misc/util.js'; + +// declare enum +export var WorkspaceManagerState; +(function (WorkspaceManagerState) { + WorkspaceManagerState[WorkspaceManagerState['DEFAULT'] = 0] = 'DEFAULT'; + WorkspaceManagerState[WorkspaceManagerState['SHOW_DESKTOP'] = 1] = 'SHOW_DESKTOP'; +})(WorkspaceManagerState || (WorkspaceManagerState = {})); + +// declare enum +export var ExtensionState; +(function (ExtensionState) { + ExtensionState[ExtensionState['DEFAULT'] = 0] = 'DEFAULT'; + ExtensionState[ExtensionState['ANIMATING'] = 1] = 'ANIMATING'; +})(ExtensionState || (ExtensionState = {})); + +class MonitorGroup { + constructor(monitor) { + this._windowActorClones = []; + this.monitor = monitor; + this._container = new Clutter.Actor({ visible: false }); + const constraint = new Layout.MonitorConstraint({ index: monitor.index }); + this._container.add_constraint(constraint); + this._bottomMidCorner = { x: this.monitor.width / 2, y: this.monitor.height, position: 'bottom-mid' }; + this._corners = [ + { x: 0, y: 0, position: 'top-left' }, + + // { x: this.monitor.width / 2, y: 0, position: 'top-mid' }, + { x: this.monitor.width, y: 0, position: 'top-right' }, + { x: this.monitor.width, y: this.monitor.height, position: 'bottom-right' }, + + // { x: this.monitor.width / 2, y: this.monitor.height, position: 'bottom-mid' }, + { x: 0, y: this.monitor.height, position: 'bottom-left' }, + ]; + + this._container.set_clip_to_allocation(true); + Main.layoutManager.uiGroup.insert_child_above(this._container, global.window_group); + } + + _addWindowActor(windowActor) { + const clone = new Clutter.Clone({ + source: windowActor, + x: windowActor.x - this.monitor.x, + y: windowActor.y - this.monitor.y, + }); + + // windowActor.opacity = 0; + windowActor.hide(); + this._windowActorClones.push({ clone, windowActor }); + this._container.insert_child_below(clone, null); + } + + _getDestPoint(clone, destCorner) { + const destY = destCorner.y; + const cloneRelXCenter = Math.round(clone.width / 2); + switch (destCorner.position) { + case 'top-left': + return { x: destCorner.x - clone.width, y: destY - clone.height }; + case 'top-mid': + return { x: destCorner.x - cloneRelXCenter, y: destY - clone.height }; + case 'top-right': + return { x: destCorner.x, y: destY - clone.height }; + case 'bottom-right': + return { x: destCorner.x, y: destY }; + case 'bottom-mid': + return { x: destCorner.x - cloneRelXCenter, y: destY }; + case 'bottom-left': + return { x: destCorner.x - clone.width, y: destY }; + } + } + + _calculateDist(p, q) { + return Math.abs(p.x - q.x) + Math.abs(p.y - q.y); + } + + _assignCorner(actorClone, corner) { + const { clone } = actorClone; + const destPoint = this._getDestPoint(clone, corner); + actorClone.translation = { + start: { x: clone.x, y: clone.y }, + end: { x: destPoint.x, y: destPoint.y }, + }; + } + + _fillCloneDestPosition(windowActorsClones) { + if (windowActorsClones.length === 0) + return; + if (windowActorsClones.length === 1) { + this._assignCorner(windowActorsClones[0], this._bottomMidCorner); + return; + } + + const distanceMetrics = []; + this._corners.forEach(corner => { + windowActorsClones.forEach(actorClone => { + distanceMetrics.push({ + value: this._calculateDist(actorClone.clone, this._getDestPoint(actorClone.clone, corner)), + actorClone, + corner, + }); + }); + }); + + const minActorsPerCorner = Math.floor(windowActorsClones.length / this._corners.length); + let extraActors = windowActorsClones.length - this._corners.length * minActorsPerCorner; + const clusterSizes = new Map(); + const takenActorClones = new Set(); + distanceMetrics.sort((a, b) => a.value - b.value); + distanceMetrics.forEach(metric => { + var _a; + const size = (_a = clusterSizes.get(metric.corner.position)) !== null && _a !== void 0 ? _a : 0; + if (takenActorClones.has(metric.actorClone)) + return; + if (size >= minActorsPerCorner) { + if (size > minActorsPerCorner || extraActors <= 0) + return; + extraActors -= 1; + } + + takenActorClones.add(metric.actorClone); + clusterSizes.set(metric.corner.position, size + 1); + this._assignCorner(metric.actorClone, metric.corner); + }); + } + + gestureBegin(windowActors) { + windowActors.forEach(this._addWindowActor.bind(this)); + this._fillCloneDestPosition(this._windowActorClones); + this._container.show(); + } + + gestureUpdate(progress) { + this._windowActorClones.forEach(actorClone => { + const { clone, translation } = actorClone; + if (translation === undefined) + return; + clone.x = lerp(translation.start.x, translation.end.x, progress); + clone.y = lerp(translation.start.y, translation.end.y, progress); + clone.opacity = lerp(255, 128, progress); + }); + } + + gestureEnd(progress, duration) { + this._windowActorClones.forEach(actorClone => { + const { clone, translation, windowActor } = actorClone; + if (translation === undefined) { + clone.destroy(); + return; + } + + easeActor(clone, { + x: lerp(translation.start.x, translation.end.x, progress), + y: lerp(translation.start.y, translation.end.y, progress), + opacity: lerp(255, 128, progress), + mode: Clutter.AnimationMode.EASE_OUT_QUAD, + duration, + onStopped: () => { + this._container.hide(); + const window = windowActor.meta_window; + if (window === null || window === void 0 ? void 0 : window.can_minimize()) { + Main.wm.skipNextEffect(windowActor); + if (progress === WorkspaceManagerState.DEFAULT) { + window.unminimize(); + windowActor.show(); + } + else { + window.minimize(); + windowActor.hide(); + } + } + else { + windowActor.show(); + } + + clone.destroy(); + }, + }); + }); + + if (this._windowActorClones.length === 0) + this._container.hide(); + this._windowActorClones = []; + } + + destroy() { + this._container.destroy(); + } +} + +export var ShowDesktopExtension = class ShowDesktopExtension { + constructor(nfingers) { + this._windows = new Set(); + this._workspaceChangedId = 0; + this._windowAddedId = 0; + this._windowRemovedId = 0; + this._windowUnMinimizedId = 0; + this._monitorChangedId = 0; + this._extensionState = ExtensionState.DEFAULT; + this._minimizingWindows = []; + this._workspaceManagerState = WorkspaceManagerState.DEFAULT; + this._monitorGroups = []; + this._pinchTracker = new TouchpadPinchGesture({ + nfingers: nfingers, + allowedModes: Shell.ActionMode.NORMAL, + }); + } + + apply() { + this._pinchTracker.connect('begin', this.gestureBegin.bind(this)); + this._pinchTracker.connect('update', this.gestureUpdate.bind(this)); + this._pinchTracker.connect('end', this.gestureEnd.bind(this)); + for (const monitor of Main.layoutManager.monitors) + this._monitorGroups.push(new MonitorGroup(monitor)); + this._workspaceChangedId = global.workspace_manager.connect('active-workspace-changed', this._workspaceChanged.bind(this)); + this._workspaceChanged(); + this._windowUnMinimizedId = global.window_manager.connect('unminimize', this._windowUnMinimized.bind(this)); + this._monitorChangedId = Main.layoutManager.connect('monitors-changed', () => { + this._monitorGroups.forEach(m => m.destroy()); + this._monitorGroups = []; + for (const monitor of Main.layoutManager.monitors) + this._monitorGroups.push(new MonitorGroup(monitor)); + }); + } + + destroy() { + var _a, _b, _c; + (_a = this._pinchTracker) === null || _a === void 0 ? void 0 : _a.destroy(); + if (this._monitorChangedId) + Main.layoutManager.disconnect(this._monitorChangedId); + if (this._windowAddedId) + (_b = this._workspace) === null || _b === void 0 ? void 0 : _b.disconnect(this._windowAddedId); + if (this._windowRemovedId) + (_c = this._workspace) === null || _c === void 0 ? void 0 : _c.disconnect(this._windowRemovedId); + if (this._workspaceChangedId) + global.workspace_manager.disconnect(this._workspaceChangedId); + if (this._windowUnMinimizedId) + global.window_manager.disconnect(this._windowUnMinimizedId); + this._resetState(); + for (const monitor of this._monitorGroups) + monitor.destroy(); + this._monitorGroups = []; + } + + _getMinimizableWindows() { + if (this._workspaceManagerState === WorkspaceManagerState.DEFAULT) { + this._minimizingWindows = global + .get_window_actors() + .filter(a => a.visible) + + // top actors should be at the beginning + .reverse() + .map(actor => actor.meta_window) + .filter(win => { + var _a; + return win.get_window_type() !== Meta.WindowType.DESKTOP && + this._windows.has(win) && + (win.is_always_on_all_workspaces() || win.get_workspace().index === ((_a = this._workspace) === null || _a === void 0 ? void 0 : _a.index)) && + !win.minimized; + }); + } + + return this._minimizingWindows; + } + + gestureBegin(tracker) { + this._extensionState = ExtensionState.ANIMATING; + Meta.disable_unredirect_for_display(global.display); + this._minimizingWindows = this._getMinimizableWindows(); + + // this._setDesktopWindowsBelow(); + for (const monitor of this._monitorGroups) { + const windowActors = this._minimizingWindows + .map(win => win.get_compositor_private()) + .filter((actor) => { + return actor instanceof Meta.WindowActor && actor.meta_window.get_monitor() === monitor.monitor.index; + }); + + monitor.gestureBegin(windowActors); + } + + tracker.confirmPinch(1, [WorkspaceManagerState.DEFAULT, WorkspaceManagerState.SHOW_DESKTOP], this._workspaceManagerState); + } + + gestureUpdate(_tracker, progress) { + // progress 0 -> NORMAL state, 1 -> SHOW Desktop + // printStack(); + for (const monitor of this._monitorGroups) + monitor.gestureUpdate(progress); + } + + gestureEnd(_tracker, duration, endProgress) { + // endProgress 0 -> NORMAL state, 1 -> SHOW Desktop + for (const monitor of this._monitorGroups) + monitor.gestureEnd(endProgress, duration); + if (endProgress === WorkspaceManagerState.DEFAULT) + this._minimizingWindows = []; + this._extensionState = ExtensionState.DEFAULT; + this._workspaceManagerState = endProgress; + Meta.enable_unredirect_for_display(global.display); + } + + _resetState(animate = false) { + // reset state, aka. undo show desktop + this._minimizingWindows.forEach(win => { + if (!this._windows.has(win)) + return; + const onStopped = () => { + Main.wm.skipNextEffect(win.get_compositor_private()); + win.unminimize(); + }; + + const actor = win.get_compositor_private(); + if (animate && actor) { + actor.show(); + actor.opacity = 0; + easeActor(actor, { + opacity: 255, + duration: 500, + mode: Clutter.AnimationMode.EASE_OUT_QUAD, + onStopped, + }); + } + else + onStopped(); + }); + + this._minimizingWindows = []; + this._workspaceManagerState = WorkspaceManagerState.DEFAULT; + } + + _workspaceChanged() { + var _a, _b; + if (this._windowAddedId) + (_a = this._workspace) === null || _a === void 0 ? void 0 : _a.disconnect(this._windowAddedId); + if (this._windowRemovedId) + (_b = this._workspace) === null || _b === void 0 ? void 0 : _b.disconnect(this._windowRemovedId); + this._resetState(false); + this._windows.clear(); + this._workspace = global.workspace_manager.get_active_workspace(); + this._windowAddedId = this._workspace.connect('window-added', this._windowAdded.bind(this)); + this._windowRemovedId = this._workspace.connect('window-removed', this._windowRemoved.bind(this)); + this._workspace.list_windows().forEach(win => this._windowAdded(this._workspace, win)); + } + + _windowAdded(_workspace, window) { + if (this._windows.has(window)) + return; + if (!window.skip_taskbar && this._extensionState === ExtensionState.DEFAULT) + this._resetState(true); + this._windows.add(window); + } + + _windowRemoved(_workspace, window) { + if (!this._windows.has(window)) + return; + this._windows.delete(window); + } + + _windowUnMinimized(_wm, actor) { + var _a; + if (actor.meta_window.get_workspace().index !== ((_a = this._workspace) === null || _a === void 0 ? void 0 : _a.index)) + return; + this._minimizingWindows = []; + this._workspaceManagerState = WorkspaceManagerState.DEFAULT; + } +}; diff --git a/src/snapWindow.js b/src/snapWindow.js new file mode 100644 index 0000000..3fa6f7c --- /dev/null +++ b/src/snapWindow.js @@ -0,0 +1,361 @@ +/* exported SnapWindowExtension */ +import Clutter from 'gi://Clutter'; +import Meta from 'gi://Meta'; +import Shell from 'gi://Shell'; +import St from 'gi://St'; + +import { registerClass } from '../common/utils/gobject.js' +import { ExtSettings } from '../constants.js' +import { createSwipeTracker } from './swipeTracker.js' +import { easeActor, easeAdjustment } from './utils/environment.js' +import { getVirtualKeyboard } from './utils/keyboard.js' +import * as Main from 'resource:///org/gnome/shell/ui/main.js'; +import * as Utils from 'resource:///org/gnome/shell/misc/util.js'; +const WINDOW_ANIMATION_TIME = 250; +const UPDATED_WINDOW_ANIMATION_TIME = 150; +const TRIGGER_THRESHOLD = 0.1; + +// define enum +export var GestureMaxUnMaxState; +(function (GestureMaxUnMaxState) { + GestureMaxUnMaxState[GestureMaxUnMaxState['MINIMIZE'] = -1] = 'MINIMIZE'; + GestureMaxUnMaxState[GestureMaxUnMaxState['UNMAXIMIZE'] = 0] = 'UNMAXIMIZE'; + GestureMaxUnMaxState[GestureMaxUnMaxState['MAXIMIZE'] = 1] = 'MAXIMIZE'; + GestureMaxUnMaxState[GestureMaxUnMaxState['FULLSCREEN'] = 2] = 'FULLSCREEN'; +})(GestureMaxUnMaxState || (GestureMaxUnMaxState = {})); + +// define enum +export var GestureTileState; +(function (GestureTileState) { + GestureTileState[GestureTileState['RIGHT_TILE'] = -1] = 'RIGHT_TILE'; + GestureTileState[GestureTileState['NORMAL'] = 0] = 'NORMAL'; + GestureTileState[GestureTileState['LEFT_TILE'] = 1] = 'LEFT_TILE'; +})(GestureTileState || (GestureTileState = {})); + +const TilePreview = registerClass(class TilePreview extends St.Widget { + _init() { + super._init({ + reactive: false, + style_class: 'tile-preview', + visible: false, + }); + + this._direction = Clutter.Orientation.VERTICAL; + this.add_style_class_name('gie-tile-window-preview'); + this.connect('destroy', this._onDestroy.bind(this)); + this._adjustment = new St.Adjustment({ + actor: this, + value: 0, + lower: -1, + upper: 2, + }); + + this._adjustment.connect('notify::value', this._valueChanged.bind(this)); + this._virtualDevice = getVirtualKeyboard(); + } + + open(window, currentProgress) { + if (this.visible) { + return false; + } + + this._window = window; + this._fullscreenBox = global.display.get_monitor_geometry(window.get_monitor()); + this._maximizeBox = this.getMaximizedBox(window); + this._normalBox = this.getNormalBox(window); + this._leftSnapBox = this._maximizeBox.copy(); + this._rightSnapBox = this._maximizeBox.copy(); + this._minimizeBox = this.getMinimizedBox(this._window, this._maximizeBox); + this._leftSnapBox.width /= 2; + this._rightSnapBox.width /= 2; + this._rightSnapBox.x += this._rightSnapBox.width; + this._direction = Clutter.Orientation.VERTICAL; + this.opacity = 0; + this._adjustment.value = currentProgress; + this._valueChanged(); + this.visible = true; + this.easeOpacity(255); + return true; + } + + finish(duration, state) { + const callback = () => { + if (!this.visible) + return; + this.easeOpacity(0, () => this.visible = false); + if (this._window) { + // maximize-unmaximize + if (this._direction === Clutter.Orientation.VERTICAL) { + // Main.wm.skipNextEffect(this._window.get_compositor_private() as Meta.WindowActor); + const stSettings = St.Settings.get(); + + // speedup animations + const prevSlowdown = stSettings.slow_down_factor; + stSettings.slow_down_factor = UPDATED_WINDOW_ANIMATION_TIME / WINDOW_ANIMATION_TIME; + switch (state) { + case GestureMaxUnMaxState.MINIMIZE: + this._window.minimize(); + break; + case GestureMaxUnMaxState.UNMAXIMIZE: + if (this._window.is_fullscreen()) + this._window.unmake_fullscreen(); + this._window.unmaximize(Meta.MaximizeFlags.BOTH); + break; + case GestureMaxUnMaxState.MAXIMIZE: + if (this._window.is_fullscreen()) + this._window.unmake_fullscreen(); + this._window.maximize(Meta.MaximizeFlags.BOTH); + break; + case GestureMaxUnMaxState.FULLSCREEN: + this._window.make_fullscreen(); + break; + } + + stSettings.slow_down_factor = prevSlowdown; + } + + // snap-left,normal,snap-right + else { + if (state !== GestureTileState.NORMAL) { + const keys = [Clutter.KEY_Super_L, (state === GestureTileState.LEFT_TILE ? Clutter.KEY_Left : Clutter.KEY_Right)]; + this._virtualDevice.sendKeys(keys); + } + } + } + + this._window = undefined; + this._normalBox = undefined; + this._maximizeBox = undefined; + this._minimizeBox = undefined; + this._leftSnapBox = undefined; + this._rightSnapBox = undefined; + this._direction = Clutter.Orientation.VERTICAL; + }; + + easeAdjustment(this._adjustment, state, { + duration: duration, + mode: Clutter.AnimationMode.EASE_OUT_QUAD, + onStopped: callback, + }); + } + + _valueChanged() { + let progress = this._adjustment.value; + let startBox, endBox; + if (this._direction === Clutter.Orientation.VERTICAL) { + if (progress < GestureMaxUnMaxState.UNMAXIMIZE) { + startBox = this._minimizeBox; + endBox = this._normalBox; + progress -= GestureMaxUnMaxState.MINIMIZE; + } + else if (progress <= GestureMaxUnMaxState.MAXIMIZE) { + // no particular reason for equality here + startBox = this._normalBox; + endBox = this._maximizeBox; + progress -= GestureMaxUnMaxState.UNMAXIMIZE; + } + else { + startBox = this._maximizeBox; + endBox = this._fullscreenBox; + progress -= GestureMaxUnMaxState.MAXIMIZE; + } + } + else { + startBox = this._normalBox; + if (progress >= GestureTileState.NORMAL) { + endBox = this._leftSnapBox; + } + else { + endBox = this._rightSnapBox; + progress = -progress; + } + } + + if (!startBox || !endBox) { + return; + } + + const [x, y] = [ + Utils.lerp(startBox.x, endBox.x, progress), + Utils.lerp(startBox.y, endBox.y, progress), + ]; + + const [width, height] = [ + Utils.lerp(startBox.width, endBox.width, progress), + Utils.lerp(startBox.height, endBox.height, progress), + ]; + + this.set_position(x, y); + this.set_size(width, height); + } + + _onDestroy() { + this._adjustment.run_dispose(); + } + + switchToSnapping(value) { + this._adjustment.remove_transition('value'); + this._adjustment.value = value; + this._direction = Clutter.Orientation.HORIZONTAL; + } + + easeOpacity(value, callback) { + easeActor(this, { + opacity: value, + duration: UPDATED_WINDOW_ANIMATION_TIME, + mode: Clutter.AnimationMode.EASE_OUT_QUAD, + onStopped: () => { + if (callback) + callback(); + }, + }); + } + + get adjustment() { + return this._adjustment; + } + + getMinimizedBox(window, monitorWorkArea) { + const [has_icon, icon_geometry] = window.get_icon_geometry(); + if (has_icon) + return icon_geometry; + const rect = monitorWorkArea.copy(); + rect.width = 0; + rect.height = 0; + return rect; + } + + getNormalBox(window) { + const normalBox = window.get_frame_rect(); + if (window.get_maximized() !== Meta.MaximizeFlags.BOTH) + return normalBox; + const [width, height] = [ + Math.round(normalBox.width * 0.05), + Math.round(normalBox.height * 0.05), + ]; + + normalBox.x += width; + normalBox.width -= 2 * width; + normalBox.y += height; + normalBox.height -= 2 * height; + return normalBox; + } + + getMaximizedBox(window) { + const monitor = window.get_monitor(); + const maximizedBox = Main.layoutManager.getWorkAreaForMonitor(monitor); + if (!window.is_fullscreen()) + return maximizedBox; + const height = Math.round(maximizedBox.height * 0.025); + maximizedBox.y += height; + maximizedBox.height -= 2 * height; + return maximizedBox; + } +}); + +export var SnapWindowExtension = class SnapWindowExtension { + constructor() { + this._connectors = []; + this._toggledDirection = false; + this._allowChangeDirection = false; + this._swipeTracker = createSwipeTracker(global.stage, (ExtSettings.DEFAULT_OVERVIEW_GESTURE ? [4] : [3]), Shell.ActionMode.NORMAL, Clutter.Orientation.VERTICAL, true, 1, { allowTouch: false }); + this._swipeTracker.allowLongSwipes = true; + this._touchpadSwipeGesture = this._swipeTracker._touchpadGesture; + this._tilePreview = new TilePreview(); + Main.layoutManager.uiGroup.add_child(this._tilePreview); + this._uiGroupAddedActorId = Main.layoutManager.uiGroup.connect('actor-added', () => { + Main.layoutManager.uiGroup.set_child_above_sibling(this._tilePreview, null); + }); + + Main.layoutManager.uiGroup.set_child_above_sibling(this._tilePreview, null); + } + + apply() { + this._swipeTracker.orientation = Clutter.Orientation.VERTICAL; + this._connectors.push(this._swipeTracker.connect('begin', this._gestureBegin.bind(this))); + this._connectors.push(this._swipeTracker.connect('update', this._gestureUpdate.bind(this))); + this._connectors.push(this._swipeTracker.connect('end', this._gestureEnd.bind(this))); + } + + destroy() { + if (this._uiGroupAddedActorId) { + Main.layoutManager.uiGroup.disconnect(this._uiGroupAddedActorId); + this._uiGroupAddedActorId = 0; + } + + this._connectors.forEach(connector => this._swipeTracker.disconnect(connector)); + Main.layoutManager.uiGroup.remove_child(this._tilePreview); + this._swipeTracker.destroy(); + this._tilePreview.destroy(); + } + + _gestureBegin(tracker, monitor) { + const window = global.display.get_focus_window(); + + // fullscreen window's can't be maximized :O + // if window can't be maximized and window is not fullscreen, return + if (!window || !(window.can_maximize() || window.is_fullscreen())) { + return; + } + + // window is on different monitor + if (window.get_monitor() !== monitor) { + return; + } + + const currentMonitor = window.get_monitor(); + const monitorArea = global.display.get_monitor_geometry(currentMonitor); + const progress = window.is_fullscreen() ? GestureMaxUnMaxState.FULLSCREEN + : window.get_maximized() === Meta.MaximizeFlags.BOTH ? GestureMaxUnMaxState.MAXIMIZE : GestureMaxUnMaxState.UNMAXIMIZE; + + this._toggledDirection = false; + this._allowChangeDirection = false; + const snapPoints = []; + switch (progress) { + case GestureMaxUnMaxState.UNMAXIMIZE: + snapPoints.push(GestureTileState.RIGHT_TILE, GestureTileState.NORMAL, GestureTileState.LEFT_TILE); + + // allow tiling gesture, when window is unmaximized and minimized gesture is not enabled + this._allowChangeDirection = !ExtSettings.ALLOW_MINIMIZE_WINDOW; + break; + case GestureMaxUnMaxState.MAXIMIZE: + snapPoints.push(GestureMaxUnMaxState.UNMAXIMIZE, GestureMaxUnMaxState.MAXIMIZE); + if (!window.is_monitor_sized() && !monitorArea.equal(window.get_buffer_rect())) + snapPoints.push(GestureMaxUnMaxState.FULLSCREEN); + break; + case GestureMaxUnMaxState.FULLSCREEN: + snapPoints.push(GestureMaxUnMaxState.MAXIMIZE, GestureMaxUnMaxState.FULLSCREEN); + break; + } + + if (this._tilePreview.open(window, progress)) { + tracker.confirmSwipe(monitorArea.height, snapPoints, progress, progress); + } + } + + _gestureUpdate(_tracker, progress) { + // log(`progress: ${progress}, toggled: ${this._toggledDirection}`); + if (this._toggledDirection) { + this._tilePreview.adjustment.value = progress; + return; + } + + // if tiling gesture is not allowed or progress is above unmaximized state + if (!this._allowChangeDirection || progress >= GestureMaxUnMaxState.UNMAXIMIZE) { + this._tilePreview.adjustment.value = progress; + } + + // switch to horizontal + else if (this._allowChangeDirection && progress <= GestureMaxUnMaxState.UNMAXIMIZE - TRIGGER_THRESHOLD) { + this._toggledDirection = true; + this._touchpadSwipeGesture.switchDirectionTo(Clutter.Orientation.HORIZONTAL); + this._swipeTracker._progress = GestureTileState.NORMAL; + this._swipeTracker._history.reset(); + this._tilePreview.switchToSnapping(GestureTileState.NORMAL); + } + } + + _gestureEnd(_tracker, duration, progress) { + this._tilePreview.finish(duration, progress); + } +}; diff --git a/src/swipeTracker.js b/src/swipeTracker.js new file mode 100644 index 0000000..f839532 --- /dev/null +++ b/src/swipeTracker.js @@ -0,0 +1,242 @@ +/* exported TouchpadSwipeGesture, createSwipeTracker */ +import Clutter from 'gi://Clutter'; +import GObject from 'gi://GObject'; +import Meta from 'gi://Meta'; +import Shell from 'gi://Shell'; + +import { registerClass } from '../common/utils/gobject.js' +import { TouchpadConstants } from '../constants.js' +import * as DBusUtils from './utils/dbus.js' +import * as Main from 'resource:///org/gnome/shell/ui/main.js'; +import { SwipeTracker } from 'resource:///org/gnome/shell/ui/swipeTracker.js'; + +// define enum +export var TouchpadState; +(function (TouchpadState) { + TouchpadState[TouchpadState['NONE'] = 0] = 'NONE'; + TouchpadState[TouchpadState['PENDING'] = 1] = 'PENDING'; + TouchpadState[TouchpadState['HANDLING'] = 2] = 'HANDLING'; + TouchpadState[TouchpadState['IGNORED'] = 3] = 'IGNORED'; +})(TouchpadState || (TouchpadState = {})); + +export var TouchpadSwipeGesture = registerClass({ + Properties: { + 'enabled': GObject.ParamSpec.boolean('enabled', 'enabled', 'enabled', GObject.ParamFlags.READWRITE, true), + 'orientation': GObject.ParamSpec.enum('orientation', 'orientation', 'orientation', GObject.ParamFlags.READWRITE, Clutter.Orientation, Clutter.Orientation.HORIZONTAL), + }, + Signals: { + 'begin': { param_types: [GObject.TYPE_UINT, GObject.TYPE_DOUBLE, GObject.TYPE_DOUBLE] }, + 'update': { param_types: [GObject.TYPE_UINT, GObject.TYPE_DOUBLE, GObject.TYPE_DOUBLE] }, + 'end': { param_types: [GObject.TYPE_UINT, GObject.TYPE_DOUBLE] }, + }, +}, class TouchpadSwipeGesture extends GObject.Object { + _init(nfingers, allowedModes, orientation, followNaturalScroll = true, checkAllowedGesture, gestureSpeed = 1.0) { + super._init(); + this._cumulativeX = 0; + this._cumulativeY = 0; + this._stageCaptureEvent = 0; + this.TOUCHPAD_BASE_HEIGHT = TouchpadConstants.TOUCHPAD_BASE_HEIGHT; + this.TOUCHPAD_BASE_WIDTH = TouchpadConstants.TOUCHPAD_BASE_WIDTH; + this.DRAG_THRESHOLD_DISTANCE = TouchpadConstants.DRAG_THRESHOLD_DISTANCE; + this.enabled = true; + this._state = TouchpadState.NONE; + this._toggledDirection = false; + this._swipeGestureBeginTime = 0; + this._holdGestureBeginTime = 0; + this._holdGestureCancelTime = 0; + this._nfingers = nfingers; + this._allowedModes = allowedModes; + this.orientation = orientation; + this._checkAllowedGesture = checkAllowedGesture; + this._followNaturalScroll = followNaturalScroll; + if (Meta.is_wayland_compositor()) { + this._stageCaptureEvent = global.stage.connect('captured-event::touchpad', this._handleEvent.bind(this)); + } + else { + DBusUtils.subscribe(this._handleEvent.bind(this)); + } + + this.SWIPE_MULTIPLIER = TouchpadConstants.SWIPE_MULTIPLIER * (typeof (gestureSpeed) !== 'number' ? 1.0 : gestureSpeed); + } + + _resetState() { + this._state = TouchpadState.NONE; + this._toggledDirection = false; + this._swipeGestureBeginTime = 0; + this._holdGestureBeginTime = 0; + this._holdGestureCancelTime = 0; + } + + _handleHoldEvent(event) { + switch (event.get_gesture_phase()) { + case Clutter.TouchpadGesturePhase.BEGIN: + this._holdGestureCancelTime = 0; + this._holdGestureBeginTime = event.get_time(); + break; + case Clutter.TouchpadGesturePhase.CANCEL: + this._holdGestureCancelTime = event.get_time(); + break; + case Clutter.TouchpadGesturePhase.END: + this._holdGestureBeginTime = 0; + this._holdGestureCancelTime = 0; + } + } + + _handleEvent(_actor, event) { + if (event.type() === Clutter.EventType.TOUCHPAD_HOLD) { + this._handleHoldEvent(event); + return Clutter.EVENT_PROPAGATE; + } + + if (event.type() !== Clutter.EventType.TOUCHPAD_SWIPE) + return Clutter.EVENT_PROPAGATE; + const gesturePhase = event.get_gesture_phase(); + if (gesturePhase === Clutter.TouchpadGesturePhase.BEGIN) { + this._swipeGestureBeginTime = event.get_time(); + this._state = TouchpadState.NONE; + this._toggledDirection = false; + } + + if (this._state === TouchpadState.IGNORED) + return Clutter.EVENT_PROPAGATE; + if (!this.enabled) + return Clutter.EVENT_PROPAGATE; + if ((this._allowedModes !== Shell.ActionMode.ALL) && ((this._allowedModes & Main.actionMode) === 0)) { + this._state = TouchpadState.IGNORED; + return Clutter.EVENT_PROPAGATE; + } + + if (!this._nfingers.includes(event.get_touchpad_gesture_finger_count())) { + this._state = TouchpadState.IGNORED; + return Clutter.EVENT_PROPAGATE; + } + + if (gesturePhase === Clutter.TouchpadGesturePhase.BEGIN && this._checkAllowedGesture !== undefined) { + try { + if (this._checkAllowedGesture(event) !== true) { + this._state = TouchpadState.IGNORED; + return Clutter.EVENT_PROPAGATE; + } + } + catch (ex) { + this._state = TouchpadState.IGNORED; + return Clutter.EVENT_PROPAGATE; + } + } + + const time = event.get_time(); + const [x, y] = event.get_coords(); + const [dx, dy] = event.get_gesture_motion_delta_unaccelerated(); + if (this._state === TouchpadState.NONE) { + if (dx === 0 && dy === 0) + return Clutter.EVENT_PROPAGATE; + this._cumulativeX = 0; + this._cumulativeY = 0; + this._state = TouchpadState.PENDING; + } + + if (this._state === TouchpadState.PENDING) { + this._cumulativeX += dx * this.SWIPE_MULTIPLIER; + this._cumulativeY += dy * this.SWIPE_MULTIPLIER; + const cdx = this._cumulativeX; + const cdy = this._cumulativeY; + const distance = Math.sqrt(cdx * cdx + cdy * cdy); + if (distance >= this.DRAG_THRESHOLD_DISTANCE) { + const gestureOrientation = Math.abs(cdx) > Math.abs(cdy) + ? Clutter.Orientation.HORIZONTAL + : Clutter.Orientation.VERTICAL; + + this._cumulativeX = 0; + this._cumulativeY = 0; + if (gestureOrientation === this.orientation) { + this._state = TouchpadState.HANDLING; + this.emit('begin', time, x, y); + } + else { + this._state = TouchpadState.IGNORED; + return Clutter.EVENT_PROPAGATE; + } + } + else { + return Clutter.EVENT_PROPAGATE; + } + } + + const vertical = this.orientation === Clutter.Orientation.VERTICAL; + let delta = ((vertical !== this._toggledDirection) ? dy : dx) * this.SWIPE_MULTIPLIER; + const distance = vertical ? this.TOUCHPAD_BASE_HEIGHT : this.TOUCHPAD_BASE_WIDTH; + switch (gesturePhase) { + case Clutter.TouchpadGesturePhase.BEGIN: + case Clutter.TouchpadGesturePhase.UPDATE: + if (this._followNaturalScroll) + delta = -delta; + this.emit('update', time, delta, distance); + break; + case Clutter.TouchpadGesturePhase.END: + case Clutter.TouchpadGesturePhase.CANCEL: + this.emit('end', time, distance); + this._resetState(); + break; + } + + return this._state === TouchpadState.HANDLING + ? Clutter.EVENT_STOP + : Clutter.EVENT_PROPAGATE; + } + + isItHoldAndSwipeGesture() { + if (this._holdGestureCancelTime === 0) + return false; + return ((this._holdGestureCancelTime - this._holdGestureBeginTime >= TouchpadConstants.HOLD_SWIPE_DELAY_DURATION) && // ms + (this._swipeGestureBeginTime - this._holdGestureCancelTime <= Math.max(100, TouchpadConstants.HOLD_SWIPE_DELAY_DURATION)) // ms + ); + } + + switchDirectionTo(direction) { + if (this._state !== TouchpadState.HANDLING) { + return; + } + + this._toggledDirection = direction !== this.orientation; + } + + destroy() { + if (this._stageCaptureEvent) { + global.stage.disconnect(this._stageCaptureEvent); + this._stageCaptureEvent = 0; + } + } +}); + +export function createSwipeTracker(actor, nfingers, allowedModes, orientation, followNaturalScroll = true, gestureSpeed = 1, params) { + var _a, _b, _c; + params = params !== null && params !== void 0 ? params : {}; + params.allowDrag = (_a = params.allowDrag) !== null && _a !== void 0 ? _a : false; + params.allowScroll = (_b = params.allowScroll) !== null && _b !== void 0 ? _b : false; + const allowTouch = (_c = params.allowTouch) !== null && _c !== void 0 ? _c : true; + delete params.allowTouch; + + // create swipeTracker + const swipeTracker = new SwipeTracker(actor, orientation, allowedModes, 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(); + swipeTracker._touchpadGesture = undefined; + } + + // add touchpadBindings to tracker + swipeTracker._touchpadGesture = new TouchpadSwipeGesture(nfingers, swipeTracker._allowedModes, swipeTracker.orientation, followNaturalScroll, undefined, gestureSpeed); + swipeTracker._touchpadGesture.connect('begin', swipeTracker._beginGesture.bind(swipeTracker)); + swipeTracker._touchpadGesture.connect('update', swipeTracker._updateGesture.bind(swipeTracker)); + swipeTracker._touchpadGesture.connect('end', swipeTracker._endTouchpadGesture.bind(swipeTracker)); + swipeTracker.bind_property('enabled', swipeTracker._touchpadGesture, 'enabled', 0); + swipeTracker.bind_property('orientation', swipeTracker._touchpadGesture, 'orientation', GObject.BindingFlags.SYNC_CREATE); + return swipeTracker; +} diff --git a/src/trackers/pinchTracker.js b/src/trackers/pinchTracker.js new file mode 100644 index 0000000..f3e7582 --- /dev/null +++ b/src/trackers/pinchTracker.js @@ -0,0 +1,287 @@ +/* exported TouchpadPinchGesture */ +import Clutter from 'gi://Clutter'; +import GObject from 'gi://GObject'; +import Meta from 'gi://Meta'; +import Shell from 'gi://Shell'; + +import { registerClass } from '../../common/utils/gobject.js' +import { TouchpadConstants } from '../../constants.js' +import * as DBusUtils from '../utils/dbus.js' +import * as Main from 'resource:///org/gnome/shell/ui/main.js'; +const MIN_ANIMATION_DURATION = 100; +const MAX_ANIMATION_DURATION = 400; + +// Derivative of easeOutCubic at t=0 +const DURATION_MULTIPLIER = 3; +const ANIMATION_BASE_VELOCITY = 0.002; +const EVENT_HISTORY_THRESHOLD_MS = 150; +const DECELERATION_TOUCHPAD = 0.997; +const VELOCITY_CURVE_THRESHOLD = 2; +const DECELERATION_PARABOLA_MULTIPLIER = 0.35; +class EventHistoryTracker { + constructor() { + this._data = []; + } + + reset() { + this._data = []; + } + + trim(time) { + const thresholdTime = time - EVENT_HISTORY_THRESHOLD_MS; + const index = this._data.findIndex(r => r.time >= thresholdTime); + this._data.splice(0, index); + } + + append(time, delta) { + this.trim(time); + this._data.push({ time, delta }); + } + + calculateVelocity() { + if (this._data.length < 2) + return 0; + const firstTime = this._data[0].time; + const lastTime = this._data[this._data.length - 1].time; + if (firstTime === lastTime) + return 0; + const totalDelta = this._data.slice(1).map(a => a.delta).reduce((a, b) => a + b); + const period = lastTime - firstTime; + return totalDelta / period; + } +} + +// define enum +export var TouchpadState; +(function (TouchpadState) { + TouchpadState[TouchpadState['NONE'] = 0] = 'NONE'; + TouchpadState[TouchpadState['HANDLING'] = 1] = 'HANDLING'; + TouchpadState[TouchpadState['IGNORED'] = 2] = 'IGNORED'; +})(TouchpadState || (TouchpadState = {})); + +export var GestureACKState; +(function (GestureACKState) { + GestureACKState[GestureACKState['NONE'] = 0] = 'NONE'; + GestureACKState[GestureACKState['PENDING_ACK'] = 1] = 'PENDING_ACK'; + GestureACKState[GestureACKState['ACKED'] = 2] = 'ACKED'; +})(GestureACKState || (GestureACKState = {})); + +export var TouchpadPinchGesture = registerClass({ + Properties: {}, + Signals: { + 'begin': { param_types: [] }, + 'update': { param_types: [GObject.TYPE_DOUBLE] }, + 'end': { param_types: [GObject.TYPE_DOUBLE, GObject.TYPE_DOUBLE] }, + }, +}, class TouchpadPinchGesture extends GObject.Object { + _init(params) { + var _a; + super._init(); + this._state = TouchpadState.NONE; + this._ackState = GestureACKState.NONE; + this._progress_scale = 1.0; + this._snapPoints = [0, 1, 2]; + this.enabled = true; + this._initialProgress = 0; + this._nfingers = params.nfingers; + this._allowedModes = params.allowedModes; + this._checkAllowedGesture = params.checkAllowedGesture; + if (Meta.is_wayland_compositor()) { + this._stageCaptureEvent = global.stage.connect('captured-event::touchpad', this._handleEvent.bind(this)); + } + else { + DBusUtils.subscribe(this._handleEvent.bind(this)); + } + + this._historyTracker = new EventHistoryTracker(); + this.PINCH_MULTIPLIER = TouchpadConstants.PINCH_MULTIPLIER * ((_a = params.pinchSpeed) !== null && _a !== void 0 ? _a : 1.0); + } + + _handleEvent(_actor, event) { + if (event.type() !== Clutter.EventType.TOUCHPAD_PINCH) + return Clutter.EVENT_PROPAGATE; + const gesturePhase = event.get_gesture_phase(); + if (gesturePhase === Clutter.TouchpadGesturePhase.BEGIN) { + this._state = TouchpadState.NONE; + this._historyTracker.reset(); + } + + if (this._state === TouchpadState.IGNORED || !this.enabled) + return Clutter.EVENT_PROPAGATE; + if ((this._allowedModes !== Shell.ActionMode.ALL) && ((this._allowedModes & Main.actionMode) === 0)) { + this._interrupt(); + this._state = TouchpadState.IGNORED; + return Clutter.EVENT_PROPAGATE; + } + + if (!this._nfingers.includes(event.get_touchpad_gesture_finger_count())) { + this._state = TouchpadState.IGNORED; + return Clutter.EVENT_PROPAGATE; + } + + if (gesturePhase === Clutter.TouchpadGesturePhase.BEGIN && this._checkAllowedGesture !== undefined) { + try { + if (this._checkAllowedGesture(event) !== true) { + this._state = TouchpadState.IGNORED; + return Clutter.EVENT_PROPAGATE; + } + } + catch (ex) { + this._state = TouchpadState.IGNORED; + return Clutter.EVENT_PROPAGATE; + } + } + + this._state = TouchpadState.HANDLING; + const time = event.get_time(); + const pinch_scale = event.get_gesture_pinch_scale(); + switch (gesturePhase) { + case Clutter.TouchpadGesturePhase.BEGIN: + // this._previous_scale = 1.0; + this._emitBegin(); + break; + case Clutter.TouchpadGesturePhase.UPDATE: + this._emitUpdate(time, pinch_scale); + break; + case Clutter.TouchpadGesturePhase.END: + case Clutter.TouchpadGesturePhase.CANCEL: + this._emitEnd(time); + this._state = TouchpadState.NONE; + this._historyTracker.reset(); + break; + } + + return Clutter.EVENT_STOP; + } + + _getBounds() { + return [this._snapPoints[0], this._snapPoints[this._snapPoints.length - 1]]; + } + + /** + * @param currentProgress must be in increasing order + */ + confirmPinch(_distance, snapPoints, currentProgress) { + if (this._ackState !== GestureACKState.PENDING_ACK) + return; + this._snapPoints = snapPoints; + this._initialProgress = currentProgress; + this._progress_scale = Math.clamp(currentProgress, ...this._getBounds()); + this._ackState = GestureACKState.ACKED; + } + + _reset() { + this._historyTracker.reset(); + this._snapPoints = []; + this._initialProgress = 0; + } + + _interrupt() { + if (this._ackState !== GestureACKState.ACKED) + return; + this._reset(); + this._ackState = GestureACKState.NONE; + this.emit('end', 0, this._initialProgress); + } + + _emitBegin() { + if (this._ackState === GestureACKState.ACKED) + return; + this._historyTracker.reset(); + this._ackState = GestureACKState.PENDING_ACK; + this._progress_scale = 1.0; + this.emit('begin'); + } + + _emitUpdate(time, pinch_scale) { + if (this._ackState !== GestureACKState.ACKED) + return; + + // this._historyTracker.append(time, delta); + // delta /= this._pinchDistance; + const new_progress = Math.log2(pinch_scale) * this.PINCH_MULTIPLIER + this._initialProgress; + const delta = new_progress - this._progress_scale; + this._historyTracker.append(time, delta); + this._progress_scale = Math.clamp(new_progress, ...this._getBounds()); + + // log(JSON.stringify({ pinch_scale, new_progress, delta })); + this.emit('update', this._progress_scale); + } + + _emitEnd(time) { + if (this._ackState !== GestureACKState.ACKED) + return; + this._historyTracker.trim(time); + let velocity = this._historyTracker.calculateVelocity(); + const endProgress = this._getEndProgress(velocity); + if ((endProgress - this._progress_scale) * velocity <= 0) + velocity = ANIMATION_BASE_VELOCITY; + let duration = Math.abs((this._progress_scale - endProgress) / velocity * DURATION_MULTIPLIER); + duration = Math.clamp(duration, MIN_ANIMATION_DURATION, MAX_ANIMATION_DURATION); + this._reset(); + this._ackState = GestureACKState.NONE; + this.emit('end', duration, endProgress); + } + + _findEndPoints() { + const current = this._progress_scale; + return { + current, + next: Math.clamp(Math.ceil(current), ...this._getBounds()), + previous: Math.clamp(Math.floor(current), ...this._getBounds()), + }; + } + + _findClosestPoint(pos) { + const distances = this._snapPoints.map(x => Math.abs(x - pos)); + const min = Math.min(...distances); + return distances.indexOf(min); + } + + _findNextPoint(pos) { + return this._snapPoints.findIndex(p => p >= pos); + } + + _findPreviousPoint(pos) { + const reversedIndex = this._snapPoints.slice().reverse().findIndex(p => p <= pos); + return this._snapPoints.length - 1 - reversedIndex; + } + + _findPointForProjection(pos, velocity) { + const initial = this._findClosestPoint(this._initialProgress); + const prev = this._findPreviousPoint(pos); + const next = this._findNextPoint(pos); + if ((velocity > 0 ? prev : next) === initial) + return velocity > 0 ? next : prev; + return this._findClosestPoint(pos); + } + + _getEndProgress(velocity) { + // if (Math.abs(velocity) < VELOCITY_THRESHOLD_TOUCHPAD) + // return this._snapPoints[this._findClosestPoint(this._progress)]; + const slope = DECELERATION_TOUCHPAD / (1.0 - DECELERATION_TOUCHPAD) / 1000.0; + let pos; + if (Math.abs(velocity) > VELOCITY_CURVE_THRESHOLD) { + const c = slope / 2 / DECELERATION_PARABOLA_MULTIPLIER; + const x = Math.abs(velocity) - VELOCITY_CURVE_THRESHOLD + c; + pos = slope * VELOCITY_CURVE_THRESHOLD + + DECELERATION_PARABOLA_MULTIPLIER * x * x - + DECELERATION_PARABOLA_MULTIPLIER * c * c; + } + else { + pos = Math.abs(velocity) * slope; + } + + pos = pos * Math.sign(velocity) + this._progress_scale; + pos = Math.clamp(pos, ...this._getBounds()); + const index = this._findPointForProjection(pos, velocity); + return this._snapPoints[index]; + } + + destroy() { + if (this._stageCaptureEvent) { + global.stage.disconnect(this._stageCaptureEvent); + this._stageCaptureEvent = 0; + } + } +}); diff --git a/src/utils/dbus.js b/src/utils/dbus.js new file mode 100644 index 0000000..72a9cfa --- /dev/null +++ b/src/utils/dbus.js @@ -0,0 +1,167 @@ +/* exported subscribe, unsubscribeAll, drop_proxy */ +import Clutter from 'gi://Clutter'; +import Gio from 'gi://Gio'; +import GObject from 'gi://GObject'; + +import { registerClass } from '../../common/utils/gobject.js' +import { printStack } from '../../common/utils/logging.js' +import * as Util from 'resource:///org/gnome/shell/misc/util.js'; +const X11GestureDaemonXml = ` + + + + + + + + + + + +`; + +const DBusWrapperGIExtension = registerClass({ + Signals: { + 'TouchpadSwipe': { + param_types: [ + GObject.TYPE_STRING, + GObject.TYPE_INT, + GObject.TYPE_DOUBLE, + GObject.TYPE_DOUBLE, + GObject.TYPE_UINT + ], + flags: GObject.SignalFlags.RUN_LAST, + accumulator: GObject.AccumulatorType.TRUE_HANDLED, + return_type: GObject.TYPE_BOOLEAN, + }, + 'TouchpadHold': { + param_types: [ + GObject.TYPE_STRING, + GObject.TYPE_INT, + GObject.TYPE_UINT, + GObject.TYPE_BOOLEAN + ], + flags: GObject.SignalFlags.RUN_LAST, + accumulator: GObject.AccumulatorType.TRUE_HANDLED, + return_type: GObject.TYPE_BOOLEAN, + }, + 'TouchpadPinch': { + param_types: [ + GObject.TYPE_STRING, + GObject.TYPE_INT, + GObject.TYPE_DOUBLE, + GObject.TYPE_DOUBLE, + GObject.TYPE_UINT + ], + flags: GObject.SignalFlags.RUN_LAST, + accumulator: GObject.AccumulatorType.TRUE_HANDLED, + return_type: GObject.TYPE_BOOLEAN, + }, + }, + Properties: {}, +}, class DBusWrapperGIExtension extends GObject.Object { + _init() { + super._init(); + this._proxyConnectSignalIds = []; + const ProxyClass = Gio.DBusProxy.makeProxyWrapper(X11GestureDaemonXml); + this._proxy = new ProxyClass(Gio.DBus.session, 'org.gestureImprovements.gestures', '/org/gestureImprovements/gestures'); + this._proxyConnectSignalIds.push(this._proxy.connectSignal('TouchpadSwipe', this._handleDbusSwipeSignal.bind(this))); + this._proxyConnectSignalIds.push(this._proxy.connectSignal('TouchpadHold', this._handleDbusHoldSignal.bind(this))); + this._proxyConnectSignalIds.push(this._proxy.connectSignal('TouchpadPinch', this._handleDbusPinchSignal.bind(this))); + } + + dropProxy() { + if (this._proxy) { + this._proxyConnectSignalIds.forEach(id => this._proxy.disconnectSignal(id)); + this._proxy.run_dispose(); + this._proxy = undefined; + } + } + + // eslint-disable-next-line @typescript-eslint/no-explicit-any + _handleDbusSwipeSignal(_proxy, _sender, params) { + // (siddu) + const [sphase, fingers, dx, dy, time] = params[0]; + this.emit('TouchpadSwipe', sphase, fingers, dx, dy, time); + } + + // eslint-disable-next-line @typescript-eslint/no-explicit-any + _handleDbusHoldSignal(_proxy, _sender, params) { + // (siub) + const [sphase, fingers, time, cancelled] = params[0]; + this.emit('TouchpadHold', sphase, fingers, time, cancelled); + } + + // eslint-disable-next-line @typescript-eslint/no-explicit-any + _handleDbusPinchSignal(_proxy, _sender, params) { + // (siddu) + const [sphase, fingers, angle_delta, scale, time] = params[0]; + this.emit('TouchpadPinch', sphase, fingers, angle_delta, scale, time); + } +}); + +function GenerateEvent(typ, sphase, fingers, time, params) { + return { + type: () => typ, + get_gesture_phase: () => { + switch (sphase) { + case 'Begin': + return Clutter.TouchpadGesturePhase.BEGIN; + case 'Update': + return Clutter.TouchpadGesturePhase.UPDATE; + default: + return params.is_cancelled ? Clutter.TouchpadGesturePhase.CANCEL : Clutter.TouchpadGesturePhase.END; + } + }, + get_touchpad_gesture_finger_count: () => fingers, + get_coords: () => global.get_pointer().slice(0, 2), + get_gesture_motion_delta_unaccelerated: () => { var _a, _b; return [(_a = params.dx) !== null && _a !== void 0 ? _a : 0, (_b = params.dy) !== null && _b !== void 0 ? _b : 0]; }, + get_time: () => time, + get_gesture_pinch_scale: () => { var _a; return (_a = params.pinch_scale) !== null && _a !== void 0 ? _a : 1.0; }, + get_gesture_pinch_angle_delta: () => { var _a; return (_a = params.pinch_angle_delta) !== null && _a !== void 0 ? _a : 0; }, + }; +} + +let proxy; +let connectedSignalIds = []; + +export function subscribe(callback) { + if (!proxy) { + printStack('starting dbus service \'gesture_improvements_gesture_daemon.service\' via spawn'); + Util.spawn(['systemctl', '--user', 'start', 'gesture_improvements_gesture_daemon.service']); + connectedSignalIds = []; + proxy = new DBusWrapperGIExtension(); + } + + connectedSignalIds.push(proxy.connect('TouchpadSwipe', (_source, sphase, fingers, dx, dy, time) => { + const event = GenerateEvent(Clutter.EventType.TOUCHPAD_SWIPE, sphase, fingers, time, { dx, dy }); + return callback(undefined, event); + })); + + connectedSignalIds.push(proxy.connect('TouchpadHold', (_source, sphase, fingers, time, is_cancelled) => { + const event = GenerateEvent(Clutter.EventType.TOUCHPAD_HOLD, sphase, fingers, time, { is_cancelled }); + return callback(undefined, event); + })); + + connectedSignalIds.push(proxy.connect('TouchpadPinch', (_source, sphase, fingers, pinch_angle_delta, pinch_scale, time) => { + const event = GenerateEvent(Clutter.EventType.TOUCHPAD_PINCH, sphase, fingers, time, { pinch_angle_delta, pinch_scale }); + return callback(undefined, event); + })); +} + +export function unsubscribeAll() { + if (proxy) { + connectedSignalIds.forEach(id => proxy === null || proxy === void 0 ? void 0 : proxy.disconnect(id)); + connectedSignalIds = []; + } +} + +export function drop_proxy() { + if (proxy) { + unsubscribeAll(); + proxy.dropProxy(); + proxy.run_dispose(); + proxy = undefined; + Util.spawn(['systemctl', '--user', 'stop', 'gesture_improvements_gesture_daemon.service']); + } +} diff --git a/src/utils/environment.js b/src/utils/environment.js new file mode 100644 index 0000000..669b532 --- /dev/null +++ b/src/utils/environment.js @@ -0,0 +1,9 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ +/* exported easeActor, easeAdjustment */ +export function easeActor(actor, params) { + actor.ease(params); +} + +export function easeAdjustment(actor, value, params) { + actor.ease(value, params); +} diff --git a/src/utils/keyboard.js b/src/utils/keyboard.js new file mode 100644 index 0000000..f025d11 --- /dev/null +++ b/src/utils/keyboard.js @@ -0,0 +1,50 @@ +/* exported getVirtualKeyboard, extensionCleanup */ +import Clutter from 'gi://Clutter'; +import GLib from 'gi://GLib'; +const DELAY_BETWEEN_KEY_PRESS = 10; // ms +const timeoutIds = new Set(); +class VirtualKeyboard { + constructor() { + const seat = Clutter.get_default_backend().get_default_seat(); + this._virtualDevice = seat.create_virtual_device(Clutter.InputDeviceType.KEYBOARD_DEVICE); + } + + sendKeys(keys) { + // log(`sending keys: ${keys}`); + // keyEvents are stored in revere order so first event can be just popped + const keyEvents = []; + keys.forEach(key => keyEvents.push([key, Clutter.KeyState.RELEASED])); + keys.reverse().forEach(key => keyEvents.push([key, Clutter.KeyState.PRESSED])); + let timeoutId = GLib.timeout_add(GLib.PRIORITY_DEFAULT, DELAY_BETWEEN_KEY_PRESS, () => { + const keyEvent = keyEvents.pop(); + if (keyEvent !== undefined) + this._sendKey(...keyEvent); + if (keyEvents.length === 0) { + timeoutIds.delete(timeoutId); + timeoutId = 0; + return GLib.SOURCE_REMOVE; + } + + return GLib.SOURCE_CONTINUE; + }); + + if (timeoutId) + timeoutIds.add(timeoutId); + } + + _sendKey(keyval, keyState) { + this._virtualDevice.notify_keyval(Clutter.get_current_event_time() * 1000, keyval, keyState); + } +} +let _keyboard; + +export function getVirtualKeyboard() { + _keyboard = _keyboard !== null && _keyboard !== void 0 ? _keyboard : new VirtualKeyboard(); + return _keyboard; +} + +export function extensionCleanup() { + timeoutIds.forEach(id => GLib.Source.remove(id)); + timeoutIds.clear(); + _keyboard = undefined; +} diff --git a/stylesheet.css b/stylesheet.css new file mode 100644 index 0000000..2d4cc92 --- /dev/null +++ b/stylesheet.css @@ -0,0 +1,38 @@ +.gie-alttab-quick-transition .switcher-popup, +.gie-alttab-quick-transition .switcher-list, +.gie-alttab-quick-transition .item-box { + transition-duration: 0ms; +} + +.gie-circle { + width: 50px; + height: 50px; + border-radius: 50px; +} + +.gie-inner-circle { + border: solid 2px #396bd7; + color: #396bd7; + background-color: #ffffff; +} + +.gie-arrow-icon { + color: #396bd7; + margin: 10px 10px; /* (50+2 - 32)/2 */ + icon-size: 32px, +} + +.gie-outer-circle { + background-color: rgba(68, 120, 175, 0.5); + border: solid 2px; +} + +.gie-close-window-preview { + background-color: rgba(255, 128, 128, 0.5); + border: 1px solid rgba(255, 128, 128); + border-radius: 12px; +} + +.gie-tile-window-preview { + border-radius: 12px; +} \ No newline at end of file diff --git a/ui/customizations.ui b/ui/customizations.ui new file mode 100644 index 0000000..c4cbe2c --- /dev/null +++ b/ui/customizations.ui @@ -0,0 +1,183 @@ + + + + + + + + Cyclic + GNOME + Overview only + + + + + Misc + emblem-system-symbolic + + + + + + + + + + Touchpad swipe speed + + + + + + true + no + + + + -3.3219280948873626 + 3.3219280948873626 + 0.01 + + + + + + + + + + + + + center + 5 + False + False + 1.00 + + + + + + + + + + Follow natural swipe + Similar to natural scrolling. Swipe moves the content, not the view + + + center + True + + + + + + + + + Revert direction of overview navigation gesture + + + center + True + + + + + + + + + Overview navigation states + overview_navigation_states_model + + + + + + + Window switcher popup delay (ms) + + + + center + + + 0 + 5000 + 5 + + + 150 + + + + + + + + + Touchpad pinch speed + + + + + + true + no + + + + -3.3219280948873626 + 3.3219280948873626 + 0.01 + + + + + + + + + + + + + center + 5 + False + False + 1.00 + + + + + + + + + + Duration between hold and swipe (ms) + + + center + + + 0 + 5000 + 5 + + + 100 + + + + + + + + + + \ No newline at end of file diff --git a/ui/gestures.ui b/ui/gestures.ui new file mode 100644 index 0000000..b2d722f --- /dev/null +++ b/ui/gestures.ui @@ -0,0 +1,121 @@ + + + + + + + + None + Show Desktop + Close Window + Invoke Ctrl+W shortcut + + + + + Gestures + gesture-swipe-right-symbolic + + + + + Swipe Gestures + + + + + 4-finger gestures for overview navigation + For navigating between desktop, activities and appgrid + + + center + True + + + + + + + + + 4-finger gestures for workspace switching + + + center + True + + + + + + + + + Window switching + + + center + True + + + + + + + + + Window manipulation + Tile, unmaximize, maximize or fullscreen a window + + + center + True + + + + + + + + + Minimize window + This will disable tiling gesture + + + + center + True + + + + + + + + + + + + + Pinch Gestures + + + + + 3 finger pinch + pinch_gestures_model + + + + + + + 4 finger pinch + pinch_gestures_model + + + + + + + \ No newline at end of file diff --git a/ui/style-dark.css b/ui/style-dark.css new file mode 100644 index 0000000..377f4d8 --- /dev/null +++ b/ui/style-dark.css @@ -0,0 +1,7 @@ +.custom-smaller-card { + min-height: 35px; +} + +.custom-information-label-row { + background-color: #44403b; +} \ No newline at end of file diff --git a/ui/style.css b/ui/style.css new file mode 100644 index 0000000..5fd26e2 --- /dev/null +++ b/ui/style.css @@ -0,0 +1,7 @@ +.custom-smaller-card { + min-height: 35px; +} + +.custom-information-label-row { + background-color: #f1e6d9; +} \ No newline at end of file From 8e5469628fef3f0e0c8d13a11cc1d4238a18f4e2 Mon Sep 17 00:00:00 2001 From: Swapnil Devesh Date: Thu, 25 Apr 2024 22:29:57 +0530 Subject: [PATCH 02/16] Fix signal error from https://github.com/harshadgavali/gnome-gesture-improvements/issues/206#issuecomment-2026336600, by @Yanndroid --- src/snapWindow.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/snapWindow.js b/src/snapWindow.js index 3fa6f7c..22664c7 100644 --- a/src/snapWindow.js +++ b/src/snapWindow.js @@ -263,7 +263,7 @@ export var SnapWindowExtension = class SnapWindowExtension { this._touchpadSwipeGesture = this._swipeTracker._touchpadGesture; this._tilePreview = new TilePreview(); Main.layoutManager.uiGroup.add_child(this._tilePreview); - this._uiGroupAddedActorId = Main.layoutManager.uiGroup.connect('actor-added', () => { + this._uiGroupAddedActorId = Main.layoutManager.uiGroup.connect('child-added', () => { Main.layoutManager.uiGroup.set_child_above_sibling(this._tilePreview, null); }); From e4ebdf8fef516361f79831eb1da436a330b48345 Mon Sep 17 00:00:00 2001 From: Swapnil Devesh Date: Thu, 25 Apr 2024 23:05:44 +0530 Subject: [PATCH 03/16] Show notification gesture --- common/settings.js | 1 + extension.js | 6 +++ ...extensions.gestureImprovements.gschema.xml | 3 +- src/pinchGestures/showNotificationList.js | 44 +++++++++++++++++++ ui/gestures.ui | 3 +- 5 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 src/pinchGestures/showNotificationList.js diff --git a/common/settings.js b/common/settings.js index 4dc3e02..8ac64b4 100644 --- a/common/settings.js +++ b/common/settings.js @@ -6,6 +6,7 @@ export var PinchGestureType; PinchGestureType[PinchGestureType['SHOW_DESKTOP'] = 1] = 'SHOW_DESKTOP'; PinchGestureType[PinchGestureType['CLOSE_WINDOW'] = 2] = 'CLOSE_WINDOW'; PinchGestureType[PinchGestureType['CLOSE_DOCUMENT'] = 3] = 'CLOSE_DOCUMENT'; + PinchGestureType[PinchGestureType['SHOW_NOTIFICATION_LIST'] = 4] = 'SHOW_NOTIFICATION_LIST'; })(PinchGestureType || (PinchGestureType = {})); // define enum diff --git a/extension.js b/extension.js index 19783d0..e85c9c5 100644 --- a/extension.js +++ b/extension.js @@ -9,6 +9,7 @@ import { ForwardBackGestureExtension } from './src/forwardBack.js' import { GestureExtension } from './src/gestures.js' import { OverviewRoundTripGestureExtension } from './src/overviewRoundTrip.js' import { CloseWindowExtension } from './src/pinchGestures/closeWindow.js' +import { ShowNotificationListExtension } from './src/pinchGestures/showNotificationList.js' import { ShowDesktopExtension } from './src/pinchGestures/showDesktop.js' import { SnapWindowExtension } from './src/snapWindow.js' import * as DBusUtils from './src/utils/dbus.js' @@ -92,6 +93,11 @@ export default class MyExtension extends Extension { const closeDocumentFingers = pinchToFingersMap.get(PinchGestureType.CLOSE_DOCUMENT); if (closeDocumentFingers === null || closeDocumentFingers === void 0 ? void 0 : closeDocumentFingers.length) this._extensions.push(new CloseWindowExtension(closeDocumentFingers, PinchGestureType.CLOSE_DOCUMENT)); + + // pinch to show notification list + const showNotificationListFingers = pinchToFingersMap.get(PinchGestureType.SHOW_NOTIFICATION_LIST); + if (showNotificationListFingers === null || showNotificationListFingers === void 0 ? void 0 : showNotificationListFingers.length) + this._extensions.push(new ShowNotificationListExtension(showNotificationListFingers)); this._extensions.forEach(extension => { var _a; return (_a = extension.apply) === null || _a === void 0 ? void 0 : _a.call(extension); }); } diff --git a/schemas/org.gnome.shell.extensions.gestureImprovements.gschema.xml b/schemas/org.gnome.shell.extensions.gestureImprovements.gschema.xml index 0032c2b..6399fe3 100644 --- a/schemas/org.gnome.shell.extensions.gestureImprovements.gschema.xml +++ b/schemas/org.gnome.shell.extensions.gestureImprovements.gschema.xml @@ -5,6 +5,7 @@ + @@ -101,4 +102,4 @@ Application keyboard shortcuts for forward-back gesture - \ No newline at end of file + diff --git a/src/pinchGestures/showNotificationList.js b/src/pinchGestures/showNotificationList.js new file mode 100644 index 0000000..d4cf058 --- /dev/null +++ b/src/pinchGestures/showNotificationList.js @@ -0,0 +1,44 @@ +/* exported CloseWindowExtension */ +import Shell from 'gi://Shell'; + +import { TouchpadPinchGesture } from '../trackers/pinchTracker.js' +import * as Main from 'resource:///org/gnome/shell/ui/main.js'; +export var ShowNotificationListGestureState; +(function (ShowNotificationListGestureState) { + ShowNotificationListGestureState[ShowNotificationListGestureState['PINCH_IN'] = -1] = 'PINCH_IN'; + ShowNotificationListGestureState[ShowNotificationListGestureState['DEFAULT'] = 0] = 'DEFAULT'; +})(ShowNotificationListGestureState || (ShowNotificationListGestureState = {})); + +export var ShowNotificationListExtension = class ShowNotificationListExtension { + constructor(nfingers) { + this._pinchTracker = new TouchpadPinchGesture({ + nfingers: nfingers, + allowedModes: Shell.ActionMode.NORMAL, + pinchSpeed: 0.25, + }); + + this._pinchTracker.connect('begin', this.gestureBegin.bind(this)); + this._pinchTracker.connect('end', this.gestureEnd.bind(this)); + } + + destroy() { + this._pinchTracker.destroy(); + } + + gestureBegin(tracker) { + tracker.confirmPinch(0, [ShowNotificationListGestureState.PINCH_IN, ShowNotificationListGestureState.DEFAULT], ShowNotificationListGestureState.DEFAULT); + } + + gestureEnd(_tracker, duration, progress) { + switch (progress) { + case ShowNotificationListGestureState.DEFAULT: + break; + case ShowNotificationListGestureState.PINCH_IN: + this._invokeGestureCompleteAction(); + } + } + + _invokeGestureCompleteAction() { + Main.panel.toggleCalendar(); + } +}; diff --git a/ui/gestures.ui b/ui/gestures.ui index b2d722f..a60feb9 100644 --- a/ui/gestures.ui +++ b/ui/gestures.ui @@ -9,6 +9,7 @@ Show Desktop Close Window Invoke Ctrl+W shortcut + Show notification list @@ -118,4 +119,4 @@ - \ No newline at end of file + From b8715bb37b5f2d8b09c97e992435a9341b6f7298 Mon Sep 17 00:00:00 2001 From: Swapnil Devesh Date: Thu, 25 Apr 2024 23:32:15 +0530 Subject: [PATCH 04/16] Add a setting to disable fullscreen window manipulation --- common/prefs.js | 1 + constants.js | 1 + extension.js | 1 + schemas/gschemas.compiled | Bin 2133 -> 0 bytes ...ll.extensions.gestureImprovements.gschema.xml | 4 ++++ src/snapWindow.js | 2 +- ui/gestures.ui | 15 +++++++++++++++ 7 files changed, 23 insertions(+), 1 deletion(-) delete mode 100644 schemas/gschemas.compiled diff --git a/common/prefs.js b/common/prefs.js index 4b1e506..238a88f 100644 --- a/common/prefs.js +++ b/common/prefs.js @@ -75,6 +75,7 @@ function bindPrefsSettings(builder, settings) { bind_boolean_value('enable-alttab-gesture', settings, builder); bind_boolean_value('enable-window-manipulation-gesture', settings, builder); bind_boolean_value('allow-minimize-window', settings, builder); + bind_boolean_value('allow-fullscreen-window', settings, builder); bind_combo_box('pinch-3-finger-gesture', settings, builder); bind_combo_box('pinch-4-finger-gesture', settings, builder); bind_combo_box('overview-navifation-states', settings, builder); diff --git a/constants.js b/constants.js index 77766e0..88fc8ee 100644 --- a/constants.js +++ b/constants.js @@ -34,6 +34,7 @@ export var ExtSettings = { DEFAULT_SESSION_WORKSPACE_GESTURE: false, DEFAULT_OVERVIEW_GESTURE: false, ALLOW_MINIMIZE_WINDOW: false, + ALLOW_FULLSCREEN_WINDOW: true, FOLLOW_NATURAL_SCROLL: true, APP_GESTURES: false, DEFAULT_OVERVIEW_GESTURE_DIRECTION: true, diff --git a/extension.js b/extension.js index e85c9c5..2ca79c5 100644 --- a/extension.js +++ b/extension.js @@ -113,6 +113,7 @@ export default class MyExtension extends Extension { 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'); + ExtSettings.ALLOW_FULLSCREEN_WINDOW = this.settings.get_boolean('allow-fullscreen-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'); diff --git a/schemas/gschemas.compiled b/schemas/gschemas.compiled deleted file mode 100644 index c95fc0ea2bad641741beb3e5bd1621f6911fd67f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2133 zcmb_dO^6&t6t0Pm8{I^sn3y$DGANE!IKE_AS4&{;>|eZ{&XLuxe5VLd~g?u*AOZzesvUr%WDMm8aFgDMF|90mcV@A5oPO%-x9WVt*74__1 zpnPHLzVJL-jAIdKsRC{HgpP-isQY20wuLW(SmOi6N_QBMd`~{eIiUzF0Q-TPfm>26 zLLLNe0}lNI{R{j!aTL!9w#`0+JP%y2{rLj%q#px+8S)3A-|*H3RQ5KlVsyO19MUzI=ln0V4@-HVXl0FPezazH%kOW=Qo`~?`l z|JX_5Nk0sp-H81HlgZ?3;z_?7{C$uC(ERiPpLo&_fqxD14dCLrR~PAwNH2olg}em3 z_u`3%$)5BB;4ed70e=6a^C0o0p9H@jNnS>hk6tLQ5>GnCvj({VJoMqxcf^xU@rRIO zVDa%w#-4P_+b-m9KvpxPGuB{#KrZ6|pZM{M?~Q-x#y{i+;EFCEda;Fyh_mdmjkI{lElmJWr$ufx4;F?Q`qR&sNTBwk}jPFOmhZgV69SB)&62QnObobr%w z$>bwToEDm{mo-w+K!@Bh>meUq<$3TBaNIfWA(RM2vXc3JmhgaY%WkrQj(IFJtDdbk z>eabCWd!zWa<$rQovE=TM@e?J*6P*MwWqgQ&Bj?;WV$fRNfv0fAWb7aJLGYnbjB)Z z8WqztDyC^v@}^PwkET&!Omi=edB<{v$0zJva#E7m@?353F!ZF8>}wz<9Ys~6`znf^ zVcK}QD6y^@+pf@qScRtFkSnTF>SInnQobDeb~RHnOS)^xxEI2gNUm1h*b;6}%-qdv z?t)EEsUFJLxSTVY*&KmQ-aC8k{?PB_o|1k@D=zJ^6RJ07MD7*tzrDn(d4Fw4+>MNxTBCh~@*y za=16%wupQg@VSUGyJQ_756L(bQLOE@^kjZ~vo*;s&t)6cRC8slqCE2a{O(y|H742H z>^!^53WfU%^@1q8RrtJcwNTv0O8jMAlAZFoGB>vgfk|J!B&_6qn%&b6>bb8x)YnLc zBB@Ht#l1`VmupO9+M*u$SBpy8(A<6dpZZd9b_bL9lHN^vM`_#y(D~ARruuXm3knZG1W`jm(qKe-b(N^Oh5S>l7smR diff --git a/schemas/org.gnome.shell.extensions.gestureImprovements.gschema.xml b/schemas/org.gnome.shell.extensions.gestureImprovements.gschema.xml index 6399fe3..43c5ad6 100644 --- a/schemas/org.gnome.shell.extensions.gestureImprovements.gschema.xml +++ b/schemas/org.gnome.shell.extensions.gestureImprovements.gschema.xml @@ -39,6 +39,10 @@ false If true, when swipe down on non-maximized window minimizes it + + true + If true, when swipe up on maximized window makes it go fullscreen + true Whether to follow natural scroll for swipe diff --git a/src/snapWindow.js b/src/snapWindow.js index 22664c7..59acc9d 100644 --- a/src/snapWindow.js +++ b/src/snapWindow.js @@ -320,7 +320,7 @@ export var SnapWindowExtension = class SnapWindowExtension { break; case GestureMaxUnMaxState.MAXIMIZE: snapPoints.push(GestureMaxUnMaxState.UNMAXIMIZE, GestureMaxUnMaxState.MAXIMIZE); - if (!window.is_monitor_sized() && !monitorArea.equal(window.get_buffer_rect())) + if (ExtSettings.ALLOW_FULLSCREEN_WINDOW && !window.is_monitor_sized() && !monitorArea.equal(window.get_buffer_rect())) snapPoints.push(GestureMaxUnMaxState.FULLSCREEN); break; case GestureMaxUnMaxState.FULLSCREEN: diff --git a/ui/gestures.ui b/ui/gestures.ui index a60feb9..395e21a 100644 --- a/ui/gestures.ui +++ b/ui/gestures.ui @@ -91,6 +91,21 @@ + + + + Fullscreen window + Fullscreen the window if its already maximized + + + + center + True + + + + + From 4ff3799cb2b99e3be6a4aa38b51aa49734eae66f Mon Sep 17 00:00:00 2001 From: Swapnil Devesh Date: Thu, 25 Apr 2024 23:51:04 +0530 Subject: [PATCH 05/16] Move extension to its own folder, add README.md --- README.md | 82 +++++++++++++++++++ .../assets}/arrow1-left-symbolic.svg | 0 .../assets}/arrow1-right-symbolic.svg | 0 .../common}/appGestures.js | 0 .../common}/prefs.js | 0 .../common}/settings.js | 0 .../common}/utils/gobject.js | 0 .../common}/utils/logging.js | 0 .../constants.js | 0 .../extension.js | 0 .../metadata.json | 0 .../prefs.js | 0 ...extensions.gestureImprovements.gschema.xml | 0 .../src}/altTab.js | 0 .../src}/animations/arrow.js | 0 .../src}/forwardBack.js | 0 .../src}/gestures.js | 0 .../src}/overviewRoundTrip.js | 0 .../src}/pinchGestures/closeWindow.js | 0 .../src}/pinchGestures/showDesktop.js | 0 .../pinchGestures/showNotificationList.js | 0 .../src}/snapWindow.js | 0 .../src}/swipeTracker.js | 0 .../src}/trackers/pinchTracker.js | 0 .../src}/utils/dbus.js | 0 .../src}/utils/environment.js | 0 .../src}/utils/keyboard.js | 0 .../stylesheet.css | 0 .../ui}/customizations.ui | 0 .../ui}/gestures.ui | 0 .../ui}/style-dark.css | 0 .../ui}/style.css | 0 32 files changed, 82 insertions(+) create mode 100644 README.md rename {assets => gestureImprovements@gestures/assets}/arrow1-left-symbolic.svg (100%) rename {assets => gestureImprovements@gestures/assets}/arrow1-right-symbolic.svg (100%) rename {common => gestureImprovements@gestures/common}/appGestures.js (100%) rename {common => gestureImprovements@gestures/common}/prefs.js (100%) rename {common => gestureImprovements@gestures/common}/settings.js (100%) rename {common => gestureImprovements@gestures/common}/utils/gobject.js (100%) rename {common => gestureImprovements@gestures/common}/utils/logging.js (100%) rename constants.js => gestureImprovements@gestures/constants.js (100%) rename extension.js => gestureImprovements@gestures/extension.js (100%) rename metadata.json => gestureImprovements@gestures/metadata.json (100%) rename prefs.js => gestureImprovements@gestures/prefs.js (100%) rename {schemas => gestureImprovements@gestures/schemas}/org.gnome.shell.extensions.gestureImprovements.gschema.xml (100%) rename {src => gestureImprovements@gestures/src}/altTab.js (100%) rename {src => gestureImprovements@gestures/src}/animations/arrow.js (100%) rename {src => gestureImprovements@gestures/src}/forwardBack.js (100%) rename {src => gestureImprovements@gestures/src}/gestures.js (100%) rename {src => gestureImprovements@gestures/src}/overviewRoundTrip.js (100%) rename {src => gestureImprovements@gestures/src}/pinchGestures/closeWindow.js (100%) rename {src => gestureImprovements@gestures/src}/pinchGestures/showDesktop.js (100%) rename {src => gestureImprovements@gestures/src}/pinchGestures/showNotificationList.js (100%) rename {src => gestureImprovements@gestures/src}/snapWindow.js (100%) rename {src => gestureImprovements@gestures/src}/swipeTracker.js (100%) rename {src => gestureImprovements@gestures/src}/trackers/pinchTracker.js (100%) rename {src => gestureImprovements@gestures/src}/utils/dbus.js (100%) rename {src => gestureImprovements@gestures/src}/utils/environment.js (100%) rename {src => gestureImprovements@gestures/src}/utils/keyboard.js (100%) rename stylesheet.css => gestureImprovements@gestures/stylesheet.css (100%) rename {ui => gestureImprovements@gestures/ui}/customizations.ui (100%) rename {ui => gestureImprovements@gestures/ui}/gestures.ui (100%) rename {ui => gestureImprovements@gestures/ui}/style-dark.css (100%) rename {ui => gestureImprovements@gestures/ui}/style.css (100%) diff --git a/README.md b/README.md new file mode 100644 index 0000000..bbeb4e3 --- /dev/null +++ b/README.md @@ -0,0 +1,82 @@ +# Touchpad Gesture Improvements + +This extension modifies and extends existing touchpad gestures on GNOME. + +This repository contains the seemingly unmaintaned extension's transpiled to JS version with some fixes to get it to work on GNOME 46, +along with some additions which were previously raised as PR on the original project repo by me but never merged. + +Credit goes to @jaophi to for getting the transpiled version to work (https://github.com/harshadgavali/gnome-gesture-improvements/issues/206#issuecomment-1782750156) +upgrade supported version in manifest by @7HE-W0R1D (https://github.com/harshadgavali/gnome-gesture-improvements/issues/206#issuecomment-2023405620) +and fix for No signal error by @Yanndroid (https://github.com/harshadgavali/gnome-gesture-improvements/issues/206#issuecomment-2026336600) + +There is still the issue of pinch gestures not working that needs to be fixed. + +## Installation +### Manually +1. Install extension +``` +Download the latest extension version from https://github.com/sidevesh/gnome-gesture-improvements--transpiled/releases +gnome-extensions install -f ~/Downloads/gestureImprovements@gestures.zip +``` +2. Log out and log in **or** just restart session (X11) +3. Enable extension via extensions app or via command line +``` +gnome-extensions enable gestureImprovements@gestures +``` + +### Additional app X11 +On X11, you also need to install [gnome-x11-gesture-daemon](https://github.com/harshadgavali/gnome-x11-gesture-daemon) + +## Gestures (including built-in ones) +| Swipe Gesture | Modes | Fingers | Direction | +| :-------------------------------------- | :------- | :------ | :-------------- | +| Switch windows | Desktop | 3 | Horizontal | +| Switch workspaces | Overview | 2/3 | Horizontal | +| Switch app pages | AppGrid | 2/3 | Horizontal | +| Switch workspaces | * | 4 | Horizontal | +| Desktop/Overview/AppGrid navigation | * | 4 | Vertical | +| Unmaximize/maximize/fullscreen a window | Desktop | 3 | Vertical | +| Minimize a window | Desktop | 3 | Vertical | +| Snap/half-tile a window | Desktop | 3 | Explained below | + +| Pinch Gesture | Modes | Fingers | +| :---------------------- | :------ | :------ | +| Show Desktop | Desktop | 3/4 | +| Show Notification List | Desktop | 3/4 | + +| Application Gestures (Configurable) | +| :--- | +| Go back or forward in browser tab | +| Switch to next or previous image in image viewer | +| Switch to next or previous audio | +| Change tabs | + +#### For activating tiling gesture (inverted T gesture) +1. Do a 3-finger vertical downward gesture on a unmaximized window +2. Wait a few milliseconds +3. Do a 3-finger horizontal gesture to tile a window to either side + +#### Notes +* Minimize gesture is available if you have dash-to-dock/panel or similar extension enabled. +* To activate application gesture, hold for few moments(configurable) before swiping +* Tiling gesture can't be activated if you enable minimize gesture + + +## Customization +* To switch to windows from *all* workspaces using 3-fingers swipes, run +``` +gsettings set org.gnome.shell.window-switcher current-workspace-only false +``` + +* Add delay to alt-tab gesture, to ensure second windows gets selected when a fast swipe is done +* Change sensitivity of swipe (touchpad swipe speed) +* Option to follow natural scrolling (seperate from option in GNOME settings) +* Revert to 3-finger swipes to switch workspace on desktop (4-fingers to switch windows) +* Revert to 3-finger swipes for overview navigation (4-fingers to maximize/unmaximize/tile) + +# Contributors +[@jacksongoode](https://github.com/jacksongoode) +[@kyteinsky](https://github.com/kyteinsky) + +# Thanks +[@ewlsh](https://gitlab.gnome.org/ewlsh) for [Typescript definitions](https://www.npmjs.com/package/@gi-types/glib) for GLib, GObject, ... diff --git a/assets/arrow1-left-symbolic.svg b/gestureImprovements@gestures/assets/arrow1-left-symbolic.svg similarity index 100% rename from assets/arrow1-left-symbolic.svg rename to gestureImprovements@gestures/assets/arrow1-left-symbolic.svg diff --git a/assets/arrow1-right-symbolic.svg b/gestureImprovements@gestures/assets/arrow1-right-symbolic.svg similarity index 100% rename from assets/arrow1-right-symbolic.svg rename to gestureImprovements@gestures/assets/arrow1-right-symbolic.svg diff --git a/common/appGestures.js b/gestureImprovements@gestures/common/appGestures.js similarity index 100% rename from common/appGestures.js rename to gestureImprovements@gestures/common/appGestures.js diff --git a/common/prefs.js b/gestureImprovements@gestures/common/prefs.js similarity index 100% rename from common/prefs.js rename to gestureImprovements@gestures/common/prefs.js diff --git a/common/settings.js b/gestureImprovements@gestures/common/settings.js similarity index 100% rename from common/settings.js rename to gestureImprovements@gestures/common/settings.js diff --git a/common/utils/gobject.js b/gestureImprovements@gestures/common/utils/gobject.js similarity index 100% rename from common/utils/gobject.js rename to gestureImprovements@gestures/common/utils/gobject.js diff --git a/common/utils/logging.js b/gestureImprovements@gestures/common/utils/logging.js similarity index 100% rename from common/utils/logging.js rename to gestureImprovements@gestures/common/utils/logging.js diff --git a/constants.js b/gestureImprovements@gestures/constants.js similarity index 100% rename from constants.js rename to gestureImprovements@gestures/constants.js diff --git a/extension.js b/gestureImprovements@gestures/extension.js similarity index 100% rename from extension.js rename to gestureImprovements@gestures/extension.js diff --git a/metadata.json b/gestureImprovements@gestures/metadata.json similarity index 100% rename from metadata.json rename to gestureImprovements@gestures/metadata.json diff --git a/prefs.js b/gestureImprovements@gestures/prefs.js similarity index 100% rename from prefs.js rename to gestureImprovements@gestures/prefs.js diff --git a/schemas/org.gnome.shell.extensions.gestureImprovements.gschema.xml b/gestureImprovements@gestures/schemas/org.gnome.shell.extensions.gestureImprovements.gschema.xml similarity index 100% rename from schemas/org.gnome.shell.extensions.gestureImprovements.gschema.xml rename to gestureImprovements@gestures/schemas/org.gnome.shell.extensions.gestureImprovements.gschema.xml diff --git a/src/altTab.js b/gestureImprovements@gestures/src/altTab.js similarity index 100% rename from src/altTab.js rename to gestureImprovements@gestures/src/altTab.js diff --git a/src/animations/arrow.js b/gestureImprovements@gestures/src/animations/arrow.js similarity index 100% rename from src/animations/arrow.js rename to gestureImprovements@gestures/src/animations/arrow.js diff --git a/src/forwardBack.js b/gestureImprovements@gestures/src/forwardBack.js similarity index 100% rename from src/forwardBack.js rename to gestureImprovements@gestures/src/forwardBack.js diff --git a/src/gestures.js b/gestureImprovements@gestures/src/gestures.js similarity index 100% rename from src/gestures.js rename to gestureImprovements@gestures/src/gestures.js diff --git a/src/overviewRoundTrip.js b/gestureImprovements@gestures/src/overviewRoundTrip.js similarity index 100% rename from src/overviewRoundTrip.js rename to gestureImprovements@gestures/src/overviewRoundTrip.js diff --git a/src/pinchGestures/closeWindow.js b/gestureImprovements@gestures/src/pinchGestures/closeWindow.js similarity index 100% rename from src/pinchGestures/closeWindow.js rename to gestureImprovements@gestures/src/pinchGestures/closeWindow.js diff --git a/src/pinchGestures/showDesktop.js b/gestureImprovements@gestures/src/pinchGestures/showDesktop.js similarity index 100% rename from src/pinchGestures/showDesktop.js rename to gestureImprovements@gestures/src/pinchGestures/showDesktop.js diff --git a/src/pinchGestures/showNotificationList.js b/gestureImprovements@gestures/src/pinchGestures/showNotificationList.js similarity index 100% rename from src/pinchGestures/showNotificationList.js rename to gestureImprovements@gestures/src/pinchGestures/showNotificationList.js diff --git a/src/snapWindow.js b/gestureImprovements@gestures/src/snapWindow.js similarity index 100% rename from src/snapWindow.js rename to gestureImprovements@gestures/src/snapWindow.js diff --git a/src/swipeTracker.js b/gestureImprovements@gestures/src/swipeTracker.js similarity index 100% rename from src/swipeTracker.js rename to gestureImprovements@gestures/src/swipeTracker.js diff --git a/src/trackers/pinchTracker.js b/gestureImprovements@gestures/src/trackers/pinchTracker.js similarity index 100% rename from src/trackers/pinchTracker.js rename to gestureImprovements@gestures/src/trackers/pinchTracker.js diff --git a/src/utils/dbus.js b/gestureImprovements@gestures/src/utils/dbus.js similarity index 100% rename from src/utils/dbus.js rename to gestureImprovements@gestures/src/utils/dbus.js diff --git a/src/utils/environment.js b/gestureImprovements@gestures/src/utils/environment.js similarity index 100% rename from src/utils/environment.js rename to gestureImprovements@gestures/src/utils/environment.js diff --git a/src/utils/keyboard.js b/gestureImprovements@gestures/src/utils/keyboard.js similarity index 100% rename from src/utils/keyboard.js rename to gestureImprovements@gestures/src/utils/keyboard.js diff --git a/stylesheet.css b/gestureImprovements@gestures/stylesheet.css similarity index 100% rename from stylesheet.css rename to gestureImprovements@gestures/stylesheet.css diff --git a/ui/customizations.ui b/gestureImprovements@gestures/ui/customizations.ui similarity index 100% rename from ui/customizations.ui rename to gestureImprovements@gestures/ui/customizations.ui diff --git a/ui/gestures.ui b/gestureImprovements@gestures/ui/gestures.ui similarity index 100% rename from ui/gestures.ui rename to gestureImprovements@gestures/ui/gestures.ui diff --git a/ui/style-dark.css b/gestureImprovements@gestures/ui/style-dark.css similarity index 100% rename from ui/style-dark.css rename to gestureImprovements@gestures/ui/style-dark.css diff --git a/ui/style.css b/gestureImprovements@gestures/ui/style.css similarity index 100% rename from ui/style.css rename to gestureImprovements@gestures/ui/style.css From 013df9d2025d035a642a1d10f8bb8161675797cf Mon Sep 17 00:00:00 2001 From: Swapnil Devesh Date: Thu, 25 Apr 2024 23:53:06 +0530 Subject: [PATCH 06/16] Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index bbeb4e3..1a16263 100644 --- a/README.md +++ b/README.md @@ -6,16 +6,16 @@ This repository contains the seemingly unmaintaned extension's transpiled to JS along with some additions which were previously raised as PR on the original project repo by me but never merged. Credit goes to @jaophi to for getting the transpiled version to work (https://github.com/harshadgavali/gnome-gesture-improvements/issues/206#issuecomment-1782750156) -upgrade supported version in manifest by @7HE-W0R1D (https://github.com/harshadgavali/gnome-gesture-improvements/issues/206#issuecomment-2023405620) +upgrade supported version in manifest.json by @7HE-W0R1D (https://github.com/harshadgavali/gnome-gesture-improvements/issues/206#issuecomment-2023405620) and fix for No signal error by @Yanndroid (https://github.com/harshadgavali/gnome-gesture-improvements/issues/206#issuecomment-2026336600) There is still the issue of pinch gestures not working that needs to be fixed. ## Installation ### Manually -1. Install extension +1. Download the latest extension version from https://github.com/sidevesh/gnome-gesture-improvements--transpiled/releases +2. Install extension ``` -Download the latest extension version from https://github.com/sidevesh/gnome-gesture-improvements--transpiled/releases gnome-extensions install -f ~/Downloads/gestureImprovements@gestures.zip ``` 2. Log out and log in **or** just restart session (X11) From 42db0fc63451b32f641d640629eb937ebcc80d33 Mon Sep 17 00:00:00 2001 From: Swapnil Devesh Date: Thu, 25 Apr 2024 23:55:33 +0530 Subject: [PATCH 07/16] Add github workflow to prepare release bundle --- .github/workflows/zip-to-publish.zip | 31 ++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 .github/workflows/zip-to-publish.zip diff --git a/.github/workflows/zip-to-publish.zip b/.github/workflows/zip-to-publish.zip new file mode 100644 index 0000000..d90f6f0 --- /dev/null +++ b/.github/workflows/zip-to-publish.zip @@ -0,0 +1,31 @@ +name: Upload release assets + +permissions: + contents: write + +on: + release: + types: + - created + +jobs: + build-deb: + name: Create zip for publishing + runs-on: ubuntu-latest + steps: + - name: Set up Git repository + uses: actions/checkout@v2 + + - name: Create zip + run: | + cd gestureImprovements@gestures + zip -r ../gestureImprovements@gestures.zip * + cd .. + + - name: Upload package + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: ./gestureImprovements@gestures.zip + asset_name: gestureImprovements@gestures.zip + tag: ${{ github.ref }} From d8ee6885b2d3e8ebe80c1546fbd4aacf76c6420c Mon Sep 17 00:00:00 2001 From: Swapnil Devesh Date: Thu, 25 Apr 2024 23:56:09 +0530 Subject: [PATCH 08/16] Update metadata.json --- gestureImprovements@gestures/metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gestureImprovements@gestures/metadata.json b/gestureImprovements@gestures/metadata.json index 4727ec3..2de732b 100644 --- a/gestureImprovements@gestures/metadata.json +++ b/gestureImprovements@gestures/metadata.json @@ -8,5 +8,5 @@ ], "url": "https://github.com/harshadgavali/gnome-gesture-improvements", "uuid": "gestureImprovements@gestures", - "version": 27 + "version": 30 } From 2c1a45db397b81b8042878edfd7fede350eed56c Mon Sep 17 00:00:00 2001 From: Swapnil Devesh Date: Thu, 25 Apr 2024 23:56:53 +0530 Subject: [PATCH 09/16] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1a16263..af1232f 100644 --- a/README.md +++ b/README.md @@ -5,8 +5,8 @@ This extension modifies and extends existing touchpad gestures on GNOME. This repository contains the seemingly unmaintaned extension's transpiled to JS version with some fixes to get it to work on GNOME 46, along with some additions which were previously raised as PR on the original project repo by me but never merged. -Credit goes to @jaophi to for getting the transpiled version to work (https://github.com/harshadgavali/gnome-gesture-improvements/issues/206#issuecomment-1782750156) -upgrade supported version in manifest.json by @7HE-W0R1D (https://github.com/harshadgavali/gnome-gesture-improvements/issues/206#issuecomment-2023405620) +Credit goes to @jaophi to for getting the transpiled version to work (https://github.com/harshadgavali/gnome-gesture-improvements/issues/206#issuecomment-1782750156) +upgrade supported version in metadata.json by @7HE-W0R1D (https://github.com/harshadgavali/gnome-gesture-improvements/issues/206#issuecomment-2023405620) and fix for No signal error by @Yanndroid (https://github.com/harshadgavali/gnome-gesture-improvements/issues/206#issuecomment-2026336600) There is still the issue of pinch gestures not working that needs to be fixed. From af6925a7ce5dd5734ae4891b49f2bd809d8fe5c0 Mon Sep 17 00:00:00 2001 From: Swapnil Devesh Date: Thu, 25 Apr 2024 23:59:27 +0530 Subject: [PATCH 10/16] github action workflow --- .github/workflows/{zip-to-publish.zip => zip-to-publish.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{zip-to-publish.zip => zip-to-publish.yml} (100%) diff --git a/.github/workflows/zip-to-publish.zip b/.github/workflows/zip-to-publish.yml similarity index 100% rename from .github/workflows/zip-to-publish.zip rename to .github/workflows/zip-to-publish.yml From 3bc46f0c3804c3a399b3023598445b819e665af0 Mon Sep 17 00:00:00 2001 From: Swapnil Devesh Date: Fri, 26 Apr 2024 21:39:37 +0530 Subject: [PATCH 11/16] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index af1232f..6c03424 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,7 @@ upgrade supported version in metadata.json by @7HE-W0R1D (https://github.com/har and fix for No signal error by @Yanndroid (https://github.com/harshadgavali/gnome-gesture-improvements/issues/206#issuecomment-2026336600) There is still the issue of pinch gestures not working that needs to be fixed. +And also application gestures not working. ## Installation ### Manually From 08bad77936ef62364be43bb610a4b3517966e43b Mon Sep 17 00:00:00 2001 From: thyttan <97237430+thyttan@users.noreply.github.com> Date: Wed, 26 Jun 2024 11:19:21 +0200 Subject: [PATCH 12/16] README.md add thanks to @harshadgavali --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6c03424..0a5c1fb 100644 --- a/README.md +++ b/README.md @@ -5,9 +5,10 @@ This extension modifies and extends existing touchpad gestures on GNOME. This repository contains the seemingly unmaintaned extension's transpiled to JS version with some fixes to get it to work on GNOME 46, along with some additions which were previously raised as PR on the original project repo by me but never merged. -Credit goes to @jaophi to for getting the transpiled version to work (https://github.com/harshadgavali/gnome-gesture-improvements/issues/206#issuecomment-1782750156) +Credit goes to @jaophi to for getting the transpiled version to work (https://github.com/harshadgavali/gnome-gesture-improvements/issues/206#issuecomment-1782750156), upgrade supported version in metadata.json by @7HE-W0R1D (https://github.com/harshadgavali/gnome-gesture-improvements/issues/206#issuecomment-2023405620) -and fix for No signal error by @Yanndroid (https://github.com/harshadgavali/gnome-gesture-improvements/issues/206#issuecomment-2026336600) +and fix for No signal error by @Yanndroid (https://github.com/harshadgavali/gnome-gesture-improvements/issues/206#issuecomment-2026336600). +And thanks to @harshadgavali for creating [Gesture Improvements](https://github.com/harshadgavali/gnome-gesture-improvements) in the first place! There is still the issue of pinch gestures not working that needs to be fixed. And also application gestures not working. From 965e6ec51654ba5fe8e94fc6120c42ff2c01b30a Mon Sep 17 00:00:00 2001 From: Flynn Duniho Date: Thu, 19 Sep 2024 16:59:46 -0400 Subject: [PATCH 13/16] Update shell version to 47 --- gestureImprovements@gestures/metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gestureImprovements@gestures/metadata.json b/gestureImprovements@gestures/metadata.json index 2de732b..02ae3a0 100644 --- a/gestureImprovements@gestures/metadata.json +++ b/gestureImprovements@gestures/metadata.json @@ -4,7 +4,7 @@ "name": "Gesture Improvements", "settings-schema": "org.gnome.shell.extensions.gestureImprovements", "shell-version": [ - "46" + "47" ], "url": "https://github.com/harshadgavali/gnome-gesture-improvements", "uuid": "gestureImprovements@gestures", From a946cf7f42bc0087b8de3720b059cb91808cef71 Mon Sep 17 00:00:00 2001 From: Flynn Duniho Date: Thu, 19 Sep 2024 17:13:05 -0400 Subject: [PATCH 14/16] Keep old 46 version too --- gestureImprovements@gestures/metadata.json | 1 + 1 file changed, 1 insertion(+) diff --git a/gestureImprovements@gestures/metadata.json b/gestureImprovements@gestures/metadata.json index 02ae3a0..bc4a2de 100644 --- a/gestureImprovements@gestures/metadata.json +++ b/gestureImprovements@gestures/metadata.json @@ -4,6 +4,7 @@ "name": "Gesture Improvements", "settings-schema": "org.gnome.shell.extensions.gestureImprovements", "shell-version": [ + "46", "47" ], "url": "https://github.com/harshadgavali/gnome-gesture-improvements", From 8484fb293a9a8e596526154d71ad5a34111d0b32 Mon Sep 17 00:00:00 2001 From: Swapnil Devesh Date: Sat, 21 Sep 2024 15:46:53 +0530 Subject: [PATCH 15/16] Update metadata.json --- gestureImprovements@gestures/metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gestureImprovements@gestures/metadata.json b/gestureImprovements@gestures/metadata.json index bc4a2de..95c9dd3 100644 --- a/gestureImprovements@gestures/metadata.json +++ b/gestureImprovements@gestures/metadata.json @@ -9,5 +9,5 @@ ], "url": "https://github.com/harshadgavali/gnome-gesture-improvements", "uuid": "gestureImprovements@gestures", - "version": 30 + "version": 31 } From 9745ad761b4edf0471a0840a74e608ce6145515e Mon Sep 17 00:00:00 2001 From: thyttan <97237430+thyttan@users.noreply.github.com> Date: Sun, 22 Sep 2024 11:49:15 +0200 Subject: [PATCH 16/16] Add license GPL 3.0 To comply with the licence associated with the original Gnome Gesture Improvements extension https://github.com/harshadgavali/gnome-gesture-improvements . --- LICENSE | 674 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 674 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..f288702 --- /dev/null +++ b/LICENSE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +.