From ef39f324cd3a739abf5f32381232ddc894b71cf4 Mon Sep 17 00:00:00 2001 From: Robert Mader Date: Sat, 1 Sep 2018 14:24:38 +0200 Subject: [PATCH 1/2] Fix switch workplace for gnome-shell <= 3.28 73f4846faea72a4d92ba59bbc2ad63e5ed41e608 broke support for older versions. This makes it work in both cases. Fixes #51 Additionally: - makes the fix work for the new explicit up and down switch actions - some indentation cleanup --- .../extension.js | 34 +++++++++++++------ 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/extendedgestures@mpiannucci.github.com/extension.js b/extendedgestures@mpiannucci.github.com/extension.js index b6e8d2f..38ed1fa 100644 --- a/extendedgestures@mpiannucci.github.com/extension.js +++ b/extendedgestures@mpiannucci.github.com/extension.js @@ -1,9 +1,11 @@ const Clutter = imports.gi.Clutter; +const Config = imports.misc.config; const Lang = imports.lang; const Main = imports.ui.main; const Meta = imports.gi.Meta; const Shell = imports.gi.Shell; const Signals = imports.signals; +const Utils = imports.misc.extensionUtils; const Gettext = imports.gettext.domain('extendedgestures'); const _ = Gettext.gettext; @@ -16,6 +18,9 @@ let gestureHandler = null; // Our settings let schema = null; +// Compatability settings +let versionSmaller330 = Utils.versionCheck(["3.26", "3.28"], Config.PACKAGE_VERSION); + function init() { schema = Convenience.getSettings(); } @@ -120,8 +125,8 @@ const TouchpadGestureAction = new Lang.Class({ Main.wm._switchApp(); break; case 2: - Main.overview.toggle(); - if (Main.overview._shown) + Main.overview.toggle(); + if (Main.overview._shown) Main.overview.viewSelector._toggleAppsPage(); break; case 3: @@ -130,16 +135,13 @@ const TouchpadGestureAction = new Lang.Class({ } else if (dir == Meta.MotionDirection.RIGHT) { dir = Meta.MotionDirection.DOWN; } - if (!Main.wm._switchData) { - let workspaceManager = global.workspace_manager; - let activeWorkspace = workspaceManager.get_active_workspace(); - Main.wm._prepareWorkspaceSwitch(activeWorkspace.index(), -1); - } - Main.wm._actionSwitchWorkspace(sender, dir); + this._switchWorkspace(sender, dir); break; case 4: const minimizedWindows = []; - const activeWorkspace = global.screen.get_active_workspace(); + // gnome-shell >= 3.30 use workspace_manager instead of screen + const activeWorkspace = versionSmaller330? + global.screen.get_active_workspace():global.workspace_manager.get_active_workspace(); // loop through workspace windows Main.layoutManager._getWindowActorsForWorkspace(activeWorkspace).forEach( windowActor => { const metaWindow = windowActor.get_meta_window(); @@ -160,16 +162,26 @@ const TouchpadGestureAction = new Lang.Class({ // Nothing break; case 6: - Main.wm._actionSwitchWorkspace(sender, Meta.MotionDirection.UP); + this._switchWorkspace(sender, Meta.MotionDirection.UP); break; case 7: - Main.wm._actionSwitchWorkspace(sender, Meta.MotionDirection.DOWN); + this._switchWorkspace(sender, Meta.MotionDirection.DOWN); break; default: break; } }, + _switchWorkspace: function (sender, dir) { + // fix for gnome-shell >= 3.30 + if (!versionSmaller330) { + let workspaceManager = global.workspace_manager; + let activeWorkspace = workspaceManager.get_active_workspace(); + Main.wm._prepareWorkspaceSwitch(activeWorkspace.index(), -1); + } + Main.wm._actionSwitchWorkspace(sender, dir); + }, + _checkSwipeValid: function (dir, fingerCount, motion) { const MOTION_THRESHOLD = 50; From 8a4302b7072b552da95c2ca462348500a477ad1c Mon Sep 17 00:00:00 2001 From: Robert Mader Date: Sat, 1 Sep 2018 14:31:48 +0200 Subject: [PATCH 2/2] advertise support for gnome-shell version 3.28 and 3.30 --- extendedgestures@mpiannucci.github.com/metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extendedgestures@mpiannucci.github.com/metadata.json b/extendedgestures@mpiannucci.github.com/metadata.json index 24e6cb9..3e0294b 100644 --- a/extendedgestures@mpiannucci.github.com/metadata.json +++ b/extendedgestures@mpiannucci.github.com/metadata.json @@ -3,7 +3,7 @@ "description": "Adds more touchpad gestures into gnome-shell", "url": "https://github.com/mpiannucci/gnome-shell-extended-gestures", "uuid": "extendedgestures@mpiannucci.github.com", - "shell-version": ["3.26"], + "shell-version": ["3.26", "3.28", "3.30"], "settings-schema": "org.gnome.shell.extensions.extendedgestures", "gettext-domain": "extendedgestures" }