From cb4d842de33b87eb77bfe565ea11daf2eb419806 Mon Sep 17 00:00:00 2001 From: Marco Allegretti Date: Tue, 19 May 2026 10:01:45 +0200 Subject: [PATCH] Add primary tile promotion --- .../scripts/shift-tiling/contents/ui/main.qml | 38 +++++++++++++++++++ tests/check-dynamic-tiles-motion.sh | 4 ++ 2 files changed, 42 insertions(+) diff --git a/kwin/scripts/shift-tiling/contents/ui/main.qml b/kwin/scripts/shift-tiling/contents/ui/main.qml index 54e0c30b..c8d8b9bf 100644 --- a/kwin/scripts/shift-tiling/contents/ui/main.qml +++ b/kwin/scripts/shift-tiling/contents/ui/main.qml @@ -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" diff --git a/tests/check-dynamic-tiles-motion.sh b/tests/check-dynamic-tiles-motion.sh index a5f0a9db..eeaa86e1 100644 --- a/tests/check-dynamic-tiles-motion.sh +++ b/tests/check-dynamic-tiles-motion.sh @@ -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"