mirror of
https://github.com/danbulant/node-x11
synced 2026-07-04 18:50:36 +00:00
Add GetScreenResources request and MODEFLAG type
- Don't include the length fields in GetScreenResources and SetScreenConfig replies as the're redundant.
This commit is contained in:
parent
76f969e311
commit
88ac8179c6
1 changed files with 75 additions and 7 deletions
|
|
@ -56,6 +56,23 @@ exports.requireExt = function(display, callback)
|
||||||
Failed: 3
|
Failed: 3
|
||||||
};
|
};
|
||||||
|
|
||||||
|
ext.ModeFlag = {
|
||||||
|
HSyncPositive: 1,
|
||||||
|
HSyncNegative: 2,
|
||||||
|
VSyncPositive: 4,
|
||||||
|
VSyncNegative: 8,
|
||||||
|
Interlace: 16,
|
||||||
|
DoubleScan: 32,
|
||||||
|
CSync: 64,
|
||||||
|
CSyncPositive: 128,
|
||||||
|
CSyncNegative: 256,
|
||||||
|
HSkewPresent: 512,
|
||||||
|
BCast: 1024,
|
||||||
|
PixelMultiplex: 2048,
|
||||||
|
DoubleClock: 4096,
|
||||||
|
ClockDivideBy2: 8192
|
||||||
|
}
|
||||||
|
|
||||||
ext.SetScreenConfig = function(win, ts, configTs, sizeId, rotation, rate, cb) {
|
ext.SetScreenConfig = function(win, ts, configTs, sizeId, rotation, rate, cb) {
|
||||||
X.seq_num ++;
|
X.seq_num ++;
|
||||||
X.pack_stream.pack('CCSLLLSSSS', [ext.majorOpcode, 2, 6, win, ts, configTs, sizeId, rotation, rate, 0]);
|
X.pack_stream.pack('CCSLLLSSSS', [ext.majorOpcode, 2, 6, win, ts, configTs, sizeId, rotation, rate, 0]);
|
||||||
|
|
@ -103,19 +120,18 @@ exports.requireExt = function(display, callback)
|
||||||
root : res [0],
|
root : res [0],
|
||||||
timestamp : res[1],
|
timestamp : res[1],
|
||||||
config_timestamp : res[2],
|
config_timestamp : res[2],
|
||||||
nSizes : res[3],
|
|
||||||
sizeID : res[4],
|
sizeID : res[4],
|
||||||
rotation : res[5],
|
rotation : res[5],
|
||||||
rate : res[6],
|
rate : res[6]
|
||||||
nInfo : res[7]
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var screens_len = info.nSizes * 4;
|
var nSizes = res[3];
|
||||||
|
var nInfo = res[7];
|
||||||
|
var screens_len = nSizes << 2;
|
||||||
var format = Array(screens_len + 1).join('S');
|
var format = Array(screens_len + 1).join('S');
|
||||||
res = buf.unpack(format, 24);
|
res = buf.unpack(format, 24);
|
||||||
info.screens = [];
|
info.screens = [];
|
||||||
for (i = 0; i < screens_len; i += 4) {
|
for (i = 0; i < screens_len; i += 4) {
|
||||||
console.log(i);
|
|
||||||
info.screens.push({
|
info.screens.push({
|
||||||
px_width : res[i],
|
px_width : res[i],
|
||||||
px_height : res[i + 1],
|
px_height : res[i + 1],
|
||||||
|
|
@ -124,9 +140,8 @@ exports.requireExt = function(display, callback)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
format = Array(info.nInfo + 1).join('S');
|
format = Array(nInfo + 1).join('S');
|
||||||
res = buf.unpack(format, 24 + screens_len * 2);
|
res = buf.unpack(format, 24 + screens_len * 2);
|
||||||
i = 0, j = 0;
|
|
||||||
for (i = 0, j = 0; i < info.screens.length; ++i, j += res[j] + 1) {
|
for (i = 0, j = 0; i < info.screens.length; ++i, j += res[j] + 1) {
|
||||||
info.screens[i].rates = res.slice(j + 1, j + 1 + res[j]);
|
info.screens[i].rates = res.slice(j + 1, j + 1 + res[j]);
|
||||||
}
|
}
|
||||||
|
|
@ -139,6 +154,59 @@ exports.requireExt = function(display, callback)
|
||||||
X.pack_stream.flush();
|
X.pack_stream.flush();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
ext.GetScreenResources = function(win, cb)
|
||||||
|
{
|
||||||
|
X.seq_num ++;
|
||||||
|
X.pack_stream.pack('CCSL', [ext.majorOpcode, 8, 2, win]);
|
||||||
|
X.replies[X.seq_num] = [
|
||||||
|
function(buf, opt) {
|
||||||
|
var i;
|
||||||
|
var pos = 0;
|
||||||
|
var res = buf.unpack('LLSSSSxxxxxxxx');
|
||||||
|
var resources = {
|
||||||
|
timestamp : res[0],
|
||||||
|
config_timestamp : res[1],
|
||||||
|
modeinfos : []
|
||||||
|
};
|
||||||
|
|
||||||
|
pos += 24;
|
||||||
|
var format = Array(res[2] + 1).join('L');
|
||||||
|
resources.crcs = buf.unpack(format, pos);
|
||||||
|
pos += res[2] << 2;
|
||||||
|
format = Array(res[3] + 1).join('L');
|
||||||
|
resources.outputs = buf.unpack(format, pos);
|
||||||
|
pos += res[3] << 2;
|
||||||
|
format = Array(res[4] + 1).join('LSSLSSSSSSSSL');
|
||||||
|
res_modes = buf.unpack(format, pos);
|
||||||
|
pos += res[4] << 5;
|
||||||
|
for (i = 0; i < res_modes[4]; i+= 13) {
|
||||||
|
resources.modeinfos.push({
|
||||||
|
id : res_modes[i + 0],
|
||||||
|
width : res_modes[i + 1],
|
||||||
|
height : res_modes[i + 2],
|
||||||
|
dot_clock : res_modes[i + 3],
|
||||||
|
h_sync_start : res_modes[i + 4],
|
||||||
|
h_sync_end : res_modes[i + 5],
|
||||||
|
h_total : res_modes[i + 6],
|
||||||
|
h_skew : res_modes[i + 7],
|
||||||
|
v_sync_start : res_modes[i + 8],
|
||||||
|
v_sync_end : res_modes[i + 9],
|
||||||
|
v_total : res_modes[i + 10],
|
||||||
|
modeflags : res_modes[i + 12],
|
||||||
|
name : buf.slice(pos, pos + res_modes[i + 11]).toString()
|
||||||
|
});
|
||||||
|
|
||||||
|
pos += res_modes[i + 11];
|
||||||
|
}
|
||||||
|
|
||||||
|
return resources;
|
||||||
|
},
|
||||||
|
cb
|
||||||
|
];
|
||||||
|
|
||||||
|
X.pack_stream.flush();
|
||||||
|
},
|
||||||
|
|
||||||
X.eventParsers[ext.firstEvent + ext.events.RRScreenChangeNotify] = function(type, seq, extra, code, raw)
|
X.eventParsers[ext.firstEvent + ext.events.RRScreenChangeNotify] = function(type, seq, extra, code, raw)
|
||||||
{
|
{
|
||||||
var event = {};
|
var event = {};
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue