Record overrides in the actionIdMap

This means we can get rid of more cases in the ugly switch in navigator.
This commit is contained in:
Tor Hedin Brønner
2018-07-15 20:41:38 +02:00
parent 1590138a65
commit c356f40f6c
2 changed files with 9 additions and 16 deletions
+9 -1
View File
@@ -272,12 +272,18 @@ function setKeybinding(name, func) {
Main.wm.setCustomKeybindingHandler(name, Shell.ActionMode.NORMAL, func);
}
function overrideAction(mutterName, action) {
setKeybinding(mutterName, action.keyHandler);
let id = Meta.prefs_get_keybinding_action(mutterName);
actionIdMap[id] = action;
}
function resolveConflicts() {
resetConflicts();
for (let conflict of Settings.findConflicts()) {
let {name, conflicts} = conflict;
let action = byMutterName(name);
conflicts.forEach(c => setKeybinding(c, action.handler));
conflicts.forEach(c => overrideAction(c, action));
overrides.push(conflict);
}
}
@@ -285,6 +291,8 @@ function resolveConflicts() {
function resetConflicts() {
let names = overrides.reduce((sum, add) => sum.concat(add.conflicts), []);
for (let name of names) {
let id = Meta.prefs_get_keybinding_action(name);
delete actionIdMap[id];
// Bultin mutter actions can be reset by setting their custom handler to
// null. However gnome-shell often sets a custom handler of its own,
// which means we most often can't rely on that
-15
View File
@@ -232,21 +232,6 @@ var PreviewedWindowNavigator = new Lang.Class({
case Meta.KeyBindingAction.WORKSPACE_DOWN: // PageDown
mutterActionId = Keybindings.idOf('previous-workspace');
break;
case Meta.KeyBindingAction.TOGGLE_TILED_RIGHT: // Right
mutterActionId = Keybindings.idOf('switch-right');
break;
case Meta.KeyBindingAction.TOGGLE_TILED_LEFT: // Left
mutterActionId = Keybindings.idOf('switch-left');
break;
case Meta.KeyBindingAction.MAXIMIZE: // Up
mutterActionId = Keybindings.idOf('switch-up');
break;
case Meta.KeyBindingAction.UNMAXIMIZE: // Down
mutterActionId = Keybindings.idOf('switch-down');
break;
case Meta.KeyBindingAction.CLOSE:
mutterActionId = Keybindings.idOf('close-window');
break;
}
if (mutterActionId