diff --git a/config/ags/js/overview/clients.js b/config/ags/js/overview/clients.js index 576a518..b4e9a3d 100644 --- a/config/ags/js/overview/clients.js +++ b/config/ags/js/overview/clients.js @@ -17,57 +17,57 @@ const IconStyle = client => `transition: font-size 0.2s linear; font-size: ${getFontSize(client)}px;`; -const Client = (client, active, clients) => Revealer({ - transition: 'crossfade', - 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), - onPrimaryClickRelease: () => { - let wsName = String(client.workspace.name).replace('special:', ''); - let wsId = client.workspace.id; - let addr = `address:${client.address}`; +const Client = (client, active, clients) => { + 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( - execAsync(`hyprctl dispatch togglespecialworkspace ${wsId}`).then( + return Revealer({ + transition: 'crossfade', + setup: rev => rev.revealChild = true, + properties: [ + ['address', client.address], + ['toDestroy', false] + ], + child: WindowButton({ + address: client.address, + onSecondaryClickRelease: () => execAsync(`hyprctl dispatch closewindow ${addr}`).catch(print), + onPrimaryClickRelease: () => { + if (wsId < 0) { + if (client.workspace.name === 'special') { + execAsync(`hyprctl dispatch movetoworkspacesilent special:${wsId},${addr}`).then( + execAsync(`hyprctl dispatch togglespecialworkspace ${wsId}`).then( + () => closeWindow('overview') + ).catch(print) + ).catch(print); + } + else { + execAsync(`hyprctl dispatch togglespecialworkspace ${wsName}`).then( () => closeWindow('overview') - ).catch(print) - ).catch(print); + ).catch(print); + } } else { - execAsync(`hyprctl dispatch togglespecialworkspace ${wsName}`).then( + // close special workspace if one is opened + let activeAddress = Hyprland.active.client.address; + let currentActive = clients.find(c => c.address === activeAddress) + + if (currentActive && currentActive.workspace.id < 0) { + execAsync(`hyprctl dispatch togglespecialworkspace ${wsName}`).catch(print); + } + execAsync(`hyprctl dispatch focuswindow ${addr}`).then( () => closeWindow('overview') ).catch(print); } - } - else { - // close special workspace if one is opened - let activeAddress = Hyprland.active.client.address; - let currentActive = clients.find(c => c.address === activeAddress) - - if (currentActive && currentActive.workspace.id < 0) { - execAsync(`hyprctl dispatch togglespecialworkspace ${wsName}`).catch(print); - } - execAsync(`hyprctl dispatch focuswindow ${addr}`).then( - () => closeWindow('overview') - ).catch(print); - } - }, - child: Icon({ - className: `window ${active}`, - style: IconStyle(client) + 'font-size: 10px;', - icon: client.class, + }, + child: Icon({ + className: `window ${active}`, + style: IconStyle(client) + 'font-size: 10px;', + icon: client.class, + }), }), - }), -}); + }); +}; export function updateClients(box) { execAsync('hyprctl clients -j').then( diff --git a/config/ags/js/overview/dragndrop.js b/config/ags/js/overview/dragndrop.js index 45ffae1..868e982 100644 --- a/config/ags/js/overview/dragndrop.js +++ b/config/ags/js/overview/dragndrop.js @@ -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); }); }, }); diff --git a/config/ags/js/overview/main.js b/config/ags/js/overview/main.js index 4c5dd38..78d8b6d 100644 --- a/config/ags/js/overview/main.js +++ b/config/ags/js/overview/main.js @@ -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], ], }),