mirror of
https://github.com/danbulant/node-x11
synced 2026-07-04 10:40:36 +00:00
PolyPoint request + test
This commit is contained in:
parent
148ba49cde
commit
ea8bc9ed5b
3 changed files with 60 additions and 3 deletions
|
|
@ -217,6 +217,21 @@ module.exports = {
|
||||||
return [format, args];
|
return [format, args];
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
|
PolyPoint: [
|
||||||
|
function(coordMode, drawable, gc, points)
|
||||||
|
{
|
||||||
|
var format = 'CCSLL';
|
||||||
|
var args = [64, coordMode, 3+points.length, drawable, gc];
|
||||||
|
for (var i=0; i < points.length; ++i)
|
||||||
|
{
|
||||||
|
format += 'S';
|
||||||
|
args.push(points[i]);
|
||||||
|
}
|
||||||
|
console.error([format, args]);
|
||||||
|
return [format, args];
|
||||||
|
}
|
||||||
|
],
|
||||||
|
|
||||||
PolyText8: [
|
PolyText8: [
|
||||||
function(drawable, gc, x, y, items) {
|
function(drawable, gc, x, y, items) {
|
||||||
|
|
@ -251,4 +266,4 @@ module.exports = {
|
||||||
return [format, args];
|
return [format, args];
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
43
test/polypoint.js
Normal file
43
test/polypoint.js
Normal file
|
|
@ -0,0 +1,43 @@
|
||||||
|
var x11 = require('../lib/x11');
|
||||||
|
|
||||||
|
var xclient = x11.createClient();
|
||||||
|
var Exposure = x11.eventMask.Exposure;
|
||||||
|
var PointerMotion = x11.eventMask.PointerMotion;
|
||||||
|
var pts = [];
|
||||||
|
|
||||||
|
|
||||||
|
xclient.on('connect', function(display) {
|
||||||
|
var X = this;
|
||||||
|
var root = display.screen[0].root;
|
||||||
|
var white = display.screen[0].white_pixel;
|
||||||
|
var black = display.screen[0].black_pixel;
|
||||||
|
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
X.PolyPoint(0, wid, gc, pts);
|
||||||
|
} else if (ev.type == 6) {
|
||||||
|
pts.push(ev.x);
|
||||||
|
pts.push(ev.y);
|
||||||
|
X.PolyPoint(0, wid, gc, [ev.x, ev.y]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
X.on('error', function(e) {
|
||||||
|
console.log(e);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
@ -22,7 +22,6 @@ xclient.on('connect', function(display) {
|
||||||
X.MapWindow(wid);
|
X.MapWindow(wid);
|
||||||
|
|
||||||
var gc = X.AllocID();
|
var gc = X.AllocID();
|
||||||
console.log('GC: ' + gc);
|
|
||||||
X.CreateGC(gc, wid, { foreground: black, background: white } );
|
X.CreateGC(gc, wid, { foreground: black, background: white } );
|
||||||
|
|
||||||
X.on('event', function(ev) {
|
X.on('event', function(ev) {
|
||||||
|
|
@ -34,4 +33,4 @@ xclient.on('connect', function(display) {
|
||||||
X.on('error', function(e) {
|
X.on('error', function(e) {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue