InternalUtils: Fix window placement (#1913)

This commit is contained in:
Leonhard 2024-05-27 18:06:46 +02:00 committed by GitHub
parent 29da53aedc
commit 2d30bee678
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -143,6 +143,9 @@ namespace Gala {
unowned WindowClone id;
}
/**
* Careful: List<TilableWindow?> windows will be modified in place and shouldn't be used afterwards.
*/
#if HAS_MUTTER45
public static List<TilableWindow?> calculate_grid_placement (Mtk.Rectangle area, List<TilableWindow?> windows) {
#else
@ -172,9 +175,8 @@ namespace Gala {
}
// Assign each window to the closest available slot
var tmplist = windows.copy ();
while (tmplist.length () > 0) {
unowned List<unowned TilableWindow?> link = tmplist.nth (0);
while (windows.length () > 0) {
unowned List<TilableWindow?> link = windows.nth (0);
var window = link.data;
var rect = window.rect;
@ -207,9 +209,9 @@ namespace Gala {
continue;
if (taken_slots[slot_candidate] != null)
tmplist.prepend (taken_slots[slot_candidate]);
windows.prepend (taken_slots[slot_candidate]);
tmplist.remove_link (link);
windows.remove_link (link);
taken_slots[slot_candidate] = window;
}