Skip to content

Commit

Permalink
Migrate to node-gyp, build successfully on Node 0.8, drop support for…
Browse files Browse the repository at this point in the history
… 0.4
  • Loading branch information
mixu committed Jul 3, 2012
1 parent db35454 commit 0342732
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 31 deletions.
32 changes: 32 additions & 0 deletions binding.gyp
@@ -0,0 +1,32 @@
{
'targets': [
{
'target_name': 'nwm',
'sources': [
'src/nwm/nwm_node.cc'
],
'dependencies': ['listc', 'nwmc']
},
{
'target_name': 'listc',
'type': 'static_library',
'sources': [
'src/nwm/list.c'
],
'cflags': ['-fPIC', '-std=c99', '-pedantic', '-Wall']
},
{
'target_name': 'nwmc',
'type': 'static_library',
'sources': [
'src/nwm/nwm.c'
],
'cflags': ['-fPIC', '-std=c99', '-pedantic', '-Wall'],
'link_settings': {
'libraries': [
'-lX11', '-lXinerama'
],
}
}
]
}
15 changes: 1 addition & 14 deletions nwm-user-sample.js
Expand Up @@ -184,17 +184,4 @@ keyboard_shortcuts.forEach(function(shortcut) {
});

// START
nwm.start(function() {
// Expose via stdout
var repl_stdout = require('repl').start();
repl_stdout.context.nwm = nwm;
repl_stdout.context.Xh = Xh;
repl_stdout.context.XK = XK;
repl_stdout.context.keypress = function(name) {
nwm.shortcuts.forEach(function(s) {
if(s.key == XK[name]) {
s.callback();
}
});
}
});
nwm.start(function() { });
14 changes: 4 additions & 10 deletions nwm.js
Expand Up @@ -6,21 +6,15 @@
// Modules
// -------

var Collection = require('./lib/collection.js');
var Monitor = require('./lib/monitor.js');
var Window = require('./lib/window.js');
var Collection = require('./lib/collection.js'),
Monitor = require('./lib/monitor.js'),
Window = require('./lib/window.js');

// Node Window Manager
// -------------------
var NWM = function() {
// A reference to the nwm C++ X11 binding
if(process.version.indexOf('v0.6') != -1) {
console.log(process.version);
// the right way would be to fix the wscript, but waf makes me cry for help
this.wm = require('./build/Release/nwm.node');
} else {
this.wm = require('./build/default/nwm.node');
}
this.wm = require('./build/default/nwm.node');
// Known layouts
this.layouts = {};
// Keyboard shortcut lookup
Expand Down
14 changes: 7 additions & 7 deletions src/nwm/nwm_node.cc
Expand Up @@ -9,7 +9,7 @@ extern "C" {
using namespace node;
using namespace v8;

static void EIO_RealLoop(EV_P_ struct ev_io* watcher, int revents);
static void EIO_Loop(uv_poll_t* handle, int status, int events);

// callback storage
Persistent<Function>* callbacks[onLast];
Expand Down Expand Up @@ -197,17 +197,17 @@ static Handle<Value> Start(const Arguments& args) {

nwm_set_emit_function(Emit);

fprintf( stdout, "EIO INIT\n");

int fd = nwm_init();
ev_io_init(&watcher, EIO_RealLoop, fd, EV_READ);
watcher.data = NULL;
ev_io_start(EV_DEFAULT_ &watcher);

uv_poll_t* handle = new uv_poll_t;
uv_poll_init(uv_default_loop(), handle, fd);
uv_poll_start(handle, UV_READABLE, EIO_Loop);

return Undefined();
}

static void EIO_RealLoop(EV_P_ struct ev_io* watcher, int revents) {
fprintf( stdout, "EIO LOOP\n");
static void EIO_Loop(uv_poll_t* handle, int status, int events) {
nwm_loop();
}

Expand Down

0 comments on commit 0342732

Please sign in to comment.