mirror of
https://github.com/danbulant/node-x11
synced 2026-06-06 16:20:17 +00:00
Add RANDR SetScreenConfig GetScreenInfo requests
- Also added ROTATION and CONFIGSTATUS types.
This commit is contained in:
parent
73dda10b1a
commit
76f969e311
1 changed files with 92 additions and 0 deletions
|
|
@ -40,6 +40,50 @@ exports.requireExt = function(display, callback)
|
||||||
All: 15
|
All: 15
|
||||||
};
|
};
|
||||||
|
|
||||||
|
ext.Rotation = {
|
||||||
|
Rotate_0: 1,
|
||||||
|
Rotate_90: 2,
|
||||||
|
Rotate_180: 4,
|
||||||
|
Rotate_270: 8,
|
||||||
|
Reflect_X: 16,
|
||||||
|
Reflect_Y: 32
|
||||||
|
};
|
||||||
|
|
||||||
|
ext.ConfigStatus = {
|
||||||
|
Sucess: 0,
|
||||||
|
InvalidConfigTime: 1,
|
||||||
|
InvalidTime: 2,
|
||||||
|
Failed: 3
|
||||||
|
};
|
||||||
|
|
||||||
|
ext.SetScreenConfig = function(win, ts, configTs, sizeId, rotation, rate, cb) {
|
||||||
|
X.seq_num ++;
|
||||||
|
X.pack_stream.pack('CCSLLLSSSS', [ext.majorOpcode, 2, 6, win, ts, configTs, sizeId, rotation, rate, 0]);
|
||||||
|
X.replies[X.seq_num] = [
|
||||||
|
function(buf, opt) {
|
||||||
|
var res = buf.unpack('LLLSSLL');
|
||||||
|
return {
|
||||||
|
status : opt,
|
||||||
|
newTs : res [0],
|
||||||
|
configTs : res[1],
|
||||||
|
root : res[2],
|
||||||
|
subpixelOrder : res[3]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
function(err, res) {
|
||||||
|
var err;
|
||||||
|
if (res.status !== 0) {
|
||||||
|
err = new Error('SetScreenConfig error');
|
||||||
|
err.code = res.status;
|
||||||
|
}
|
||||||
|
|
||||||
|
cb(err, res);
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
X.pack_stream.flush();
|
||||||
|
},
|
||||||
|
|
||||||
ext.SelectInput = function(win, mask)
|
ext.SelectInput = function(win, mask)
|
||||||
{
|
{
|
||||||
X.seq_num++;
|
X.seq_num++;
|
||||||
|
|
@ -47,6 +91,54 @@ exports.requireExt = function(display, callback)
|
||||||
X.pack_stream.flush();
|
X.pack_stream.flush();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
ext.GetScreenInfo = function(win, cb) {
|
||||||
|
X.seq_num ++;
|
||||||
|
X.pack_stream.pack('CCSL', [ext.majorOpcode, 5, 2, win]);
|
||||||
|
X.replies[X.seq_num] = [
|
||||||
|
function(buf, opt) {
|
||||||
|
var i, j;
|
||||||
|
var res = buf.unpack('LLLSSSSSS');
|
||||||
|
var info = {
|
||||||
|
rotations : opt,
|
||||||
|
root : res [0],
|
||||||
|
timestamp : res[1],
|
||||||
|
config_timestamp : res[2],
|
||||||
|
nSizes : res[3],
|
||||||
|
sizeID : res[4],
|
||||||
|
rotation : res[5],
|
||||||
|
rate : res[6],
|
||||||
|
nInfo : res[7]
|
||||||
|
};
|
||||||
|
|
||||||
|
var screens_len = info.nSizes * 4;
|
||||||
|
var format = Array(screens_len + 1).join('S');
|
||||||
|
res = buf.unpack(format, 24);
|
||||||
|
info.screens = [];
|
||||||
|
for (i = 0; i < screens_len; i += 4) {
|
||||||
|
console.log(i);
|
||||||
|
info.screens.push({
|
||||||
|
px_width : res[i],
|
||||||
|
px_height : res[i + 1],
|
||||||
|
mm_width : res[i + 2],
|
||||||
|
mm_height : res[i + 3]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
format = Array(info.nInfo + 1).join('S');
|
||||||
|
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) {
|
||||||
|
info.screens[i].rates = res.slice(j + 1, j + 1 + res[j]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return info;
|
||||||
|
},
|
||||||
|
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