Preparation for wayland bindings

250 views
Skip to first unread message

Henri Tuhola

unread,
Apr 9, 2013, 6:33:29 PM4/9/13
to nod...@googlegroups.com
Since Wayland is becoming stable finally, it's the time to implement bindings for several dynamic languages. As it can fertilize Linux for large-scale GUI design&development efforts. I plan doing exactly this, but I have forgotten several things about node.js bindings.

There's several simple things I need to solve:

I need to get a pointer to my wrappings that let me route events through those proxies. I wonder how to get such pointer (that doesn't change at the next garbage collect cycle), and how to turn all those proxies into event dispatchers.. or is it okay that they call regular functions?

As a second thing, I should pick up the known interface descriptors from the libwayland and provide them to the generated functions name-by-name.

As a third thing, I should hook the node.js event listener to the display. I remember I'd have some reference code in node-udev, but this needs to be verified.

Fourth thing, I wonder if the generated code from IDL should be .js or .cc.

Fifth thing, once things are autogenerated, I should supply some functions into them. I wonder how to do this.

If you need some extra references to answer, they can be found from:

I plan getting this done within this weekend. Everything seems simple enough so it won't probably need more time than that. If you have answers to some of my problems, I guess I might get through it even faster.

Fred Chien

unread,
Apr 10, 2013, 2:55:14 AM4/10/13
to nod...@googlegroups.com

Hi,

I am really  interested in this project, I think I can help you and answer your questions.

in fact,  I wrote a jsdx-toolkit module  before,  which is a gui toolkit, based on clutter. I've done a lot works for gui things there and solved that garbage collection problem already.

For event handler,  i also wrote a node-gcontext to integrate  GLib event loop to node's uv. I think you can see my code.

Cheers,
Fred

--
--
Job Board: http://jobs.nodejs.org/
Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nod...@googlegroups.com
To unsubscribe from this group, send email to
nodejs+un...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en
 
---
You received this message because you are subscribed to the Google Groups "nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Henri Tuhola

unread,
Apr 10, 2013, 7:35:45 AM4/10/13
to nod...@googlegroups.com
All right. I put up a repository for this project: https://github.com/cheery/node-wayland

I'll start it by writing bindings for the wl_proxy probably.

I remembered there were some example c++ modules around, and finally found them again. These modules should be helpful when recalling how to write bindings for node.js: https://github.com/kkaefer/node-cpp-modules

If you're willing to help me on this, you probably want to build your own wayland to test the module. I'll post some instructions later that may be useful, especially if you're using ubuntu like me. It needs a small patch to skip libffi. It's the same patch used by java bindings.

I'm also lurking in IRC on freenode.net#wayland


You received this message because you are subscribed to a topic in the Google Groups "nodejs" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/nodejs/zOQPHIVaNX8/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to nodejs+un...@googlegroups.com.

Henri Tuhola

unread,
Apr 10, 2013, 7:52:04 PM4/10/13
to nod...@googlegroups.com
I were able to call wl_display_get_registry and get some stub listener calls back: https://github.com/cheery/node-wayland

It looks like I need to process byte arrays at requests and events. I wonder how to do it properly.

I also wonder what it should look like finally? Perhaps like this?

wl = request "wayland/client"
display = wl.connect()
registry = display.get_registry()
registry.listen {
    global: (args...) ->
        console.log(args)
}
display.roundtrip()

Fred Chien

unread,
Apr 11, 2013, 1:04:56 AM4/11/13
to nod...@googlegroups.com
I just reviewed your code. My suggestion is to implement a class in JavaScript to wrap your C++ addon, then you can easily implement event dispatcher in JavaScript with callback mechanism.

For low-level things that's like byte processing, it's better to do its all jobs in C++.

How about this design:

var Wayland = require('wayland');
var wl = new Waylan();

// wl.init will do connect(), get_registry(), and initialize event emitter
wl.init(function() {
});

---

Wayland.Client Class:
connect()

Wayland.Display Class:
get_registry()
roundtrip()

Wayland.Registry Class:
on() // event listener
emit() // emitter

Cheers,
Fred




2013/4/11 Henri Tuhola <henri....@gmail.com>
--

Henri Tuhola

unread,
Apr 11, 2013, 6:48:04 AM4/11/13
to nod...@googlegroups.com
Thank you for reviewing it. It indeed looks like we need to write some javascript to get it on its foot. Lets clear some things out of the way though.

The Display and Registry are both proxies. The get_registry() -method looks like this:

    WL_DISPLAY_GET_REGISTRY = 1
    registry = display.proxy.create(get_interface_by_name('wl_registry'))
    display.proxy.marshal(WL_DISPLAY_GET_REGISTRY, registry)
    return registry

That code will be automatically generated for our bindings.

wl_display_roundtrip in other hand is a thing we need to retrieve from C. We are going to inject it into the display-class before we pass it around. I neither know if it needs emitters. It looks like there's always one layer between wayland and an user application.

Also, the wayland-client and wayland-server interfaces differ a bit. And usually the user uses the -client. It might be we want to give the clientside shorter require path indeed.

You received this message because you are subscribed to a topic in the Google Groups "nodejs" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/nodejs/zOQPHIVaNX8/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to nodejs+un...@googlegroups.com.

Fred Chien

unread,
Apr 11, 2013, 8:14:13 AM4/11/13
to nod...@googlegroups.com
I can try to write a prototype javascript class then we can have discussion based on it.

If you can give me some example code to show how to write an small application with libwayland, it's helpful. :-)


2013/4/11 Henri Tuhola <henri....@gmail.com>

Henri Tuhola

unread,
Apr 11, 2013, 9:17:05 AM4/11/13
to nod...@googlegroups.com


Accelerated graphics require EGL bindings that are next in the line after wayland bindings. >:-)

Henri Tuhola

unread,
Apr 11, 2013, 6:46:55 PM4/11/13
to nod...@googlegroups.com
If you look into https://github.com/cheery/node-wayland now, you'd see that I have one new example.

The example list an output from the registry. It only needs the code generator and after that we should be able to write considerably more complex clients.

keskiviikko, 10. huhtikuuta 2013 1.33.29 UTC+3 Henri Tuhola kirjoitti:

Henri Tuhola

unread,
Apr 13, 2013, 10:10:30 AM4/13/13
to nod...@googlegroups.com
There are some rough edges left, but it seems the wayland/client is otherwise ready for action.

There's the first screenshot about a client that's written entirely in coffeescript. It draws a checkerboard into a shared memory buffer: https://raw.github.com/cheery/node-wayland/master/screenshots/2013-4-13-simple-shm.jpg

I'll probably write some more examples, none of them will use opengl. Although I already have opengl ES2 bindings that I'd need to tune only slightly to get them work with wayland. I think I'll first want to get some functioning windowing related demos and wayland-server bindings done.
Reply all
Reply to author
Forward
0 new messages