From 53c5df562b98b098bb5d36f2bc32748e97fb93eb Mon Sep 17 00:00:00 2001 From: Andrey Sidorov Date: Fri, 9 Sep 2011 10:04:19 +1000 Subject: [PATCH] initial big-reqests support --- lib/x11/corereqs.js | 4 ++-- lib/x11/ext/big-requests.js | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 lib/x11/ext/big-requests.js diff --git a/lib/x11/corereqs.js b/lib/x11/corereqs.js index 24773b9..3230b58 100644 --- a/lib/x11/corereqs.js +++ b/lib/x11/corereqs.js @@ -330,10 +330,10 @@ 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 = 6 + padded/4; // (length + 3) >> 2 ??? + var reqLen = 7 + 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 [ 'CCSLLSSssCCxxaa', [72, format, reqLen, drawable, gc, width, height, dstX, dstY, leftPad, depth, data, pad]]; + return [ 'CCSLLLSSssCCxxaa', [72, format, 0, 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 new file mode 100644 index 0000000..a56d798 --- /dev/null +++ b/lib/x11/ext/big-requests.js @@ -0,0 +1,28 @@ +// http://www.x.org/releases/X11R7.6/doc/bigreqsproto/bigreq.html + +// TODO: move to templates +exports.requireExt = function(display, callback) +{ + var X = display.client; + X.QueryExtension('BIG_REQUESTS', function(ext) { + + if (!ext.present) + callback(new Error('extension not available')); + + ext.Enable = function( callback ) + { + X.seq_num++; + X.pack_stream.pack('CCSL', [ext.majorOpcode, 0, 1]); + X.replies[X.seq_num] = [ + function(buf, opt) { + // max packet size in reply + console.log([buf, opt]); + }, + callback + ]; + X.pack_stream.flush(); + } + + callback(ext); + }); +}