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,14 +46,14 @@ 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;
// Make sure the order is correct
box._workspaces.forEach(workspace => {
workspace.get_parent().reorder_child(workspace, workspace._id)
});
if (newWorkspaces.length > box._workspaces.length) {
box._updateWs(box); box._updateWs(box);
}
if (box._canUpdate)
box._updateApps(box); box._updateApps(box);
}], }],
@ -140,23 +140,25 @@ export const Overview = Window({
}], }],
['updateWs', box => { ['updateWs', box => {
if (!box._canUpdate)
return;
box._canUpdate = false;
const id = Hyprland.instance.connect('changed', () => {
Hyprland.workspaces.forEach(ws => { Hyprland.workspaces.forEach(ws => {
if (box._workspaces.some(ch => ch._id == ws.id)) let currentWs = box._workspaces.find(ch => ch._id == ws.id)
return; if (currentWs) {
if (!currentWs._ordered) {
currentWs.get_parent().reorder_child(currentWs, ws._id);
currentWs._ordered = true;
}
}
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],
['ordered', false],
],
className: 'workspace', className: 'workspace',
child: EventBox({ child: EventBox({
tooltipText: `Workspace: ${ws.id}`, tooltipText: `Workspace: ${ws.id}`,
@ -164,16 +166,11 @@ export const Overview = Window({
type: Gtk.Fixed, type: Gtk.Fixed,
}), }),
}), }),
})
);
}); });
box.show_all(); box.children[childI].centerWidget.add(currentWs);
if (box._workspaces.length > 0) {
Hyprland.instance.disconnect(id);
box._canUpdate = true;
box._updateApps(box);
} }
}); });
box.show_all();
}], }],
], ],
}), }),