Skip to content

Commit 94bdce5

Browse files
committed
Fixed a crash when a window would auto-close but remain listed as a tiling suggestion.
All windows that close while suggestions are visible are now removed from the suggestion list.
1 parent 1c8f009 commit 94bdce5

4 files changed

Lines changed: 59 additions & 28 deletions

File tree

src/contents/ui/AutoTiler.qml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,7 @@ QtObject {
631631
let windowIndex = data.index;
632632
logAutoTiler('i: ' + i + ' w: ' + windowIndex);
633633
logAutoTiler('RETILE 2.1 - width before: ' + mapping.windows[windowIndex].width);
634-
root.moveAndResizeWindow(mapping.windows[windowIndex], data.geometry);
634+
root.moveAndResizeWindow(mapping.windows[windowIndex], data.geometry, true);
635635
logAutoTiler('RETILE 2.2 - width after: ' + mapping.windows[windowIndex].width);
636636
isVisible[windowIndex] = true;
637637
if (updateLayerKeepBelow) {
@@ -735,7 +735,7 @@ QtObject {
735735
logAutoTiler('INSERT Z ---- currentMapping.geometries: ' + currentMapping.geometries.length + ' wanted: ' + geometryIndex);
736736
let geometry = JSON.parse(JSON.stringify(currentMapping.geometries[geometryIndex]));
737737
root.addMargins(geometry, true, true, true, true);
738-
root.moveAndResizeWindow(window, geometry);
738+
root.moveAndResizeWindow(window, geometry, false);
739739
return;
740740
}
741741
logAutoTiler('INSERT Z index: ' + index);
@@ -917,7 +917,7 @@ QtObject {
917917
let geometry = JSON.parse(JSON.stringify(currentMapping.geometries[geometryIndex]));
918918
disableAutoTiling(window);
919919
root.addMargins(geometry, true, true, true, true);
920-
root.moveAndResizeWindow(window, geometry);
920+
root.moveAndResizeWindow(window, geometry, false);
921921
} else if (currentMapping.id == previousMapping.id) {
922922
logAutoTiler('windowDropped 5 target index: ' + targetIndex);
923923

src/contents/ui/WindowSuggestions.qml

Lines changed: 44 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -244,34 +244,55 @@ PlasmaCore.Dialog {
244244
let index = localWindows.indexOf(window);
245245
if (index != -1) {
246246
localWindows.splice(index, 1);
247-
}
248247

249-
if (!window.desktops.includes(currentDesktop)) {
250-
window.desktops = [currentDesktop];
251-
}
252-
if (!window.activities.includes(currentActivity)) {
253-
window.activities = [currentActivity];
254-
}
255-
if (window.mt_auto) {
256-
autoTiler.disableAutoTiling(window);
257-
}
258-
if (window.minimized) {
259-
window.minimized = false;
248+
if (!window.desktops.includes(currentDesktop)) {
249+
window.desktops = [currentDesktop];
250+
}
251+
if (!window.activities.includes(currentActivity)) {
252+
window.activities = [currentActivity];
253+
}
254+
if (window.mt_auto) {
255+
autoTiler.disableAutoTiling(window);
256+
}
257+
if (window.minimized) {
258+
window.minimized = false;
259+
}
260+
root.moveAndResizeWindow(window, geometry);
261+
Workspace.raiseWindow(window);
262+
263+
activeIndex = 0;
264+
265+
if (localWindows.length == 0 || convertedOverlay.length == 0) {
266+
windowSuggestions.visible = false;
267+
validWindows = [];
268+
} else {
269+
validWindows = localWindows;
270+
if (suggestionsInsideTile) {
271+
updateSizes();
272+
}
273+
updateOffsets();
274+
}
260275
}
261-
root.moveAndResizeWindow(window, geometry);
262-
Workspace.raiseWindow(window);
276+
}
277+
}
263278

264-
activeIndex = 0;
279+
function windowClosed(window) {
280+
log('Closed window caption: ' + window.caption);
265281

266-
if (localWindows.length == 0 || convertedOverlay.length == 0) {
267-
windowSuggestions.visible = false;
268-
validWindows = [];
269-
} else {
270-
validWindows = localWindows;
271-
if (suggestionsInsideTile) {
272-
updateSizes();
282+
if (activeIndex != -1 && validWindows.length > 0) {
283+
let localWindows = [...validWindows];
284+
let index = localWindows.indexOf(window);
285+
if (index != -1) {
286+
localWindows.splice(index, 1);
287+
288+
if (localWindows.length == 0) {
289+
validWindows = [];
290+
} else {
291+
validWindows = localWindows;
292+
if (suggestionsInsideTile) {
293+
updateSizes();
294+
}
273295
}
274-
updateOffsets();
275296
}
276297
}
277298
}

src/contents/ui/main.qml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -792,6 +792,7 @@ SPECIAL_AUTO_TILER_3`;
792792
doCleanup();
793793
}
794794
autoTiler.windowClosed(client);
795+
windowSuggestions.windowClosed(client);
795796
disconnectAll();
796797
removeEmptyVirtualDesktops();
797798
}
@@ -1127,7 +1128,15 @@ SPECIAL_AUTO_TILER_3`;
11271128
}
11281129
}
11291130

1130-
function moveAndResizeWindow(window, geometry) {
1131+
function moveAndResizeWindow(window, geometry, autoTile = false) {
1132+
if (autoTile && !autoTiler.isValidAutoTileWindow(window)) {
1133+
logE('Not a valid auto tile window anymore!');
1134+
return false;
1135+
} else if (!isValidWindow(window)) {
1136+
logE('Not a valid window anymore!');
1137+
return false;
1138+
}
1139+
11311140
log('Moving and resizing: ' + window.caption);
11321141
if (window.resizeable) {
11331142
if (geometry.width > 20 && geometry.height > 20) {
@@ -1136,6 +1145,7 @@ SPECIAL_AUTO_TILER_3`;
11361145
} else {
11371146
window.frameGeometry = Qt.rect(geometry.x, geometry.y, window.width, window.height);
11381147
}
1148+
return true;
11391149
}
11401150

11411151
function updateWindowVisibility() {

src/metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"Description": "Tile your windows with minimal effort",
1111
"Icon": "preferences-desktop-virtual",
1212
"Id": "mousetiler",
13-
"Version": "6.2.0",
13+
"Version": "6.2.1",
1414
"License": "GPLv3",
1515
"Website": "https://github.com/rxappdev/MouseTiler"
1616
},

0 commit comments

Comments
 (0)