summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlittleblack111 <littleblack11111@gmail.com>2025-07-27 23:13:34 +0800
committerlittleblack111 <littleblack11111@gmail.com>2025-07-27 23:13:34 +0800
commit69421040c5a28bf5442f7450a6fe1a930aa0a195 (patch)
treecbafbda2179ee054ac647bde4920038fbf87f6c4
parent1a1846e43eec41d1f40c04ea9bd6dd873b6e630a (diff)
ws: fix regression with activerect when hovered not updating
-rw-r--r--bar/Workspace.qml13
1 files 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