mirror of
https://github.com/danbulant/node-x11
synced 2026-06-14 12:11:26 +00:00
bigreq+putimage test
This commit is contained in:
parent
53c5df562b
commit
f41ec2f635
1 changed files with 58 additions and 0 deletions
58
test/putimage1.js
Normal file
58
test/putimage1.js
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
var Buffer = require('buffer').Buffer;
|
||||
var x11 = require('../lib/x11');
|
||||
|
||||
var xclient = x11.createClient();
|
||||
var Exposure = x11.eventMask.Exposure;
|
||||
var PointerMotion = x11.eventMask.PointerMotion;
|
||||
|
||||
var bitmap = new Buffer(128*128*4); // 16384 bits, 2048 bytes bitmap
|
||||
for (var i=0; i < bitmap.length; ++i)
|
||||
{
|
||||
var byteNum = i%4;
|
||||
if (byteNum == 0)
|
||||
bitmap[i] = parseInt((i/512)%256);
|
||||
if (byteNum == 1)
|
||||
bitmap[i] = parseInt((i/2048)%256);
|
||||
if (byteNum == 2)
|
||||
bitmap[i] = parseInt((i/256)%256);
|
||||
|
||||
}
|
||||
|
||||
xclient.on('connect', function(display) {
|
||||
var X = this;
|
||||
|
||||
X.QueryExtension('BIG-REQUESTS', function(BigReq) {
|
||||
console.log(BigReq);
|
||||
BigReq.Enable(function(maxLen) { console.log( maxLen ); });
|
||||
|
||||
var root = display.screen[0].root;
|
||||
var white = display.screen[0].white_pixel;
|
||||
var black = display.screen[0].black_pixel;
|
||||
//console.log(display.screen[0]);
|
||||
|
||||
var wid = X.AllocID();
|
||||
X.CreateWindow(
|
||||
wid, root,
|
||||
10, 10, 400, 300,
|
||||
1, 1, 0,
|
||||
{
|
||||
backgroundPixel: white, eventMask: Exposure|PointerMotion
|
||||
}
|
||||
);
|
||||
X.MapWindow(wid);
|
||||
|
||||
var gc = X.AllocID();
|
||||
X.CreateGC(gc, wid, { foreground: black, background: white } );
|
||||
|
||||
X.on('event', function(ev) {
|
||||
if (ev.type == 12) // expose
|
||||
{
|
||||
X.PutImage(2, wid, gc, 128, 128, 0, 0, 0, 24, bitmap);
|
||||
}
|
||||
});
|
||||
X.on('error', function(e) {
|
||||
console.log(e);
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
Loading…
Reference in a new issue