mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-06-11 00:47:22 +00:00
Add primary tile promotion
This commit is contained in:
parent
7c51f76cc0
commit
cb4d842de3
2 changed files with 42 additions and 0 deletions
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
Loading…
Reference in a new issue