perf(ags overview): move window check to improve perf

This commit is contained in:
matt1432 2023-10-12 19:37:26 -04:00
parent 8ea47d4932
commit a24736ea1c
2 changed files with 13 additions and 7 deletions

View file

@ -70,9 +70,6 @@ const Client = (client, active, clients) => Revealer({
}); });
export function updateClients(box) { export function updateClients(box) {
if (!App.getWindow('overview').visible)
return;
execAsync('hyprctl clients -j').then( execAsync('hyprctl clients -j').then(
result => { result => {
let clients = JSON.parse(result).filter(client => client.class) let clients = JSON.parse(result).filter(client => client.class)

View file

@ -1,10 +1,15 @@
import { Hyprland, Widget } from '../../imports.js'; import { App, Hyprland, Widget } from '../../imports.js';
const { Box } = Widget; const { Box } = Widget;
import { PopupWindow } from '../misc/popup.js'; import { PopupWindow } from '../misc/popup.js';
import { WorkspaceRow, getWorkspaces, updateWorkspaces } from './workspaces.js'; import { WorkspaceRow, getWorkspaces, updateWorkspaces } from './workspaces.js';
import { updateClients } from './clients.js'; import { updateClients } from './clients.js';
function update(box) {
box._getWorkspaces(box);
box._updateWorkspaces(box);
box._updateClients(box);
}
export default PopupWindow({ export default PopupWindow({
name: 'overview', 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: [ connections: [
[Hyprland, box => { [Hyprland, box => {
box._getWorkspaces(box); if (!App.getWindow('overview').visible)
box._updateWorkspaces(box); return;
box._updateClients(box);
print('running overview');
update(box);
}], }],
], ],
properties: [ properties: [