From a24736ea1c54203e0fe5848c8cc0e9f6cab706b1 Mon Sep 17 00:00:00 2001 From: matt1432 Date: Thu, 12 Oct 2023 19:37:26 -0400 Subject: [PATCH] perf(ags overview): move window check to improve perf --- config/ags/js/overview/clients.js | 3 --- config/ags/js/overview/main.js | 17 +++++++++++++---- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/config/ags/js/overview/clients.js b/config/ags/js/overview/clients.js index cc0a2beb..576a5187 100644 --- a/config/ags/js/overview/clients.js +++ b/config/ags/js/overview/clients.js @@ -70,9 +70,6 @@ const Client = (client, active, clients) => Revealer({ }); export function updateClients(box) { - if (!App.getWindow('overview').visible) - return; - execAsync('hyprctl clients -j').then( result => { let clients = JSON.parse(result).filter(client => client.class) diff --git a/config/ags/js/overview/main.js b/config/ags/js/overview/main.js index 91bc2daa..4c5dd388 100644 --- a/config/ags/js/overview/main.js +++ b/config/ags/js/overview/main.js @@ -1,10 +1,15 @@ -import { Hyprland, Widget } from '../../imports.js'; +import { App, Hyprland, Widget } from '../../imports.js'; const { Box } = Widget; import { PopupWindow } from '../misc/popup.js'; import { WorkspaceRow, getWorkspaces, updateWorkspaces } from './workspaces.js'; import { updateClients } from './clients.js'; +function update(box) { + box._getWorkspaces(box); + box._updateWorkspaces(box); + box._updateClients(box); +} export default PopupWindow({ name: 'overview', @@ -27,11 +32,15 @@ export default PopupWindow({ ], }), ], + // The timeout is because the list of clients is async + setup: box => setTimeout(() => update(box), 100), connections: [ [Hyprland, box => { - box._getWorkspaces(box); - box._updateWorkspaces(box); - box._updateClients(box); + if (!App.getWindow('overview').visible) + return; + + print('running overview'); + update(box); }], ], properties: [