Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hyprland workspaces "lastwindow" property is not updated when changing focus #514

Open
theoahfeldt opened this issue Jul 22, 2024 · 1 comment · May be fixed by #571
Open

Hyprland workspaces "lastwindow" property is not updated when changing focus #514

theoahfeldt opened this issue Jul 22, 2024 · 1 comment · May be fixed by #571

Comments

@theoahfeldt
Copy link

theoahfeldt commented Jul 22, 2024

AGS version: 1.8.2

I am using the built in hyprland service. When changing focus between windows on the same workspace in hyprland, the change is signaled in AGS, but the lastwindow property does not change. I believe this is a bug since using hyprctl will give the correct updated value. To illustrate:

const hyprland = await Service.import("hyprland")

const example = Widget.Box().hook(hyprland, () => {
    const workspaces = JSON.parse(Utils.exec("hyprctl workspaces -j"))
    for (const ws_ctl of workspaces) {
	const id = ws_ctl.id
	const ws_ags = hyprland.getWorkspace(id)
	print(`Workspace ${id} ctl lastwindow: ${ws_ctl.lastwindow}`)
	print(`Workspace ${id} ags lastwindow: ${ws_ags.lastwindow}\n`)
    }
})

App.config({
    windows: [ Widget.Window({ name: example }) ]
})

In this example, I expect that ws_ctl.lastwindow should be equal to ws_ags.lastwindow. However, when changing focus between the windows on my workspace, only ws_ctl.lastwindow will change. In contrast, ws_ags.lastwindow will only update after other actions like closing or opening a window.

It also seems that the same behavior is happening for client.focusHistoryID of AGS' hyprland service's client objects.

@theoahfeldt
Copy link
Author

I took a quick look at the source code, and it seems that it is not updating workspaces or clients on the activewindow IPC event https://github.com/Aylur/ags/blob/main/src/service/hyprland.ts#L337.

Adding the following lines under this case would presumably solve the issue:

await this._syncClients(false);
await this._syncWorkspaces(false);
['clients', 'workspaces'].forEach(e => this.notify(e));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant