refactor(ags overview): try to make code cleaner

This commit is contained in:
matt1432 2023-10-13 10:25:56 -04:00
parent 1bd135057a
commit 2b0c55584f
3 changed files with 48 additions and 51 deletions

View file

@ -17,23 +17,22 @@ const IconStyle = client => `transition: font-size 0.2s linear;
font-size: ${getFontSize(client)}px;`;
const Client = (client, active, clients) => Revealer({
const Client = (client, active, clients) => {
let wsName = String(client.workspace.name).replace('special:', '');
let wsId = client.workspace.id;
let addr = `address:${client.address}`;
return Revealer({
transition: 'crossfade',
setup: rev => {
rev.revealChild = true;
},
setup: rev => rev.revealChild = true,
properties: [
['address', client.address],
['toDestroy', false]
],
child: WindowButton({
address: client.address,
onSecondaryClickRelease: () => execAsync(`hyprctl dispatch closewindow address:${client.address}`).catch(print),
onSecondaryClickRelease: () => execAsync(`hyprctl dispatch closewindow ${addr}`).catch(print),
onPrimaryClickRelease: () => {
let wsName = String(client.workspace.name).replace('special:', '');
let wsId = client.workspace.id;
let addr = `address:${client.address}`;
if (wsId < 0) {
if (client.workspace.name === 'special') {
execAsync(`hyprctl dispatch movetoworkspacesilent special:${wsId},${addr}`).then(
@ -68,6 +67,7 @@ const Client = (client, active, clients) => Revealer({
}),
}),
});
};
export function updateClients(box) {
execAsync('hyprctl clients -j').then(

View file

@ -8,6 +8,7 @@ import Gdk from 'gi://Gdk';
import Cairo from 'cairo';
import { Button } from '../misc/cursorbox.js';
import { updateClients } from './clients.js';
const TARGET = [Gtk.TargetEntry.new('text/plain', Gtk.TargetFlags.SAME_APP, 0)];
@ -66,7 +67,7 @@ export const WindowButton = ({address, ...params} = {}) => Button({
button.get_parent().destroy();
let mainBox = getWindow('overview').child.children[0].child;
mainBox._updateClients(mainBox);
updateClients(mainBox);
});
},
});

View file

@ -6,9 +6,9 @@ import { WorkspaceRow, getWorkspaces, updateWorkspaces } from './workspaces.js';
import { updateClients } from './clients.js';
function update(box) {
box._getWorkspaces(box);
box._updateWorkspaces(box);
box._updateClients(box);
getWorkspaces(box);
updateWorkspaces(box);
updateClients(box);
}
export default PopupWindow({
@ -45,10 +45,6 @@ export default PopupWindow({
],
properties: [
['workspaces'],
['getWorkspaces', getWorkspaces],
['updateWorkspaces', updateWorkspaces],
['updateClients', updateClients],
],
}),