From 1a1846e43eec41d1f40c04ea9bd6dd873b6e630a Mon Sep 17 00:00:00 2001 From: littleblack111 Date: Sun, 27 Jul 2025 22:55:59 +0800 Subject: ws: dynamically fetch ws occupied status for activerect fixes same issue, but the previous solution doesn't work as the isOccupied value returned from js isn't reactive, so binding the onValue wouldn't work --- bar/Workspace.qml | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'bar/Workspace.qml') diff --git a/bar/Workspace.qml b/bar/Workspace.qml index ee6810b..1520362 100644 --- a/bar/Workspace.qml +++ b/bar/Workspace.qml @@ -14,7 +14,6 @@ Item { property var ws: Hyprland.workspaces property int activeIndex: -1 - property bool activeOccupied: false property bool toChild: false property real activeRectX: { @@ -37,8 +36,8 @@ Item { source: activeRect radius: 8 cached: true - color: root.activeOccupied ? Colors.d2 : Colors.foreground1 - opacity: root.activeOccupied ? Bar.wsActiveOpacity : Bar.wsEmptyOpacity / 3 + color: getWorkspaceStats(activeIndex).isOccupied ? Colors.d2 : Colors.foreground1 + opacity: getWorkspaceStats(activeIndex).isOccupied ? Bar.wsActiveOpacity : Bar.wsEmptyOpacity / 3 Behavior on color { NumberAnimation { @@ -60,8 +59,8 @@ Item { implicitWidth: Bar.wsActiveIconSize implicitHeight: Bar.wsIconSize - Bar.wsHorizontalSpacing radius: Bar.wsRounding - color: root.activeOccupied ? Colors.d2 : Colors.foreground1 - opacity: root.activeOccupied ? Bar.wsActiveOpacity : Bar.wsEmptyOpacity / 3 + color: getWorkspaceStats(activeIndex).isOccupied ? Colors.d2 : Colors.foreground1 + opacity: getWorkspaceStats(activeIndex).isOccupied ? Bar.wsActiveOpacity : Bar.wsEmptyOpacity / 3 Behavior on x { ISpringAnimation {} } @@ -138,7 +137,6 @@ Item { } function moveActive() { activeRect.x = parent.x; - root.activeOccupied = st.isOccupied || false; activeRect.implicitWidth = active ? Bar.wsActiveIconSize : Bar.wsIconSize; } onEntered: { @@ -199,7 +197,6 @@ Item { onActiveChanged: if (active) { root.activeIndex = index; - root.activeOccupied = st.isOccupied; activeRect.implicitWidth = Bar.wsActiveIconSize; activeRect.x = activeRectX; } @@ -218,7 +215,6 @@ Item { onPositionChanged: { const abovedItemIndex = Math.round((mouseX - layout.x) / (Bar.wsIconSize + Bar.wsSpacing)) - 1; // TODO: workspaceActiveIconSize might be before activeRect.x = mouseX - activeRect.width / 2; - root.activeOccupied = getWorkspaceStats(abovedItemIndex).isOccupied || false; activeRect.implicitWidth = root.activeIndex === abovedItemIndex ? Bar.wsActiveIconSize : Bar.wsIconSize; } onExited: { @@ -226,7 +222,6 @@ Item { // just in case activeRect.x = layout.x + root.activeIndex * Bar.wsIconSize + root.activeIndex * Bar.wsSpacing; activeRect.implicitWidth = Bar.wsActiveIconSize; - root.activeOccupied = getWorkspaceStats(root.activeIndex).isOccupied || false; } } onWheel: event => { -- cgit v1.2.3