mirror of
https://github.com/gosticks/PaperWM.git
synced 2026-10-04 19:46:53 +00:00
Use native mutter actions to override keybindings
This means that we won't kill keybindings on disable (which could be worked around) or crashes (which would be much harder to work around). NB: it's necessary to go into dconf and restore `switch-applications[-backward]`, `switch-group[-backward]` to get the keybindings working again.
This commit is contained in:
+33
-14
@@ -189,6 +189,10 @@ function restoreKeybindings() {
|
||||
}
|
||||
}
|
||||
|
||||
function setKeybinding(name, func) {
|
||||
Main.wm.setCustomKeybindingHandler(name, Shell.ActionMode.NORMAL, func);
|
||||
}
|
||||
|
||||
let nWorkspacesSignal;
|
||||
let workspaceRemovedSignal;
|
||||
let windowCreatedSignal;
|
||||
@@ -210,13 +214,21 @@ function enable() {
|
||||
settings.set_strv("maximize-horizontally", ['<super>f'])
|
||||
settings.set_strv("toggle-fullscreen", ['<super><shift>f']);
|
||||
|
||||
// We want to use
|
||||
killKeybinding('switch-applications', wmSettings);
|
||||
killKeybinding('switch-applications-backward', wmSettings);
|
||||
killKeybinding('switch-group', wmSettings);
|
||||
killKeybinding('switch-group-backward', wmSettings);
|
||||
// Super-n is used for new-window
|
||||
killKeybinding('focus-active-notification', shellSettings);
|
||||
setKeybinding('switch-applications',
|
||||
utils.dynamic_function_ref('liveAltTab',
|
||||
LiveAltTab));
|
||||
setKeybinding('switch-applications-backward',
|
||||
utils.dynamic_function_ref('liveAltTab',
|
||||
LiveAltTab));
|
||||
setKeybinding('switch-group',
|
||||
utils.dynamic_function_ref("preview_navigate",
|
||||
Navigator));
|
||||
setKeybinding('switch-group-backward',
|
||||
utils.dynamic_function_ref("preview_navigate",
|
||||
Navigator));
|
||||
|
||||
setKeybinding('focus-active-notification', // `<Super>N`
|
||||
utils.as_key_handler('newWindow', App));
|
||||
// Switched to '<super>escape' in 3.28
|
||||
killKeybinding('restore-shortcuts',
|
||||
new Gio.Settings({ schema_id: "org.gnome.mutter.wayland.keybindings"}));
|
||||
@@ -234,15 +246,22 @@ function disable() {
|
||||
debug("disable", SESSIONID);
|
||||
// Disconnect focus and reset scale and pivot
|
||||
|
||||
setKeybinding('switch-applications',
|
||||
Main.wm._startSwitcher.bind(Main.wm));
|
||||
setKeybinding('switch-applications-backward',
|
||||
Main.wm._startSwitcher.bind(Main.wm));
|
||||
setKeybinding('switch-group',
|
||||
Main.wm._startSwitcher.bind(Main.wm));
|
||||
setKeybinding('switch-group-backward',
|
||||
Main.wm._startSwitcher.bind(Main.wm));
|
||||
|
||||
Main.wm.setCustomKeybindingHandler('focus-active-notification',
|
||||
Shell.ActionMode.NORMAL |
|
||||
Shell.ActionMode.OVERVIEW,
|
||||
Main.messageTray._expandActiveNotification.bind(Main.messageTray));
|
||||
|
||||
modules.forEach(m => m.disable && m.disable());
|
||||
|
||||
// Restore default gnome bindings
|
||||
// restoreKeybindings(wmSettings);
|
||||
|
||||
// Kill our custom bindings
|
||||
// killKeybinding('live-alt-tab', paperSettings)
|
||||
// killKeybinding('live-alt-tab-backward', paperSettings)
|
||||
|
||||
enabled = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -213,6 +213,16 @@ var PreviewedWindowNavigator = new Lang.Class({
|
||||
|
||||
_doAction: function(mutterActionId) {
|
||||
let paperActions = Extension.imports.extension.paperActions;
|
||||
|
||||
switch (mutterActionId) {
|
||||
case Meta.KeyBindingAction.SWITCH_GROUP:
|
||||
mutterActionId = paperActions.idOf('previous-workspace');
|
||||
break;
|
||||
case Meta.KeyBindingAction.SWITCH_GROUP_BACKWARD:
|
||||
mutterActionId = paperActions.idOf('previous-workspace-backward');
|
||||
break;
|
||||
}
|
||||
|
||||
if (mutterActionId === paperActions.idOf("switch-next")) {
|
||||
this._select(this._next());
|
||||
return true;
|
||||
|
||||
Binary file not shown.
@@ -23,20 +23,20 @@
|
||||
</key>
|
||||
|
||||
<key type="as" name="live-alt-tab">
|
||||
<default><![CDATA[['<Super>Tab']]]></default>
|
||||
<default><![CDATA[[]]]></default>
|
||||
<summary>Switch to previously used window</summary>
|
||||
</key>
|
||||
<key type="as" name="live-alt-tab-backward">
|
||||
<default><![CDATA[['<Super><Shift>Tab']]]></default>
|
||||
<default><![CDATA[[]]]></default>
|
||||
<summary>Switch to previously used window, backward order</summary>
|
||||
</key>
|
||||
|
||||
<key type="as" name="previous-workspace">
|
||||
<default><![CDATA[['<Super>d', '<Super>Above_Tab']]]></default>
|
||||
<default><![CDATA[['<Super>d']]]></default>
|
||||
<summary>Switch to previously used workspace</summary>
|
||||
</key>
|
||||
<key type="as" name="previous-workspace-backward">
|
||||
<default><![CDATA[['<Super>u', '<Super><Shift>Above_Tab']]]></default>
|
||||
<default><![CDATA[['<Super>u']]]></default>
|
||||
<summary>Switch to the previously used workspace, backward order</summary>
|
||||
</key>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user