diff options
| author | littleblack111 <littleblack11111@gmail.com> | 2025-07-13 18:14:37 +0800 |
|---|---|---|
| committer | littleblack111 <littleblack11111@gmail.com> | 2025-07-13 18:14:37 +0800 |
| commit | 55878dc1b046e4b27c30bcd07c7e56e62f86ca37 (patch) | |
| tree | 66772d2947571db22161dfc41e0fd65501dd7db8 | |
| parent | bda58f5c340f29600e99165b57b1a10caaaa1fce (diff) | |
fix workspace opacity shit
| -rw-r--r-- | bar/Workspace.qml | 45 |
1 files 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<bool> 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 } } } |
