bar: fix workspaces occupied

Also some optimisations
This commit is contained in:
2 * r + 2 * t 2025-05-01 15:50:28 +10:00
parent fc55cb7426
commit 79892c9272
3 changed files with 8 additions and 6 deletions

View file

@ -14,10 +14,10 @@ Rectangle {
required property real maskHeight
required property int groupOffset
property int currentIdx: Hyprland.activeWsId - 1 - groupOffset
property real leading: (vertical ? workspaces[currentIdx]?.y : workspaces[currentIdx]?.x) ?? 0
property real trailing: (vertical ? workspaces[currentIdx]?.y : workspaces[currentIdx]?.x) ?? 0
property real currentSize: (workspaces[currentIdx]?.size) ?? 0
readonly property Workspace currentWs: workspaces[Hyprland.activeWsId - 1 - groupOffset]
property real leading: (vertical ? currentWs?.y : currentWs?.x) ?? 0
property real trailing: (vertical ? currentWs?.y : currentWs?.x) ?? 0
property real currentSize: (currentWs?.size) ?? 0
property real size: Math.abs(leading - trailing) + currentSize
property real offset: Math.min(leading, trailing)

View file

@ -17,8 +17,10 @@ Item {
onOccupiedChanged: {
let count = 0;
const start = groupOffset;
const end = start + BarConfig.workspaces.shown;
for (const [ws, occ] of Object.entries(occupied)) {
if (ws > 0 && occ) {
if (ws > start && ws <= end && occ) {
if (!occupied[ws - 1]) {
if (pills[count])
pills[count].start = ws;

View file

@ -14,7 +14,7 @@ Item {
acc[curr.id] = curr.lastIpcObject.windows > 0;
return acc;
}, {})
readonly property int groupOffset: Math.floor(((Hyprland.activeWorkspace?.id ?? 1) - 1) / BarConfig.workspaces.shown) * BarConfig.workspaces.shown
readonly property int groupOffset: Math.floor((Hyprland.activeWsId - 1) / BarConfig.workspaces.shown) * BarConfig.workspaces.shown
implicitWidth: layout.implicitWidth
implicitHeight: layout.implicitHeight