From 69421040c5a28bf5442f7450a6fe1a930aa0a195 Mon Sep 17 00:00:00 2001 From: littleblack111 Date: Sun, 27 Jul 2025 23:13:34 +0800 Subject: ws: fix regression with activerect when hovered not updating --- bar/Workspace.qml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/bar/Workspace.qml b/bar/Workspace.qml index 1520362..4a4102e 100644 --- a/bar/Workspace.qml +++ b/bar/Workspace.qml @@ -14,6 +14,7 @@ Item { property var ws: Hyprland.workspaces property int activeIndex: -1 + property int hoveredIndex: -1 property bool toChild: false property real activeRectX: { @@ -25,7 +26,7 @@ Item { function getWorkspaceStats(index) { const w = ws.values.find(i => i.id === index + 1); return { - isOccupied: w?.toplevels?.values?.length, + isOccupied: w?.toplevels?.values?.length > 0, isActive: w?.active, isUrgent: w?.urgent }; @@ -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: getWorkspaceStats(hoveredIndex === -1 ? activeIndex : hoveredIndex).isOccupied ? Colors.d2 : Colors.foreground1 + opacity: getWorkspaceStats(hoveredIndex === -1 ? activeIndex : hoveredIndex).isOccupied ? 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: getWorkspaceStats(hoveredIndex === -1 ? activeIndex : hoveredIndex).isOccupied ? Colors.d2 : Colors.foreground1 + opacity: getWorkspaceStats(hoveredIndex === -1 ? activeIndex : hoveredIndex).isOccupied ? Bar.wsActiveOpacity : Bar.wsEmptyOpacity / 3 Behavior on x { ISpringAnimation {} } @@ -216,6 +217,7 @@ Item { const abovedItemIndex = Math.round((mouseX - layout.x) / (Bar.wsIconSize + Bar.wsSpacing)) - 1; // TODO: workspaceActiveIconSize might be before activeRect.x = mouseX - activeRect.width / 2; activeRect.implicitWidth = root.activeIndex === abovedItemIndex ? Bar.wsActiveIconSize : Bar.wsIconSize; + root.hoveredIndex = abovedItemIndex; } onExited: { if (!root.toChild && root.activeIndex >= 0) { @@ -223,6 +225,7 @@ Item { activeRect.x = layout.x + root.activeIndex * Bar.wsIconSize + root.activeIndex * Bar.wsSpacing; activeRect.implicitWidth = Bar.wsActiveIconSize; } + root.hoveredIndex = -1; } onWheel: event => { // no idea wats wrong w/ prev so we just unify it to use +/- 1 -- cgit v1.2.3