]> Freerunner's - simpledwindle.git/commitdiff
bugfix: also reorder the tree, if a window is dragged out by mouse main
authorAndre Ramnitz <andre.ramnitz@mail.de>
Tue, 20 Oct 2026 20:49:23 +0000 (22:49 +0200)
committerAndre Ramnitz <andre.ramnitz@mail.de>
Tue, 20 Oct 2026 20:49:23 +0000 (22:49 +0200)
contents/code/main.js

index 4341d08df6a59865fa4a06e37f92f61ff0ce24ca..01e18112185a5aa18e4433dd267cd6bf0777d907 100644 (file)
@@ -9,7 +9,7 @@
 
 // SimpleDwindle
 // KWin 6.8 - Minimal chronological Dwindle
 
 // SimpleDwindle
 // KWin 6.8 - Minimal chronological Dwindle
-const VERSION = "0.5.1";
+const VERSION = "0.5.2";
 
 // ------------------------------------------------------------
 // Configuration
 
 // ------------------------------------------------------------
 // Configuration
@@ -69,6 +69,7 @@ const managed = [];
 const floating = [];
 const suspended = [];
 const watched = [];
 const floating = [];
 const suspended = [];
 const watched = [];
+const interactiveMoves = new Map();
 
 // ------------------------------------------------------------
 // Helpers
 
 // ------------------------------------------------------------
 // Helpers
@@ -670,6 +671,14 @@ function watchWindow(w) {
     w.outputChanged.connect(function() {
         handleWindowLocationChanged(w);
     });
     w.outputChanged.connect(function() {
         handleWindowLocationChanged(w);
     });
+
+    w.interactiveMoveResizeStarted.connect(function() {
+        handleInteractiveStart(w);
+    });
+
+    w.interactiveMoveResizeFinished.connect(function() {
+        handleInteractiveFinish(w);
+    });
 }
 
 function handleWindowAdded(w) {
 }
 
 function handleWindowAdded(w) {
@@ -744,6 +753,7 @@ function handleWindowLocationChanged(w) {
 }
 
 function handleWindowRemoved(w) {
 }
 
 function handleWindowRemoved(w) {
+    interactiveMoves.delete(w);
     detachWindow(w);
 
     removeFromList(floating, w);
     detachWindow(w);
 
     removeFromList(floating, w);
@@ -751,6 +761,42 @@ function handleWindowRemoved(w) {
     removeFromList(watched, 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
 // ------------------------------------------------------------
 // ------------------------------------------------------------
 // Events
 // ------------------------------------------------------------