diff options
Diffstat (limited to 'config/quickshell/overview/services')
| -rw-r--r-- | config/quickshell/overview/services/HyprlandData.qml | 88 |
1 files changed, 8 insertions, 80 deletions
diff --git a/config/quickshell/overview/services/HyprlandData.qml b/config/quickshell/overview/services/HyprlandData.qml index 6127e989..e23472d0 100644 --- a/config/quickshell/overview/services/HyprlandData.qml +++ b/config/quickshell/overview/services/HyprlandData.qml @@ -5,7 +5,6 @@ import QtQuick import Quickshell import Quickshell.Io import Quickshell.Hyprland -import "../common" /** * Provides access to some Hyprland data not available in Quickshell.Hyprland. @@ -16,17 +15,11 @@ Singleton { property var addresses: [] property var windowByAddress: ({}) property var workspaces: [] - property var allWorkspaces: [] property var workspaceIds: [] property var workspaceById: ({}) property var activeWorkspace: null property var monitors: [] property var layers: ({}) - property bool pendingWindowsUpdate: false - property bool pendingMonitorsUpdate: false - property bool pendingLayersUpdate: false - property bool pendingWorkspacesUpdate: false - property bool pendingActiveWorkspaceUpdate: false function updateWindowList() { getClients.running = true; @@ -46,46 +39,10 @@ Singleton { } function updateAll() { - scheduleUpdates(true, true, true, true, true); - } - - function scheduleUpdates(windows, monitors, layers, workspaces, activeWorkspace) { - pendingWindowsUpdate = pendingWindowsUpdate || !!windows; - pendingMonitorsUpdate = pendingMonitorsUpdate || !!monitors; - pendingLayersUpdate = pendingLayersUpdate || !!layers; - pendingWorkspacesUpdate = pendingWorkspacesUpdate || !!workspaces; - pendingActiveWorkspaceUpdate = pendingActiveWorkspaceUpdate || !!activeWorkspace; - - const debounceMs = Math.max(0, Config.options.hacks.hyprlandEventDebounceMs); - if (debounceMs === 0) { - flushPendingUpdates(); - } else { - eventDebounceTimer.interval = debounceMs; - eventDebounceTimer.restart(); - } - } - - function flushPendingUpdates() { - if (pendingWindowsUpdate) { - pendingWindowsUpdate = false; - updateWindowList(); - } - if (pendingMonitorsUpdate) { - pendingMonitorsUpdate = false; - updateMonitors(); - } - if (pendingLayersUpdate) { - pendingLayersUpdate = false; - updateLayers(); - } - if (pendingWorkspacesUpdate) { - pendingWorkspacesUpdate = false; - getWorkspaces.running = true; - } - if (pendingActiveWorkspaceUpdate) { - pendingActiveWorkspaceUpdate = false; - getActiveWorkspace.running = true; - } + updateWindowList(); + updateMonitors(); + updateLayers(); + updateWorkspaces(); } function biggestWindowForWorkspace(workspaceId) { @@ -98,51 +55,24 @@ Singleton { } Component.onCompleted: { - scheduleUpdates(true, true, true, true, true); - flushPendingUpdates(); + updateAll(); } Connections { target: Hyprland function onRawEvent(event) { - const eventName = `${event?.name ?? event?.event ?? event?.type ?? ""}`; - if (["openlayer", "closelayer", "screencast"].includes(eventName)) - return; - - if (eventName === "openwindow" || eventName === "closewindow" || eventName === "movewindow" || eventName === "movewindowv2" || eventName === "windowtitle") { - scheduleUpdates(true, false, false, true, false); - return; - } - - if (eventName === "workspace" || eventName === "workspacev2" || eventName === "focusedmon" || eventName === "focusedmonv2" || eventName === "activewindow" || eventName === "activewindowv2") { - scheduleUpdates(false, false, false, true, true); - return; - } - - if (eventName.startsWith("monitor") || eventName === "configreloaded") { - scheduleUpdates(true, true, false, true, true); - return; - } - - scheduleUpdates(true, true, true, true, true); + updateAll() } } - Timer { - id: eventDebounceTimer - interval: Math.max(0, Config.options.hacks.hyprlandEventDebounceMs) - repeat: false - onTriggered: root.flushPendingUpdates() - } - Process { id: getClients command: ["hyprctl", "clients", "-j"] stdout: StdioCollector { id: clientsCollector onStreamFinished: { - root.windowList = JSON.parse(clientsCollector.text); + root.windowList = JSON.parse(clientsCollector.text) let tempWinByAddress = {}; for (var i = 0; i < root.windowList.length; ++i) { var win = root.windowList[i]; @@ -182,9 +112,7 @@ Singleton { stdout: StdioCollector { id: workspacesCollector onStreamFinished: { - const rawWorkspaces = JSON.parse(workspacesCollector.text); - root.allWorkspaces = rawWorkspaces; - root.workspaces = rawWorkspaces.filter(ws => ws.id >= 1 && ws.id <= 100); + root.workspaces = JSON.parse(workspacesCollector.text); let tempWorkspaceById = {}; for (var i = 0; i < root.workspaces.length; ++i) { var ws = root.workspaces[i]; |
