From ebb77199fc6f3040dbabd57e2db8ed1f8c6b32c4 Mon Sep 17 00:00:00 2001 From: Andrey Sidorov Date: Mon, 3 Mar 2014 11:55:44 +1100 Subject: [PATCH] fix in error parsing: bad_value, min/maj opcode now calculated correctly --- lib/xcore.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/lib/xcore.js b/lib/xcore.js index 60328f8..cee0ea4 100644 --- a/lib/xcore.js +++ b/lib/xcore.js @@ -235,6 +235,8 @@ XClient.prototype.AllocID = function() return (this.display.rsrc_id << this.display.rsrc_shift) + this.display.resource_base; } + +// TODO: move core events unpackers to corereqs.js XClient.prototype.unpackEvent = function(type, seq, extra, code, raw) { var event = {}; // TODO: constructor & base functions @@ -372,7 +374,7 @@ XClient.prototype.unpackEvent = function(type, seq, extra, code, raw) event.requestor = values[1]; event.selection = values[2]; event.target = values[3]; - event.property = values[4]; + event.property = values[4]; } else if (type == 31) {// SelectionNotify event.name = 'SelectionNotify'; event.time = extra; @@ -380,7 +382,7 @@ XClient.prototype.unpackEvent = function(type, seq, extra, code, raw) event.requestor = values[0]; event.selection = values[1]; event.target = values[2]; - event.property = values[3]; + event.property = values[3]; } else if (type == 33) {// ClientMessage event.name = 'ClientMessage'; event.format = code; @@ -394,13 +396,14 @@ XClient.prototype.unpackEvent = function(type, seq, extra, code, raw) XClient.prototype.expectReplyHeader = function() { - // TODO: BigReq!!!! + // TODO: move error parsers to corereqs.js var client = this; client.pack_stream.get( 8, function(headerBuf) { var res = headerBuf.unpack('CCSL'); var type = res[0]; var seq_num = res[2]; + var bad_value = res[3]; if (type == 0) { @@ -414,14 +417,15 @@ XClient.prototype.expectReplyHeader = function() // unpack error packet (32 bytes for all error types, 8 of them in CCSL header) client.pack_stream.get(24, function(buf) { + // TODO: dispatch, use sequence number //TODO: add more generic way to read common values // if (error_code == 14) { - var res = buf.unpack('LSC'); - error.badParam = res[0]; // id: GC, WinID, Font, Atom etc; Value - error.minorOpcode = res[1]; - error.majorOpcode = res[2]; + var res = buf.unpack('SC'); + error.badParam = bad_value; + error.minorOpcode = res[0]; + error.majorOpcode = res[1]; } var handler = client.replies[seq_num]; if (handler) {