Skip to content

Commit

Permalink
Merge pull request #87 from dmo60/gnome-shell-3.30
Browse files Browse the repository at this point in the history
Update for gnome shell 3.30
  • Loading branch information
p91paul authored Sep 18, 2018
2 parents edf440f + cc0d35f commit 9632122
Show file tree
Hide file tree
Showing 7 changed files with 142 additions and 108 deletions.
50 changes: 25 additions & 25 deletions [email protected]/coverflowSwitcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const PREVIEW_SCALE = 0.5;
function appendParams(base, extra) {
for (let key in extra) { base[key] = extra[key]; }
}

function Switcher() {
this._init.apply(this, arguments);
}
Expand All @@ -59,13 +59,13 @@ Switcher.prototype = {

_createPreviews: function() {
let monitor = this._activeMonitor;
let currentWorkspace = global.screen.get_active_workspace();
let currentWorkspace = this._manager.workspace_manager.get_active_workspace();

this._yOffset = monitor.height / 2 - this._settings.offset;
this._xOffsetLeft = monitor.width * 0.1;
this._xOffsetRight = monitor.width - this._xOffsetLeft;
this._xOffsetCenter = monitor.width / 2;

this._previews = [];
for (let i in this._windows) {
let metaWin = this._windows[i];
Expand Down Expand Up @@ -120,22 +120,22 @@ Switcher.prototype = {
this._updatePreviews(-1);
}
},

_flipStack: function(gravity) {
this._looping = true;

let xOffset, angle;

if(gravity == Clutter.Gravity.WEST) {
xOffset = -this._xOffsetLeft;
angle = BLEND_OUT_ANGLE;
} else {
xOffset = this._activeMonitor.width + this._xOffsetLeft;
angle = -BLEND_OUT_ANGLE;
}

let animation_time = this._settings.animation_time * 2/3;

for (let i in this._previews) {
let preview = this._previews[i];
preview._cfIsLast = (i == this._windows.length-1);
Expand All @@ -150,10 +150,10 @@ Switcher.prototype = {
});
}
},

_onFlipIn: function(preview, index, gravity) {
let xOffsetStart, xOffsetEnd, angleStart, angleEnd;

if(gravity == Clutter.Gravity.WEST) {
xOffsetStart = this._activeMonitor.width + this._xOffsetLeft;
xOffsetEnd = this._xOffsetRight;
Expand All @@ -165,9 +165,9 @@ Switcher.prototype = {
angleStart = BLEND_OUT_ANGLE;
angleEnd = SIDE_ANGLE;
}

let animation_time = this._settings.animation_time * 2/3;

preview.rotation_angle_y = angleStart;
preview.x = xOffsetStart + 50 * (index - this._currentIndex);
let lastExtraParams = {
Expand All @@ -176,7 +176,7 @@ Switcher.prototype = {
onCompleteScope: this
};
let oppositeGravity = (gravity == Clutter.Gravity.WEST) ? Clutter.Gravity.EAST : Clutter.Gravity.WEST;

if (index == this._currentIndex) {
preview.raise_top();
let extraParams = preview._cfIsLast ? lastExtraParams : null;
Expand All @@ -186,28 +186,28 @@ Switcher.prototype = {
preview.raise_top();
else
preview.lower_bottom();

let extraParams = {
opacity: 255,
rotation_angle_y: angleEnd,
time: animation_time,
transition: TRANSITION_TYPE
};

if (preview._cfIsLast)
appendParams(extraParams, lastExtraParams);
this._animatePreviewToSide(preview, index, oppositeGravity, xOffsetEnd, extraParams);
}
},

_onFlipComplete: function() {
this._looping = false;
if(this._requiresUpdate == true) {
this._requiresUpdate = false;
this._updatePreviews();
}
},

_animatePreviewToMid: function(preview, oldGravity, animation_time, extraParams) {
let rotation_vertex_x = (oldGravity == Clutter.Gravity.EAST) ? preview.width / 2 : -preview.width / 2;
preview.move_anchor_point_from_gravity(Clutter.Gravity.CENTER);
Expand All @@ -223,13 +223,13 @@ Switcher.prototype = {
time: animation_time,
transition: TRANSITION_TYPE
};

if(extraParams)
appendParams(tweenParams, extraParams);

Tweener.addTween(preview, tweenParams);
},

_animatePreviewToSide: function(preview, index, gravity, xOffset, extraParams) {
preview.move_anchor_point_from_gravity(gravity);
preview.rotation_center_y = new Clutter.Vertex({ x: 0.0, y: 0.0, z: 0.0 });
Expand All @@ -240,9 +240,9 @@ Switcher.prototype = {
width: Math.max(preview.target_width_side * (10 - Math.abs(index - this._currentIndex)) / 10, 0),
height: Math.max(preview.target_height_side * (10 - Math.abs(index - this._currentIndex)) / 10, 0),
};

appendParams(tweenParams, extraParams);

Tweener.addTween(preview, tweenParams);
},

Expand All @@ -251,10 +251,10 @@ Switcher.prototype = {
this._requiresUpdate = true;
return;
}

let monitor = this._activeMonitor;
let animation_time = this._settings.animation_time;

// preview windows
for (let i in this._previews) {
let preview = this._previews[i];
Expand Down
5 changes: 4 additions & 1 deletion [email protected]/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ function enable() {
platform = new Platform.PlatformCinnamon18();
keybinder = HAS_META_KEYBIND_API ? new Keybinder.KeybinderNewApi() : new Keybinder.KeybinderOldApi();
} else {
if(parseInt(PACKAGE_VERSION.split(".")[1]) >= 21 && PACKAGE_VERSION >= "3.21.0") {
if(parseInt(PACKAGE_VERSION.split(".")[1]) >= 30 && PACKAGE_VERSION >= "3.30.0") {
platform = new Platform.PlatformGnomeShell314();
keybinder = new Keybinder.Keybinder330Api();
} else if(parseInt(PACKAGE_VERSION.split(".")[1]) >= 21 && PACKAGE_VERSION >= "3.21.0") {
platform = new Platform.PlatformGnomeShell314();
keybinder = new Keybinder.Keybinder322Api();
} else if(parseInt(PACKAGE_VERSION.split(".")[1]) >= 14 && PACKAGE_VERSION >= "3.14.0") {
Expand Down
76 changes: 48 additions & 28 deletions [email protected]/keybinder.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,43 @@ AbstractKeybinder.prototype = {
}
}


function Keybinder330Api() {
this._init();
}

Keybinder330Api.prototype = {
__proto__: AbstractKeybinder.prototype,

_init: function() {
AbstractKeybinder.prototype._init.call(this);
},

enable: function(startAppSwitcherBind) {
let Shell = imports.gi.Shell;
let mode = Shell.ActionMode ? Shell.ActionMode : Shell.KeyBindingMode;
Main.wm.setCustomKeybindingHandler('switch-applications', mode.NORMAL, startAppSwitcherBind);
Main.wm.setCustomKeybindingHandler('switch-windows', mode.NORMAL, startAppSwitcherBind);
Main.wm.setCustomKeybindingHandler('switch-group', mode.NORMAL, startAppSwitcherBind);
Main.wm.setCustomKeybindingHandler('switch-panels', mode.NORMAL, startAppSwitcherBind);
Main.wm.setCustomKeybindingHandler('switch-applications-backward', mode.NORMAL, startAppSwitcherBind);
Main.wm.setCustomKeybindingHandler('switch-windows-backward', mode.NORMAL, startAppSwitcherBind);
Main.wm.setCustomKeybindingHandler('switch-group-backward', mode.NORMAL, startAppSwitcherBind);
},

disable: function() {
let Shell = imports.gi.Shell;
let mode = Shell.ActionMode ? Shell.ActionMode : Shell.KeyBindingMode;
Main.wm.setCustomKeybindingHandler('switch-applications', mode.NORMAL, Lang.bind(Main.wm, Main.wm._startSwitcher));
Main.wm.setCustomKeybindingHandler('switch-windows', mode.NORMAL, Lang.bind(Main.wm, Main.wm._startSwitcher));
Main.wm.setCustomKeybindingHandler('switch-group', mode.NORMAL, Lang.bind(Main.wm, Main.wm._startSwitcher));
Main.wm.setCustomKeybindingHandler('switch-panels', mode.NORMAL, Lang.bind(Main.wm, Main.wm._startA11ySwitcher));
Main.wm.setCustomKeybindingHandler('switch-applications-backward', mode.NORMAL, Lang.bind(Main.wm, Main.wm._startSwitcher));
Main.wm.setCustomKeybindingHandler('switch-windows-backward', mode.NORMAL, Lang.bind(Main.wm, Main.wm._startSwitcher));
Main.wm.setCustomKeybindingHandler('switch-group-backward', mode.NORMAL, Lang.bind(Main.wm, Main.wm._startSwitcher));
}
};

function KeybinderNewApi() {
this._init();
}
Expand Down Expand Up @@ -82,11 +119,11 @@ function KeybinderNewGSApi() {

KeybinderNewGSApi.prototype = {
__proto__: AbstractKeybinder.prototype,

_init: function() {
AbstractKeybinder.prototype._init.call(this);
},

enable: function(startAppSwitcherBind) {
let Shell = imports.gi.Shell;
let mode = Shell.ActionMode ? Shell.ActionMode : Shell.KeyBindingMode;
Expand All @@ -101,7 +138,7 @@ KeybinderNewGSApi.prototype = {

disable: function() {
let Shell = imports.gi.Shell;
let mode = Shell.ActionMode ? Shell.ActionMode : Shell.KeyBindingMode;
let mode = Shell.ActionMode ? Shell.ActionMode : Shell.KeyBindingMode;
Main.wm.setCustomKeybindingHandler('switch-applications', mode.NORMAL, Lang.bind(Main.wm, Main.wm._startAppSwitcher));
Main.wm.setCustomKeybindingHandler('switch-windows', mode.NORMAL, Lang.bind(Main.wm, Main.wm._startWindowSwitcher));
Main.wm.setCustomKeybindingHandler('switch-group', mode.NORMAL, Lang.bind(Main.wm, Main.wm._startAppSwitcher));
Expand All @@ -118,34 +155,17 @@ function Keybinder322Api() {
}

Keybinder322Api.prototype = {
__proto__: AbstractKeybinder.prototype,
__proto__: Keybinder330Api.prototype,

_init: function() {
AbstractKeybinder.prototype._init.call(this);
},

enable: function(startAppSwitcherBind) {
let Shell = imports.gi.Shell;
let mode = Shell.ActionMode ? Shell.ActionMode : Shell.KeyBindingMode;
Main.wm.setCustomKeybindingHandler('switch-applications', mode.NORMAL, startAppSwitcherBind);
Main.wm.setCustomKeybindingHandler('switch-windows', mode.NORMAL, startAppSwitcherBind);
Main.wm.setCustomKeybindingHandler('switch-group', mode.NORMAL, startAppSwitcherBind);
Main.wm.setCustomKeybindingHandler('switch-panels', mode.NORMAL, startAppSwitcherBind);
Main.wm.setCustomKeybindingHandler('switch-applications-backward', mode.NORMAL, startAppSwitcherBind);
Main.wm.setCustomKeybindingHandler('switch-windows-backward', mode.NORMAL, startAppSwitcherBind);
Main.wm.setCustomKeybindingHandler('switch-group-backward', mode.NORMAL, startAppSwitcherBind);
Keybinder330Api.prototype._init.call(this);
},

disable: function() {
let Shell = imports.gi.Shell;
let mode = Shell.ActionMode ? Shell.ActionMode : Shell.KeyBindingMode;
Main.wm.setCustomKeybindingHandler('switch-applications', mode.NORMAL, Lang.bind(Main.wm, Main.wm._startSwitcher));
Main.wm.setCustomKeybindingHandler('switch-windows', mode.NORMAL, Lang.bind(Main.wm, Main.wm._startSwitcher));
Main.wm.setCustomKeybindingHandler('switch-group', mode.NORMAL, Lang.bind(Main.wm, Main.wm._startSwitcher));
Main.wm.setCustomKeybindingHandler('switch-panels', mode.NORMAL, Lang.bind(Main.wm, Main.wm._startA11ySwitcher));
Main.wm.setCustomKeybindingHandler('switch-applications-backward', mode.NORMAL, Lang.bind(Main.wm, Main.wm._startSwitcher));
Main.wm.setCustomKeybindingHandler('switch-windows-backward', mode.NORMAL, Lang.bind(Main.wm, Main.wm._startSwitcher));
Main.wm.setCustomKeybindingHandler('switch-group-backward', mode.NORMAL, Lang.bind(Main.wm, Main.wm._startSwitcher));
enable: function(startAppSwitcherBind330) {
let startAppSwitcherBind = function(display, screen, window, binding) {
startAppSwitcherBind330(display, window, binding);
}
Keybinder330Api.prototype.enable.call(this, startAppSwitcherBind);
}
};

Expand Down
14 changes: 12 additions & 2 deletions [email protected]/manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,16 @@ Manager.prototype = {
_init: function(platform, keybinder) {
this.platform = platform;
this.keybinder = keybinder;

if (global.workspace_manager && global.workspace_manager.get_active_workspace)
this.workspace_manager = global.workspace_manager;
else
this.workspace_manager = global.screen;

if (global.display && global.display.get_n_monitors)
this.display = global.display;
else
this.display = global.screen;
},

enable: function() {
Expand All @@ -75,9 +85,9 @@ Manager.prototype = {
win.delete(global.get_current_time());
},

_startWindowSwitcher: function(display, screen, window, binding) {
_startWindowSwitcher: function(display, window, binding) {
let windows = [];
let currentWorkspace = screen.get_active_workspace();
let currentWorkspace = this.workspace_manager.get_active_workspace();

// Construct a list with all windows
let windowActors = global.get_window_actors();
Expand Down
57 changes: 29 additions & 28 deletions [email protected]/metadata.json
Original file line number Diff line number Diff line change
@@ -1,38 +1,39 @@
{
"description": "Replacement of Alt-Tab, iterates through windows in a cover-flow manner.",
"description": "Replacement of Alt-Tab, iterates through windows in a cover-flow manner.",
"cinnamon-version": [
"1.2",
"1.4",
"1.6",
"1.8",
"1.9",
"2.0",
"2.1",
"2.2",
"2.3",
"2.4",
"2.8",
"1.2",
"1.4",
"1.6",
"1.8",
"1.9",
"2.0",
"2.1",
"2.2",
"2.3",
"2.4",
"2.8",
"3.0",
"3.2"
],
"3.2"
],
"shell-version": [
"3.4",
"3.6",
"3.8",
"3.10",
"3.12",
"3.14",
"3.16",
"3.18",
"3.20",
"3.4",
"3.6",
"3.8",
"3.10",
"3.12",
"3.14",
"3.16",
"3.18",
"3.20",
"3.22",
"3.23",
"3.24",
"3.26",
"3.28"
],
"dangerous": false,
"name": "Coverflow Alt-Tab",
"url": "https://github.com/dmo60/CoverflowAltTab",
"3.28",
"3.30"
],
"dangerous": false,
"name": "Coverflow Alt-Tab",
"url": "https://github.com/dmo60/CoverflowAltTab",
"uuid": "[email protected]"
}
Loading

0 comments on commit 9632122

Please sign in to comment.