From 2a0b49a58454a91cd4ad695643757dc4e80dfb0c Mon Sep 17 00:00:00 2001 From: littleblack111 Date: Sun, 27 Jul 2025 23:50:33 +0800 Subject: Revert "ws: dynamically fetch ws occupied status for activerect" This reverts commit 1a1846e43eec41d1f40c04ea9bd6dd873b6e630a. doesn't work, random race condition :/ --- bar/Workspace.qml | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'bar') diff --git a/bar/Workspace.qml b/bar/Workspace.qml index 1520362..ee6810b 100644 --- a/bar/Workspace.qml +++ b/bar/Workspace.qml @@ -14,6 +14,7 @@ Item { property var ws: Hyprland.workspaces property int activeIndex: -1 + property bool activeOccupied: false property bool toChild: false property real activeRectX: { @@ -36,8 +37,8 @@ Item { source: activeRect radius: 8 cached: true - color: getWorkspaceStats(activeIndex).isOccupied ? Colors.d2 : Colors.foreground1 - opacity: getWorkspaceStats(activeIndex).isOccupied ? Bar.wsActiveOpacity : Bar.wsEmptyOpacity / 3 + color: root.activeOccupied ? Colors.d2 : Colors.foreground1 + opacity: root.activeOccupied ? Bar.wsActiveOpacity : Bar.wsEmptyOpacity / 3 Behavior on color { NumberAnimation { @@ -59,8 +60,8 @@ Item { implicitWidth: Bar.wsActiveIconSize implicitHeight: Bar.wsIconSize - Bar.wsHorizontalSpacing radius: Bar.wsRounding - color: getWorkspaceStats(activeIndex).isOccupied ? Colors.d2 : Colors.foreground1 - opacity: getWorkspaceStats(activeIndex).isOccupied ? Bar.wsActiveOpacity : Bar.wsEmptyOpacity / 3 + color: root.activeOccupied ? Colors.d2 : Colors.foreground1 + opacity: root.activeOccupied ? Bar.wsActiveOpacity : Bar.wsEmptyOpacity / 3 Behavior on x { ISpringAnimation {} } @@ -137,6 +138,7 @@ Item { } function moveActive() { activeRect.x = parent.x; + root.activeOccupied = st.isOccupied || false; activeRect.implicitWidth = active ? Bar.wsActiveIconSize : Bar.wsIconSize; } onEntered: { @@ -197,6 +199,7 @@ Item { onActiveChanged: if (active) { root.activeIndex = index; + root.activeOccupied = st.isOccupied; activeRect.implicitWidth = Bar.wsActiveIconSize; activeRect.x = activeRectX; } @@ -215,6 +218,7 @@ 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: { @@ -222,6 +226,7 @@ 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