mirror of
https://github.com/esjeon/krohnkite.git
synced 2024-10-03 23:07:13 +03:00
moving floating windows w/ shortcut (#41)
Allow moving floating windows with swap shortcuts.
This commit is contained in:
parent
f7e047c421
commit
ad25afb88f
@ -199,10 +199,10 @@ class TilingController {
|
||||
case Shortcut.ShiftUp : if (window) this.engine.swapOrder(window, -1); break;
|
||||
case Shortcut.ShiftDown: if (window) this.engine.swapOrder(window, +1); break;
|
||||
|
||||
case Shortcut.SwapUp : this.engine.swapDirection(ctx, "up"); break;
|
||||
case Shortcut.SwapDown : this.engine.swapDirection(ctx, "down"); break;
|
||||
case Shortcut.SwapLeft : this.engine.swapDirection(ctx, "left"); break;
|
||||
case Shortcut.SwapRight: this.engine.swapDirection(ctx, "right"); break;
|
||||
case Shortcut.SwapUp : this.engine.swapDirOrMoveFloat(ctx, "up"); break;
|
||||
case Shortcut.SwapDown : this.engine.swapDirOrMoveFloat(ctx, "down"); break;
|
||||
case Shortcut.SwapLeft : this.engine.swapDirOrMoveFloat(ctx, "left"); break;
|
||||
case Shortcut.SwapRight: this.engine.swapDirOrMoveFloat(ctx, "right"); break;
|
||||
|
||||
case Shortcut.SetMaster : if (window) this.engine.setMaster(window); break;
|
||||
case Shortcut.ToggleFloat: if (window) this.engine.toggleFloat(window); break;
|
||||
|
@ -315,6 +315,44 @@ class TilingEngine {
|
||||
this.windows.swap(window, neighbor);
|
||||
}
|
||||
|
||||
/**
|
||||
* Move the given window towards the given direction by one step.
|
||||
* @param window a floating window
|
||||
* @param dir which direction
|
||||
*/
|
||||
public moveFloat(window: Window, dir: Direction) {
|
||||
const srf = window.surface;
|
||||
|
||||
// TODO: configurable step size?
|
||||
const hStepSize = srf.workingArea.width * 0.05;
|
||||
const vStepSize = srf.workingArea.height * 0.05;
|
||||
|
||||
let hStep, vStep;
|
||||
switch (dir) {
|
||||
case "up" : hStep = 0, vStep = -1; break;
|
||||
case "down" : hStep = 0, vStep = 1; break;
|
||||
case "left" : hStep = -1, vStep = 0; break;
|
||||
case "right": hStep = 1, vStep = 0; break;
|
||||
}
|
||||
|
||||
const geometry = window.actualGeometry;
|
||||
const x = geometry.x + hStepSize * hStep;
|
||||
const y = geometry.y + vStepSize * vStep;
|
||||
|
||||
window.forceSetGeometry(new Rect(x, y, geometry.width, geometry.height));
|
||||
}
|
||||
|
||||
public swapDirOrMoveFloat(ctx: IDriverContext, dir: Direction) {
|
||||
const window = ctx.currentWindow;
|
||||
if (!window) return;
|
||||
|
||||
const state = window.state;
|
||||
if (Window.isFloatingState(state))
|
||||
this.moveFloat(window, dir);
|
||||
else if (Window.isTiledState(state))
|
||||
this.swapDirection(ctx, dir);
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle float mode of window.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user