From 79892c927285cd695cea211c694dd78fae265a71 Mon Sep 17 00:00:00 2001 From: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> Date: Thu, 1 May 2025 15:50:28 +1000 Subject: bar: fix workspaces occupied Also some optimisations --- modules/bar/components/workspaces/ActiveIndicator.qml | 8 ++++---- modules/bar/components/workspaces/OccupiedBg.qml | 4 +++- modules/bar/components/workspaces/Workspaces.qml | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) (limited to 'modules/bar/components') diff --git a/modules/bar/components/workspaces/ActiveIndicator.qml b/modules/bar/components/workspaces/ActiveIndicator.qml index 5eb446e..4d9a0c4 100644 --- a/modules/bar/components/workspaces/ActiveIndicator.qml +++ b/modules/bar/components/workspaces/ActiveIndicator.qml @@ -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) diff --git a/modules/bar/components/workspaces/OccupiedBg.qml b/modules/bar/components/workspaces/OccupiedBg.qml index 70aee84..774e176 100644 --- a/modules/bar/components/workspaces/OccupiedBg.qml +++ b/modules/bar/components/workspaces/OccupiedBg.qml @@ -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; diff --git a/modules/bar/components/workspaces/Workspaces.qml b/modules/bar/components/workspaces/Workspaces.qml index 35cc2b0..692ae32 100644 --- a/modules/bar/components/workspaces/Workspaces.qml +++ b/modules/bar/components/workspaces/Workspaces.qml @@ -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 -- cgit v1.2.3-freya