fix(ags): order workspaces correctly in overview

This commit is contained in:
matt1432 2023-09-20 16:02:04 -04:00
parent 5eb5f5478e
commit ed1b9272a1

View file

@ -46,15 +46,15 @@ export const Overview = Window({
[Hyprland, box => { [Hyprland, box => {
let childI = 0; let childI = 0;
box._workspaces = box.children[childI++].centerWidget.children.concat( box._workspaces = box.children[childI++].centerWidget.children.concat(
box.children[childI].centerWidget.children) box.children[childI].centerWidget.children);
let newWorkspaces = Hyprland.workspaces;
if (newWorkspaces.length > box._workspaces.length) { // Make sure the order is correct
box._updateWs(box); box._workspaces.forEach(workspace => {
} workspace.get_parent().reorder_child(workspace, workspace._id)
});
if (box._canUpdate) box._updateWs(box);
box._updateApps(box); box._updateApps(box);
}], }],
], ],
@ -140,40 +140,37 @@ export const Overview = Window({
}], }],
['updateWs', box => { ['updateWs', box => {
if (!box._canUpdate) Hyprland.workspaces.forEach(ws => {
return; let currentWs = box._workspaces.find(ch => ch._id == ws.id)
if (currentWs) {
box._canUpdate = false; if (!currentWs._ordered) {
const id = Hyprland.instance.connect('changed', () => { currentWs.get_parent().reorder_child(currentWs, ws._id);
Hyprland.workspaces.forEach(ws => { currentWs._ordered = true;
if (box._workspaces.some(ch => ch._id == ws.id)) }
return; }
else {
var childI = 0; var childI = 0;
if (ws.id < 0) { if (ws.id < 0) {
childI = 1; childI = 1;
} }
box.children[childI].centerWidget.add( currentWs = Box({
Box({ properties: [
properties: [['id', ws.id]], ['id', ws.id],
className: 'workspace', ['ordered', false],
child: EventBox({ ],
tooltipText: `Workspace: ${ws.id}`, className: 'workspace',
child: ags.Widget({ child: EventBox({
type: Gtk.Fixed, tooltipText: `Workspace: ${ws.id}`,
}), child: ags.Widget({
type: Gtk.Fixed,
}), }),
}) }),
); });
}); box.children[childI].centerWidget.add(currentWs);
box.show_all();
if (box._workspaces.length > 0) {
Hyprland.instance.disconnect(id);
box._canUpdate = true;
box._updateApps(box);
} }
}); });
box.show_all();
}], }],
], ],
}), }),