From: Andre Ramnitz Date: Tue, 20 Oct 2026 20:49:23 +0000 (+0200) Subject: bugfix: also reorder the tree, if a window is dragged out by mouse X-Git-Url: https://git.ramnitz.eu/?a=commitdiff_plain;h=refs%2Fheads%2Fmain;p=simpledwindle.git bugfix: also reorder the tree, if a window is dragged out by mouse --- diff --git a/contents/code/main.js b/contents/code/main.js index 4341d08..01e1811 100644 --- a/contents/code/main.js +++ b/contents/code/main.js @@ -9,7 +9,7 @@ // SimpleDwindle // KWin 6.8 - Minimal chronological Dwindle -const VERSION = "0.5.1"; +const VERSION = "0.5.2"; // ------------------------------------------------------------ // Configuration @@ -69,6 +69,7 @@ const managed = []; const floating = []; const suspended = []; const watched = []; +const interactiveMoves = new Map(); // ------------------------------------------------------------ // Helpers @@ -670,6 +671,14 @@ function watchWindow(w) { w.outputChanged.connect(function() { handleWindowLocationChanged(w); }); + + w.interactiveMoveResizeStarted.connect(function() { + handleInteractiveStart(w); + }); + + w.interactiveMoveResizeFinished.connect(function() { + handleInteractiveFinish(w); + }); } function handleWindowAdded(w) { @@ -744,6 +753,7 @@ function handleWindowLocationChanged(w) { } function handleWindowRemoved(w) { + interactiveMoves.delete(w); detachWindow(w); removeFromList(floating, w); @@ -751,6 +761,42 @@ function handleWindowRemoved(w) { removeFromList(watched, w); } +// ------------------------------------------------------------ +// Interactive moves +// ------------------------------------------------------------ + +// Only react to KWin's user-driven move/resize lifecycle. Layout +// assignments to frameGeometry do not emit these window signals. +function handleInteractiveStart(w) { + if (!contains(managed, w) || w.fullScreen || w.minimized) + return; + + const r = w.frameGeometry; + interactiveMoves.set(w, { + x: r.x, y: r.y, width: r.width, height: r.height + }); +} + +function handleInteractiveFinish(w) { + const before = interactiveMoves.get(w); + interactiveMoves.delete(w); + + if (!before || !contains(managed, w)) + return; + + const after = w.frameGeometry; + const moved = Math.abs(after.x - before.x) > 1 || + Math.abs(after.y - before.y) > 1; + const resized = Math.abs(after.width - before.width) > 1 || + Math.abs(after.height - before.height) > 1; + + // Do not interpret an interactive resize as a move-to-floating. + if (moved && !resized) { + floatWindow(w); + log("DRAGGED/FLOATING: " + w.caption); + } +} + // ------------------------------------------------------------ // Events // ------------------------------------------------------------