mixu / nwm

Tiling window manager for X11 written in Node.js
http://mixu.net/nwm/
MIT License
789 stars 72 forks source link

async binding to X #33

Closed dominictarr closed 9 years ago

dominictarr commented 12 years ago

I've just discovered this:

http://xcb.freedesktop.org/tutorial/

it seems that Xlib is badly designed, and doesn't pipe line requests, so for example if you tell a window to move, and then to resize, that is two IO round trips.

with xcb, it pipelines the requests and receives the response asynchronously. of course, node is awesome at this...

the question now, is which task is less unpleasant: writing a C binding, or parsing a binary protocol?

mixu commented 12 years ago

sidorares has written a Node binding for X (https://github.com/sidorares/node-x11) and CrypticSwarm has done some work towards xcb (https://github.com/CrypticSwarm/XCBJS). However, for me personally porting nwm to use xcb is low priority; we already poll events using libuv and aren't all that heavy on window operations. It would be nice, but my priority is on the JS side as I feel that needs more improvements. I'd say that rewriting the C binding is easier (than parsing the protocol), as it is fairly small and then all the bugs can be traced to our own code rather than the interfacing library.

dominictarr commented 12 years ago

The impression that I get from reading the page that I linked is that xlib actually blocks on requests, so when you go moveWindow(x, y) that function doesn't return until the request has responded, event though this performs IO.

sidoraes/node-x11 looks really good. CrypticSwarm/XCBJS doesn't compile for me unfortunately.

Have a look at the js in my fork and tell me what you think. I've refactored all the windows and stuff. Now the event for each window is emitted on it's window object, which will bubble up towards the monitor. I've temporaily removed workspaces and multiple monitors (don't have another monitor to test with), but plan to add them back later.