After replacing Lang.Class with ES6 classes and adopting arrow notation for anonymous callbacks, we only use the Lang module to bind `this` to named callbacks. However since ES5, this functionality is already provided by Function.prototype.bind() - in fact, Lang.bind() itself uses it when no extra arguments are specified. So just use the built-in function directly instead of the wrapper. Fixes https://gitlab.gnome.org/GNOME/gnome-shell-extensions/issues/30
63 lines
2.1 KiB
JavaScript
63 lines
2.1 KiB
JavaScript
/* -*- mode: js; js-basic-offset: 4; indent-tabs-mode: nil -*- */
|
|
|
|
const Clutter = imports.gi.Clutter;
|
|
const Meta = imports.gi.Meta;
|
|
const Shell = imports.gi.Shell;
|
|
|
|
const AltTab = imports.ui.altTab;
|
|
const Main = imports.ui.main;
|
|
const WindowManager = imports.ui.windowManager;
|
|
|
|
let injections = {};
|
|
|
|
function init(metadata) {
|
|
}
|
|
|
|
function setKeybinding(name, func) {
|
|
Main.wm.setCustomKeybindingHandler(name, Shell.ActionMode.NORMAL, func);
|
|
}
|
|
|
|
function enable() {
|
|
injections['_keyPressHandler'] = AltTab.WindowSwitcherPopup.prototype._keyPressHandler;
|
|
AltTab.WindowSwitcherPopup.prototype._keyPressHandler = function(keysym, action) {
|
|
switch(action) {
|
|
case Meta.KeyBindingAction.SWITCH_APPLICATIONS:
|
|
action = Meta.KeyBindingAction.SWITCH_WINDOWS;
|
|
break;
|
|
case Meta.KeyBindingAction.SWITCH_APPLICATIONS_BACKWARD:
|
|
action = Meta.KeyBindingAction.SWITCH_WINDOWS_BACKWARD;
|
|
break;
|
|
}
|
|
return injections['_keyPressHandler'].call(this, keysym, action);
|
|
};
|
|
|
|
Main.wm._forcedWindowSwitcher = function(display, screen, window, binding) {
|
|
/* prevent a corner case where both popups show up at once */
|
|
if (this._workspaceSwitcherPopup != null)
|
|
this._workspaceSwitcherPopup.destroy();
|
|
|
|
let tabPopup = new AltTab.WindowSwitcherPopup();
|
|
|
|
if (!tabPopup.show(binding.is_reversed(), binding.get_name(), binding.get_mask()))
|
|
tabPopup.destroy();
|
|
};
|
|
|
|
setKeybinding('switch-applications',
|
|
Main.wm._forcedWindowSwitcher.bind(Main.wm));
|
|
setKeybinding('switch-applications-backward',
|
|
Main.wm._forcedWindowSwitcher.bind(Main.wm));
|
|
}
|
|
|
|
function disable() {
|
|
var prop;
|
|
|
|
setKeybinding('switch-applications',
|
|
Main.wm._startSwitcher.bind(Main.wm));
|
|
setKeybinding('switch-applications-backward',
|
|
Main.wm._startSwitcher.bind(Main.wm));
|
|
|
|
for (prop in injections)
|
|
AltTab.WindowSwitcherPopup.prototype[prop] = injections[prop];
|
|
delete Main.wm._forcedWindowSwitcher;
|
|
}
|