mirror of
https://github.com/danbulant/node-x11
synced 2026-05-24 12:35:39 +00:00
fix ChangeGC request, add PolyRectangle, lint
This commit is contained in:
parent
20886399ed
commit
208ce038b0
1 changed files with 912 additions and 912 deletions
208
lib/corereqs.js
208
lib/corereqs.js
|
|
@ -202,8 +202,7 @@ for (var req in valueMask) {
|
||||||
names[masks[m].mask] = m;
|
names[masks[m].mask] = m;
|
||||||
}
|
}
|
||||||
|
|
||||||
function packValueMask(reqname, values)
|
function packValueMask(reqname, values) {
|
||||||
{
|
|
||||||
var bitmask = 0;
|
var bitmask = 0;
|
||||||
var masksList = [];
|
var masksList = [];
|
||||||
var format = '';
|
var format = '';
|
||||||
|
|
@ -213,8 +212,7 @@ function packValueMask(reqname, values)
|
||||||
if (!reqValueMask)
|
if (!reqValueMask)
|
||||||
throw new Error(reqname + ': no value mask description');
|
throw new Error(reqname + ': no value mask description');
|
||||||
|
|
||||||
for (var value in values)
|
for (var value in values) {
|
||||||
{
|
|
||||||
var v = reqValueMask[value];
|
var v = reqValueMask[value];
|
||||||
if (v) {
|
if (v) {
|
||||||
var valueBit = v.mask;
|
var valueBit = v.mask;
|
||||||
|
|
@ -231,13 +229,12 @@ function packValueMask(reqname, values)
|
||||||
});
|
});
|
||||||
|
|
||||||
var args = [];
|
var args = [];
|
||||||
for (m in masksList)
|
for (m in masksList) {
|
||||||
{
|
|
||||||
var valueName = reqValueMaskName[masksList[m]];
|
var valueName = reqValueMaskName[masksList[m]];
|
||||||
format += reqValueMask[valueName].format
|
format += reqValueMask[valueName].format;
|
||||||
args.push(values[valueName]);
|
args.push(values[valueName]);
|
||||||
}
|
}
|
||||||
return [format, bitmask, args]
|
return [format, bitmask, args];
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -276,7 +273,7 @@ var templates = {
|
||||||
if (visual === undefined)
|
if (visual === undefined)
|
||||||
visual = 0;
|
visual = 0;
|
||||||
if (values === undefined)
|
if (values === undefined)
|
||||||
values = {}
|
values = {};
|
||||||
|
|
||||||
var format = 'CCSLLssSSSSLL';
|
var format = 'CCSLLssSSSSLL';
|
||||||
|
|
||||||
|
|
@ -313,8 +310,7 @@ var templates = {
|
||||||
|
|
||||||
GetWindowAttributes: [
|
GetWindowAttributes: [
|
||||||
['CxSL', [3, 2]],
|
['CxSL', [3, 2]],
|
||||||
function(buf, backingStore)
|
function(buf, backingStore) {
|
||||||
{
|
|
||||||
// TODO: change from array to named object fields
|
// TODO: change from array to named object fields
|
||||||
var res = buf.unpack('LSCCLLCCCCLLLS');
|
var res = buf.unpack('LSCCLLCCCCLLLS');
|
||||||
var ret = {
|
var ret = {
|
||||||
|
|
@ -335,9 +331,8 @@ var templates = {
|
||||||
],
|
],
|
||||||
|
|
||||||
ChangeSaveSet: [
|
ChangeSaveSet: [
|
||||||
function(isInsert, wid)
|
function(isInsert, wid) {
|
||||||
{
|
return ['CCSL', [6, (isInsert ? 0 : 1), 2, wid]];
|
||||||
return [ 'CCSL', [6, (isInsert ? 0 : 1), 2, wid]]
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
|
|
@ -377,31 +372,46 @@ var templates = {
|
||||||
|
|
||||||
ResizeWindow: [
|
ResizeWindow: [
|
||||||
function(win, width, height) {
|
function(win, width, height) {
|
||||||
return module.exports.ConfigureWindow[0](win, { width : width, height: height });
|
return module.exports.ConfigureWindow[0](win, {
|
||||||
|
width: width,
|
||||||
|
height: height
|
||||||
|
});
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
MoveWindow: [
|
MoveWindow: [
|
||||||
function(win, x, y) {
|
function(win, x, y) {
|
||||||
return module.exports.ConfigureWindow[0](win, { x : x, y: y });
|
return module.exports.ConfigureWindow[0](win, {
|
||||||
|
x: x,
|
||||||
|
y: y
|
||||||
|
});
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
MoveResizeWindow: [
|
MoveResizeWindow: [
|
||||||
function(win, x, y, width, height) {
|
function(win, x, y, width, height) {
|
||||||
return module.exports.ConfigureWindow[0](win, { x : x, y: y, width : width, height: height });
|
return module.exports.ConfigureWindow[0](win, {
|
||||||
|
x: x,
|
||||||
|
y: y,
|
||||||
|
width: width,
|
||||||
|
height: height
|
||||||
|
});
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
RaiseWindow: [
|
RaiseWindow: [
|
||||||
function(win) {
|
function(win) {
|
||||||
return module.exports.ConfigureWindow[0](win, { stackMode : 0 });
|
return module.exports.ConfigureWindow[0](win, {
|
||||||
|
stackMode: 0
|
||||||
|
});
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
LowerWindow: [
|
LowerWindow: [
|
||||||
function(win) {
|
function(win) {
|
||||||
return module.exports.ConfigureWindow[0](win, { stackMode : 1 });
|
return module.exports.ConfigureWindow[0](win, {
|
||||||
|
stackMode: 1
|
||||||
|
});
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
|
|
@ -422,8 +432,7 @@ var templates = {
|
||||||
|
|
||||||
// opcode 16
|
// opcode 16
|
||||||
InternAtom: [
|
InternAtom: [
|
||||||
function (returnOnlyIfExist, value)
|
function(returnOnlyIfExist, value) {
|
||||||
{
|
|
||||||
var padded = xutil.padded_string(value);
|
var padded = xutil.padded_string(value);
|
||||||
return ['CCSSxxa', [16, returnOnlyIfExist ? 1 : 0, 2 + padded.length / 4, value.length, padded]];
|
return ['CCSSxxa', [16, returnOnlyIfExist ? 1 : 0, 2 + padded.length / 4, value.length, padded]];
|
||||||
},
|
},
|
||||||
|
|
@ -461,8 +470,7 @@ var templates = {
|
||||||
ChangeProperty: [
|
ChangeProperty: [
|
||||||
// mode: 0 replace, 1 prepend, 2 append
|
// mode: 0 replace, 1 prepend, 2 append
|
||||||
// format: 8/16/32
|
// format: 8/16/32
|
||||||
function(mode, wid, name, type, units, data)
|
function(mode, wid, name, type, units, data) {
|
||||||
{
|
|
||||||
var padded4 = (data.length + 3) >> 2;
|
var padded4 = (data.length + 3) >> 2;
|
||||||
var pad = new Buffer((padded4 << 2) - data.length);
|
var pad = new Buffer((padded4 << 2) - data.length);
|
||||||
var format = 'CCSLLLCxxxLaa';
|
var format = 'CCSLLLCxxxLaa';
|
||||||
|
|
@ -491,7 +499,7 @@ var templates = {
|
||||||
var prop = {};
|
var prop = {};
|
||||||
prop.type = res[0];
|
prop.type = res[0];
|
||||||
prop.bytesAfter = res[1];
|
prop.bytesAfter = res[1];
|
||||||
var len = res[2]*(format >> 3)
|
var len = res[2] * (format >> 3);
|
||||||
prop.data = buf.slice(24, 24 + len);
|
prop.data = buf.slice(24, 24 + len);
|
||||||
return prop;
|
return prop;
|
||||||
}
|
}
|
||||||
|
|
@ -499,8 +507,7 @@ var templates = {
|
||||||
|
|
||||||
ListProperties: [
|
ListProperties: [
|
||||||
|
|
||||||
function(wid)
|
function(wid) {
|
||||||
{
|
|
||||||
return ['CxSL', [21, 2, wid]];
|
return ['CxSL', [21, 2, wid]];
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -517,8 +524,7 @@ var templates = {
|
||||||
],
|
],
|
||||||
|
|
||||||
SetSelectionOwner: [
|
SetSelectionOwner: [
|
||||||
function(owner, selection, time)
|
function(owner, selection, time) {
|
||||||
{
|
|
||||||
if (!time)
|
if (!time)
|
||||||
time = 0; // current time
|
time = 0; // current time
|
||||||
return ['CxSLLL', [22, 4, owner, selection, time]];
|
return ['CxSLLL', [22, 4, owner, selection, time]];
|
||||||
|
|
@ -526,8 +532,7 @@ var templates = {
|
||||||
],
|
],
|
||||||
|
|
||||||
GetSelectionOwner: [
|
GetSelectionOwner: [
|
||||||
function(selection)
|
function(selection) {
|
||||||
{
|
|
||||||
return ['CxSL', [23, 2, selection]];
|
return ['CxSL', [23, 2, selection]];
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -546,8 +551,7 @@ var templates = {
|
||||||
|
|
||||||
SendEvent: [
|
SendEvent: [
|
||||||
|
|
||||||
function(destination, propagate, eventMask, eventRawData)
|
function(destination, propagate, eventMask, eventRawData) {
|
||||||
{
|
|
||||||
return ['CCSLLa', [25, propagate, 11, destination, eventMask, eventRawData]];
|
return ['CCSLLa', [25, propagate, 11, destination, eventMask, eventRawData]];
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
@ -555,7 +559,8 @@ var templates = {
|
||||||
GrabPointer: [
|
GrabPointer: [
|
||||||
function(wid, ownerEvents, mask, pointerMode, keybMode, confineTo, cursor, time) {
|
function(wid, ownerEvents, mask, pointerMode, keybMode, confineTo, cursor, time) {
|
||||||
return ['CCSLSCCLLL', [26, ownerEvents, 6, wid, mask, pointerMode, keybMode,
|
return ['CCSLSCCLLL', [26, ownerEvents, 6, wid, mask, pointerMode, keybMode,
|
||||||
confineTo, cursor, time] ];
|
confineTo, cursor, time
|
||||||
|
]];
|
||||||
},
|
},
|
||||||
function(buf, status) {
|
function(buf, status) {
|
||||||
return status;
|
return status;
|
||||||
|
|
@ -571,7 +576,8 @@ var templates = {
|
||||||
GrabButton: [
|
GrabButton: [
|
||||||
function(wid, ownerEvents, mask, pointerMode, keybMode, confineTo, cursor, button, modifiers) {
|
function(wid, ownerEvents, mask, pointerMode, keybMode, confineTo, cursor, button, modifiers) {
|
||||||
return ['CCSLSCCLLCxS', [28, ownerEvents, 6, wid, mask, pointerMode, keybMode, confineTo,
|
return ['CCSLSCCLLCxS', [28, ownerEvents, 6, wid, mask, pointerMode, keybMode, confineTo,
|
||||||
cursor, button, modifiers ] ];
|
cursor, button, modifiers
|
||||||
|
]];
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
|
|
@ -649,8 +655,7 @@ var templates = {
|
||||||
function(srcWid, dstWid, srcX, srcY) {
|
function(srcWid, dstWid, srcX, srcY) {
|
||||||
return ['CxSLLSS', [40, 4, srcWid, dstWid, srcX, srcY]];
|
return ['CxSLLSS', [40, 4, srcWid, dstWid, srcX, srcY]];
|
||||||
},
|
},
|
||||||
function(buf, sameScreen)
|
function(buf, sameScreen) {
|
||||||
{
|
|
||||||
var res = buf.unpack('Lss');
|
var res = buf.unpack('Lss');
|
||||||
var ext = {};
|
var ext = {};
|
||||||
ext.child = res[0];
|
ext.child = res[0];
|
||||||
|
|
@ -673,8 +678,7 @@ var templates = {
|
||||||
function() {
|
function() {
|
||||||
return ['CxS', [43, 1]];
|
return ['CxS', [43, 1]];
|
||||||
},
|
},
|
||||||
function(buf, revertTo)
|
function(buf, revertTo) {
|
||||||
{
|
|
||||||
return {
|
return {
|
||||||
focus: buf.unpack('L')[0],
|
focus: buf.unpack('L')[0],
|
||||||
revertTo: revertTo
|
revertTo: revertTo
|
||||||
|
|
@ -684,31 +688,36 @@ var templates = {
|
||||||
|
|
||||||
WarpPointer: [
|
WarpPointer: [
|
||||||
|
|
||||||
function (srcWin, dstWin, srcX, srcY, srcWidth, srcHeight, dstX, dstY)
|
function(srcWin, dstWin, srcX, srcY, srcWidth, srcHeight, dstX, dstY) {
|
||||||
{
|
|
||||||
return ['CxSLLssSSss', [41, 6, srcWin, dstWin, srcX, srcY, srcWidth, srcHeight, dstX, dstY]];
|
return ['CxSLLssSSss', [41, 6, srcWin, dstWin, srcX, srcY, srcWidth, srcHeight, dstX, dstY]];
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
|
QueryTextExtents: [
|
||||||
|
function(fontable, text) {
|
||||||
|
return ['CxSLLssSSss', [48, 6, srcWin, dstWin, srcX, srcY, srcWidth, srcHeight, dstX, dstY]];
|
||||||
|
},
|
||||||
|
function(buf) {
|
||||||
|
// TODO: wip
|
||||||
|
throw new Error('not implemented yet, please add deserializer');
|
||||||
|
}
|
||||||
|
],
|
||||||
|
|
||||||
ListFonts: [
|
ListFonts: [
|
||||||
function(pattern, max)
|
function(pattern, max) {
|
||||||
{
|
|
||||||
var req_len = 2 + xutil.padded_length(pattern.length) / 4;
|
var req_len = 2 + xutil.padded_length(pattern.length) / 4;
|
||||||
return ['CxSSSp', [49, req_len, max, pattern.length, pattern]];
|
return ['CxSSSp', [49, req_len, max, pattern.length, pattern]];
|
||||||
},
|
},
|
||||||
|
|
||||||
function(buf) {
|
function(buf) {
|
||||||
console.log(buf);
|
|
||||||
// TODO: move to buffer.unpackStringList
|
// TODO: move to buffer.unpackStringList
|
||||||
var res = [];
|
var res = [];
|
||||||
var off = 24;
|
var off = 24;
|
||||||
while (off < buf.length)
|
while (off < buf.length) {
|
||||||
{
|
|
||||||
var len = buf[off++];
|
var len = buf[off++];
|
||||||
if (len == 0)
|
if (len === 0)
|
||||||
break;
|
break;
|
||||||
if (off + len > buf.length)
|
if (off + len > buf.length) {
|
||||||
{
|
|
||||||
len = buf.length - off;
|
len = buf.length - off;
|
||||||
if (len <= 0)
|
if (len <= 0)
|
||||||
break;
|
break;
|
||||||
|
|
@ -732,21 +741,15 @@ var templates = {
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
FreePixmap: [
|
|
||||||
function (pixmap) {
|
|
||||||
return [ 'CxSL', [54, 2, pixmap] ];
|
|
||||||
}
|
|
||||||
],
|
|
||||||
|
|
||||||
CreateCursor: [
|
CreateCursor: [
|
||||||
function(cid, source, mask, foreRGB, backRGB, x, y) {
|
function(cid, source, mask, foreRGB, backRGB, x, y) {
|
||||||
foreR = foreRGB.R
|
foreR = foreRGB.R;
|
||||||
foreG = foreRGB.G
|
foreG = foreRGB.G;
|
||||||
foreB = foreRGB.B
|
foreB = foreRGB.B;
|
||||||
|
|
||||||
backR = backRGB.R
|
backR = backRGB.R;
|
||||||
backG = backRGB.G
|
backG = backRGB.G;
|
||||||
backB = backRGB.B
|
backB = backRGB.B;
|
||||||
return ['CxSLLLSSSSSSSS', [93, 8, cid, source, mask, foreR, foreG, foreB, backR, backG, backB, x, y]];
|
return ['CxSLLLSSSSSSSS', [93, 8, cid, source, mask, foreR, foreG, foreB, backR, backG, backB, x, y]];
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
@ -758,9 +761,9 @@ var templates = {
|
||||||
var vals = packValueMask('CreateGC', values);
|
var vals = packValueMask('CreateGC', values);
|
||||||
var packetLength = 4 + (values ? vals[2].length : 0);
|
var packetLength = 4 + (values ? vals[2].length : 0);
|
||||||
var args = [55, packetLength, cid, drawable];
|
var args = [55, packetLength, cid, drawable];
|
||||||
format += vals[0]
|
format += vals[0];
|
||||||
args.push(vals[1]); // values bitmask
|
args.push(vals[1]); // values bitmask
|
||||||
args = args.concat(vals[2])
|
args = args.concat(vals[2]);
|
||||||
return [format, args];
|
return [format, args];
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
@ -771,38 +774,34 @@ var templates = {
|
||||||
var vals = packValueMask('CreateGC', values);
|
var vals = packValueMask('CreateGC', values);
|
||||||
var packetLength = 3 + (values ? vals[2].length : 0);
|
var packetLength = 3 + (values ? vals[2].length : 0);
|
||||||
var args = [56, packetLength, cid];
|
var args = [56, packetLength, cid];
|
||||||
args.push(vals[0]); // values bitmask
|
args.push(vals[1]); // values bitmask
|
||||||
var valArr = vals[1];
|
var valArr = vals[2];
|
||||||
for (var v in valArr)
|
for (var v = 0; v < valArr.length; ++v) {
|
||||||
{
|
format += vals[0][v];
|
||||||
format += 'L'; // TODO: we know format string length in advance and += inefficient for string
|
|
||||||
args.push(valArr[v]);
|
args.push(valArr[v]);
|
||||||
}
|
}
|
||||||
return [format, args];
|
return [format, args];
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
|
|
||||||
ClearArea: [
|
ClearArea: [
|
||||||
function(wid, x, y, width, height, exposures) {
|
function(wid, x, y, width, height, exposures) {
|
||||||
return [ 'CCSLssSS', [61, exposures, 4, wid, x, y, width, height] ];
|
return [ 'CCSLssSS', [61, exposures, 4, wid, x, y, width, height] ];
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
//
|
|
||||||
CopyArea: [
|
CopyArea: [
|
||||||
function(srcDrawable, dstDrawable, gc, srcX, srcY, dstX, dstY, width, height) {
|
function(srcDrawable, dstDrawable, gc, srcX, srcY, dstX, dstY, width, height) {
|
||||||
return [ 'CxSLLLssssSS', [62, 7, srcDrawable, dstDrawable, gc, srcX, srcY, dstX, dstY, width, height] ];
|
return [ 'CxSLLLssssSS', [62, 7, srcDrawable, dstDrawable, gc, srcX, srcY, dstX, dstY, width, height] ];
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
|
|
||||||
PolyPoint: [
|
PolyPoint: [
|
||||||
function(coordMode, drawable, gc, points)
|
function(coordMode, drawable, gc, points) {
|
||||||
{
|
|
||||||
var format = 'CCSLL';
|
var format = 'CCSLL';
|
||||||
var args = [64, coordMode, 3 + points.length / 2, drawable, gc];
|
var args = [64, coordMode, 3 + points.length / 2, drawable, gc];
|
||||||
for (var i=0; i < points.length; ++i)
|
for (var i = 0; i < points.length; ++i) {
|
||||||
{
|
|
||||||
format += 'S';
|
format += 'S';
|
||||||
args.push(points[i]);
|
args.push(points[i]);
|
||||||
}
|
}
|
||||||
|
|
@ -812,12 +811,10 @@ var templates = {
|
||||||
|
|
||||||
PolyLine: [
|
PolyLine: [
|
||||||
// TODO: remove copy-paste - exectly same as PolyPoint, only differ with opcode
|
// TODO: remove copy-paste - exectly same as PolyPoint, only differ with opcode
|
||||||
function(coordMode, drawable, gc, points)
|
function(coordMode, drawable, gc, points) {
|
||||||
{
|
|
||||||
var format = 'CCSLL';
|
var format = 'CCSLL';
|
||||||
var args = [65, coordMode, 3 + points.length / 2, drawable, gc];
|
var args = [65, coordMode, 3 + points.length / 2, drawable, gc];
|
||||||
for (var i=0; i < points.length; ++i)
|
for (var i = 0; i < points.length; ++i) {
|
||||||
{
|
|
||||||
format += 'S';
|
format += 'S';
|
||||||
args.push(points[i]);
|
args.push(points[i]);
|
||||||
}
|
}
|
||||||
|
|
@ -826,13 +823,25 @@ var templates = {
|
||||||
|
|
||||||
],
|
],
|
||||||
|
|
||||||
|
PolyRectangle: [
|
||||||
|
function(drawable, gc, coords) { // x1, y1, w1, h1, x2, y2, w2, h2...
|
||||||
|
var format = 'CxSLL';
|
||||||
|
var numrects4bytes = coords.length / 2;
|
||||||
|
var args = [67, 3 + numrects4bytes, drawable, gc];
|
||||||
|
for (var i = 0; i < coords.length; ++i) {
|
||||||
|
format += 'S';
|
||||||
|
args.push(coords[i]);
|
||||||
|
}
|
||||||
|
return [format, args];
|
||||||
|
}
|
||||||
|
],
|
||||||
|
|
||||||
PolyFillRectangle: [
|
PolyFillRectangle: [
|
||||||
function(drawable, gc, coords) { // x1, y1, w1, h1, x2, y2, w2, h2...
|
function(drawable, gc, coords) { // x1, y1, w1, h1, x2, y2, w2, h2...
|
||||||
var format = 'CxSLL';
|
var format = 'CxSLL';
|
||||||
var numrects4bytes = coords.length / 2;
|
var numrects4bytes = coords.length / 2;
|
||||||
var args = [70, 3 + numrects4bytes, drawable, gc];
|
var args = [70, 3 + numrects4bytes, drawable, gc];
|
||||||
for (var i=0; i < coords.length; ++i)
|
for (var i = 0; i < coords.length; ++i) {
|
||||||
{
|
|
||||||
format += 'S';
|
format += 'S';
|
||||||
args.push(coords[i]);
|
args.push(coords[i]);
|
||||||
}
|
}
|
||||||
|
|
@ -845,8 +854,7 @@ var templates = {
|
||||||
var format = 'CxSLL';
|
var format = 'CxSLL';
|
||||||
var numrects4bytes = coords.length / 2;
|
var numrects4bytes = coords.length / 2;
|
||||||
var args = [71, 3 + numrects4bytes, drawable, gc];
|
var args = [71, 3 + numrects4bytes, drawable, gc];
|
||||||
for (var i=0; i < coords.length; ++i)
|
for (var i = 0; i < coords.length; ++i) {
|
||||||
{
|
|
||||||
format += 'S';
|
format += 'S';
|
||||||
args.push(coords[i]);
|
args.push(coords[i]);
|
||||||
}
|
}
|
||||||
|
|
@ -869,12 +877,10 @@ var templates = {
|
||||||
],
|
],
|
||||||
|
|
||||||
GetImage: [
|
GetImage: [
|
||||||
function(format, drawable, x, y, width, height, planeMask)
|
function(format, drawable, x, y, width, height, planeMask) {
|
||||||
{
|
|
||||||
return ['CCSLssSSL', [73, format, 5, drawable, x, y, width, height, planeMask]];
|
return ['CCSLssSSL', [73, format, 5, drawable, x, y, width, height, planeMask]];
|
||||||
},
|
},
|
||||||
function(buf, depth)
|
function(buf, depth) {
|
||||||
{
|
|
||||||
var visualId = buf.unpack('L')[0];
|
var visualId = buf.unpack('L')[0];
|
||||||
return {
|
return {
|
||||||
depth: depth,
|
depth: depth,
|
||||||
|
|
@ -886,15 +892,14 @@ var templates = {
|
||||||
|
|
||||||
PolyText8: [
|
PolyText8: [
|
||||||
function(drawable, gc, x, y, items) {
|
function(drawable, gc, x, y, items) {
|
||||||
|
console.log(['PolyText', items]);
|
||||||
var format = 'CxSLLss';
|
var format = 'CxSLLss';
|
||||||
var numItems = items.length;
|
var numItems = items.length;
|
||||||
var reqLen = 16;
|
var reqLen = 16;
|
||||||
var args = [74, 0, drawable, gc, x, y];
|
var args = [74, 0, drawable, gc, x, y];
|
||||||
for (var i=0; i < numItems; ++i)
|
for (var i = 0; i < numItems; ++i) {
|
||||||
{
|
|
||||||
var it = items[i];
|
var it = items[i];
|
||||||
if (typeof it == 'string')
|
if (typeof it == 'string') {
|
||||||
{
|
|
||||||
if (it.length > 254) // TODO: split string in set of items
|
if (it.length > 254) // TODO: split string in set of items
|
||||||
throw 'not supported yet';
|
throw 'not supported yet';
|
||||||
format += 'CCa';
|
format += 'CCa';
|
||||||
|
|
@ -910,7 +915,7 @@ var templates = {
|
||||||
var padLen = len4 * 4 - reqLen;
|
var padLen = len4 * 4 - reqLen;
|
||||||
args[1] = len4; // set request length to calculated value
|
args[1] = len4; // set request length to calculated value
|
||||||
var pad = '';
|
var pad = '';
|
||||||
for (var i=0; i < padLen; ++i)
|
for (i = 0; i < padLen; ++i)
|
||||||
pad += String.fromCharCode(0);
|
pad += String.fromCharCode(0);
|
||||||
format += 'a';
|
format += 'a';
|
||||||
args.push(pad);
|
args.push(pad);
|
||||||
|
|
@ -918,10 +923,8 @@ var templates = {
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
CreateColormap:
|
CreateColormap: [
|
||||||
[
|
function(cmid, wid, vid, alloc) {
|
||||||
function(cmid, wid, vid, alloc)
|
|
||||||
{
|
|
||||||
return ['CCSLLL', [78, alloc, 4, cmid, wid, vid]];
|
return ['CCSLLL', [78, alloc, 4, cmid, wid, vid]];
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
@ -965,13 +968,11 @@ var templates = {
|
||||||
// TODO: move to buffer.unpackStringList
|
// TODO: move to buffer.unpackStringList
|
||||||
var res = [];
|
var res = [];
|
||||||
var off = 24;
|
var off = 24;
|
||||||
while (off < buf.length)
|
while (off < buf.length) {
|
||||||
{
|
|
||||||
var len = buf[off++];
|
var len = buf[off++];
|
||||||
if (len == 0)
|
if (len === 0)
|
||||||
break;
|
break;
|
||||||
if (off + len > buf.length)
|
if (off + len > buf.length) {
|
||||||
{
|
|
||||||
len = buf.length - off;
|
len = buf.length - off;
|
||||||
if (len <= 0)
|
if (len <= 0)
|
||||||
break;
|
break;
|
||||||
|
|
@ -985,7 +986,7 @@ var templates = {
|
||||||
|
|
||||||
GetKeyboardMapping: [
|
GetKeyboardMapping: [
|
||||||
function(startCode, num) {
|
function(startCode, num) {
|
||||||
return [ 'CxSCCxx', [101, 2, startCode, num] ]
|
return ['CxSCCxx', [101, 2, startCode, num]];
|
||||||
},
|
},
|
||||||
function(buff, listLength) {
|
function(buff, listLength) {
|
||||||
var res = [];
|
var res = [];
|
||||||
|
|
@ -1001,13 +1002,12 @@ var templates = {
|
||||||
// todo: move up to keep reque
|
// todo: move up to keep reque
|
||||||
GetGeometry: [
|
GetGeometry: [
|
||||||
function(drawable) {
|
function(drawable) {
|
||||||
return ['CxSL', [14, 2, drawable]]
|
return ['CxSL', [14, 2, drawable]];
|
||||||
},
|
},
|
||||||
function(buff, depth)
|
function(buff, depth) {
|
||||||
{
|
|
||||||
var res = buff.unpack('LssSSSx');
|
var res = buff.unpack('LssSSSx');
|
||||||
var ext = {};
|
var ext = {};
|
||||||
ext.windowid = res[0]
|
ext.windowid = res[0];
|
||||||
ext.xPos = res[1];
|
ext.xPos = res[1];
|
||||||
ext.yPos = res[2];
|
ext.yPos = res[2];
|
||||||
ext.width = res[3];
|
ext.width = res[3];
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue