mirror of
https://github.com/danbulant/node-x11
synced 2026-06-14 04:01:10 +00:00
cleanups/renames
This commit is contained in:
parent
f2c3090e9a
commit
65dd846cb8
30 changed files with 123 additions and 1581 deletions
|
|
@ -1,103 +0,0 @@
|
|||
var x11 = require('../../lib/x11');
|
||||
var watchMobile = require('./staticserver');
|
||||
var PointerMotion = x11.eventMask.PointerMotion;
|
||||
|
||||
var X, Render;
|
||||
var rocketX = 400;
|
||||
var rocketY = 300;
|
||||
var speedX = 0;
|
||||
var speedY = 0;
|
||||
var angle = 0;
|
||||
var acc = 0;
|
||||
|
||||
|
||||
var xclient = x11.createClient(function(display) {
|
||||
X = display.client;
|
||||
var root = display.screen[0].root;
|
||||
X.require('render', function(rendExt) {
|
||||
|
||||
|
||||
Render = rendExt;
|
||||
var wid = X.AllocID();
|
||||
|
||||
var white = display.screen[0].white_pixel;
|
||||
var black = display.screen[0].black_pixel;
|
||||
X.CreateWindow(wid, root, 10, 10, 900, 600, 1, 1, 0, { backgroundPixel: white, eventMask: PointerMotion });
|
||||
X.MapWindow(wid);
|
||||
|
||||
var gc = X.AllocID();
|
||||
X.CreateGC(gc, wid, { foreground: white, background: black } );
|
||||
|
||||
var pict = X.AllocID();
|
||||
Render.CreatePicture(pict, wid, Render.rgb24);
|
||||
var pictGrad = X.AllocID();
|
||||
Render.RadialGradient(pictGrad, [50,56], [50,50], 0, 50,
|
||||
[
|
||||
[0, [0,0,0xffff,0xffff ] ],
|
||||
[0.95, [0,0,0,0x00ff00 ] ],
|
||||
[0.997, [0xffff, 0xf, 0, 0x1] ],
|
||||
[1, [0xffff, 0xffff, 0, 0x0] ]
|
||||
]);
|
||||
|
||||
var solid = Render.SolidFill
|
||||
var dark_grad = X.AllocID();
|
||||
Render.LinearGradient(dark_grad, [0,0], [1000,100],
|
||||
[
|
||||
[0, [0,0,0,0x0 ] ],
|
||||
[0.1, [0xfff, 0, 0xffff, 0] ] ,
|
||||
[0.25, [0xfff, 0, 0xfff, 0] ] ,
|
||||
[0.5, [0xfff, 0, 0xffff, 0] ] ,
|
||||
[1, [0xfff, 0xffff, 0, 0] ]
|
||||
]);
|
||||
|
||||
function draw(x, y) {
|
||||
|
||||
X.PolyFillRectangle(wid, gc, [0, 0, 1000, 1000]);
|
||||
Render.Composite(3, pictGrad, 0, pict, 0, 0, 0, 0, rocketX - 50, rocketY - 50, 100, 100);
|
||||
// draw directed triangle
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
var pts = [
|
||||
rocketX + Math.cos(angle)*50, rocketY + Math.sin(angle)*50,
|
||||
rocketX + Math.cos(angle + 1)*50, rocketY + Math.sin(angle+1)*50,
|
||||
rocketX + Math.cos(angle + 2)*50, rocketY + Math.sin(angle+2)*50,
|
||||
|
||||
];
|
||||
//Render.Triangles(3, dark_grad, 0, 0, dark_grad, 0, pts);
|
||||
X.PolyLine(0, wid, gc, pts);
|
||||
}
|
||||
|
||||
X.on('event', function(ev) {
|
||||
//draw(ev.x, ev.y);
|
||||
});
|
||||
|
||||
watchMobile(function(x, y, z) {
|
||||
//console.log([x, y, z]);
|
||||
//console.log(x);
|
||||
angle = 2*Math.PI*(y/360);
|
||||
acc = 90 - z;
|
||||
draw();
|
||||
});
|
||||
|
||||
function updateScene()
|
||||
{
|
||||
rocketX += speedX;
|
||||
rocketY += speedY;
|
||||
speedX += Math.cos(angle + 1)*acc/500;
|
||||
speedY += Math.sin(angle + 1)*acc/500;
|
||||
console.log(acc);
|
||||
if (rocketX+100 > 900)
|
||||
speedX = -speedX;
|
||||
if (rocketX-100 < 0)
|
||||
speedX = -speedX;
|
||||
if (rocketY+100 > 600)
|
||||
speedY = -speedY;
|
||||
if (rocketY-100 < 0)
|
||||
speedY = -speedY;
|
||||
}
|
||||
setInterval(updateScene, 50);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
@ -1 +0,0 @@
|
|||
Subproject commit aa529ee711d3c0704c9721710f164acedc5b2fc7
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="initial-scale=1.0; maximum-scale=1.0; user-scalable=no" />
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
window.addEventListener('deviceorientation', function(event){
|
||||
//console.log(angles);
|
||||
|
||||
xmlhttp=new XMLHttpRequest();
|
||||
xmlhttp.open("GET","orientation_" + event.alpha + "_" + event.gamma + "_" + event.beta, true);
|
||||
//xmlhttp.open("GET","orientation_", true);
|
||||
xmlhttp.send();
|
||||
}, true);
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="head">
|
||||
<a href="index.html">« Back</a>
|
||||
<b>Mobile Power! by @cpojer.</b> <a href="http://github.com/cpojer">GitHub</a> <a href="http://twitter.com/cpojer">Twitter</a>
|
||||
</div>
|
||||
<div class="container">
|
||||
<div id="box1" class="box">
|
||||
Orientation!
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1,45 +0,0 @@
|
|||
var http = require("http"),
|
||||
url = require("url"),
|
||||
path = require("path"),
|
||||
fs = require("fs")
|
||||
port = process.argv[2] || 8888;
|
||||
|
||||
module.exports = function(cb)
|
||||
{
|
||||
console.log('here');
|
||||
http.createServer(function(request, response) {
|
||||
|
||||
var uri = url.parse(request.url).pathname
|
||||
, filename = path.join(process.cwd(), uri);
|
||||
|
||||
path.exists(filename, function(exists) {
|
||||
if(!exists) {
|
||||
var params = filename.split('_');
|
||||
console.log(params);
|
||||
if (params.length == 4)
|
||||
cb(params[1], params[2], params[3]);
|
||||
response.writeHead(404, {"Content-Type": "text/plain"});
|
||||
response.write("404 Not Found\n");
|
||||
response.end();
|
||||
return;
|
||||
}
|
||||
|
||||
if (fs.statSync(filename).isDirectory()) filename += '/index.html';
|
||||
|
||||
fs.readFile(filename, "binary", function(err, file) {
|
||||
if(err) {
|
||||
response.writeHead(500, {"Content-Type": "text/plain"});
|
||||
response.write(err + "\n");
|
||||
response.end();
|
||||
return;
|
||||
}
|
||||
|
||||
response.writeHead(200);
|
||||
response.write(file, "binary");
|
||||
response.end();
|
||||
});
|
||||
});
|
||||
}).listen(parseInt(port, 10));
|
||||
|
||||
console.log("Static file server running at\n => http://localhost:" + port + "/\nCTRL + C to shutdown");
|
||||
}
|
||||
|
|
@ -1,482 +0,0 @@
|
|||
// this will be eventually moved to lib/node-x11/extensions
|
||||
|
||||
var x11 = require('../lib/x11');
|
||||
|
||||
// adding XRender functions manually from
|
||||
// http://cgit.freedesktop.org/xcb/proto/tree/src/render.xml?id=HEAD
|
||||
// and http://www.x.org/releases/X11R7.6/doc/renderproto/renderproto.txt
|
||||
// TODO: move to templates
|
||||
x11.createClient(
|
||||
function(display) {
|
||||
var X = display.client;
|
||||
X.QueryExtension('RENDER', function(ext) {
|
||||
|
||||
console.log(ext);
|
||||
|
||||
function RenderQueryVersion(clientMaj, clientMin, callback)
|
||||
{
|
||||
X.seq_num++;
|
||||
X.pack_stream.pack('CCSLL', [ext.majorOpcode, 0, 3, clientMaj, clientMin]);
|
||||
X.replies[X.seq_num] = [
|
||||
function(buf, opt) {
|
||||
var res = buf.unpack('LL');
|
||||
return res;
|
||||
},
|
||||
callback
|
||||
];
|
||||
X.pack_stream.flush();
|
||||
}
|
||||
|
||||
function RenderQueryPictFormat(callback)
|
||||
{
|
||||
X.seq_num++;
|
||||
X.pack_stream.pack('CCS', [ext.majorOpcode, 1, 1]);
|
||||
X.replies[X.seq_num] = [
|
||||
function (buf, opt) {
|
||||
var res = {};
|
||||
var res1 = buf.unpack('LLLLL');
|
||||
var num_formats = res1[0];
|
||||
var num_screens = res1[1];
|
||||
var num_depths = res1[2];
|
||||
var num_visuals = res1[3];
|
||||
var num_subpixel = res1[4];
|
||||
// formats list:
|
||||
var offset = 24;
|
||||
res.formats = [];
|
||||
for (var i=0; i < num_formats; ++i)
|
||||
{
|
||||
var format = {};
|
||||
var f = buf.unpack('LCCxxSSSSSSSSL', offset);
|
||||
res.formats.push(f);
|
||||
offset += 28;
|
||||
}
|
||||
return res;
|
||||
},
|
||||
callback
|
||||
];
|
||||
X.pack_stream.flush();
|
||||
}
|
||||
|
||||
function RenderQueryFilters(callback)
|
||||
{
|
||||
X.seq_num++;
|
||||
X.pack_stream.pack('CCSL', [ext.majorOpcode, 29, 2, display.screen[0].root]);
|
||||
X.replies[X.seq_num] = [
|
||||
function(buf, opt) {
|
||||
var h = buf.unpack('LL');
|
||||
var num_aliases = h[0];
|
||||
var num_filters = h[1];
|
||||
var aliases = [];
|
||||
var offset = 24; // LL + 16 bytes pad
|
||||
for (var i=0; i < num_aliases; ++i)
|
||||
{
|
||||
aliases.push(buf.unpack('S', offset)[0]);
|
||||
offset+=2;
|
||||
}
|
||||
var filters = [];
|
||||
for (var i=0; i < num_filters; ++i)
|
||||
{
|
||||
var len = buf.unpack('C', offset)[0];
|
||||
//if (!len) break;
|
||||
offset++;
|
||||
filters.push(buf.toString('ascii', offset, offset+len));
|
||||
offset+=len;
|
||||
}
|
||||
return [aliases, filters];
|
||||
},
|
||||
callback
|
||||
];
|
||||
X.pack_stream.flush();
|
||||
}
|
||||
|
||||
var valueList = [
|
||||
['repeat', 'C'],
|
||||
['alphaMap', 'L'],
|
||||
['alphaXOrigin', 's'],
|
||||
['alphaYOrigin', 's'],
|
||||
['clipXOrigin', 's'],
|
||||
['clipYOrigin', 's'],
|
||||
['clipMask', 'L'],
|
||||
['graphicsExposures', 'C'],
|
||||
['subwindowMode', 'C'],
|
||||
['polyEdge', 'C'],
|
||||
['polyMode', 'C'],
|
||||
['dither', 'L'],
|
||||
['componentAlpha', 'C']
|
||||
];
|
||||
|
||||
var argumentLength = {
|
||||
C: 1,
|
||||
S: 2,
|
||||
s: 2,
|
||||
L: 4,
|
||||
x: 1
|
||||
};
|
||||
|
||||
function RenderCreatePicture(pid, drawable, pictformat, values)
|
||||
{
|
||||
X.seq_num++;
|
||||
var mask = 0;
|
||||
var reqLen = 5; // + (values + pad)/4
|
||||
var format = 'CCSLLLL';
|
||||
var params = [ext.majorOpcode, 4, reqLen, pid, drawable, pictformat, mask];
|
||||
|
||||
if (values)
|
||||
{
|
||||
var valuesLength = 0;
|
||||
for (var i=0; i < valueList.length; ++i)
|
||||
{
|
||||
var val = values[valueList[i][0]];
|
||||
if (val) {
|
||||
mask |= (1 << i);
|
||||
params.push(val);
|
||||
var valueFormat = valueList[i][1];
|
||||
format += valueFormat;
|
||||
valuesLength += argumentLength[valueFormat];
|
||||
}
|
||||
}
|
||||
var pad4 = (valuesLength + 3) >> 2;
|
||||
var toPad = (pad4 << 2) - valuesLength;
|
||||
for (var i=0; i < toPad; ++i)
|
||||
format += 'x';
|
||||
reqLen += pad4;
|
||||
params[2] = reqLen;
|
||||
params[6] = mask;
|
||||
}
|
||||
X.pack_stream.pack(format, params);
|
||||
X.pack_stream.flush();
|
||||
}
|
||||
|
||||
function floatToFix(f)
|
||||
{
|
||||
return parseInt(f*65536);
|
||||
}
|
||||
|
||||
// see example of blur filter here: https://github.com/richoH/rxvt-unicode/blob/master/src/background.C
|
||||
// TODO: not ready yet.
|
||||
function RenderSetPictureFilter(pid, name, filterParams)
|
||||
{
|
||||
X.seq_num++;
|
||||
var reqLen = 2; //header + params + 1xStopfix+2xColors
|
||||
var format = 'CCSLa';
|
||||
var params = [ext.majorOpcode, 30, reqLen, pid];
|
||||
/*
|
||||
if (name == 'convolution')
|
||||
{
|
||||
reqLen += 2;
|
||||
format += 'L';
|
||||
params.push(floatToFix(filterParams));
|
||||
} else {
|
||||
throw 'Not implemented filter ' + name;
|
||||
}
|
||||
*/
|
||||
params[2] = reqLen;
|
||||
//console.log([format, params]);
|
||||
X.pack_stream.pack(format, params);
|
||||
X.pack_stream.flush();
|
||||
}
|
||||
|
||||
function RenderRadialGradient(pid, p1, p2, r1, r2, stops)
|
||||
{
|
||||
// TODO: merge with linear gradient
|
||||
X.seq_num++;
|
||||
var reqLen = 9+stops.length*3; //header + params + 1xStopfix+2xColors
|
||||
var format = 'CCSLLLLLLLL';
|
||||
var params = [ext.majorOpcode, 35, reqLen, pid];
|
||||
params.push(floatToFix(p1[0])); // L
|
||||
params.push(floatToFix(p1[1]));
|
||||
params.push(floatToFix(p2[0]));
|
||||
params.push(floatToFix(p2[1])); // L
|
||||
params.push(floatToFix(r1)); // L
|
||||
params.push(floatToFix(r2)); // L
|
||||
params.push(stops.length);
|
||||
|
||||
// [ [float stopDist, [float r, g, b, a] ], ...]
|
||||
// stop distances
|
||||
for (var i=0; i < stops.length; ++i)
|
||||
{
|
||||
format += 'L';
|
||||
// TODO: we know total params length in advance. ? params[index] =
|
||||
params.push(floatToFix(stops[i][0]))
|
||||
}
|
||||
// colors
|
||||
for (var i=0; i < stops.length; ++i)
|
||||
{
|
||||
format += 'SSSS';
|
||||
for (var j=0; j < 4; ++j)
|
||||
params.push(stops[i][1][j]);
|
||||
}
|
||||
//console.log([format, params]);
|
||||
X.pack_stream.pack(format, params);
|
||||
X.pack_stream.flush();
|
||||
}
|
||||
|
||||
function RenderLinearGradient(pid, p1, p2, stops)
|
||||
{
|
||||
X.seq_num++;
|
||||
var reqLen = 7+stops.length*3; //header + params + 1xStopfix+2xColors
|
||||
var format = 'CCSLLLLLL';
|
||||
var params = [ext.majorOpcode, 34, reqLen, pid];
|
||||
params.push(floatToFix(p1[0])); // L
|
||||
params.push(floatToFix(p1[1]));
|
||||
params.push(floatToFix(p2[0]));
|
||||
params.push(floatToFix(p2[1])); // L
|
||||
|
||||
params.push(stops.length);
|
||||
|
||||
// [ [float stopDist, [float r, g, b, a] ], ...]
|
||||
// stop distances
|
||||
for (var i=0; i < stops.length; ++i)
|
||||
{
|
||||
format += 'L';
|
||||
// TODO: we know total params length in advance. ? params[index] =
|
||||
params.push(floatToFix(stops[i][0]))
|
||||
}
|
||||
// colors
|
||||
for (var i=0; i < stops.length; ++i)
|
||||
{
|
||||
format += 'SSSS';
|
||||
for (var j=0; j < 4; ++j)
|
||||
params.push(stops[i][1][j]);
|
||||
}
|
||||
//console.log([format, params]);
|
||||
X.pack_stream.pack(format, params);
|
||||
X.pack_stream.flush();
|
||||
}
|
||||
|
||||
function RenderConicalGradient(pid, center, angle, stops)
|
||||
{
|
||||
X.seq_num++;
|
||||
var reqLen = 6+stops.length*3; //header + params + 1xStopfix+2xColors
|
||||
var format = 'CCSLLLLL';
|
||||
var params = [ext.majorOpcode, 36, reqLen, pid];
|
||||
params.push(floatToFix(center[0])); // L
|
||||
params.push(floatToFix(center[1]));
|
||||
params.push(floatToFix(angle)); // L
|
||||
|
||||
params.push(stops.length);
|
||||
|
||||
// [ [float stopDist, [float r, g, b, a] ], ...]
|
||||
// stop distances
|
||||
for (var i=0; i < stops.length; ++i)
|
||||
{
|
||||
format += 'L';
|
||||
// TODO: we know total params length in advance. ? params[index] =
|
||||
params.push(floatToFix(stops[i][0]))
|
||||
}
|
||||
// colors
|
||||
for (var i=0; i < stops.length; ++i)
|
||||
{
|
||||
format += 'SSSS';
|
||||
for (var j=0; j < 4; ++j)
|
||||
params.push(stops[i][1][j]);
|
||||
}
|
||||
//console.log([format, params]);
|
||||
X.pack_stream.pack(format, params);
|
||||
X.pack_stream.flush();
|
||||
}
|
||||
|
||||
function RenderFillRectangles(op, pid, color, rects)
|
||||
{
|
||||
X.seq_num++;
|
||||
var reqLen = 5+rects.length/2;
|
||||
var format = 'CCSCxxxLSSSS';
|
||||
var params = [ext.majorOpcode, 26, reqLen, op, pid];
|
||||
for (var j=0; j < 4; ++j)
|
||||
params.push(color[j]);
|
||||
for (var i=0; i < rects.length; i+=4)
|
||||
{
|
||||
format += 'ssSS';
|
||||
params.push(rects[i*4]);
|
||||
params.push(rects[i*4 + 1]);
|
||||
params.push(rects[i*4 + 2]);
|
||||
params.push(rects[i*4 + 3]);
|
||||
}
|
||||
//console.log([format, params]);
|
||||
X.pack_stream.pack(format, params);
|
||||
X.pack_stream.flush();
|
||||
}
|
||||
|
||||
function RenderComposite(op, src, mask, dst, srcX, srcY, maskX, maskY, dstX, dstY, width, height)
|
||||
{
|
||||
X.seq_num++;
|
||||
X.pack_stream.pack(
|
||||
'CCSCxxxLLLssssssSS',
|
||||
[ext.majorOpcode, 8, 9, op, src, mask, dst, srcX, srcY, maskX, maskY, dstX, dstY, width, height]
|
||||
)
|
||||
.flush();
|
||||
//console.log([ 'CCSCxxxLLLssssssSS',
|
||||
// [ext.majorOpcode, 8, 9, op, src, mask, dst, srcX, srcY, maskX, maskY, dstX, dstY, width, height]]);
|
||||
}
|
||||
|
||||
function RenderTrapezoids(op, src, srcX, srcY, dst, maskFormat, trapz)
|
||||
{
|
||||
X.seq_num++;
|
||||
var format = 'CCSCxxxLLLss';
|
||||
var params = [ext.majorOpcode, 10, 6+trapz.length, op, src, dst, maskFormat, srcX, srcY];
|
||||
for (var i=0; i < trapz.length; i+=10)
|
||||
{
|
||||
format += 'llllllllll';
|
||||
for (var j=0; j < 10; ++j)
|
||||
params.push(floatToFix(trapz[i*10 + j]));
|
||||
}
|
||||
//console.log([format, params]);
|
||||
X.pack_stream.pack(format, params);
|
||||
X.pack_stream.flush();
|
||||
}
|
||||
|
||||
function RenderTriangles(op, src, srcX, srcY, dst, maskFormat, tris)
|
||||
{
|
||||
X.seq_num++;
|
||||
var format = 'CCSCxxxLLLss';
|
||||
var params = [ext.majorOpcode, 11, 6+tris.length, op, src, dst, maskFormat, srcX, srcY];
|
||||
for (var i=0; i < tris.length; i+=6)
|
||||
{
|
||||
format += 'llllll';
|
||||
//TODO: Array.copy
|
||||
params.push(floatToFix(tris[i*6 + 0])); // x1
|
||||
params.push(floatToFix(tris[i*6 + 1])); // y1
|
||||
params.push(floatToFix(tris[i*6 + 2])); // x2
|
||||
params.push(floatToFix(tris[i*6 + 3])); // y2
|
||||
params.push(floatToFix(tris[i*6 + 4])); // x3
|
||||
params.push(floatToFix(tris[i*6 + 5])); // y3
|
||||
}
|
||||
X.pack_stream.pack(format, params);
|
||||
X.pack_stream.flush();
|
||||
}
|
||||
|
||||
var root = display.screen[0].root;
|
||||
var win = X.AllocID();
|
||||
var white = display.screen[0].white_pixel;
|
||||
var black = display.screen[0].black_pixel;
|
||||
X.CreateWindow(win, root, 0, 0, 500, 500, 4, 1, 0,
|
||||
{
|
||||
backgroundPixel: white,
|
||||
eventMask: x11.eventMask.Exposure | x11.eventMask.ButtonPress | x11.eventMask.PointerMotion
|
||||
});
|
||||
X.MapWindow(win);
|
||||
|
||||
RenderQueryPictFormat(function(formats) {
|
||||
var mono1, rgb24, rgba32;
|
||||
for (var i=0; i < formats.formats.length; ++i) {
|
||||
var f = formats.formats[i];
|
||||
if (f[2] == 1 && f[10] == 1)
|
||||
mono1 = f[0] ;
|
||||
if (f[2] == 24 && f[3] == 16 && f[5] == 8 && f[7] == 0)
|
||||
rgb24 = f[0];
|
||||
if (f[2] == 32 && f[3] == 16 && f[5] == 8 && f[7] == 0 && f[9] == 24)
|
||||
rgba32 = f[0] ;
|
||||
}
|
||||
|
||||
var picture = X.AllocID();
|
||||
RenderCreatePicture(picture, win, rgb24, { polyEdge: 1, polyMode: 0 } );
|
||||
var pixmap = X.AllocID();
|
||||
X.CreatePixmap(pixmap, win, 32, 500, 500);
|
||||
var pix_pict = X.AllocID();
|
||||
RenderCreatePicture(pix_pict, pixmap, rgba32, { polyEdge: 1, polyMode: 0 });
|
||||
|
||||
var pic_grad = X.AllocID();
|
||||
RenderLinearGradient(pic_grad, [0,0], [1000,100],
|
||||
//RenderRadialGradient(pic_grad, [0,0], [1000,100], 10, 1000,
|
||||
//RenderConicalGradient(pic_grad, [250,250], 360,
|
||||
[
|
||||
[0, [0,0,0,0x3000 ] ],
|
||||
[0.1, [0xfff, 0, 0xffff, 0x1000] ] ,
|
||||
[0.25, [0xffff, 0, 0xfff, 0x3000] ] ,
|
||||
[0.5, [0xffff, 0, 0xffff, 0x4000] ] ,
|
||||
[1, [0xffff, 0xffff, 0, 0x8000] ]
|
||||
]);
|
||||
|
||||
var pic_grad1 = X.AllocID();
|
||||
|
||||
RenderConicalGradient(pic_grad1, [250,250], 10,
|
||||
[
|
||||
[0, [0,0,0,0x5000 ] ],
|
||||
[0.1, [0xfff, 0, 0xffff, 0x3000] ] ,
|
||||
[0.25, [0xffff, 0, 0xfff, 0x2000] ] ,
|
||||
[0.5, [0xffff, 0, 0xffff, 0x1000] ] ,
|
||||
[1, [0xffff, 0xffff, 0, 0x8000] ]
|
||||
]);
|
||||
|
||||
var pic_grad2 = X.AllocID();
|
||||
RenderRadialGradient(pic_grad2, [250,250], [250,250], 0, 250,
|
||||
[
|
||||
[0, [0,0,0,0x5000 ] ],
|
||||
[0.99, [0xffff, 0xffff, 0, 0xffff] ],
|
||||
[1, [0xffff, 0xffff, 0, 0x0] ]
|
||||
]);
|
||||
|
||||
var pixmap1 = X.AllocID();
|
||||
X.CreatePixmap(pixmap1, win, 32, 500, 500);
|
||||
var pix_pict1 = X.AllocID();
|
||||
RenderCreatePicture(pix_pict1, pixmap1, rgba32, { polyEdge: 1, polyMode: 0 });
|
||||
RenderComposite(3, pic_grad2, 0, pix_pict1, 0, 0, 0, 0, 0, 0, 500, 500);
|
||||
|
||||
var pixmap2 = X.AllocID();
|
||||
X.CreatePixmap(pixmap2, win, 32, 500, 500);
|
||||
var pix_pict2 = X.AllocID();
|
||||
RenderCreatePicture(pix_pict2, pixmap2, rgba32, { polyEdge: 1, polyMode: 0 });
|
||||
for(var i=0; i < 100; ++i)
|
||||
{
|
||||
var pts = [];
|
||||
for (var coord = 0; coord < 6; coord++)
|
||||
pts.push(Math.random()*500);
|
||||
RenderTriangles(3, pic_grad, Math.random()*600, Math.random()*500, pix_pict2, 0, pts);
|
||||
}
|
||||
|
||||
function update()
|
||||
{
|
||||
RenderFillRectangles(1, pix_pict, [0xffff, 0xffff, 0xffff, 0xffff], [0, 0, 500, 500]);
|
||||
RenderComposite(3, pix_pict2, 0, pix_pict, 0, 0, 0, 0, X.x1, X.y1, 500, 500);
|
||||
//RenderComposite(3, pic_grad, 0, pix_pict, 0, 0, 0, 0, 0, 0, 500, 500);
|
||||
RenderComposite(3, pix_pict1, 0, pix_pict, 0, 0, 0, 0, X.x2, X.y2, 500, 500);
|
||||
}
|
||||
|
||||
function draw()
|
||||
{
|
||||
RenderComposite(3, pix_pict, 0, picture, 0, 0, 0, 0, 0, 0, 500, 500);
|
||||
}
|
||||
|
||||
X.x1 = X.y1 = X.x2 = X.y2 = 0;
|
||||
update();
|
||||
draw();
|
||||
|
||||
X.on('event', function(ev) {
|
||||
if (ev.type == 4)
|
||||
{
|
||||
if (ev.keycode == 4)
|
||||
X.x1 += 10;
|
||||
else
|
||||
X.x1 -= 10;
|
||||
update();
|
||||
draw();
|
||||
} else if (ev.type == 6) // mouse move
|
||||
{
|
||||
X.x2 = ev.x - 250;
|
||||
X.y2 = ev.y - 250;
|
||||
update();
|
||||
draw();
|
||||
} else {
|
||||
draw();
|
||||
}
|
||||
|
||||
//RenderFillRectangles(1, picture, [0xffff, 0xffff, 0xffff, 0xffff], [0, 0, 500, 500]);
|
||||
//RenderFillRectangles(1, picture, [0xffff, 0xffff, 0x0000, 0xffff], [10, 10, 50, 50]);
|
||||
|
||||
//RenderTriangles(3, pic_grad, 0, 0, picture, 0, [0, 0, 500, 0, 0, 500]);
|
||||
//RenderTriangles(3, pic_grad, 0, 0, picture, 0, [0, 500, 500, 500, 500, 0]);
|
||||
//RenderTrapezoids(3, pic_grad, 0, 0, picture, 0, [100, 500, 240, 0, 0, 500, 500, 500, 260, 0]);
|
||||
//RenderTrapezoids(3, pic_grad, 0, 0, picture, 0, [0, 500, 0, 0, 0, 500, 500, 500, 500, 0]);
|
||||
//RenderSetPictureFilter(pix_pict, 'convolution', [3, 3, 0, 0, 0, 0, 9, 0, 0, 0, 0]);
|
||||
//RenderComposite(3, pix_pict, 0, picture, 0, 0, 0, 0, 0, 0, 500, 500);
|
||||
//RenderComposite(3, pic_grad, 0, picture, 0, 0, 0, 0, 0, 0, 500, 500);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
}); // <- everything above is a body of callback to QueryPictFormats
|
||||
}
|
||||
|
||||
).on('error', function(err) {
|
||||
console.log(['error! : ', err]);
|
||||
});
|
||||
34
examples/simple/alloccolor.js
Normal file
34
examples/simple/alloccolor.js
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
var x11 = require('../lib/x11');
|
||||
|
||||
var Exposure = x11.eventMask.Exposure;
|
||||
|
||||
x11.createClient(function(display) {
|
||||
var repaint;
|
||||
var X = display.client;
|
||||
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
|
||||
);
|
||||
X.MapWindow(wid);
|
||||
|
||||
// parameters: colormap, red, green, blue
|
||||
X.AllocColor(display.screen[0].default_colormap, 0xffff, 0xffff, 0, function(err, color) {
|
||||
var gc = X.AllocID();
|
||||
X.CreateGC(gc, wid, { foreground: color.pixel, background: black } );
|
||||
repaint = setInterval(function() {
|
||||
X.PolyFillRectangle(wid, gc, [100, 100, 200, 100]);
|
||||
}, 1000);
|
||||
});
|
||||
X.on('error', function(e) {
|
||||
console.log(e);
|
||||
});
|
||||
X.on('end', function() {
|
||||
console.log('client destroyed');
|
||||
clearInterval(repaint);
|
||||
});
|
||||
});
|
||||
7
examples/simple/createwindow.js
Normal file
7
examples/simple/createwindow.js
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
var x11 = require('../../lib/x11');
|
||||
x11.createClient(function(display) {
|
||||
var X = display.client;
|
||||
var wid = X.AllocID();
|
||||
X.CreateWindow(wid, display.screen[0].root, 100, 100, 400, 300);
|
||||
X.MapWindow(wid);
|
||||
});
|
||||
13
examples/simple/events.js
Normal file
13
examples/simple/events.js
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
var x11 = require('../../lib/x11');
|
||||
x11.createClient(function(display) {
|
||||
var X = display.client;
|
||||
var wid = X.AllocID();
|
||||
X.CreateWindow(wid, display.screen[0].root, 100, 100, 400, 300);
|
||||
X.ChangeWindowAttributes(wid, { eventMask: x11.eventMask.PointerMotion|x11.eventMask.KeyPress });
|
||||
X.MapWindow(wid)
|
||||
X.on('event', function(ev) {
|
||||
if (ev.type === 2) // keypress
|
||||
X.terminate();
|
||||
console.log(ev);
|
||||
});
|
||||
});
|
||||
5
examples/simple/hello.js
Normal file
5
examples/simple/hello.js
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
var x11 = require('../../lib/x11');
|
||||
x11.createClient(function(display) {
|
||||
console.log('succesfully connected to \"' + display.vendor + '\" server');
|
||||
display.client.terminate();
|
||||
});
|
||||
26
examples/simple/lsatoms.js
Normal file
26
examples/simple/lsatoms.js
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
var x11 = require('../../lib/x11');
|
||||
x11.createClient(function(display) {
|
||||
var maxstd = 0;
|
||||
var atomName;
|
||||
for (atomName in display.atoms)
|
||||
{
|
||||
var id = display.atoms[atomName];
|
||||
console.log(id + '\t' + atomName);
|
||||
if (id > maxstd)
|
||||
maxstd = id;
|
||||
}
|
||||
(
|
||||
function getAtoms(atomId)
|
||||
{
|
||||
display.client.GetAtomName(atomId, function(err, atom) {
|
||||
if (err) {
|
||||
display.client.terminate();
|
||||
return true;
|
||||
} else {
|
||||
console.log(atomId + '\t' + atom);
|
||||
getAtoms(atomId +1);
|
||||
}
|
||||
});
|
||||
}
|
||||
)(maxstd+1);
|
||||
});
|
||||
36
examples/simple/lsatomsp.js
Normal file
36
examples/simple/lsatomsp.js
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
var x11 = require('../../lib/x11');
|
||||
x11.createClient(function(display) {
|
||||
var maxstd = 0;
|
||||
var atomName;
|
||||
for (atomName in display.client.atoms)
|
||||
{
|
||||
var id = display.client.atoms[atomName];
|
||||
console.log(id + '\t' + atomName);
|
||||
if (id > maxstd)
|
||||
maxstd = id;
|
||||
}
|
||||
(
|
||||
function getAtoms(atomIdStart, atomIdEnd)
|
||||
{
|
||||
var atomId;
|
||||
var numInBatch = atomIdEnd - atomIdStart;
|
||||
for (atomId = atomIdStart; atomId < atomIdEnd; atomId++)
|
||||
{
|
||||
(function(id) {
|
||||
display.client.GetAtomName(id, function(err, atom) {
|
||||
if (err) {
|
||||
display.client.terminate();
|
||||
return true;
|
||||
} else {
|
||||
console.log(id + '\t' + atom);
|
||||
numInBatch--;
|
||||
if (numInBatch === 0) {
|
||||
getAtoms(atomIdStart + 100, atomIdEnd+ 100);
|
||||
}
|
||||
}
|
||||
});
|
||||
})(atomId);
|
||||
}
|
||||
}
|
||||
)(maxstd+1, maxstd+100);
|
||||
});
|
||||
|
|
@ -1,15 +1,14 @@
|
|||
var x11 = require('../lib/x11');
|
||||
var x11 = require('../../lib/x11');
|
||||
var PointerMotion = x11.eventMask.PointerMotion;
|
||||
|
||||
var xclient = x11.createClient(function(display) {
|
||||
var X = display.client;
|
||||
var root = display.screen[0].root;
|
||||
display.client.require('render', function(Render) {
|
||||
console.log(Render);
|
||||
var wid = X.AllocID();
|
||||
var white = display.screen[0].white_pixel;
|
||||
varblack = display.screen[0].black_pixel;
|
||||
X.CreateWindow(wid, root, 10, 10, 400, 300, 1, 1, 0, { backgroundPixel: white, eventMask: PointerMotion });
|
||||
X.CreateWindow(wid, root, 10, 10, 400, 300, 0, 0, 0, 0, { backgroundPixel: white, eventMask: PointerMotion });
|
||||
X.MapWindow(wid);
|
||||
|
||||
var pict = X.AllocID();
|
||||
|
|
@ -1,48 +0,0 @@
|
|||
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.AllocColor(display.screen[0].default_colormap, 0xffff, 0, 0, function(redcolor) {
|
||||
// todo: it is possible for PolyLine to be called before CreateGC!
|
||||
console.log(redcolor);
|
||||
X.CreateGC(gc, wid, { foreground: redcolor.pixel, background: white } );
|
||||
});
|
||||
|
||||
X.on('event', function(ev) {
|
||||
if (ev.type == 12)
|
||||
{
|
||||
if (pts.length > 4)
|
||||
X.PolyLine(0, wid, gc, pts);
|
||||
} else if (ev.type == 6) {
|
||||
pts.push(ev.x);
|
||||
pts.push(ev.y);
|
||||
if (pts.length > 4)
|
||||
X.PolyLine(0, wid, gc, pts.slice(-4));
|
||||
}
|
||||
});
|
||||
|
||||
X.on('error', function(e) {
|
||||
console.log(e);
|
||||
});
|
||||
});
|
||||
|
|
@ -1,51 +0,0 @@
|
|||
// WinServ2008R2 64bit, Intel(R) Core(TM) i7 CPU 870 @2.93GHz, Xming 6.9.0.31
|
||||
// 0.4.3/cygwin 32bit: 12000 +/-1000 InternAtom/sec
|
||||
// 0.5.1/win32 : 12000 +/-1000
|
||||
|
||||
// Ubuntu 11.04 32bit, Intel(R) Core(TM)2 Duo CPU T7250 @2.00GHz, XOrg 1:7.6+4ubuntu3.1
|
||||
// 0.4.9pre: 23300 +/-200
|
||||
|
||||
|
||||
var x11 = require('../lib/x11');
|
||||
|
||||
var xclient = x11.createClient();
|
||||
var counter = 0;
|
||||
var t = +new Date();
|
||||
var t0 = t;
|
||||
var num = 100000;
|
||||
xclient.on('connect', function(display) {
|
||||
console.log(display);
|
||||
process.exit(0);
|
||||
var X = this;
|
||||
for (var i=0; i < num; ++i)
|
||||
{
|
||||
var hello = 'Hello, node.js ' + i;
|
||||
X.InternAtom(false, hello, function(atomId) {
|
||||
if (counter == 0)
|
||||
{
|
||||
var t1 = +new Date();
|
||||
console.log('first reply after sending %d atoms in %d ms', num, t1-t);
|
||||
t = t1;
|
||||
}
|
||||
//console.log('atom %d saved on server', atomId);
|
||||
|
||||
if ((counter % 10000) == 0)
|
||||
{
|
||||
var t1 = +new Date();
|
||||
console.log('received 10000 (up to %d) atom ids in %d ms', counter, t1 - t);
|
||||
t = t1;
|
||||
}
|
||||
|
||||
counter++;
|
||||
if (counter == (num-1))
|
||||
{
|
||||
var t1 = +new Date();
|
||||
var delta = t1 - t0;
|
||||
console.log(delta);
|
||||
console.log('reqs/msec: ' + num/delta);
|
||||
console.log('msec per req: ' + delta/num);
|
||||
process.exit(0); // TODO: X.end() ?
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
@ -1,63 +0,0 @@
|
|||
// test results:
|
||||
|
||||
// WinServ2008R2, Intel(R) Core(TM) i7 CPU 870 @ 2.93GHz + Xming 6.9.0.31
|
||||
//
|
||||
// 0.4.3/cygwin 32bit : 8500 +/- 2000 InternAtom/sec
|
||||
// 0.5.1/win32 : N/A
|
||||
//
|
||||
// Ubuntu 11.04 32bit, Intel(R) Core(TM)2 Duo CPU T7250 @2.00GHz, XOrg 1:7.6+4ubuntu3.1
|
||||
// 0.4.9pre: 16700 +/-300
|
||||
|
||||
|
||||
var x11 = require('../lib/x11');
|
||||
|
||||
var xclient = x11.createClient();
|
||||
var reqcounter = 0;
|
||||
var rescounter = 0;
|
||||
|
||||
var num = 400000;
|
||||
var X;
|
||||
|
||||
var t0 = +new Date();
|
||||
|
||||
function benchmarkAtoms()
|
||||
{
|
||||
if (reqcounter > num)
|
||||
return;
|
||||
|
||||
X.InternAtom(false, 'test ' + reqcounter, function(atomId) {
|
||||
rescounter++;
|
||||
//console.log('%d received', rescounter);
|
||||
if ( (rescounter % 10000) == 0)
|
||||
{
|
||||
var t2 = X.t1;
|
||||
X.t1 = +new Date();
|
||||
var delta = X.t1 - t2;
|
||||
console.log(reqcounter - rescounter);
|
||||
console.log('reqs/msec: ' + 10000/delta);
|
||||
console.log('msec per req: ' + delta/10000);
|
||||
}
|
||||
if (rescounter == (num-2))
|
||||
{
|
||||
var t1 = +new Date();
|
||||
var delta = t1 - t0;
|
||||
console.log(delta);
|
||||
console.log('reqs/msec: ' + num/delta);
|
||||
console.log('msec per req: ' + delta/num);
|
||||
|
||||
process.exit(0);
|
||||
}
|
||||
});
|
||||
|
||||
reqcounter++;
|
||||
//console.log('%d sent', reqcounter);
|
||||
process.nextTick(benchmarkAtoms);
|
||||
}
|
||||
|
||||
|
||||
|
||||
xclient.on('connect', function(display) {
|
||||
X = this;
|
||||
X.t1 = +new Date();
|
||||
benchmarkAtoms();
|
||||
});
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
LDFLAGS=-lX11
|
||||
|
||||
simplewin: simplewin.o
|
||||
|
|
@ -1,42 +0,0 @@
|
|||
#include <X11/Xlib.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
int main(void) {
|
||||
Display *d;
|
||||
Window w, w1;
|
||||
XEvent e;
|
||||
char *msg = "Hello, world!";
|
||||
int s;
|
||||
|
||||
d = XOpenDisplay(NULL);
|
||||
if (d == NULL) {
|
||||
fprintf(stderr, "Cannot open display\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
s = DefaultScreen(d);
|
||||
w = XCreateSimpleWindow(d, RootWindow(d, s), 10, 10, 100, 100, 1,
|
||||
BlackPixel(d, s), WhitePixel(d, s));
|
||||
|
||||
w1 = XCreateSimpleWindow(d, RootWindow(d, s), 50, 50, 50, 50, 1,
|
||||
BlackPixel(d, s), WhitePixel(d, s));
|
||||
XSelectInput(d, w, ExposureMask | KeyPressMask);
|
||||
XSelectInput(d, w1, ExposureMask);
|
||||
XMapWindow(d, w);
|
||||
XMapWindow(d, w1);
|
||||
|
||||
while (1) {
|
||||
XNextEvent(d, &e);
|
||||
if (e.type == Expose) {
|
||||
XFillRectangle(e.xany.display, e.xany.window, DefaultGC(d, s), 20, 20, 10, 10);
|
||||
XDrawString(e.xany.display, e.xany.window, DefaultGC(d, s), 10, 50, msg, strlen(msg));
|
||||
}
|
||||
if (e.type == KeyPress)
|
||||
break;
|
||||
}
|
||||
|
||||
XCloseDisplay(d);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
var x11 = require('../lib/x11');
|
||||
|
||||
var xclient = x11.createClient();
|
||||
var PointerMotion = x11.eventMask.PointerMotion;
|
||||
var mapped = true;
|
||||
|
||||
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: PointerMotion });
|
||||
var cid = X.AllocID();
|
||||
X.CreateGC(cid, wid);
|
||||
});
|
||||
|
|
@ -1,32 +0,0 @@
|
|||
var x11 = require('../lib/x11');
|
||||
|
||||
var xclient = x11.createClient();
|
||||
var PointerMotion = x11.eventMask.PointerMotion;
|
||||
var Button1Motion = x11.eventMask.Button1Motion;
|
||||
var Button2Motion = x11.eventMask.Button2Motion;
|
||||
var Button3Motion = x11.eventMask.Button3Motion;
|
||||
var Button4Motion = x11.eventMask.Button4Motion;
|
||||
var Button5Motion = x11.eventMask.Button5Motion;
|
||||
var ButtonPress = x11.eventMask.ButtonPress;
|
||||
var ButtonRelease = x11.eventMask.ButtonRelease;
|
||||
var EnterWindow = x11.eventMask.EnterWindow;
|
||||
var LeaveWindow = x11.eventMask.LeaveWindow;
|
||||
|
||||
//var mask = PointerMotion|Button1Motion|Button2Motion|Button3Motion|Button4Motion|Button5Motion|ButtonPress|ButtonRelease;
|
||||
//var mask = Button1Motion|Button2Motion|Button3Motion|Button4Motion|Button5Motion|ButtonPress|ButtonRelease;
|
||||
var mask = Button1Motion|ButtonPress|EnterWindow|LeaveWindow;
|
||||
|
||||
xclient.on('connect', function(display) {
|
||||
var X = this;
|
||||
var root = display.screen[0].root;
|
||||
var wid = X.AllocID();
|
||||
var white = display.screen[0].white_pixel;
|
||||
var black = display.screen[0].black_pixel;
|
||||
|
||||
X.CreateWindow(wid, root, 10, 10, 400, 300, 1, 1, 0, { backgroundPixel: white, eventMask: mask });
|
||||
X.MapWindow(wid);
|
||||
});
|
||||
|
||||
xclient.on('event', function(ev) {
|
||||
console.log(ev);
|
||||
});
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
var x11 = require('../lib/x11');
|
||||
|
||||
var xclient = x11.createClient();
|
||||
var atomId = 1;
|
||||
xclient.on('connect', function(display) {
|
||||
var X = this;
|
||||
function listAtoms()
|
||||
{
|
||||
function getAtom(a)
|
||||
{
|
||||
X.GetAtomName(a, function(str) {
|
||||
if (a == 1)
|
||||
console.log('module.exports = {')
|
||||
if (a != 68)
|
||||
console.log(' %s: %d,', str, a);
|
||||
else
|
||||
console.log(' %s: %d\n}', str, a);
|
||||
listAtoms();
|
||||
});
|
||||
}
|
||||
if (atomId <= 68)
|
||||
getAtom(atomId);
|
||||
else
|
||||
X.terminate();
|
||||
atomId++;
|
||||
}
|
||||
listAtoms();
|
||||
});
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
var x11 = require('../lib/x11');
|
||||
|
||||
var xclient = x11.createClient();
|
||||
var PropertyChange = x11.eventMask.PropertyChange;
|
||||
|
||||
xclient.on('connect', function(display) {
|
||||
var X = this;
|
||||
var root = display.screen[0].root;
|
||||
var wid = X.AllocID();
|
||||
var white = display.screen[0].white_pixel;
|
||||
var black = display.screen[0].black_pixel;
|
||||
|
||||
X.CreateWindow(wid, root, 10, 10, 400, 300, 1, 1, 0, { backgroundPixel: white, eventMask: PropertyChange });
|
||||
X.MapWindow(wid);
|
||||
|
||||
// mode: 0 replace, 1 prepend, 2 append
|
||||
// mode, wid, name, type, format, data
|
||||
X.ChangeProperty(0, wid, xclient.atoms.WM_NAME, xclient.atoms.STRING, 8, 'Hello, NodeJS');
|
||||
setInterval(function() {
|
||||
X.ChangeProperty(0, wid, xclient.atoms.WM_NAME, xclient.atoms.STRING, 8, 'Hello, NodeJS ' + new Date());
|
||||
}, 1000);
|
||||
|
||||
xclient.on('event', function(ev) {
|
||||
X.GetProperty(0, wid, xclient.atoms.WM_NAME, xclient.atoms.STRING, 0, 10000000, function(prop) {
|
||||
if (prop.type == xclient.atoms.STRING)
|
||||
prop.data = prop.data.toString();
|
||||
console.log(prop.data);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
@ -1,53 +0,0 @@
|
|||
// test results:
|
||||
|
||||
// WinServ2008R2, Intel(R) Core(TM) i7 CPU 870 @ 2.93GHz + Xming 6.9.0.31
|
||||
//
|
||||
// 0.4.3/cygwin 32bit : 6900 +/- 200 req/sec
|
||||
// 0.5.1/win32 : 3700 +/- 200 req/sec
|
||||
// cygwin x11perf -sync -pointer : 2800 +/- 200 req/sec
|
||||
// cygwin x11perf -pointer : 5600 +/- 200 req/sec
|
||||
|
||||
//
|
||||
// Ubuntu 11.04 32bit, Intel(R) Core(TM)2 Duo CPU T7250 @2.00GHz, XOrg 1:7.6+4ubuntu3.1
|
||||
// 0.4.9pre :
|
||||
// x11perf -sync -pointer :
|
||||
// x11perf -pointer :
|
||||
|
||||
var x11 = require('../lib/x11');
|
||||
var X = x11.createClient();
|
||||
|
||||
var total = 50000;
|
||||
var num_qp_resp_left = total;
|
||||
var num_qp_req_left = total;
|
||||
var start = +new Date();
|
||||
var wid;
|
||||
|
||||
function benchmarkQP()
|
||||
{
|
||||
num_qp_req_left--;
|
||||
X.QueryPointer(wid, function(res) {
|
||||
num_qp_resp_left--;
|
||||
if (num_qp_resp_left == 0)
|
||||
{
|
||||
var end = +new Date();
|
||||
var delta = (end - start)/1000
|
||||
console.error( 'Finished ' + total + ' requests in ' + delta + ' sec, ' + total/delta + ' req/sec');
|
||||
X.terminate();
|
||||
}
|
||||
});
|
||||
|
||||
if (num_qp_req_left > 0)
|
||||
process.nextTick(benchmarkQP);
|
||||
}
|
||||
|
||||
X.on('connect', function(display) {
|
||||
var screen = display.screen[0];
|
||||
wid = X.AllocID();
|
||||
X.CreateWindow(wid, screen.root, 10, 10, 400, 300, 1, 1, 0, { backgroundPixel: screen.white_pixel });
|
||||
X.MapWindow(wid);
|
||||
benchmarkQP(wid);
|
||||
});
|
||||
|
||||
X.on('error', function(err) {
|
||||
console.log(err);
|
||||
});
|
||||
|
|
@ -1,48 +0,0 @@
|
|||
// test results:
|
||||
|
||||
// WinServ2008R2, Intel(R) Core(TM) i7 CPU 870 @ 2.93GHz + Xming 6.9.0.31
|
||||
//
|
||||
// 0.4.3/cygwin 32bit : 2900 +/- 300 req/sec
|
||||
// 0.5.1/win32 : 5500 +/- 1000 req/sec
|
||||
// cygwin x11perf -sync -pointer : 2800 +/- 200 req/sec
|
||||
// cygwin x11perf -pointer : 5600 +/- 200 req/sec
|
||||
|
||||
//
|
||||
// Ubuntu 11.04 32bit, Intel(R) Core(TM)2 Duo CPU T7250 @2.00GHz, XOrg 1:7.6+4ubuntu3.1
|
||||
// 0.4.9pre :
|
||||
// x11perf -sync -pointer :
|
||||
// x11perf -pointer :
|
||||
|
||||
var x11 = require('../lib/x11');
|
||||
var X = x11.createClient();
|
||||
|
||||
var total = 50000;
|
||||
var num_qp_left = total;
|
||||
var start = +new Date();
|
||||
|
||||
function benchmarkQP(wid)
|
||||
{
|
||||
X.QueryPointer(wid, function(res) {
|
||||
num_qp_left--;
|
||||
if (num_qp_left > 0)
|
||||
benchmarkQP(wid);
|
||||
else {
|
||||
var end = +new Date();
|
||||
var delta = (end - start)/1000
|
||||
console.log( 'Finished ' + total + ' requests in ' + delta + ' sec, ' + total/delta + ' req/sec');
|
||||
X.terminate();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
X.on('connect', function(display) {
|
||||
var screen = display.screen[0];
|
||||
var wid = X.AllocID();
|
||||
X.CreateWindow(wid, screen.root, 10, 10, 400, 300, 1, 1, 0, { backgroundPixel: screen.white_pixel });
|
||||
X.MapWindow(wid);
|
||||
benchmarkQP(wid);
|
||||
});
|
||||
|
||||
X.on('error', function(err) {
|
||||
console.log(err);
|
||||
});
|
||||
|
|
@ -1,48 +0,0 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
use X11::Protocol;
|
||||
use strict;
|
||||
use IO::Select;
|
||||
my $X = new X11::Protocol;
|
||||
$X->init_extension("RENDER") or die;
|
||||
|
||||
my($rgb24, $rgba32);
|
||||
|
||||
$rgb24 = 71;
|
||||
$rgba32 = 69;
|
||||
|
||||
my $win = $X->new_rsrc;
|
||||
$X->CreateWindow($win, $X->root, 'InputOutput', $X->root_depth,
|
||||
'CopyFromParent', (0, 0), 500, 500, 4,
|
||||
'event_mask' => $X->pack_event_mask('Exposure'));
|
||||
|
||||
$X->MapWindow($win);
|
||||
my $picture = $X->new_rsrc;
|
||||
$X->RenderCreatePicture($picture, $win, $rgb24, 'poly_edge' => 'Smooth', 'poly_mode' => 'Precise');
|
||||
|
||||
my $pixmap = $X->new_rsrc;
|
||||
$X->CreatePixmap($pixmap, $win, 32, 1000, 1000);
|
||||
my $pix_pict = $X->new_rsrc;
|
||||
$X->RenderCreatePicture($pix_pict, $pixmap, $rgba32, 'poly_edge' => 'Smooth', 'poly_mode' => 'Precise');
|
||||
$X->RenderFillRectangles('Src', $pix_pict, [0xffff, 0, 0, 0x8000], [0, 0, 1000, 1000]);
|
||||
|
||||
$X->event_handler('queue');
|
||||
#my $fds = IO::Select->new($X->connection->fh);
|
||||
|
||||
sub draw {
|
||||
$X->RenderFillRectangles('Src', $picture, [(0xffff)x4], [0, 0, 500, 500]);
|
||||
|
||||
$X->RenderSetPictureFilter($pix_pict, "nearest");
|
||||
$X->RenderTriangles('Over', $pix_pict, 500, 500, $picture, 0, [(250, 100), (100, 350), (400, 350), (175, 100), (185, 100), (180, 0)]);
|
||||
#$X->RenderFillRectangles('Src', $picture, [(0xffff, 0, 0, 0xffff)], [10, 10, 50, 50]);
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
my %e;
|
||||
$X->handle_input;
|
||||
if (%e = $X->dequeue_event) {
|
||||
if ($e{'name'} eq "Expose") {
|
||||
draw();
|
||||
}
|
||||
}
|
||||
}
|
||||
173
test/render.h
173
test/render.h
|
|
@ -1,173 +0,0 @@
|
|||
/*
|
||||
* $XFree86: xc/include/extensions/render.h,v 1.11 2002/11/23 02:34:45 keithp Exp $
|
||||
*
|
||||
* Copyright © 2000 SuSE, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and its
|
||||
* documentation for any purpose is hereby granted without fee, provided that
|
||||
* the above copyright notice appear in all copies and that both that
|
||||
* copyright notice and this permission notice appear in supporting
|
||||
* documentation, and that the name of SuSE not be used in advertising or
|
||||
* publicity pertaining to distribution of the software without specific,
|
||||
* written prior permission. SuSE makes no representations about the
|
||||
* suitability of this software for any purpose. It is provided "as is"
|
||||
* without express or implied warranty.
|
||||
*
|
||||
* SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
|
||||
* BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Author: Keith Packard, SuSE, Inc.
|
||||
*/
|
||||
|
||||
#ifndef _RENDER_H_
|
||||
#define _RENDER_H_
|
||||
|
||||
typedef unsigned long Glyph;
|
||||
typedef unsigned long GlyphSet;
|
||||
typedef unsigned long Picture;
|
||||
typedef unsigned long PictFormat;
|
||||
|
||||
#define RENDER_NAME "RENDER"
|
||||
#define RENDER_MAJOR 0
|
||||
#define RENDER_MINOR 8
|
||||
|
||||
#define X_RenderQueryVersion 0
|
||||
#define X_RenderQueryPictFormats 1
|
||||
#define X_RenderQueryPictIndexValues 2 /* 0.7 */
|
||||
#define X_RenderQueryDithers 3
|
||||
#define X_RenderCreatePicture 4
|
||||
#define X_RenderChangePicture 5
|
||||
#define X_RenderSetPictureClipRectangles 6
|
||||
#define X_RenderFreePicture 7
|
||||
#define X_RenderComposite 8
|
||||
#define X_RenderScale 9
|
||||
#define X_RenderTrapezoids 10
|
||||
#define X_RenderTriangles 11
|
||||
#define X_RenderTriStrip 12
|
||||
#define X_RenderTriFan 13
|
||||
#define X_RenderColorTrapezoids 14
|
||||
#define X_RenderColorTriangles 15
|
||||
/* #define X_RenderTransform 16 */
|
||||
#define X_RenderCreateGlyphSet 17
|
||||
#define X_RenderReferenceGlyphSet 18
|
||||
#define X_RenderFreeGlyphSet 19
|
||||
#define X_RenderAddGlyphs 20
|
||||
#define X_RenderAddGlyphsFromPicture 21
|
||||
#define X_RenderFreeGlyphs 22
|
||||
#define X_RenderCompositeGlyphs8 23
|
||||
#define X_RenderCompositeGlyphs16 24
|
||||
#define X_RenderCompositeGlyphs32 25
|
||||
#define X_RenderFillRectangles 26
|
||||
/* 0.5 */
|
||||
#define X_RenderCreateCursor 27
|
||||
/* 0.6 */
|
||||
#define X_RenderSetPictureTransform 28
|
||||
#define X_RenderQueryFilters 29
|
||||
#define X_RenderSetPictureFilter 30
|
||||
#define X_RenderCreateAnimCursor 31
|
||||
#define RenderNumberRequests (X_RenderCreateAnimCursor+1)
|
||||
|
||||
#define BadPictFormat 0
|
||||
#define BadPicture 1
|
||||
#define BadPictOp 2
|
||||
#define BadGlyphSet 3
|
||||
#define BadGlyph 4
|
||||
#define RenderNumberErrors (BadGlyph+1)
|
||||
|
||||
#define PictTypeIndexed 0
|
||||
#define PictTypeDirect 1
|
||||
|
||||
#define PictOpMinimum 0
|
||||
#define PictOpClear 0
|
||||
#define PictOpSrc 1
|
||||
#define PictOpDst 2
|
||||
#define PictOpOver 3
|
||||
#define PictOpOverReverse 4
|
||||
#define PictOpIn 5
|
||||
#define PictOpInReverse 6
|
||||
#define PictOpOut 7
|
||||
#define PictOpOutReverse 8
|
||||
#define PictOpAtop 9
|
||||
#define PictOpAtopReverse 10
|
||||
#define PictOpXor 11
|
||||
#define PictOpAdd 12
|
||||
#define PictOpSaturate 13
|
||||
#define PictOpMaximum 13
|
||||
|
||||
/*
|
||||
* Operators only available in version 0.2
|
||||
*/
|
||||
#define PictOpDisjointMinimum 0x10
|
||||
#define PictOpDisjointClear 0x10
|
||||
#define PictOpDisjointSrc 0x11
|
||||
#define PictOpDisjointDst 0x12
|
||||
#define PictOpDisjointOver 0x13
|
||||
#define PictOpDisjointOverReverse 0x14
|
||||
#define PictOpDisjointIn 0x15
|
||||
#define PictOpDisjointInReverse 0x16
|
||||
#define PictOpDisjointOut 0x17
|
||||
#define PictOpDisjointOutReverse 0x18
|
||||
#define PictOpDisjointAtop 0x19
|
||||
#define PictOpDisjointAtopReverse 0x1a
|
||||
#define PictOpDisjointXor 0x1b
|
||||
#define PictOpDisjointMaximum 0x1b
|
||||
|
||||
#define PictOpConjointMinimum 0x20
|
||||
#define PictOpConjointClear 0x20
|
||||
#define PictOpConjointSrc 0x21
|
||||
#define PictOpConjointDst 0x22
|
||||
#define PictOpConjointOver 0x23
|
||||
#define PictOpConjointOverReverse 0x24
|
||||
#define PictOpConjointIn 0x25
|
||||
#define PictOpConjointInReverse 0x26
|
||||
#define PictOpConjointOut 0x27
|
||||
#define PictOpConjointOutReverse 0x28
|
||||
#define PictOpConjointAtop 0x29
|
||||
#define PictOpConjointAtopReverse 0x2a
|
||||
#define PictOpConjointXor 0x2b
|
||||
#define PictOpConjointMaximum 0x2b
|
||||
|
||||
#define PolyEdgeSharp 0
|
||||
#define PolyEdgeSmooth 1
|
||||
|
||||
#define PolyModePrecise 0
|
||||
#define PolyModeImprecise 1
|
||||
|
||||
#define CPRepeat (1 << 0)
|
||||
#define CPAlphaMap (1 << 1)
|
||||
#define CPAlphaXOrigin (1 << 2)
|
||||
#define CPAlphaYOrigin (1 << 3)
|
||||
#define CPClipXOrigin (1 << 4)
|
||||
#define CPClipYOrigin (1 << 5)
|
||||
#define CPClipMask (1 << 6)
|
||||
#define CPGraphicsExposure (1 << 7)
|
||||
#define CPSubwindowMode (1 << 8)
|
||||
#define CPPolyEdge (1 << 9)
|
||||
#define CPPolyMode (1 << 10)
|
||||
#define CPDither (1 << 11)
|
||||
#define CPComponentAlpha (1 << 12)
|
||||
#define CPLastBit 11
|
||||
|
||||
/* Filters included in 0.6 */
|
||||
#define FilterNearest "nearest"
|
||||
#define FilterBilinear "bilinear"
|
||||
|
||||
#define FilterFast "fast"
|
||||
#define FilterGood "good"
|
||||
#define FilterBest "best"
|
||||
|
||||
#define FilterAliasNone -1
|
||||
|
||||
/* Subpixel orders included in 0.6 */
|
||||
#define SubPixelUnknown 0
|
||||
#define SubPixelHorizontalRGB 1
|
||||
#define SubPixelHorizontalBGR 2
|
||||
#define SubPixelVerticalRGB 3
|
||||
#define SubPixelVerticalBGR 4
|
||||
#define SubPixelNone 5
|
||||
|
||||
#endif /* _RENDER_H_ */
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
var x11 = require('../lib/x11');
|
||||
x11.createClient(function(display) {
|
||||
var X = display.client;
|
||||
var root = display.screen[0].root;
|
||||
var wid = X.AllocID();
|
||||
X.CreateWindow(wid, root, 10, 10, 400, 300, 1, 1, 0);
|
||||
X.MapWindow(wid);
|
||||
setInterval( function() {
|
||||
X.ResiseWindow(wid, 800, 200);
|
||||
}, 1200);
|
||||
setInterval( function() {
|
||||
X.ResiseWindow(wid, 400, 300);
|
||||
}, 510);
|
||||
});
|
||||
|
|
@ -1,43 +0,0 @@
|
|||
var x11 = require('../lib/x11');
|
||||
var Window = require('./wndwrap');
|
||||
|
||||
x11.createClient(function(display) {
|
||||
|
||||
var pts = [];
|
||||
new Window(display.client, 0, 0, 700, 500)
|
||||
.handle({
|
||||
|
||||
mousemove: function(ev) {
|
||||
if (this.pressed)
|
||||
{
|
||||
var lastpoly = pts[pts.length - 1];
|
||||
lastpoly.push(ev.x);
|
||||
lastpoly.push(ev.y);
|
||||
if (lastpoly.length > 3)
|
||||
this.gc.polyLine(lastpoly.slice(-4));
|
||||
}
|
||||
},
|
||||
|
||||
mousedown: function(ev) {
|
||||
if (ev.keycode == 1) // left button
|
||||
{
|
||||
this.pressed = true;
|
||||
pts.push([]);
|
||||
}
|
||||
},
|
||||
|
||||
mouseup: function(ev) {
|
||||
if (ev.keycode == 1) // left button
|
||||
this.pressed = false;
|
||||
},
|
||||
|
||||
expose: function(ev) {
|
||||
for (var i=0; i < pts.length ; ++i) {
|
||||
this.gc.polyLine(pts[i]);
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
.map()
|
||||
.title = 'Hello, world!';
|
||||
});
|
||||
|
|
@ -1,199 +0,0 @@
|
|||
var x11 = require('../lib/x11');
|
||||
|
||||
// adding XRender functions manually from
|
||||
// http://cgit.freedesktop.org/xcb/proto/tree/src/render.xml?id=HEAD
|
||||
// and http://www.x.org/releases/X11R7.6/doc/renderproto/renderproto.txt
|
||||
// TODO: move to templates
|
||||
x11.createClient(
|
||||
function(display) {
|
||||
var X = display.client;
|
||||
X.QueryExtension('RENDER', function(ext) {
|
||||
function RenderQueryVersion(clientMaj, clientMin, callback)
|
||||
{
|
||||
X.seq_num++;
|
||||
X.pack_stream.pack('CCSLL', [ext.majorOpcode, 0, 3, clientMaj, clientMin]);
|
||||
X.replies[X.seq_num] = [
|
||||
function(buf, opt) {
|
||||
var res = buf.unpack('LL');
|
||||
return res;
|
||||
},
|
||||
callback
|
||||
];
|
||||
X.pack_stream.flush();
|
||||
}
|
||||
|
||||
function RenderQueryFilters(callback)
|
||||
{
|
||||
X.seq_num++;
|
||||
X.pack_stream.pack('CCSL', [ext.majorOpcode, 29, 2, display.screen[0].root]);
|
||||
X.replies[X.seq_num] = [
|
||||
function(buf, opt) {
|
||||
var h = buf.unpack('LL');
|
||||
var num_aliases = h[0];
|
||||
var num_filters = h[1];
|
||||
var aliases = [];
|
||||
var offset = 24; // LL + 16 bytes pad
|
||||
for (var i=0; i < num_aliases; ++i)
|
||||
{
|
||||
aliases.push(buf.unpack('S', offset)[0]);
|
||||
offset+=2;
|
||||
}
|
||||
var filters = [];
|
||||
for (var i=0; i < num_filters; ++i)
|
||||
{
|
||||
var len = buf.unpack('C', offset)[0];
|
||||
//if (!len) break;
|
||||
offset++;
|
||||
filters.push(buf.toString('ascii', offset, offset+len));
|
||||
offset+=len;
|
||||
}
|
||||
return [aliases, filters];
|
||||
},
|
||||
callback
|
||||
];
|
||||
X.pack_stream.flush();
|
||||
}
|
||||
|
||||
var valueList = [
|
||||
['repeat', 'C'],
|
||||
['alphaMap', 'L'],
|
||||
['alphaXOrigin', 's'],
|
||||
['alphaYOrigin', 's'],
|
||||
['clipMask', 'L'],
|
||||
['graphicsExposures', 'C'],
|
||||
['subwindowMode', 'C'],
|
||||
['polyEdge', 'C'],
|
||||
['polyMode', 'C'],
|
||||
['dither', 'L'],
|
||||
['componentAlpha', 'C']
|
||||
];
|
||||
|
||||
var argumentLength = {
|
||||
C: 1,
|
||||
S: 2,
|
||||
s: 2,
|
||||
L: 4,
|
||||
x: 1
|
||||
};
|
||||
|
||||
function RenderCreatePicture(pid, drawable, pictformat, values)
|
||||
{
|
||||
X.seq_num++;
|
||||
var mask = 0;
|
||||
var reqLen = 5; // + (values + pad)/4
|
||||
var format = 'CCSLLLL';
|
||||
var params = [ext.majorOpcode, 4, reqLen, pid, drawable, pictformat, mask];
|
||||
|
||||
if (values)
|
||||
{
|
||||
var valuesLength = 0;
|
||||
for (var i=0; i < valueList.length; ++i)
|
||||
{
|
||||
var val = values[valueList[i][0]];
|
||||
if (val) {
|
||||
mask |= (1 << i);
|
||||
params.push(val);
|
||||
var valueFormat = valueList[i][1];
|
||||
format += valueFormat;
|
||||
valuesLength += argumentLength[valueFormat];
|
||||
}
|
||||
}
|
||||
var pad4 = (valuesLength + 3) >> 2;
|
||||
var toPad = (pad4 << 2) - valuesLength;
|
||||
for (var i=0; i < toPad; ++i)
|
||||
format += 'x';
|
||||
reqLen += pad4;
|
||||
params[2] = reqLen;
|
||||
params[6] = mask;
|
||||
}
|
||||
console.log([format, params]);
|
||||
X.pack_stream.pack(format, params);
|
||||
X.pack_stream.flush();
|
||||
}
|
||||
|
||||
function floatToFix(f)
|
||||
{
|
||||
return parseInt(f*(1<<16));
|
||||
}
|
||||
|
||||
function RenderLinearGradient(pid, p1, p2, stops)
|
||||
{
|
||||
X.seq_num++;
|
||||
var reqLen = 7+stops.length*3; //header + params + 1xStopfix+2xColors
|
||||
var format = 'CCSLLLLLL';
|
||||
var params = [ext.majorOpcode, 34, reqLen, pid];
|
||||
params.push(floatToFix(p1[0])); // L
|
||||
params.push(floatToFix(p1[1]));
|
||||
params.push(floatToFix(p2[0]));
|
||||
params.push(floatToFix(p2[1])); // L
|
||||
|
||||
params.push(stops.length);
|
||||
|
||||
// [ [float stopDist, [float r, g, b, a] ], ...]
|
||||
// stop distances
|
||||
for (var i=0; i < stops.length; ++i)
|
||||
{
|
||||
format += 'L';
|
||||
// TODO: we know total params length in advance. ? params[index] =
|
||||
params.push(floatToFix(stops[i][0]))
|
||||
}
|
||||
// colors
|
||||
for (var i=0; i < stops.length; ++i)
|
||||
{
|
||||
format += 'SSSS';
|
||||
for (var j=0; j < 4; ++j)
|
||||
params.push(stops[i][1][j]);
|
||||
}
|
||||
console.log([format, params]);
|
||||
X.pack_stream.pack(format, params);
|
||||
X.pack_stream.flush();
|
||||
}
|
||||
|
||||
function RenderFillRectangles(op, pid, color, rects)
|
||||
{
|
||||
X.seq_num++;
|
||||
var reqLen = 5+rects.length*2;
|
||||
var format = 'CCSCxxxLSSSS';
|
||||
var params = [ext.majorOpcode, 26, reqLen, op, pid];
|
||||
for (var j=0; j < 4; ++j)
|
||||
params.push(color[j]);
|
||||
for (var i=0; i < rects.length; i+=4)
|
||||
{
|
||||
format += 'ssSS';
|
||||
params.push(rects[i*4]);
|
||||
params.push(rects[i*4 + 1]);
|
||||
params.push(rects[i*4 + 2]);
|
||||
params.push(rects[i*4 + 3]);
|
||||
}
|
||||
console.log([format, params]);
|
||||
X.pack_stream.pack(format, params);
|
||||
X.pack_stream.flush();
|
||||
}
|
||||
|
||||
//RenderQueryVersion(0,9, function(serverVersion) { console.log(serverVersion); });
|
||||
//RenderQueryFilters(function(resp) { console.log(resp); });
|
||||
|
||||
var root = display.screen[0].root;
|
||||
var wid = X.AllocID();
|
||||
var white = display.screen[0].white_pixel;
|
||||
var black = display.screen[0].black_pixel;
|
||||
X.CreateWindow(wid, root, 10, 10, 400, 300, 1, 1, 0, { backgroundPixel: white, eventMask: x11.eventMask.Exposure });
|
||||
var pid = X.AllocID();
|
||||
RenderCreatePicture(pid, wid, 71, { repeat: 1} );
|
||||
var pidGrad = X.AllocID();
|
||||
|
||||
//RenderLinearGradient(pidGrad, [0,0], [100,100], [ [0, [0,0,0,0xffff]], [100, [0xffff, 0xffff, 0xffff, 0xffff]]]);
|
||||
|
||||
X.MapWindow(wid);
|
||||
|
||||
X.on('event', function(ev) {
|
||||
console.log(ev);
|
||||
//RenderFillRectangles(1, pid, [0, 0, 0, 0x8000], [0, 0, 400, 500]);
|
||||
RenderFillRectangles(1, pid, [0, 0x8000, 0, 0xffff], [100, 200, 400, 500]);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
).on('error', function(err) {
|
||||
console.log(err);
|
||||
});
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
var x11 = require('../lib/x11');
|
||||
|
||||
var xclient = x11.createClient();
|
||||
var atomId = 10;
|
||||
xclient.on('connect', function(display) {
|
||||
var X = this;
|
||||
function listAtoms()
|
||||
{
|
||||
function getAtom(a)
|
||||
{
|
||||
X.GetAtomName(a, function(str) {
|
||||
if (typeof str != 'string') // 'Bad atom' error
|
||||
{
|
||||
X.terminate();
|
||||
return;
|
||||
}
|
||||
console.log(a + ' ' + str);
|
||||
listAtoms();
|
||||
});
|
||||
}
|
||||
getAtom(atomId);
|
||||
atomId++;
|
||||
}
|
||||
listAtoms();
|
||||
});
|
||||
Loading…
Reference in a new issue