mirror of
https://github.com/danbulant/node-x11
synced 2026-06-24 17:21:47 +00:00
initial support to add event parsers from extension
This commit is contained in:
parent
58e526d913
commit
0b68bbbdb0
1 changed files with 11 additions and 3 deletions
|
|
@ -24,9 +24,10 @@ function XClient(stream, displayNum, screenNum)
|
||||||
EventEmitter.call(this);
|
EventEmitter.call(this);
|
||||||
this.stream = stream;
|
this.stream = stream;
|
||||||
|
|
||||||
|
// TODO: this is probably not used
|
||||||
this.core_requests = {};
|
this.core_requests = {};
|
||||||
this.ext_requests = {};
|
this.ext_requests = {};
|
||||||
|
|
||||||
this.displayNum = displayNum;
|
this.displayNum = displayNum;
|
||||||
this.screenNum = screenNum;
|
this.screenNum = screenNum;
|
||||||
this.authHost = os.hostname();
|
this.authHost = os.hostname();
|
||||||
|
|
@ -37,7 +38,7 @@ function XClient(stream, displayNum, screenNum)
|
||||||
// read requests set by calls to .unpack and .unpackTo
|
// read requests set by calls to .unpack and .unpackTo
|
||||||
//stream.pipe(pack_stream);
|
//stream.pipe(pack_stream);
|
||||||
|
|
||||||
// pack_stream write requests are buffered and
|
// pack_stream write requests are buffered and
|
||||||
// flushed to stream as result of call to .flush
|
// flushed to stream as result of call to .flush
|
||||||
// TODO: listen for drain event and flush automatically
|
// TODO: listen for drain event and flush automatically
|
||||||
//pack_stream.pipe(stream);
|
//pack_stream.pipe(stream);
|
||||||
|
|
@ -68,7 +69,8 @@ function XClient(stream, displayNum, screenNum)
|
||||||
this.replies = {};
|
this.replies = {};
|
||||||
this.atoms = stdatoms;
|
this.atoms = stdatoms;
|
||||||
this.event_consumers = {}; // maps window id to eventemitter TODO: bad name
|
this.event_consumers = {}; // maps window id to eventemitter TODO: bad name
|
||||||
|
this.eventParsers = {};
|
||||||
|
|
||||||
this.importRequestsFromTemplates(this, coreRequests);
|
this.importRequestsFromTemplates(this, coreRequests);
|
||||||
|
|
||||||
this.startHandshake();
|
this.startHandshake();
|
||||||
|
|
@ -164,6 +166,12 @@ XClient.prototype.unpackEvent = function(type, seq, extra, code, raw)
|
||||||
event.type = type;
|
event.type = type;
|
||||||
event.seq = seq;
|
event.seq = seq;
|
||||||
|
|
||||||
|
var extUnpacker = this.eventParsers[type];
|
||||||
|
if (extUnpacker)
|
||||||
|
{
|
||||||
|
return extUnpacker(type, seq, extra, code, raw);
|
||||||
|
}
|
||||||
|
|
||||||
if (type == 2 || type == 3 || type == 4 || type == 5 || type == 6) { // motion event
|
if (type == 2 || type == 3 || type == 4 || type == 5 || type == 6) { // motion event
|
||||||
var values = raw.unpack('LLLssssSC');
|
var values = raw.unpack('LLLssssSC');
|
||||||
//event.raw = values;
|
//event.raw = values;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue