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
15 changes: 12 additions & 3 deletions src/contents/ui/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -1331,8 +1331,10 @@ SPECIAL_AUTO_TILER_3`;
let window = Workspace.stackingOrder[i];
if (isValidWindow(window)) {
if (window.onAllDesktops) {
// A window occupies all windows - do not remove anything
return;
// Pinned to all desktops: it exists on every desktop, so it must
// not keep an otherwise-empty desktop alive. Skip it instead of
// aborting the whole sweep.
continue;
}
for (let d = 0; d < window.desktops.length; d++) {
let index = Workspace.desktops.indexOf(window.desktops[d]);
Expand All @@ -1349,7 +1351,7 @@ SPECIAL_AUTO_TILER_3`;
}

// i must be > 0, we do not delete the first desktop
for (let i = virtualDesktopWindowCount.length; i > 0; i--) {
for (let i = virtualDesktopWindowCount.length - 1; i > 0; i--) {
if (virtualDesktopWindowCount[i] == 0) {
log('Trying to remove empty virtual desktop with index: ' + i);
Workspace.removeDesktop(Workspace.desktops[i]);
Expand Down Expand Up @@ -1547,6 +1549,13 @@ SPECIAL_AUTO_TILER_3`;
addWindow(client);
}

function onWindowRemoved(client) {
// Backstop for auto-remove: the per-window "closed" handler wired in
// addWindow() only covers windows this script registered as valid.
// This workspace-level signal fires for every removal.
removeEmptyVirtualDesktops();
}

function onCurrentDesktopChanged(previous) {
setCurrentVirtualDesktop();
}
Expand Down