BigReq should work now

This commit is contained in:
sidorares 2011-09-09 11:30:18 +10:00
parent 9b439d3d80
commit d6bc4d5c32
3 changed files with 16 additions and 14 deletions

View file

@ -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]];
}
],

View file

@ -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);
});
}

View file

@ -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;