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