Add primary tile promotion

This commit is contained in:
Marco Allegretti 2026-05-19 10:01:45 +02:00
parent 7c51f76cc0
commit cb4d842de3
2 changed files with 42 additions and 0 deletions

View file

@ -647,6 +647,34 @@ Item {
}
}
function promoteWindow(win) {
if (!isTileable(win)) return;
const outputName = screenNameForWindow(win) || (win.output ? win.output.name : "");
if (!outputName) return;
const key = windowKey(win);
const windows = orderedWindowsForScreen(outputName);
if (!key || windows.length < 2) return;
const reordered = [];
let promoted = null;
for (let i = 0; i < windows.length; i++) {
if (windowKey(windows[i]) === key) {
promoted = windows[i];
} else {
reordered.push(windows[i]);
}
}
if (!promoted) return;
reordered.unshift(promoted);
setStableLayout(outputName, reordered);
retileScreen(outputName);
scheduleRetile(outputName);
KWinComponents.Workspace.activeWindow = win;
}
// Keyboard navigation helpers
function centreOf(rect) {
@ -1044,6 +1072,16 @@ Item {
}
}
KWinComponents.ShortcutHandler {
name: "SHIFT Tiling Promote Primary"
text: "SHIFT Tiling: Promote active window to primary tile"
sequence: "Meta+Shift+Return"
onActivated: {
const win = KWinComponents.Workspace.activeWindow;
if (win) root.promoteWindow(win);
}
}
// Tiling on/off
KWinComponents.ShortcutHandler {
name: "SHIFT Tiling Toggle"

View file

@ -67,6 +67,10 @@ require_line "$tiling_script" "setStableLayout(outputName, remaining)"
require_line "$tiling_script" "retileScreen(name)"
require_line "$tiling_script" "retileScreen(targetName)"
require_line "$tiling_script" "if (Math.abs(fromCenterX) < insertIntentDeadZone && Math.abs(fromCenterY) < insertIntentDeadZone)"
require_line "$tiling_script" "function promoteWindow(win)"
require_line "$tiling_script" "setStableLayout(outputName, reordered)"
require_line "$tiling_script" "name: \"SHIFT Tiling Promote Primary\""
require_line "$tiling_script" "sequence: \"Meta+Shift+Return\""
reject_line "$tiling_script" "targetKey = lastLeafKey(rootNode)"
reject_line "$tiling_script" "setScreenLayout(outputName, splitLeaf(rootNode, targetKey"