diff --git a/lib/ext/randr.js b/lib/ext/randr.js index dbbe3e4..4a3ddf5 100644 --- a/lib/ext/randr.js +++ b/lib/ext/randr.js @@ -204,7 +204,43 @@ exports.requireExt = function(display, callback) X.pack_stream.flush(); }, + ext.GetOutputInfo = function(output, ts, cb) + { + X.seq_num ++; + X.pack_stream.pack('CCSLL', [ext.majorOpcode, 9, 3, output, ts ]); + X.replies[X.seq_num] = [ + function(buf, opt) { + var i; + var pos = 0; + var res = buf.unpack('LLLLCCSSSSS'); + var info = { + timestamp : res[0], + crtc : res[1], + mm_width : res[2], + mm_height : res[3], + connection : res[4], + subpixelOrder : res[5], + preferredModes: res[8] + }; + pos += 28; + var format = Array(res[6] + 1).join('L'); + info.crtcs = buf.unpack(format, pos); + pos += res[6] << 2; + format = Array(res[7] + 1).join('L'); + info.modes = buf.unpack(format, pos); + pos += res[7] << 2; + format = Array(res[9] + 1).join('L'); + info.clones = buf.unpack(format, pos); + pos += res[9] << 2; + info.name = buf.slice(pos, pos + res_modes[10]).toString('binary'); + return info; + }, + cb + ]; + + X.pack_stream.flush(); + }, ext.GetCrtcInfo = function(crtc, configTs, cb) { X.seq_num ++; X.pack_stream.pack('CCSLL', [ext.majorOpcode, 20, 3, crtc, configTs ]); diff --git a/test/randr.js b/test/randr.js index 6320c8f..bbef058 100644 --- a/test/randr.js +++ b/test/randr.js @@ -1,4 +1,5 @@ var x11 = require('../lib'); +var async = require('async'); var should = require('should'); var assert = require('assert'); var util = require('util'); @@ -35,6 +36,26 @@ describe('RANDR extension', function() { }); }); + it('GetScreenResources && GetOutputInfo', function(done) { + var self = this; + this.randr.GetScreenResources(this.root, function(err, resources) { + should.not.exist(err); + should.exist(resources); + async.each( + resources.outputs, + function(output, cb) { + self.randr.GetOutputInfo(output, 0, function(err, info) { + should.not.exist(err); + should.exist(info); + cb(); + }); + }, + done + ); + + }); + }); + after(function(done) { this.X.terminate(); this.X.on('end', done);