0cdae2dae0
The original extension author really hated the app switcher with a passion and took over all its uses, but there's really no reason to replace the 'switch-group' shortcuts - not least because the window switcher doesn't implement switching between windows of a single application. So just keep the extension to making the 'switch-application' shortcuts behave as 'switch-windows' for the "classic" session (and all users who rather install an extension than change shortcut settings). https://bugzilla.gnome.org/show_bug.cgi?id=771531
60 lines
2.0 KiB
JavaScript
60 lines
2.0 KiB
JavaScript
/* -*- mode: js; js-basic-offset: 4; indent-tabs-mode: nil -*- */
|
|
|
|
const Clutter = imports.gi.Clutter;
|
|
const Lang = imports.lang;
|
|
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', Lang.bind(Main.wm, Main.wm._forcedWindowSwitcher));
|
|
setKeybinding('switch-applications-backward', Lang.bind(Main.wm, Main.wm._forcedWindowSwitcher));
|
|
}
|
|
|
|
function disable() {
|
|
var prop;
|
|
|
|
setKeybinding('switch-applications', Lang.bind(Main.wm, Main.wm._startSwitcher));
|
|
setKeybinding('switch-applications-backward', Lang.bind(Main.wm, Main.wm._startSwitcher));
|
|
|
|
for (prop in injections)
|
|
AltTab.WindowSwitcherPopup.prototype[prop] = injections[prop];
|
|
delete Main.wm._forcedWindowSwitcher;
|
|
}
|