mirror of
https://github.com/danbulant/node-x11
synced 2026-05-27 05:52:02 +00:00
XC-MISC extension
This commit is contained in:
parent
b0931f1feb
commit
f40eb4e3d2
2 changed files with 87 additions and 0 deletions
68
lib/x11/ext/xc-misc.js
Normal file
68
lib/x11/ext/xc-misc.js
Normal file
|
|
@ -0,0 +1,68 @@
|
||||||
|
// http://www.x.org/releases/X11R7.6/doc/xcmiscproto/xc-misc.pdf
|
||||||
|
|
||||||
|
var x11 = require('..');
|
||||||
|
// TODO: move to templates
|
||||||
|
|
||||||
|
exports.requireExt = function(display, callback)
|
||||||
|
{
|
||||||
|
var X = display.client;
|
||||||
|
X.QueryExtension('XC-MISC', function(err, ext) {
|
||||||
|
|
||||||
|
if (!ext.present)
|
||||||
|
callback(new Error('extension not available'));
|
||||||
|
|
||||||
|
ext.QueryVersion = function(clientMaj, clientMin, cb)
|
||||||
|
{
|
||||||
|
X.seq_num++;
|
||||||
|
X.pack_stream.pack('CCSSS', [ext.majorOpcode, 0, 2, clientMaj, clientMin]);
|
||||||
|
X.replies[X.seq_num] = [
|
||||||
|
function(buf, opt) {
|
||||||
|
var res = buf.unpack('SS');
|
||||||
|
return res;
|
||||||
|
},
|
||||||
|
cb
|
||||||
|
];
|
||||||
|
X.pack_stream.flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
ext.GetXIDRange = function(cb)
|
||||||
|
{
|
||||||
|
X.seq_num++;
|
||||||
|
X.pack_stream.pack('CCS', [ext.majorOpcode, 1, 1]);
|
||||||
|
X.replies[X.seq_num] = [
|
||||||
|
function(buf, opt) {
|
||||||
|
var res = buf.unpack('LL');
|
||||||
|
return {
|
||||||
|
startId: res[0],
|
||||||
|
count: res[1]
|
||||||
|
};
|
||||||
|
},
|
||||||
|
cb
|
||||||
|
];
|
||||||
|
X.pack_stream.flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
ext.GetXIDList = function( count, cb )
|
||||||
|
{
|
||||||
|
X.seq_num++;
|
||||||
|
X.pack_stream.pack('CCSL', [ext.majorOpcode, 2, 2, count]);
|
||||||
|
X.replies[X.seq_num] = [
|
||||||
|
function(buf, opt) {
|
||||||
|
var numIds = buf.unpack('L')[0];
|
||||||
|
var res = [];
|
||||||
|
for (var i = 0; i < numIds; ++i)
|
||||||
|
res.push(buf.unpack('L', 24+i*4));
|
||||||
|
return res;
|
||||||
|
},
|
||||||
|
cb
|
||||||
|
];
|
||||||
|
X.pack_stream.flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
ext.QueryVersion(1, 1, function(err, vers) {
|
||||||
|
ext.major = vers[0];
|
||||||
|
ext.minor = vers[1];
|
||||||
|
callback(ext);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
19
test/xcmisc.js
Normal file
19
test/xcmisc.js
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
var x11 = require('../lib/x11');
|
||||||
|
|
||||||
|
x11.createClient(function(display) {
|
||||||
|
var X = display.client;
|
||||||
|
var root = display.screen[0].root;
|
||||||
|
X.require('xc-misc', function(Misc) {
|
||||||
|
var xid = X.AllocID();
|
||||||
|
console.log("first ID from connection: " + xid);
|
||||||
|
debugger;
|
||||||
|
Misc.GetXIDRange(function(err, range) {
|
||||||
|
console.log("ID range from GetIDRange: [start:" + range.startId + ", count: " + range.count + "]");
|
||||||
|
});
|
||||||
|
Misc.GetXIDList(100, function(err, list) {
|
||||||
|
console.log("ID list from GetIDList(100) : " + list);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
X.on('error', function(err) { console.log("Error", err); });
|
||||||
|
|
||||||
|
});
|
||||||
Loading…
Reference in a new issue