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

View File

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