mirror of
https://github.com/danbulant/node-x11
synced 2026-05-22 05:49:11 +00:00
more event decoders
This commit is contained in:
parent
270c30f9e5
commit
a6cb1c2629
1 changed files with 38 additions and 7 deletions
|
|
@ -66,7 +66,7 @@ function XClient(stream, displayNum, screenNum)
|
|||
|
||||
this.pack_stream = pack_stream;
|
||||
|
||||
this.rcrc_id = 0; // generated for each new resource
|
||||
this.rsrc_id = 0; // generated for each new resource
|
||||
this.seq_num = 0; // incremented in each request. (even if we don't expect reply)
|
||||
this.seq2stack = {}; // debug: map seq_num to stack at the moment request was issued
|
||||
|
||||
|
|
@ -194,14 +194,45 @@ XClient.prototype.unpackEvent = function(type, seq, extra, code, raw)
|
|||
event.height = values[3];
|
||||
event.count = values[4]; // TODO: ???
|
||||
} else if (type == 16) { // CreateNotify
|
||||
var values = raw.unpack('LLSSSSS');
|
||||
var values = raw.unpack('LLssSSSc');
|
||||
event.parent = extra;
|
||||
event.wid = values[0];
|
||||
event.x = values[2];
|
||||
event.y = values[3];
|
||||
event.width = values[4];
|
||||
event.height = values[5];
|
||||
event.overrideRedirect = values[6] ? true : false;
|
||||
// x, y, width, height, border
|
||||
} else if (type == 17) { // destroy notify
|
||||
var values = raw.unpack('LL');
|
||||
event.wid = extra;
|
||||
event.wid1 = values[0];
|
||||
} else if (type == 19) { // MapNotify
|
||||
var values = raw.unpack('LLC');
|
||||
//event.wid = extra;
|
||||
event.wid = extra;
|
||||
event.wid1 = values[0];
|
||||
} else if (type == 20) {
|
||||
var values = raw.unpack('LL');
|
||||
event.parent = extra;
|
||||
event.wid = values[0]
|
||||
} else if (type == 23) {
|
||||
var values = raw.unpack('LLLssSSS');
|
||||
event.parent = extra;
|
||||
event.wid = values[0];
|
||||
event.x = values[1]
|
||||
event.y = values[2]
|
||||
event.width = values[3]
|
||||
event.height = values[4]
|
||||
event.borderWidth = values[5];
|
||||
//
|
||||
// The value-mask indicates which components were specified in
|
||||
// the request. The value-mask and the corresponding values are reported as given
|
||||
// in the request. The remaining values are filled in from the current geometry of the
|
||||
// window, except in the case of sibling and stack-mode, which are reported as None
|
||||
// and Above (respectively) if not given in the request.
|
||||
event.mask = values[6];
|
||||
// 322, [ 12582925, 0, 0, 484, 316, 1, 12, 0
|
||||
//console.log([extra, code, values]);
|
||||
}
|
||||
return event;
|
||||
}
|
||||
|
|
@ -239,9 +270,10 @@ XClient.prototype.expectReplyHeader = function()
|
|||
var handler = client.replies[seq_num];
|
||||
if (handler) {
|
||||
var callback = handler[1];
|
||||
callback(error);
|
||||
if (!error.handled)
|
||||
var handled = callback(error);
|
||||
if (!handled)
|
||||
client.emit('error', error);
|
||||
// TODO: should we delete seq2stack and reply even if there is no handler?
|
||||
delete client.seq2stack[seq_num];
|
||||
delete client.replies[seq_num];
|
||||
} else
|
||||
|
|
@ -342,7 +374,6 @@ module.exports.createClient = function(initCb, display)
|
|||
// try local socket on non-windows platforms
|
||||
if ( ['cygwin', 'win32', 'win64'].indexOf(process.platform) < 0 )
|
||||
{
|
||||
console.log(['here1', display, process.platform]);
|
||||
if (process.platform == 'darwin' || process.platform == 'mac')
|
||||
{
|
||||
// socket path on OSX is /tmp/launch-(some id)/org.x:0
|
||||
|
|
@ -350,7 +381,7 @@ module.exports.createClient = function(initCb, display)
|
|||
{
|
||||
socketPath = display;
|
||||
}
|
||||
} else if(host == '127.0.0.1')
|
||||
} else if(host == '127.0.0.1') //TODO check if it's consistent with xlib (DISPLAY=127.0.0.1:0 -> local unix socket or port 6000?)
|
||||
socketPath = '/tmp/.X11-unix/X' + displayNum;
|
||||
}
|
||||
if(socketPath)
|
||||
|
|
|
|||
Loading…
Reference in a new issue