Add swap keybinds

This commit is contained in:
2023-05-14 00:27:44 +09:00
parent 46d1296d2a
commit 91d9741744
4 changed files with 82 additions and 24 deletions
+34 -13
View File
@@ -58,30 +58,20 @@ var KeyboardManager = GObject.registerClass(
this._switchLayout("floating")
);
this._addBinding("cycle-next", () => {
this._addBinding("cycle-prev", () => {
const mon = global.display.get_current_monitor();
const state = this._state.monitors[mon];
const idx = this._state.workIndexByHandle(state.focused);
const newW = this._state.workIndex(mon, state.tags, idx + 1);
this._state.focus(newW.handle);
});
this._addBinding("cycle-prev", () => {
this._addBinding("cycle-next", () => {
const mon = global.display.get_current_monitor();
const state = this._state.monitors[mon];
const idx = this._state.workIndexByHandle(state.focused);
const win = this._state.workIndex(mon, state.tags, idx - 1);
this._state.focus(win.handle);
});
this._addBinding("zoom", () => {
const mon = global.display.get_current_monitor();
const state = this._state.monitors[mon];
const beforeZoom = state.focused;
if (this._state.workIndexByHandle(state.focused)) {
const win = this._state.workIndex(mon, state.tags, 0);
this._state.focus(win.handle);
} else this.state.focus(state.beforeZoom);
state.beforeZoom = beforeZoom;
});
this._addBinding("incrmfact", () => {
const mon = global.display.get_current_monitor();
@@ -107,6 +97,34 @@ var KeyboardManager = GObject.registerClass(
this._state.monitors[mon].nmaster -= 1;
this._renderer.render(mon);
});
this._addBinding("swap-prev", () => {
const mon = global.display.get_current_monitor();
const state = this._state.monitors[mon];
const idx = this._state.workIndexByHandle(state.focused);
this._state.swap(mon, state.tags, idx, idx + 1);
this._renderer.render(mon);
});
this._addBinding("swap-next", () => {
const mon = global.display.get_current_monitor();
const state = this._state.monitors[mon];
const idx = this._state.workIndexByHandle(state.focused);
this._state.swap(mon, state.tags, idx, idx - 1);
this._renderer.render(mon);
});
this._addBinding("zoom", () => {
const mon = global.display.get_current_monitor();
const state = this._state.monitors[mon];
const idx = this._state.workIndexByHandle(state.focused);
// if the master is not focused
if (idx !== 0)
this._state.swap(mon, state.tags, idx, 0)
else
this._state.swap(mon, state.tags, idx, state.beforeZoom);
state.beforeZoom = idx;
this._renderer.render(mon);
});
}
disable() {
@@ -116,12 +134,15 @@ var KeyboardManager = GObject.registerClass(
this._removeBinding("cycle-next");
this._removeBinding("cycle-prev");
this._removeBinding("zoom");
this._removeBinding("incrmfact");
this._removeBinding("decrmfact");
this._removeBinding("incrnmaster");
this._removeBinding("decrnmaster");
this._removeBinding("swap-next");
this._removeBinding("swap-prev");
this._removeBinding("zoom");
}
}
);