Skip to content

Commit

Permalink
InternalUtils: Fix window placement (#1913)
Browse files Browse the repository at this point in the history
  • Loading branch information
leolost2605 authored May 27, 2024
1 parent 29da53a commit 2d30bee
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/InternalUtils.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 2d30bee

Please sign in to comment.