udevbe / westfield

Wayland HTML5 Browser IPC

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Javascript binding question

tavoda opened this issue · comments

Hello Erik,
I'm looking for some Java/Javascript bridges to wayland and wayfire. I see you did a lot in this space. I'm impressed with amount of code and time you dedicated to this area.
Java bindings looks like dead. I was able to compile udevbe/wayland-java-bindings but I was not able to generate new proxies for wayfire (what is my primary target). This project jekstrand/wayland-java also doesn't work anymore.
It looks like this project is active and you generate some crazy stuff (greenfield project). Can I use some of 'subprojects' in westfield to generated javascript stubs for wayland and wayfire to be able to write 'applications' or something like gnome-shell for wayfire? This mean run node.js based application against wayland/wayfire interface directly?

TNX

/Pavel

You are free to use and take whatever you want from this project, given that you do it in accordance with the MIT license ;)

There are however some changes you'll have to make to get them to work for nodejs.

Currently the whole stack has been written to work in the context of a webbrowser. This means that it has no notion of regular file descriptors (which as you know, are basically just numbers), instead it uses 'WebFD' objects that wraps an fd and contains additional context and information. Thinking of it, you can probably just use these WebFD objects without (much) modification.

Another big missing piece is the integration with unix sockets. In libwayland the protocol dispatching logic and the unix socket reading/writing are very tightly coupled. In Westfield this has been decoupled and instead there is a function you can call to 'feed' the library binary messages from any source, as well as a callback function that you must implement to send messages back. This approach gives Westfield the liberty to talk with Wayland applications over websocket or messages directly send to a webworker that contains a wayland application inside your browser.

This is unfortunately not compatible with libwayland, as it provides a higher level callback function that you must implement in order to dispatch calls to protocol objects. You'll probably have to re-implement these functions if you want to use them with libwayland.

Another big difference with libwayland is that Westfield is asynchronous between clients. This means that if you use an async event handler for a proxy object, all messages for that client will be queued up until the async method resumes. In the meanwhile the processing of events for other clients simply continues without blocking. This is mostly important for the server side, on the client side the same mechanism applies but there you're only dealing with yourself as the client.

Thanks for response. Do you think I have to change generator somehow to reflect this 'async' problems you mentioned in your response?

No, the generator doesn't know or care. It's the dispatch function that manages the awaits. So you basically have a choice to whether or not to support async event handler functions (in my experience you will want this).

Thanks for your time and wish you luck with greenfield.