// SimpleDwindle
// KWin 6.8 - Minimal chronological Dwindle
-const VERSION = "0.5.0";
+const VERSION = "0.5.1";
// ------------------------------------------------------------
// Configuration
w.minimizedChanged.connect(function() {
handleMinimized(w);
});
+
+ w.desktopsChanged.connect(function() {
+ handleWindowLocationChanged(w);
+ });
+
+ w.outputChanged.connect(function() {
+ handleWindowLocationChanged(w);
+ });
}
function handleWindowAdded(w) {
tileWindow(w);
}
+// Reconcile a tiled window after KWin moves it to another desktop/output.
+// The old tree is identified by membership, not by the window's new desktop.
+function handleWindowLocationChanged(w) {
+ if (!contains(managed, w))
+ return;
+
+ const oldLayout = findWindowLayout(w);
+ if (!oldLayout)
+ return;
+
+ const desktop = w.desktops.length
+ ? w.desktops[0]
+ : workspace.currentDesktop;
+
+ if (oldLayout.desktop === desktop && oldLayout.output === w.output)
+ return;
+
+ removeNode(oldLayout, w);
+ normalizeSplits(oldLayout.root);
+ arrange(oldLayout);
+
+ // Only join a destination that already has a tiled tree.
+ const target = layouts.find(l =>
+ l.desktop === desktop &&
+ l.output === w.output &&
+ l.root !== null
+ );
+
+ if (target) {
+ insertWindow(target, w);
+ normalizeSplits(target.root);
+ arrange(target);
+ log("MOVED/TILED: " + w.caption);
+ } else {
+ removeFromList(managed, w);
+ removeFromList(suspended, w);
+ if (!contains(floating, w))
+ floating.push(w);
+
+ w.keepBelow = false;
+ log("MOVED/FLOATING: " + w.caption);
+ }
+}
+
function handleWindowRemoved(w) {
detachWindow(w);