Fix: Fix incorrect ordering

There was an issue where, when you started Gnome Shell, the icons
weren't corrently ordered. It seems that this issue was caused by a
combination of the following two things:

1. When determining the insertion index in `determineInsertionIndex` (in
   `getPositionAndBoxOverwrite` in `_overwritePanelAddToPanelBox`) the
   `boxOrder` got set to `boxOrders.something`, which doesn't make much
   sense considering that the `index` was determined by using
   `resolvedBoxOrders.something`.
   So set `boxOrder` to `resolvedBoxOrders.something` instead, to obtain
   an `insertionIndex`, which makes sense.
2. Ordering the `right` panel box from right to left (in
   `_orderTopBarItems`) seemed to cause issues (, which are probably
   caused by the indices not making sense with the children box counts
   at insertion time).
   Therefore and also because the regular (left-to-right) ordering seems
   to work just fine even for the case described in the comment (, which
   provides the reason for right-to-left ordering,) just use regular
   ordering for all boxes.

Fixing these two things may also fix other incorrect ordering behaviour
at other times.
This commit is contained in:
Julian 2021-06-22 00:00:04 +02:00
parent 0eee0e8ef9
commit 689a8107e2
Signed by: julian
GPG Key ID: 094C2AC34192FA11

View File

@ -248,21 +248,21 @@ class Extension {
if (indices.left !== -1) { if (indices.left !== -1) {
return { return {
position: determineInsertionIndex(indices.left, this._boxOrderCreator.createRestrictedValidBoxOrder("left"), boxOrders.left), position: determineInsertionIndex(indices.left, this._boxOrderCreator.createRestrictedValidBoxOrder("left"), resolvedBoxOrders.left),
box: "left" box: "left"
}; };
} }
if (indices.center !== -1) { if (indices.center !== -1) {
return { return {
position: determineInsertionIndex(indices.center, this._boxOrderCreator.createRestrictedValidBoxOrder("center"), boxOrders.center), position: determineInsertionIndex(indices.center, this._boxOrderCreator.createRestrictedValidBoxOrder("center"), resolvedBoxOrders.center),
box: "center" box: "center"
}; };
} }
if (indices.right !== -1) { if (indices.right !== -1) {
return { return {
position: determineInsertionIndex(indices.right, this._boxOrderCreator.createRestrictedValidBoxOrder("right"), boxOrders.right), position: determineInsertionIndex(indices.right, this._boxOrderCreator.createRestrictedValidBoxOrder("right"), resolvedBoxOrders.right),
box: "right" box: "right"
}; };
} }
@ -407,41 +407,13 @@ class Extension {
/// Go through the items (or rather their roles) of the validBoxOrder /// Go through the items (or rather their roles) of the validBoxOrder
/// and order the panelBox accordingly. /// and order the panelBox accordingly.
// Declare panelBoxChildCount here, because we might need it later. for (let i = 0; i < validBoxOrder.length; i++) {
let panelBoxChildCount; const role = validBoxOrder[i];
switch (box) { // Get the indicator container associated with the current role.
// If the left or center box is the target box, order form left to const associatedIndicatorContainer = Main.panel.statusArea[role].container;
// right.
case "left":
case "center":
for (let i = 0; i < validBoxOrder.length; i++) {
const role = validBoxOrder[i];
// Get the indicator container associated with the current
// role.
const associatedIndicatorContainer = Main.panel.statusArea[role].container;
associatedIndicatorContainer.get_parent().remove_child(associatedIndicatorContainer); associatedIndicatorContainer.get_parent().remove_child(associatedIndicatorContainer);
panelBox.insert_child_at_index(associatedIndicatorContainer, i); panelBox.insert_child_at_index(associatedIndicatorContainer, i);
}
break;
// If the right box is the target box, order from right to left.
// The order direction is important for the case, where the box
// order got set to a box order, which doesn't include all the roles
// to cover all items of the respective box.
// This could happen, when the box order gets set to a permutation
// of an outdated box order.
case "right":
panelBoxChildCount = Math.max(panelBox.get_children().length, validBoxOrder.length);
for (let i = 0; i < validBoxOrder.length; i++) {
const role = validBoxOrder[validBoxOrder.length - 1 - i];
// Get the indicator container associated with the current
// role.
const associatedIndicatorContainer = Main.panel.statusArea[role].container;
associatedIndicatorContainer.get_parent().remove_child(associatedIndicatorContainer);
panelBox.insert_child_at_index(associatedIndicatorContainer, panelBoxChildCount - 1 -i);
}
break;
} }
// To handle the case, where the box order got set to a permutation // To handle the case, where the box order got set to a permutation
// of an outdated box order, it would be wise, if the caller updated the // of an outdated box order, it would be wise, if the caller updated the