diff --git a/lib/x11/corereqs.js b/lib/x11/corereqs.js index 3230b58..db7341d 100644 --- a/lib/x11/corereqs.js +++ b/lib/x11/corereqs.js @@ -108,6 +108,7 @@ module.exports = { CreateWindow: [ // create request packet - function OR format string function(id, parentId, x, y, width, height, borderWidth, _class, visual, values) { + // TODO: ??? there is depth field in xproto, but xlib just sets it to zero var depth = 0; @@ -156,7 +157,7 @@ module.exports = { ], MapWindow: [ - // 8 - opcode, 2 - length + // 8 - opcode, 2 - length, wid added as parameter [ 'CxSL', [8, 2] ] ], @@ -330,10 +331,13 @@ module.exports = { // format: 0 - Bitmap, 1 - XYPixmap, 2 - ZPixmap function(format, drawable, gc, width, height, dstX, dstY, leftPad, depth, data) { var padded = xutil.padded_length(data.length); - var reqLen = 7 + padded/4; // (length + 3) >> 2 ??? + var reqLen = 6 + padded/4; // (length + 3) >> 2 ??? var padLength = padded - data.length; var pad = new Buffer(padLength); // TODO: new pack format 'X' - skip amount of bytes supplied in numerical argument - return [ 'CCSLLLSSssCCxxaa', [72, format, 0, reqLen, drawable, gc, width, height, dstX, dstY, leftPad, depth, data, pad]]; + + // TODO: move code to calculate reqLength and use BigReq if needed outside of corereq.js + // NOTE: big req is used here (first 'L' in format, 0 and +1 in params), won't work if not enabled + return [ 'CCSLLLSSssCCxxaa', [72, format, 0, 1+reqLen, drawable, gc, width, height, dstX, dstY, leftPad, depth, data, pad]]; } ], diff --git a/lib/x11/ext/big-requests.js b/lib/x11/ext/big-requests.js index a56d798..172d365 100644 --- a/lib/x11/ext/big-requests.js +++ b/lib/x11/ext/big-requests.js @@ -4,25 +4,23 @@ exports.requireExt = function(display, callback) { var X = display.client; - X.QueryExtension('BIG_REQUESTS', function(ext) { + X.QueryExtension('BIG-REQUESTS', function(ext) { if (!ext.present) callback(new Error('extension not available')); - ext.Enable = function( callback ) + ext.Enable = function( cb ) { X.seq_num++; - X.pack_stream.pack('CCSL', [ext.majorOpcode, 0, 1]); + X.pack_stream.pack('CCS', [ext.majorOpcode, 0, 1]); X.replies[X.seq_num] = [ function(buf, opt) { - // max packet size in reply - console.log([buf, opt]); + return buf.unpack('L')[0]; }, - callback + cb ]; X.pack_stream.flush(); } - callback(ext); }); } diff --git a/test/putimage1.js b/test/putimage1.js index f7960b4..87a0733 100644 --- a/test/putimage1.js +++ b/test/putimage1.js @@ -19,10 +19,10 @@ for (var i=0; i < bitmap.length; ++i) } xclient.on('connect', function(display) { - var X = this; - - X.QueryExtension('BIG-REQUESTS', function(BigReq) { - console.log(BigReq); + + var X = display.client; + X.require('big-requests', function(BigReq) { + BigReq.Enable(function(maxLen) { console.log( maxLen ); }); var root = display.screen[0].root;