Hyprland clients are now fetched from a binding instead of get_clients(). (#642)

* Get clients from bindings.

* Active workspaces now show properly on all workspace configurations.

* Filter clients by current workspace.
This commit is contained in:
Jas Singh
2024-12-27 01:03:40 -08:00
committed by GitHub
parent 188af390cd
commit 45cb701b3b
2 changed files with 12 additions and 15 deletions

View File

@@ -194,25 +194,25 @@ export const renderClassnames = (
monitor: number,
i: number,
): string => {
const isWorkspaceActive = hyprlandService.focusedWorkspace?.id === i || isWorkspaceActiveOnMonitor(monitor, i);
const isActive = isWorkspaceActive ? 'active' : '';
if (showIcons) {
return 'workspace-icon txt-icon bar';
return `workspace-icon txt-icon bar ${isActive}`;
}
if (showNumbered || showWsIcons) {
const numActiveInd =
hyprlandService.focusedWorkspace?.id === i || isWorkspaceActiveOnMonitor(monitor, i)
? numberedActiveIndicator
: '';
const numActiveInd = isWorkspaceActive ? numberedActiveIndicator : '';
const wsIconClass = showWsIcons ? 'txt-icon' : '';
const smartHighlightClass = smartHighlight ? 'smart-highlight' : '';
const className = `workspace-number can_${numberedActiveIndicator} ${numActiveInd} ${wsIconClass} ${smartHighlightClass}`;
const className = `workspace-number can_${numberedActiveIndicator} ${numActiveInd} ${wsIconClass} ${smartHighlightClass} ${isActive}`;
return className.trim();
}
return 'default';
return `default ${isActive}`;
};
/**

View File

@@ -55,8 +55,9 @@ export const WorkspaceModule = ({ monitor }: WorkspaceModuleProps): JSX.Element
bind(applicationIconFallback),
bind(matugen),
bind(smartHighlight),
bind(hyprlandService, 'clients'),
bind(hyprlandService, 'monitors'),
bind(ignored),
bind(showAllActive),
bind(hyprlandService, 'focusedWorkspace'),
@@ -84,10 +85,9 @@ export const WorkspaceModule = ({ monitor }: WorkspaceModuleProps): JSX.Element
applicationIconFallback: string,
matugenEnabled: boolean,
smartHighlightEnabled: boolean,
clients: AstalHyprland.Client[],
monitorList: AstalHyprland.Monitor[],
) => {
const activeWorkspace = hyprlandService.focusedWorkspace?.id || -99999;
const workspacesToRender = getWorkspacesToRender(
totalWorkspaces,
workspaceList,
@@ -149,11 +149,8 @@ export const WorkspaceModule = ({ monitor }: WorkspaceModuleProps): JSX.Element
monitor,
)}
setup={(self) => {
self.toggleClassName('active', activeWorkspace === wsId);
self.toggleClassName(
'occupied',
(hyprlandService.get_workspace(wsId)?.get_clients()?.length || 0) > 0,
);
const currentWsClients = clients.filter((client) => client.workspace.id === wsId);
self.toggleClassName('occupied', currentWsClients.length > 0);
}}
/>
</button>