Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 41 additions & 18 deletions lib/extension/tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,9 @@ export class Node extends GObject.Object {
// Since contains() tries to find node on all descendants,
// detach only from the immediate parent
let parentNode = node.parentNode;
refNode = parentNode.childNodes.splice(node.index, 1);
refNode = parentNode.childNodes[node.index];

parentNode.childNodes.splice(node.index, 1);
refNode.parentNode = null;
}
if (!refNode) {
Expand Down Expand Up @@ -709,6 +711,28 @@ export class Tree extends Node {
global.window_group.remove_child(existingWsNode.actorBin);

this.removeChild(existingWsNode);

let workspaces = this.nodeWorkpaces;
workspaces.forEach((wsNode) => {
// Extract the current integer index from "ws{n}"
let currentIndex = parseInt(wsNode.nodeValue.replace("ws", ""));

// If the workspace was after the deleted one, shift it down
if (currentIndex > wsIndex) {
let newIndex = currentIndex - 1;
wsNode._data = `ws${newIndex}`;

// Also update the IDs of the Monitor children
wsNode.childNodes.forEach((child) => {
if (child.nodeType === NODE_TYPES.MONITOR) {
// Monitor node values look like "mo{m}ws{n}"
let parts = child.nodeValue.split("ws");
child._data = `${parts[0]}ws${newIndex}`;
}
});
}
});

return true;
}

Expand Down Expand Up @@ -1295,8 +1319,7 @@ export class Tree extends Node {
let metaWin = w.nodeValue;
try {
this.extWm.move(metaWin, w.renderRect);
} catch (e) {
}
} catch (e) {}
} else {
Logger.debug(`ignoring apply for ${w.renderRect.width}x${w.renderRect.height}`);
}
Expand Down Expand Up @@ -1407,17 +1430,19 @@ export class Tree extends Node {
}

// Skip windows whose actors were destroyed mid-render
tiledChildren.filter((c) => c.isNodeValid()).forEach((child, index) => {
// A monitor can contain a window or container child
if (node.layout === LAYOUT_TYPES.HSPLIT || node.layout === LAYOUT_TYPES.VSPLIT) {
this.processSplit(node, child, params, index);
} else if (node.layout === LAYOUT_TYPES.STACKED) {
this.processStacked(node, child, params, index);
} else if (node.layout === LAYOUT_TYPES.TABBED) {
this.processTabbed(node, child, params, index);
}
this.processNode(child);
});
tiledChildren
.filter((c) => c.isNodeValid())
.forEach((child, index) => {
// A monitor can contain a window or container child
if (node.layout === LAYOUT_TYPES.HSPLIT || node.layout === LAYOUT_TYPES.VSPLIT) {
this.processSplit(node, child, params, index);
} else if (node.layout === LAYOUT_TYPES.STACKED) {
this.processStacked(node, child, params, index);
} else if (node.layout === LAYOUT_TYPES.TABBED) {
this.processTabbed(node, child, params, index);
}
this.processNode(child);
});
}

if (node.isWindow()) {
Expand Down Expand Up @@ -1558,8 +1583,7 @@ export class Tree extends Node {
if (child.actor?.border) {
borderWidth = child.actor.border.get_theme_node().get_border_width(St.Side.TOP);
}
} catch (e) {
}
} catch (e) {}

// Make adjustments to the gaps
let adjust = 4 * Utils.dpi();
Expand All @@ -1584,8 +1608,7 @@ export class Tree extends Node {
if (child.tab && !decoration.contains(child.tab)) {
try {
decoration.add_child(child.tab);
} catch (e) {
}
} catch (e) {}
}
}

Expand Down
Loading