From b30a2d8fe3e5c4c9d6f2ef5689382081c4c7ab85 Mon Sep 17 00:00:00 2001 From: sbosse Date: Mon, 21 Jul 2025 23:03:28 +0200 Subject: [PATCH] Mon 21 Jul 22:43:21 CEST 2025 --- js/x11/core/ext/xc-misc.js | 70 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 js/x11/core/ext/xc-misc.js diff --git a/js/x11/core/ext/xc-misc.js b/js/x11/core/ext/xc-misc.js new file mode 100644 index 0000000..17e20a1 --- /dev/null +++ b/js/x11/core/ext/xc-misc.js @@ -0,0 +1,70 @@ +// http://www.x.org/releases/X11R7.6/doc/xcmiscproto/xc-misc.pdf + +var x11 = Require('x11/core/x11'); +// TODO: move to templates + +exports.requireExt = function(display, callback) +{ + var X = display.client; + X.QueryExtension('XC-MISC', function(err, ext) { + + if (!ext.present) + return 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) { + if (err) + return callback(err); + ext.major = vers[0]; + ext.minor = vers[1]; + callback(null, ext); + }); + }); +}