mirror of
https://github.com/zoriya/fairy.git
synced 2026-06-03 03:01:21 +00:00
Add swap keybinds
This commit is contained in:
+34
-13
@@ -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");
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user