fix in error parsing: bad_value, min/maj opcode now calculated correctly

This commit is contained in:
Andrey Sidorov 2014-03-03 11:55:44 +11:00
parent a5e75b4e7d
commit ebb77199fc

View file

@ -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) {