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

Add support for hyprland's new IPC event since v0.37.0 and change 'switch case' to map #366

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

A7R7
Copy link
Contributor

@A7R7 A7R7 commented Mar 27, 2024

This pr changes the 'switch case' code structure to a Map of events to callbacks, which will slightly improve performace and make it convenient for the following changes.

On top of that, it adds support for hyprland's new IPC event since v0.37.0.
If Hyprland's version is greater than v0.37.0 (if the commit date is after 2024-3-16), then
workspacev2, createworkspacev2, destoryworkspacev2, movewindowv2, moveworkspacev2
is listend instead of their non-v2 versions.

Note that under createworkspacev2 and destoryworkspacev2, workspace-added and
workspace-removed signal return workspace's id, not name.

This will slightly improve performace and make it convenient for the future changes.
If Hyprland's version is greater than v0.37.0 (if the commit date is after 2024-3-16), then
`workspacev2`, `createworkspacev2`, `destoryworkspacev2`, `movewindowv2`, `moveworkspacev2`
is listend instead of their non-v2 versions.

Note that under `createworkspacev2` and `destoryworkspacev2`, `workspace-added` and
`workspace-removed` signal return workspace's id, not name.
@A7R7 A7R7 marked this pull request as draft March 27, 2024 03:10
@A7R7 A7R7 marked this pull request as ready for review March 27, 2024 04:06
@Aylur
Copy link
Owner

Aylur commented Mar 27, 2024

the performance difference between a map and a switch statement should be insignificant, while the switch statement is a lot more readable

I think its fine to just update the events to v2 and the signals type to ['int', 'string'] without checking Hyprland versions

@A7R7 A7R7 changed the title Add support for hyprland's new IPC event since v0.37.0 Add support for hyprland's new IPC event since v0.37.0 and change 'switch case' to map Mar 27, 2024
@A7R7
Copy link
Contributor Author

A7R7 commented Mar 27, 2024

I've dropped backward compatibility support.
Also, I've made another pr #367, which does not change the original switch case structure.
You may choose one to merge :D

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 this pull request may close these issues.

None yet

2 participants