From e8fe4ef673ebb3bc89f192ad5dba0b6d54149f34 Mon Sep 17 00:00:00 2001 From: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> Date: Wed, 30 Apr 2025 13:49:05 +1000 Subject: feat: bar workspaces show windows Better hyprland clients (update existing instead of resetting every time) Option for ws trail Custom label for occupied ws as well --- services/Hyprland.qml | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'services') diff --git a/services/Hyprland.qml b/services/Hyprland.qml index 336be73..f47c0cb 100644 --- a/services/Hyprland.qml +++ b/services/Hyprland.qml @@ -8,12 +8,13 @@ import QtQuick Singleton { id: root - property list clients: [] + readonly property list clients: [] readonly property var workspaces: Hyprland.workspaces readonly property var monitors: Hyprland.monitors property Client activeClient: null readonly property HyprlandWorkspace activeWorkspace: focusedMonitor?.activeWorkspace ?? null readonly property HyprlandMonitor focusedMonitor: Hyprland.monitors.values.find(m => m.lastIpcObject.focused) ?? null + readonly property int activeWsId: activeWorkspace?.id ?? 1 function reload() { Hyprland.refreshWorkspaces(); @@ -43,9 +44,25 @@ Singleton { stdout: SplitParser { onRead: data => { const clients = JSON.parse(data); - root.clients = clients.map(c => clientComp.createObject(root, { - lastIpcObject: c - })).filter(c => c); + const rClients = root.clients; + + const len = rClients.length; + for (let i = 0; i < len; i++) { + const client = rClients[i]; + if (!clients.find(c => c.address === client.address)) + rClients.splice(i, 1); + } + + for (const client of clients) { + const match = rClients.find(c => c.address === client.address); + if (match) { + match.lastIpcObject = client; + } else { + rClients.push(clientComp.createObject(root, { + lastIpcObject: client + })); + } + } } } } @@ -78,6 +95,7 @@ Singleton { property bool floating: lastIpcObject.floating property bool fullscreen: lastIpcObject.fullscreen property int pid: lastIpcObject.pid + property int focusHistoryId: lastIpcObject.focusHistoryID } Component { -- cgit v1.2.3-freya