src: fix some more events parsing

- DestroyNotify, UnmapNotify, MapNotify and MapRequest.
- Add some tests.
This commit is contained in:
Santiago Gimeno 2015-10-01 11:46:13 +02:00
parent 3b18e43fe6
commit dbe2d97bee
2 changed files with 37 additions and 14 deletions

View file

@ -313,24 +313,24 @@ XClient.prototype.unpackEvent = function(type, seq, extra, code, raw, headerBuf)
event.overrideRedirect = values[6] ? true : false;
// x, y, width, height, border
} else if (type == 17) { // destroy notify
var values = raw.unpack('LL');
var values = raw.unpack('L');
event.name = 'DestroyNotify'
event.event = extra;
event.wid = values[0];
} else if (type == 18) { // UnmapNotify
var values = raw.unpack('LLC');
var values = raw.unpack('LC');
event.name = 'UnmapNotify'
event.event = extra;
event.wid = values[0];
event.fromConfigure = values[1] ? true : false;
} else if (type == 19) { // MapNotify
var values = raw.unpack('LLC');
var values = raw.unpack('LC');
event.name = 'MapNotify'
event.event = extra;
event.wid = values[0];
event.overrideRedirect = values[1] ? true : false;
} else if (type == 20) {
var values = raw.unpack('LL');
var values = raw.unpack('L');
event.name = 'MapRequest'
event.parent = extra;
event.wid = values[0];

View file

@ -63,18 +63,41 @@ describe('CreateWindow request', function() {
var root = display.screen[0].root;
X.ChangeWindowAttributes(root, { eventMask: x11.eventMask.SubstructureNotify });
X.on('event', function(ev) {
ev.name.should.equal('CreateNotify');
ev.parent.should.equal(root);
ev.wid.should.equal(wid);
ev.x.should.equal(0);
ev.y.should.equal(0);
ev.width.should.equal(1);
ev.height.should.equal(1);
ev.borderWidth.should.equal(0);
ev.overrideRedirect.should.equal(false);
done();
switch (ev.name) {
case 'CreateNotify':
ev.parent.should.equal(root);
ev.wid.should.equal(wid);
ev.x.should.equal(0);
ev.y.should.equal(0);
ev.width.should.equal(1);
ev.height.should.equal(1);
ev.borderWidth.should.equal(0);
ev.overrideRedirect.should.equal(false);
break;
case 'MapNotify':
ev.event.should.equal(root);
ev.wid.should.equal(wid);
ev.overrideRedirect.should.equal(false);
X.UnmapWindow(wid);
break;
case 'UnmapNotify':
ev.event.should.equal(root);
ev.wid.should.equal(wid);
ev.fromConfigure.should.equal(false);
X.DestroyWindow(wid);
break;
case 'DestroyNotify':
ev.event.should.equal(root);
ev.wid.should.equal(wid);
done();
break;
}
});
X.CreateWindow(wid, root, 0, 0, 1, 1); // 1x1 pixel window
X.MapWindow(wid);
})
});