WayfireWM / wayfire

A modular and extensible wayland compositor
https://wayfire.org/
MIT License
2.36k stars 174 forks source link

Allow event-specific notification via IPC #2437

Closed EoceneMiacid closed 3 weeks ago

EoceneMiacid commented 3 weeks ago

Currently, IPC allows us to subscribe to any window event like so:

{"method":"window-rules/events/watch"}

This is overkill in practice, because it will cause Wayfire to spam large amounts of data to the socket, all of which requires to be parsed and processed by the receiver, only for the huge majority of it to be discarded afterwards.

So, it would be much more efficient (on both ends) if we could specify which events we are interested in. In my case, I only need information about view-mapped and view-unmapped events.

So, if we could do something like

{"method":"window-rules/events/watch","events":{"view-mapped,"view-unmapped"}}

(assuming the syntax is correct)

This would save Wayfire a lot of work, and make using IPC much nicer.

Thanks for considering.

ammen99 commented 3 weeks ago

This is already available, take a look at the python bindings ;)

https://github.com/WayfireWM/pywayfire/blob/4ad8960c1408cac3cf3640b3196402ebc85ab4f0/wayfire/ipc.py#L215 https://github.com/WayfireWM/pywayfire/blob/4ad8960c1408cac3cf3640b3196402ebc85ab4f0/scripts/inactive-alpha.py#L8

EoceneMiacid commented 3 weeks ago

Very interesting! Can you provide an example of what Json message to write for a specific event in this case?

marcusbritanicus commented 3 weeks ago

I think the json would be something like this:

{
    "method": "window-rules/events/watch",
    "data": {
        "events": [ "view-mapped", "view-unmapped" ]
    }
}

E&OE. Please correct me if something is wrong.

EoceneMiacid commented 3 weeks ago

No this is perfect, it's working exactly as expected. Awesome :)

Thank you so much!