Skip to content

Commit

Permalink
Merge pull request #52 from treba123/master
Browse files Browse the repository at this point in the history
Fix switch workplace for gnome-shell <= 3.28
  • Loading branch information
mpiannucci committed Sep 5, 2018
2 parents 4bcbb5c + 8a4302b commit e8e00ac
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 12 deletions.
34 changes: 23 additions & 11 deletions 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;
Expand All @@ -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();
}
Expand Down Expand Up @@ -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:
Expand All @@ -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();
Expand All @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion extendedgestures@mpiannucci.github.com/metadata.json
Expand Up @@ -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"
}

0 comments on commit e8e00ac

Please sign in to comment.