// SimpleDwindle
// KWin 6.8 - Minimal chronological Dwindle
-const VERSION = "0.4.0";
+const VERSION = "0.5.0";
// ------------------------------------------------------------
// Configuration
output: w.output,
desktop: desktop,
root: null,
- last: null
+ last: null,
+ rootWide: false
};
layouts.push(layout);
return true;
}
+// Keep alternating split directions after promoting a sibling.
function normalizeSplits(node, depth = 0) {
if (!node || node.window)
return;
node.vertical = (depth % 2 === 0);
-
normalizeSplits(node.first, depth + 1);
normalizeSplits(node.second, depth + 1);
}
// Geometry
// ------------------------------------------------------------
-function applyNode(node, rect) {
+function applyNode(node, rect, rootWide = false, isRoot = true) {
if (!node)
return;
if (node.window) {
const w = node.window;
+ // One tiled window: centered at two thirds of the work area.
+ if (isRoot) {
+ const width = rect.width * (2 / 3);
+ rect = {
+ x: rect.x + (rect.width - width) / 2,
+ y: rect.y,
+ width: width,
+ height: rect.height
+ };
+ }
+
// Fullscreen windows retain their tree position,
// but KWin controls their geometry.
if (w.fullScreen || w.minimized)
}
if (node.vertical) {
- const half = rect.width / 2;
+ const half = rect.width * (isRoot && rootWide ? 2 / 3 : 1 / 2);
applyNode(node.first, {
x: rect.x,
y: rect.y,
width: half,
height: rect.height
- });
+ }, rootWide, false);
applyNode(node.second, {
x: rect.x + half,
y: rect.y,
width: rect.width - half,
height: rect.height
- });
+ }, rootWide, false);
} else {
const half = rect.height / 2;
y: rect.y,
width: rect.width,
height: half
- });
+ }, rootWide, false);
applyNode(node.second, {
x: rect.x,
y: rect.y + half,
width: rect.width,
height: rect.height - half
- });
+ }, rootWide, false);
}
}
layout.desktop
);
- applyNode(layout.root, area);
+ applyNode(layout.root, area, layout.rootWide);
}
// ------------------------------------------------------------
// ------------------------------------------------------------
// Use tree-assigned rectangles, not asynchronous frameGeometry updates.
-function collectLeaves(node, rect, result) {
+function collectLeaves(node, rect, result, rootWide = false, isRoot = true) {
if (!node)
return;
}
if (node.vertical) {
- const half = rect.width / 2;
+ const half = rect.width * (isRoot && rootWide ? 2 / 3 : 1 / 2);
collectLeaves(node.first, {
x: rect.x, y: rect.y,
width: half, height: rect.height
- }, result);
+ }, result, rootWide, false);
collectLeaves(node.second, {
x: rect.x + half, y: rect.y,
width: rect.width - half, height: rect.height
- }, result);
+ }, result, rootWide, false);
} else {
const half = rect.height / 2;
collectLeaves(node.first, {
x: rect.x, y: rect.y,
width: rect.width, height: half
- }, result);
+ }, result, rootWide, false);
collectLeaves(node.second, {
x: rect.x, y: rect.y + half,
width: rect.width, height: rect.height - half
- }, result);
+ }, result, rootWide, false);
}
}
KWin.MaximizeArea, layout.output, layout.desktop
);
const leaves = [];
- collectLeaves(layout.root, area, leaves);
+ collectLeaves(layout.root, area, leaves, layout.rootWide);
const source = leaves.find(item => item.node.window === w);
if (!source)
toggleFloating
);
+registerShortcut(
+ "SimpleDwindleToggleRootRatio",
+ "SimpleDwindle: Toggle Root Split Ratio",
+ "Meta+Shift+R",
+ function () {
+ const w = workspace.activeWindow;
+ const layout = w ? findWindowLayout(w) : null;
+ if (!layout)
+ return;
+
+ layout.rootWide = !layout.rootWide;
+ arrange(layout);
+ log("ROOT RATIO: " + (layout.rootWide ? "66.7:33.3" : "50:50"));
+ }
+);
+
registerShortcut("SimpleDwindleSwapLeft", "SimpleDwindle: Swap Left", "Meta+Shift+H", function() { swapDirection("left"); });
registerShortcut("SimpleDwindleSwapDown", "SimpleDwindle: Swap Down", "Meta+Shift+J", function() { swapDirection("down"); });
registerShortcut("SimpleDwindleSwapUp", "SimpleDwindle: Swap Up", "Meta+Shift+K", function() { swapDirection("up"); });