From 55878dc1b046e4b27c30bcd07c7e56e62f86ca37 Mon Sep 17 00:00:00 2001 From: littleblack111 Date: Sun, 13 Jul 2025 18:14:37 +0800 Subject: fix workspace opacity shit --- bar/Workspace.qml | 45 +++++++++++---------------------------------- 1 file changed, 11 insertions(+), 34 deletions(-) diff --git a/bar/Workspace.qml b/bar/Workspace.qml index d9e1c0a..52db8a1 100644 --- a/bar/Workspace.qml +++ b/bar/Workspace.qml @@ -10,46 +10,25 @@ Item { id: root // required property ShellScreen screen // multi monitor + property var ws: Hyprland.workspaces // readonly property HyprlandMonitor monitor: Hyprland.monitorFor(screen) // multi monitor - property list workspaceOccupied: [] - - function updateWorkspaceOccupied() { - // workspaceOccupied = Array.from({ length: Config.options.bar.workspaces.shown }, (_, i) => { - // return Hyprland.workspaces.values.some(ws => ws.id === workspaceGroup * Config.options.bar.workspaces.shown + i + 1); - // }) - workspaceOccupied = Array.from({ - length: Config.Bar.workspaces - }, (_, i) => { - return Hyprland.workspaces.values.some(ws => ws?.id === (i + 1)); - }); - } // dont work no more for some reason function isActive(index: int): bool { - return Hyprland.focusedWorkspace?.id === (index + 1); - // return monitor.activeWorkspace.id === (index + 1); // multi monitor + for (let i of ws.values) + if (i.id === (index + 1) && i.active) + return true; + return false; } function isOccupied(index: int): bool { - return workspaceOccupied[index] === true; - } - - // TODO: allow specific index after tl can do that - // function isEmpty(): bool { - // for (let i of ToplevelManager.toplevels.values) - // if (i.activated) - // return false; - // return true; - // } - - Connections { - target: Hyprland.workspaces - function onValuesChanged() { - updateWorkspaceOccupied(); + for (let i of ws.values) { + if (i.id === (index + 1) && i?.toplevels?.values?.length > 0) { + return true; + } } + return false; } - Component.onCompleted: updateWorkspaceOccupied() - implicitWidth: layout.implicitWidth RowLayout { @@ -64,8 +43,6 @@ Item { Rectangle { id: workspaceRect - // text: Hyprland.focusedWorkspace?.id.toString() == (index + 1).toString() - // text: isActive(index) implicitWidth: !isActive(index) ? Config.Bar.workspaceIconSize : Config.Bar.workspaceActiveIconSize implicitHeight: Config.Bar.workspaceIconSize - Config.Bar.workspaceHorizontalSpacing @@ -80,7 +57,7 @@ Item { } color: isOccupied(index) ? Config.Colors.alt : Config.Colors.foreground - opacity: isActive(index) ? Config.Bar.workspaceActiveOpacity : isOccupied(index) ? Config.Bar.workspaceOpacity : Config.Bar.workspaceEmptyOpacity + opacity: isActive(index) && isOccupied(index) ? Config.Bar.workspaceActiveOpacity : isOccupied(index) ? Config.Bar.workspaceOpacity : Config.Bar.workspaceEmptyOpacity } } } -- cgit v1.2.3