mirror of
https://github.com/danbulant/node-x11
synced 2026-06-15 12:41:29 +00:00
MotionNotify unpack code
This commit is contained in:
parent
594456a9c3
commit
3f4c8b5700
1 changed files with 30 additions and 1 deletions
|
|
@ -82,6 +82,7 @@ XClient.prototype.importRequestsFromTemplates = function(target, reqs)
|
|||
// r is request name
|
||||
target[r] = (function(reqName) {
|
||||
var reqFunc = function req_proxy() {
|
||||
client.seq_num++; // TODO: handle overflw (seq should be last 15 (?) bits of the number
|
||||
var args = Array.prototype.slice.call(req_proxy.arguments);
|
||||
// TODO: setup last argument to be reply/error callback
|
||||
// var callback = args.length > 0 ? null : args[args.length - 1];
|
||||
|
|
@ -127,6 +128,31 @@ XClient.prototype.AllocID = function()
|
|||
return (this.display.rsrc_id << this.display.rsrc_shift) + this.display.resource_base;
|
||||
}
|
||||
|
||||
XClient.prototype.unpackEvent = function(type, seq, extra, raw)
|
||||
{
|
||||
var event = {}; // TODO: constructor & base functions
|
||||
event.type = type;
|
||||
event.seq = seq;
|
||||
|
||||
if (type == 6) { // motion event
|
||||
var values = raw.unpack('LLLSSSSSC'); //TODO: should be LLLLsssssSC
|
||||
//event.raw = values;
|
||||
// TODO: use unpackTo???
|
||||
event.time = extra;
|
||||
event.root = values[0];
|
||||
event.wid = values[1];
|
||||
event.child = values[2];
|
||||
event.rootx = values[3];
|
||||
event.rooty = values[4];
|
||||
event.x = values[5];
|
||||
event.y = values[6];
|
||||
event.buttons = values[7];
|
||||
event.sameScreen = values[8];
|
||||
}
|
||||
//console.log(event);
|
||||
return event;
|
||||
}
|
||||
|
||||
XClient.prototype.expectReplyHeader = function()
|
||||
{
|
||||
var client = this;
|
||||
|
|
@ -147,8 +173,11 @@ XClient.prototype.expectReplyHeader = function()
|
|||
} else if (type > 1)
|
||||
{
|
||||
client.pack_stream.get(24, function(buf) {
|
||||
var extra = res[3];
|
||||
var ev = client.unpackEvent(type, seq_num, extra, buf);
|
||||
client.emit('event', ev);
|
||||
// TODO: dispatch, use sequence number
|
||||
console.error('event!!!! ' + type);
|
||||
// console.error('event!!!! ' + type);
|
||||
client.expectReplyHeader();
|
||||
} );
|
||||
return;
|
||||
|
|
|
|||
Loading…
Reference in a new issue