mirror of
https://github.com/danbulant/node-x11
synced 2026-09-21 07:23:56 +00:00
Merge pull request #70 from Champii/master
CreateCursor, valueMask and format
This commit is contained in:
commit
3e3846d6e6
42 changed files with 500 additions and 412 deletions
|
|
@ -15,7 +15,7 @@ var ButtonRelease = x11.eventMask.ButtonRelease;
|
||||||
var kbdImg = require('./node-jpg').readJpeg('./keyboard.jpg');
|
var kbdImg = require('./node-jpg').readJpeg('./keyboard.jpg');
|
||||||
var keycoords = require('./coordinates');
|
var keycoords = require('./coordinates');
|
||||||
|
|
||||||
// from https://github.com/substack/node-keysym
|
// from https://github.com/substack/node-keysym
|
||||||
var keysyms = require('./keysyms').records;
|
var keysyms = require('./keysyms').records;
|
||||||
var ks2name = {};
|
var ks2name = {};
|
||||||
for (var k in keysyms)
|
for (var k in keysyms)
|
||||||
|
|
@ -23,18 +23,18 @@ for (var k in keysyms)
|
||||||
var kk2name = {};
|
var kk2name = {};
|
||||||
|
|
||||||
|
|
||||||
x11.createClient(function(err, display)
|
x11.createClient(function(err, display)
|
||||||
{
|
{
|
||||||
var X = display.client;
|
var X = display.client;
|
||||||
X.require('big-requests', function(BigReq)
|
X.require('big-requests', function(err, BigReq)
|
||||||
{
|
{
|
||||||
X.require('render', function(Render) {
|
X.require('render', function(err, Render) {
|
||||||
X.Render = Render;
|
X.Render = Render;
|
||||||
BigReq.Enable(function(err, maxLen)
|
BigReq.Enable(function(err, maxLen)
|
||||||
{
|
{
|
||||||
var min = display.min_keycode;
|
var min = display.min_keycode;
|
||||||
var max = display.max_keycode;
|
var max = display.max_keycode;
|
||||||
X.GetKeyboardMapping(min, max-min, function(err, list)
|
X.GetKeyboardMapping(min, max-min, function(err, list)
|
||||||
{
|
{
|
||||||
// map keycode to key name
|
// map keycode to key name
|
||||||
for (var i=0; i < list.length; ++i)
|
for (var i=0; i < list.length; ++i)
|
||||||
|
|
@ -62,26 +62,26 @@ function main(X)
|
||||||
|
|
||||||
var win = X.AllocID();
|
var win = X.AllocID();
|
||||||
X.CreateWindow(
|
X.CreateWindow(
|
||||||
win, root,
|
win, root,
|
||||||
0, 0, kbdImg.width, kbdImg.height,
|
0, 0, kbdImg.width, kbdImg.height,
|
||||||
0, 0, 0, 0,
|
0, 0, 0, 0,
|
||||||
{
|
{
|
||||||
backgroundPixel: white, eventMask: Exposure|KeyPress|ButtonPress
|
backgroundPixel: white, eventMask: Exposure|KeyPress|ButtonPress
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
X.MapWindow(win);
|
X.MapWindow(win);
|
||||||
|
|
||||||
var win1 = X.AllocID();
|
var win1 = X.AllocID();
|
||||||
X.CreateWindow(
|
X.CreateWindow(
|
||||||
win1, root,
|
win1, root,
|
||||||
0, 0, kbdImg.width, kbdImg.height,
|
0, 0, kbdImg.width, kbdImg.height,
|
||||||
0, 0, 0, 0,
|
0, 0, 0, 0,
|
||||||
{
|
{
|
||||||
backgroundPixel: white, eventMask: Exposure|KeyPress|ButtonPress
|
backgroundPixel: white, eventMask: Exposure|KeyPress|ButtonPress
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
X.MapWindow(win1);
|
X.MapWindow(win1);
|
||||||
|
|
||||||
var gc = X.AllocID();
|
var gc = X.AllocID();
|
||||||
X.CreateGC(gc, win);
|
X.CreateGC(gc, win);
|
||||||
|
|
||||||
|
|
@ -103,15 +103,15 @@ function main(X)
|
||||||
var picKbd = X.AllocID();
|
var picKbd = X.AllocID();
|
||||||
X.PutImage(2, pixmapKbd, gc, kbdImg.width, kbdImg.height, 0, 0, 0, 24, kbdImg.data);
|
X.PutImage(2, pixmapKbd, gc, kbdImg.width, kbdImg.height, 0, 0, 0, 24, kbdImg.data);
|
||||||
Render.CreatePicture(picKbd, pixmapKbd, Render.rgb24);
|
Render.CreatePicture(picKbd, pixmapKbd, Render.rgb24);
|
||||||
|
|
||||||
var pixmapHeat = X.AllocID();
|
var pixmapHeat = X.AllocID();
|
||||||
X.CreatePixmap(pixmapHeat, win, 32, kbdImg.width, kbdImg.height);
|
X.CreatePixmap(pixmapHeat, win, 32, kbdImg.width, kbdImg.height);
|
||||||
var picHeat = X.AllocID();
|
var picHeat = X.AllocID();
|
||||||
Render.CreatePicture(picHeat, pixmapHeat, Render.rgba32);
|
Render.CreatePicture(picHeat, pixmapHeat, Render.rgba32);
|
||||||
|
|
||||||
var picWin = X.AllocID();
|
var picWin = X.AllocID();
|
||||||
Render.CreatePicture(picWin, win, Render.rgb24);
|
Render.CreatePicture(picWin, win, Render.rgb24);
|
||||||
|
|
||||||
var picWin1 = X.AllocID();
|
var picWin1 = X.AllocID();
|
||||||
Render.CreatePicture(picWin1, win1, Render.rgb24);
|
Render.CreatePicture(picWin1, win1, Render.rgb24);
|
||||||
|
|
||||||
|
|
@ -135,12 +135,12 @@ function main(X)
|
||||||
mindist = dist;
|
mindist = dist;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Render.Composite(3, picKbd, 0, picWin, 0, 0, 0, 0, 0, 0, kbdImg.width, kbdImg.height);
|
Render.Composite(3, picKbd, 0, picWin, 0, 0, 0, 0, 0, 0, kbdImg.width, kbdImg.height);
|
||||||
Render.Composite(3, picHeatPush, 0, picWin, 0, 0, 0, 0, x -150/2, y-150/2, 150, 150);
|
Render.Composite(3, picHeatPush, 0, picWin, 0, 0, 0, 0, x -150/2, y-150/2, 150, 150);
|
||||||
|
|
||||||
} if (ev.type == 2) {
|
} if (ev.type == 2) {
|
||||||
|
|
||||||
var name = kk2name[ev.keycode];
|
var name = kk2name[ev.keycode];
|
||||||
for (var n in name)
|
for (var n in name)
|
||||||
{
|
{
|
||||||
|
|
@ -152,7 +152,7 @@ function main(X)
|
||||||
Render.Composite(3, picHeatPush, 0, picHeat, 0, 0, 0, 0, pt[0] -150/2, pt[1]-150/2, 150, 150);
|
Render.Composite(3, picHeatPush, 0, picHeat, 0, 0, 0, 0, pt[0] -150/2, pt[1]-150/2, 150, 150);
|
||||||
Render.Composite(3, picHeatPush, 0, picWin1, 0, 0, 0, 0, pt[0] -150/2, pt[1]-150/2, 150, 150);
|
Render.Composite(3, picHeatPush, 0, picWin1, 0, 0, 0, 0, pt[0] -150/2, pt[1]-150/2, 150, 150);
|
||||||
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
//console.log(name);
|
//console.log(name);
|
||||||
|
|
|
||||||
|
|
@ -294,7 +294,7 @@ x11.createClient(function(error, display) {
|
||||||
var root = display.screen[0].root;
|
var root = display.screen[0].root;
|
||||||
var width = 500;
|
var width = 500;
|
||||||
var height = 500;
|
var height = 500;
|
||||||
X.require('glx', function(GLX) {
|
X.require('glx', function(err, GLX) {
|
||||||
var depth = 24;
|
var depth = 24;
|
||||||
findBestVisual(display, function(err, visual) {
|
findBestVisual(display, function(err, visual) {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ var listId = 1;
|
||||||
x11.createClient(function(err, display) {
|
x11.createClient(function(err, display) {
|
||||||
var X = display.client;
|
var X = display.client;
|
||||||
var root = display.screen[0].root;
|
var root = display.screen[0].root;
|
||||||
X.require('glx', function(GLX) {
|
X.require('glx', function(err, GLX) {
|
||||||
var visual = 0;
|
var visual = 0;
|
||||||
var visuals = display.screen[0].depths[24];
|
var visuals = display.screen[0].depths[24];
|
||||||
for (visual in visuals) {
|
for (visual in visuals) {
|
||||||
|
|
|
||||||
|
|
@ -304,7 +304,7 @@ x11.createClient(function(err, display) {
|
||||||
var root = display.screen[0].root;
|
var root = display.screen[0].root;
|
||||||
var width = 1000;
|
var width = 1000;
|
||||||
var height = 1000;
|
var height = 1000;
|
||||||
X.require('glx', function(GLX) {
|
X.require('glx', function(err, GLX) {
|
||||||
var visual = 0xa1;
|
var visual = 0xa1;
|
||||||
var win = X.AllocID();
|
var win = X.AllocID();
|
||||||
X.CreateWindow(win, root, 0, 0, width, height, 0, 0, 0, 0, { eventMask: eventmask });
|
X.CreateWindow(win, root, 0, 0, width, height, 0, 0, 0, 0, { eventMask: eventmask });
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ for(var i=0; i < 20000; ++i) {
|
||||||
var xclient = x11.createClient(function(err, display) {
|
var xclient = x11.createClient(function(err, display) {
|
||||||
var X = display.client;
|
var X = display.client;
|
||||||
var root = display.screen[0].root;
|
var root = display.screen[0].root;
|
||||||
X.require('glx', function(GLX) {
|
X.require('glx', function(err, GLX) {
|
||||||
var screen = 0;
|
var screen = 0;
|
||||||
var isDirect = 0;
|
var isDirect = 0;
|
||||||
var ctx = X.AllocID();
|
var ctx = X.AllocID();
|
||||||
|
|
|
||||||
|
|
@ -10,10 +10,10 @@ var gradNo = 0;
|
||||||
var xclient = x11.createClient(function(err, display) {
|
var xclient = x11.createClient(function(err, display) {
|
||||||
X = display.client;
|
X = display.client;
|
||||||
var root = display.screen[0].root;
|
var root = display.screen[0].root;
|
||||||
X.require('render', function(rendExt) {
|
X.require('render', function(err, rendExt) {
|
||||||
Render = rendExt;
|
Render = rendExt;
|
||||||
var wid = X.AllocID();
|
var wid = X.AllocID();
|
||||||
|
|
||||||
var white = display.screen[0].white_pixel;
|
var white = display.screen[0].white_pixel;
|
||||||
var black = display.screen[0].black_pixel;
|
var black = display.screen[0].black_pixel;
|
||||||
X.CreateWindow(wid, root, 10, 10, 400, 300, 0, 0, 0, 0, { backgroundPixel: white, eventMask: PointerMotion|ButtonPress|ButtonRelease });
|
X.CreateWindow(wid, root, 10, 10, 400, 300, 0, 0, 0, 0, { backgroundPixel: white, eventMask: PointerMotion|ButtonPress|ButtonRelease });
|
||||||
|
|
@ -36,8 +36,8 @@ var xclient = x11.createClient(function(err, display) {
|
||||||
|
|
||||||
function draw(x, y) {
|
function draw(x, y) {
|
||||||
Render.Composite(3, pictGrad[gradNo], 0, pict, 0, 0, 0, 0, x-50, y-50, 100, 100);
|
Render.Composite(3, pictGrad[gradNo], 0, pict, 0, 0, 0, 0, x-50, y-50, 100, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
X.on('event', function(ev) {
|
X.on('event', function(ev) {
|
||||||
if (ev.type == 4 && ev.keycode == 1)
|
if (ev.type == 4 && ev.keycode == 1)
|
||||||
pressed = true;
|
pressed = true;
|
||||||
|
|
@ -45,14 +45,14 @@ var xclient = x11.createClient(function(err, display) {
|
||||||
pressed = false;
|
pressed = false;
|
||||||
else if (ev.type == 5 && ev.keycode == 4)
|
else if (ev.type == 5 && ev.keycode == 4)
|
||||||
{
|
{
|
||||||
gradNo--;
|
gradNo--;
|
||||||
if (gradNo < 0)
|
if (gradNo < 0)
|
||||||
gradNo = 0;
|
gradNo = 0;
|
||||||
console.log(gradNo);
|
console.log(gradNo);
|
||||||
}
|
}
|
||||||
else if (ev.type == 5 && ev.keycode == 5)
|
else if (ev.type == 5 && ev.keycode == 5)
|
||||||
{
|
{
|
||||||
gradNo++;
|
gradNo++;
|
||||||
if (gradNo > 9)
|
if (gradNo > 9)
|
||||||
gradNo = 9;
|
gradNo = 9;
|
||||||
console.log(gradNo);
|
console.log(gradNo);
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ var Exposure = x11.eventMask.Exposure;
|
||||||
x11.createClient(function(err, display)
|
x11.createClient(function(err, display)
|
||||||
{
|
{
|
||||||
var X = display.client;
|
var X = display.client;
|
||||||
X.require('render', function(Render) {
|
X.require('render', function(err, Render) {
|
||||||
var root = display.screen[0].root;
|
var root = display.screen[0].root;
|
||||||
main(root, X, Render);
|
main(root, X, Render);
|
||||||
});
|
});
|
||||||
|
|
@ -15,7 +15,7 @@ x11.createClient(function(err, display)
|
||||||
|
|
||||||
|
|
||||||
function main(root, X, Render) {
|
function main(root, X, Render) {
|
||||||
|
|
||||||
var win, picWin, pic, gc;
|
var win, picWin, pic, gc;
|
||||||
|
|
||||||
win = X.AllocID();
|
win = X.AllocID();
|
||||||
|
|
@ -39,7 +39,7 @@ function main(root, X, Render) {
|
||||||
Render.CreatePicture(logoPicture, logoPixmap, Render.rgb24);
|
Render.CreatePicture(logoPicture, logoPixmap, Render.rgb24);
|
||||||
var winPicture = X.AllocID();
|
var winPicture = X.AllocID();
|
||||||
Render.CreatePicture(winPicture, win, Render.rgb24);
|
Render.CreatePicture(winPicture, win, Render.rgb24);
|
||||||
|
|
||||||
X.on('event', function(ev) {
|
X.on('event', function(ev) {
|
||||||
if (ev.name == 'Expose')
|
if (ev.name == 'Expose')
|
||||||
Render.Composite(3, logoPicture, 0, winPicture, 0, 0, 0, 0, 0, 0, logo.width, logo.height);
|
Render.Composite(3, logoPicture, 0, winPicture, 0, 0, 0, 0, 0, 0, logo.width, logo.height);
|
||||||
|
|
|
||||||
|
|
@ -9,21 +9,21 @@ var x11 = require('../../lib');
|
||||||
x11.createClient(
|
x11.createClient(
|
||||||
function(err, display) {
|
function(err, display) {
|
||||||
var X = display.client;
|
var X = display.client;
|
||||||
X.require('render', function(Render) {
|
X.require('render', function(err, Render) {
|
||||||
|
|
||||||
var root = display.screen[0].root;
|
var root = display.screen[0].root;
|
||||||
var win = X.AllocID();
|
var win = X.AllocID();
|
||||||
var white = display.screen[0].white_pixel;
|
var white = display.screen[0].white_pixel;
|
||||||
var black = display.screen[0].black_pixel;
|
var black = display.screen[0].black_pixel;
|
||||||
X.CreateWindow(win, root, 0, 0, 500, 500, 0, 0, 0, 0,
|
X.CreateWindow(win, root, 0, 0, 500, 500, 0, 0, 0, 0,
|
||||||
{
|
{
|
||||||
backgroundPixel: white,
|
backgroundPixel: white,
|
||||||
eventMask: x11.eventMask.Exposure | x11.eventMask.ButtonPress | x11.eventMask.PointerMotion
|
eventMask: x11.eventMask.Exposure | x11.eventMask.ButtonPress | x11.eventMask.PointerMotion
|
||||||
});
|
});
|
||||||
X.MapWindow(win);
|
X.MapWindow(win);
|
||||||
|
|
||||||
var picture = X.AllocID();
|
var picture = X.AllocID();
|
||||||
Render.CreatePicture(picture, win, Render.rgb24, { polyEdge: 1, polyMode: 0 } );
|
Render.CreatePicture(picture, win, Render.rgb24, { polyEdge: 1, polyMode: 0 } );
|
||||||
var pixmap = X.AllocID();
|
var pixmap = X.AllocID();
|
||||||
X.CreatePixmap(pixmap, win, 32, 2500, 2500);
|
X.CreatePixmap(pixmap, win, 32, 2500, 2500);
|
||||||
var pix_pict = X.AllocID();
|
var pix_pict = X.AllocID();
|
||||||
|
|
@ -34,30 +34,30 @@ x11.createClient(
|
||||||
//RenderRadialGradient(pic_grad, [0,0], [1000,100], 10, 1000,
|
//RenderRadialGradient(pic_grad, [0,0], [1000,100], 10, 1000,
|
||||||
//RenderConicalGradient(pic_grad, [250,250], 360,
|
//RenderConicalGradient(pic_grad, [250,250], 360,
|
||||||
[
|
[
|
||||||
[0, [0,0,0,0x3000 ] ],
|
[0, [0,0,0,0x3000 ] ],
|
||||||
[0.1, [0xfff, 0, 0xffff, 0x1000] ] ,
|
[0.1, [0xfff, 0, 0xffff, 0x1000] ] ,
|
||||||
[0.25, [0xffff, 0, 0xfff, 0x3000] ] ,
|
[0.25, [0xffff, 0, 0xfff, 0x3000] ] ,
|
||||||
[0.5, [0xffff, 0, 0xffff, 0x4000] ] ,
|
[0.5, [0xffff, 0, 0xffff, 0x4000] ] ,
|
||||||
[1, [0xffff, 0xffff, 0, 0x8000] ]
|
[1, [0xffff, 0xffff, 0, 0x8000] ]
|
||||||
]);
|
]);
|
||||||
|
|
||||||
var pic_grad1 = X.AllocID();
|
var pic_grad1 = X.AllocID();
|
||||||
|
|
||||||
Render.ConicalGradient(pic_grad1, [250,250], 10,
|
Render.ConicalGradient(pic_grad1, [250,250], 10,
|
||||||
[
|
[
|
||||||
[0, [0,0,0,0x5000 ] ],
|
[0, [0,0,0,0x5000 ] ],
|
||||||
[0.1, [0xfff, 0, 0xffff, 0x3000] ] ,
|
[0.1, [0xfff, 0, 0xffff, 0x3000] ] ,
|
||||||
[0.25, [0xffff, 0, 0xfff, 0x2000] ] ,
|
[0.25, [0xffff, 0, 0xfff, 0x2000] ] ,
|
||||||
[0.5, [0xffff, 0, 0xffff, 0x1000] ] ,
|
[0.5, [0xffff, 0, 0xffff, 0x1000] ] ,
|
||||||
[1, [0xffff, 0xffff, 0, 0x8000] ]
|
[1, [0xffff, 0xffff, 0, 0x8000] ]
|
||||||
]);
|
]);
|
||||||
|
|
||||||
var pic_grad2 = X.AllocID();
|
var pic_grad2 = X.AllocID();
|
||||||
Render.RadialGradient(pic_grad2, [250,250], [250,250], 0, 250,
|
Render.RadialGradient(pic_grad2, [250,250], [250,250], 0, 250,
|
||||||
[
|
[
|
||||||
[0, [0,0,0,0x5000 ] ],
|
[0, [0,0,0,0x5000 ] ],
|
||||||
[0.99, [0xffff, 0xffff, 0, 0xffff] ],
|
[0.99, [0xffff, 0xffff, 0, 0xffff] ],
|
||||||
[1, [0xffff, 0xffff, 0, 0x0] ]
|
[1, [0xffff, 0xffff, 0, 0x0] ]
|
||||||
]);
|
]);
|
||||||
|
|
||||||
var pixmap1 = X.AllocID();
|
var pixmap1 = X.AllocID();
|
||||||
|
|
@ -112,7 +112,7 @@ x11.createClient(
|
||||||
draw();
|
draw();
|
||||||
} else {
|
} else {
|
||||||
draw();
|
draw();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ var PointerMotion = x11.eventMask.PointerMotion;
|
||||||
var xclient = x11.createClient(function(err, display) {
|
var xclient = x11.createClient(function(err, display) {
|
||||||
var X = display.client;
|
var X = display.client;
|
||||||
var root = display.screen[0].root;
|
var root = display.screen[0].root;
|
||||||
display.client.require('render', function(Render) {
|
display.client.require('render', function(err, Render) {
|
||||||
var wid = X.AllocID();
|
var wid = X.AllocID();
|
||||||
var white = display.screen[0].white_pixel;
|
var white = display.screen[0].white_pixel;
|
||||||
varblack = display.screen[0].black_pixel;
|
varblack = display.screen[0].black_pixel;
|
||||||
|
|
@ -24,8 +24,8 @@ var xclient = x11.createClient(function(err, display) {
|
||||||
|
|
||||||
function draw(x, y) {
|
function draw(x, y) {
|
||||||
Render.Composite(3, pictGrad, 0, pict, 0, 0, 0, 0, x-26, y-26, 52, 52);
|
Render.Composite(3, pictGrad, 0, pict, 0, 0, 0, 0, x-26, y-26, 52, 52);
|
||||||
}
|
}
|
||||||
|
|
||||||
X.on('event', function(ev) {
|
X.on('event', function(ev) {
|
||||||
draw(ev.x, ev.y);
|
draw(ev.x, ev.y);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ function padWidth(buf, width) {
|
||||||
var xclient = x11.createClient({ debug: true }, function(err, display) {
|
var xclient = x11.createClient({ debug: true }, function(err, display) {
|
||||||
var X = display.client;
|
var X = display.client;
|
||||||
var root = display.screen[0].root;
|
var root = display.screen[0].root;
|
||||||
display.client.require('render', function(Render) {
|
display.client.require('render', function(err, Render) {
|
||||||
var wid = X.AllocID();
|
var wid = X.AllocID();
|
||||||
var white = display.screen[0].white_pixel;
|
var white = display.screen[0].white_pixel;
|
||||||
varblack = display.screen[0].black_pixel;
|
varblack = display.screen[0].black_pixel;
|
||||||
|
|
|
||||||
|
|
@ -3,18 +3,18 @@ var x11 = require('../../lib');
|
||||||
x11.createClient(function(err, display) {
|
x11.createClient(function(err, display) {
|
||||||
var X = display.client;
|
var X = display.client;
|
||||||
var root = display.screen[0].root;
|
var root = display.screen[0].root;
|
||||||
X.require('apple-wm', function(AppleWM) {
|
X.require('apple-wm', function(err, AppleWM) {
|
||||||
//AppleWM.SetFrontProcess();
|
//AppleWM.SetFrontProcess();
|
||||||
//AppleWM.CanQuit(true);
|
//AppleWM.CanQuit(true);
|
||||||
AppleWM.SelectInput(AppleWM.NotifyMask.All)
|
AppleWM.SelectInput(AppleWM.NotifyMask.All)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
for (level in AppleWM.WindowLevel)
|
for (level in AppleWM.WindowLevel)
|
||||||
{
|
{
|
||||||
var win = X.AllocID();
|
var win = X.AllocID();
|
||||||
X.CreateWindow(win, root, 0, 0, 300, 300);
|
X.CreateWindow(win, root, 0, 0, 300, 300);
|
||||||
X.MapWindow(win);
|
X.MapWindow(win);
|
||||||
X.ChangeProperty(0, win, X.atoms.WM_NAME, X.atoms.STRING, 8, level);
|
X.ChangeProperty(0, win, X.atoms.WM_NAME, X.atoms.STRING, 8, level);
|
||||||
AppleWM.SetWindowLevel(win, AppleWM.WindowLevel[level]);
|
AppleWM.SetWindowLevel(win, AppleWM.WindowLevel[level]);
|
||||||
};
|
};
|
||||||
*/
|
*/
|
||||||
|
|
@ -22,7 +22,7 @@ x11.createClient(function(err, display) {
|
||||||
var win1 = X.AllocID();
|
var win1 = X.AllocID();
|
||||||
X.CreateWindow(win1, root, 0, 0, 300, 300);
|
X.CreateWindow(win1, root, 0, 0, 300, 300);
|
||||||
X.MapWindow(win1);
|
X.MapWindow(win1);
|
||||||
X.ChangeProperty(0, win1, X.atoms.WM_NAME, X.atoms.STRING, 8, "parent");
|
X.ChangeProperty(0, win1, X.atoms.WM_NAME, X.atoms.STRING, 8, "parent");
|
||||||
var win2 = X.AllocID();
|
var win2 = X.AllocID();
|
||||||
X.CreateWindow(win2, root, 0, 0, 200, 200);
|
X.CreateWindow(win2, root, 0, 0, 200, 200);
|
||||||
X.MapWindow(win2);
|
X.MapWindow(win2);
|
||||||
|
|
@ -37,12 +37,12 @@ x11.createClient(function(err, display) {
|
||||||
// (screen, window, frameClass, attr, ix, iy, iw, ih, ox, oy, ow, oh, titleLength)
|
// (screen, window, frameClass, attr, ix, iy, iw, ih, ox, oy, ow, oh, titleLength)
|
||||||
var gc = X.AllocID();
|
var gc = X.AllocID();
|
||||||
X.CreateGC(gc, win);
|
X.CreateGC(gc, win);
|
||||||
|
|
||||||
function r(v) { var res = parseInt(Math.random()*v); console.log(res); return res;}
|
function r(v) { var res = parseInt(Math.random()*v); console.log(res); return res;}
|
||||||
function df() { X.PolyFillRectangle(win, gc, [0, 0, 1000, 1000]); AppleWM.FrameDraw(0, win, 65535, r(65535), 30, 30, 500, 50, 0, 0, 550, 100, "title title");}
|
function df() { X.PolyFillRectangle(win, gc, [0, 0, 1000, 1000]); AppleWM.FrameDraw(0, win, 65535, r(65535), 30, 30, 500, 50, 0, 0, 550, 100, "title title");}
|
||||||
//setInterval(df, 100);
|
//setInterval(df, 100);
|
||||||
X.on('event', function(ev) { console.log("Event", ev); df(); });
|
X.on('event', function(ev) { console.log("Event", ev); df(); });
|
||||||
});
|
});
|
||||||
X.on('error', function(err) { console.log("Error", err); });
|
X.on('error', function(err) { console.log("Error", err); });
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@ var x11 = require('../../lib');
|
||||||
x11.createClient(function(err, display) {
|
x11.createClient(function(err, display) {
|
||||||
var X = display.client;
|
var X = display.client;
|
||||||
var root = display.screen[0].root;
|
var root = display.screen[0].root;
|
||||||
X.require('composite', function(Composite) {
|
X.require('composite', function(err, Composite) {
|
||||||
X.require('damage', function(Damage) {
|
X.require('damage', function(err, Damage) {
|
||||||
var wid = parseInt(process.argv[2]);
|
var wid = parseInt(process.argv[2]);
|
||||||
//Composite.GetOverlayWindow(wid, function(err, overlayid) {
|
//Composite.GetOverlayWindow(wid, function(err, overlayid) {
|
||||||
// console.log("OVERLAY:", err, overlayid);
|
// console.log("OVERLAY:", err, overlayid);
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ var x11 = require('../../lib');
|
||||||
x11.createClient(function(err, display) {
|
x11.createClient(function(err, display) {
|
||||||
var X = display.client;
|
var X = display.client;
|
||||||
var root = display.screen[0].root;
|
var root = display.screen[0].root;
|
||||||
X.require('damage', function(Damage) {
|
X.require('damage', function(err, Damage) {
|
||||||
console.log(Damage);
|
console.log(Damage);
|
||||||
var id = parseInt(process.argv[2]);
|
var id = parseInt(process.argv[2]);
|
||||||
var damage = X.AllocID();
|
var damage = X.AllocID();
|
||||||
|
|
@ -14,5 +14,5 @@ x11.createClient(function(err, display) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
X.on('error', function(err) { console.log(err); });
|
X.on('error', function(err) { console.log(err); });
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ var x11 = require('../../lib');
|
||||||
x11.createClient(function(err, display) {
|
x11.createClient(function(err, display) {
|
||||||
var X = display.client;
|
var X = display.client;
|
||||||
var root = display.screen[0].root;
|
var root = display.screen[0].root;
|
||||||
X.require('fixes', function(Fixes) {
|
X.require('fixes', function(err, Fixes) {
|
||||||
console.log(Fixes);
|
console.log(Fixes);
|
||||||
var win = X.AllocID();
|
var win = X.AllocID();
|
||||||
X.CreateWindow(win, root, 0, 0, 100, 100);
|
X.CreateWindow(win, root, 0, 0, 100, 100);
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ x11.createClient(function(err, display) {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
|
|
||||||
var X = display.client;
|
var X = display.client;
|
||||||
X.require('render', function(Render) {
|
X.require('render', function(err, Render) {
|
||||||
|
|
||||||
var root = display.screen[0].root;
|
var root = display.screen[0].root;
|
||||||
var white = display.screen[0].white_pixel;
|
var white = display.screen[0].white_pixel;
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ var x11 = require('../../lib');
|
||||||
x11.createClient(function(err, display) {
|
x11.createClient(function(err, display) {
|
||||||
var X = display.client;
|
var X = display.client;
|
||||||
var root = display.screen[0].root;
|
var root = display.screen[0].root;
|
||||||
X.require('randr', function(Randr) {
|
X.require('randr', function(err, Randr) {
|
||||||
//console.log(Randr);
|
//console.log(Randr);
|
||||||
//Randr.QueryVersion(1, 4, console.log);
|
//Randr.QueryVersion(1, 4, console.log);
|
||||||
Randr.SelectInput(root, Randr.NotifyMask.ScreenChange);
|
Randr.SelectInput(root, Randr.NotifyMask.ScreenChange);
|
||||||
|
|
|
||||||
|
|
@ -3,11 +3,11 @@ var x11 = require('../../lib');
|
||||||
x11.createClient(function(err, display) {
|
x11.createClient(function(err, display) {
|
||||||
var X = display.client;
|
var X = display.client;
|
||||||
var root = display.screen[0].root;
|
var root = display.screen[0].root;
|
||||||
X.require('shape', function(Shape) {
|
X.require('shape', function(err, Shape) {
|
||||||
var win = X.AllocID();
|
var win = X.AllocID();
|
||||||
X.CreateWindow(win, root, 0, 0, 200, 200);
|
X.CreateWindow(win, root, 0, 0, 200, 200);
|
||||||
var gc = X.AllocID();
|
var gc = X.AllocID();
|
||||||
X.CreateGC(gc, win);
|
X.CreateGC(gc, win);
|
||||||
//X.MapWindow(win);
|
//X.MapWindow(win);
|
||||||
Shape.SelectInput(win, 1);
|
Shape.SelectInput(win, 1);
|
||||||
Shape.InputSelected(win, function(err, isSelected) {
|
Shape.InputSelected(win, function(err, isSelected) {
|
||||||
|
|
@ -23,5 +23,5 @@ x11.createClient(function(err, display) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
X.on('error', function(err) { console.log(err); });
|
X.on('error', function(err) { console.log(err); });
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ x11.createClient(function(err, display) {
|
||||||
X.SetScreenSaver(20, 10, 2, 2);
|
X.SetScreenSaver(20, 10, 2, 2);
|
||||||
|
|
||||||
|
|
||||||
X.require('screen-saver', function(SS) {
|
X.require('screen-saver', function(err, SS) {
|
||||||
SS.SelectInput(root, SS.eventMask.Notify|SS.eventMask.Cycle);
|
SS.SelectInput(root, SS.eventMask.Notify|SS.eventMask.Cycle);
|
||||||
//console.log(SS);
|
//console.log(SS);
|
||||||
//setTimeout(function() {
|
//setTimeout(function() {
|
||||||
|
|
@ -15,7 +15,7 @@ x11.createClient(function(err, display) {
|
||||||
//}, 5000);
|
//}, 5000);
|
||||||
setInterval(function() {
|
setInterval(function() {
|
||||||
SS.QueryInfo(root, function(err, info) {
|
SS.QueryInfo(root, function(err, info) {
|
||||||
console.log(info.until);
|
console.log(info.until);
|
||||||
//SS.SelectInput(root, SS.eventMask.Notify|SS.eventMask.Cycle);
|
//SS.SelectInput(root, SS.eventMask.Notify|SS.eventMask.Cycle);
|
||||||
});
|
});
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
|
@ -24,5 +24,5 @@ x11.createClient(function(err, display) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
X.on('error', function(err) { console.log(err); });
|
X.on('error', function(err) { console.log(err); });
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -25,18 +25,18 @@ x11.createClient(function(err, display) {
|
||||||
|
|
||||||
var cmid = X.AllocID();
|
var cmid = X.AllocID();
|
||||||
var depth = 32;
|
var depth = 32;
|
||||||
X.CreateColormap(cmid, root, visual, 0); // 0=AllocNone, 1 AllocAll
|
X.CreateColormap(cmid, root, visual, 0); // 0=AllocNone, 1 AllocAll
|
||||||
|
|
||||||
X.CreateWindow(wid, root, 10, 10, 168, 195, 1, depth, 1, visual, { eventMask: x11.eventMask.Exposure, colormap: cmid, backgroundPixel: 0, borderPixel: 0 });
|
X.CreateWindow(wid, root, 10, 10, 168, 195, 1, depth, 1, visual, { eventMask: x11.eventMask.Exposure, colormap: cmid, backgroundPixel: 0, borderPixel: 0 });
|
||||||
X.MapWindow(wid);
|
X.MapWindow(wid);
|
||||||
|
|
||||||
var gc = X.AllocID();
|
var gc = X.AllocID();
|
||||||
X.require('render', function(Render) {
|
X.require('render', function(err, Render) {
|
||||||
|
|
||||||
var pict = X.AllocID();
|
var pict = X.AllocID();
|
||||||
Render.CreatePicture(pict, wid, Render.rgba32);
|
Render.CreatePicture(pict, wid, Render.rgba32);
|
||||||
var gradients = [];
|
var gradients = [];
|
||||||
|
|
||||||
function randomLinear() {
|
function randomLinear() {
|
||||||
var stops = [];
|
var stops = [];
|
||||||
for (var i=0; i<3; ++i)
|
for (var i=0; i<3; ++i)
|
||||||
|
|
@ -49,8 +49,8 @@ x11.createClient(function(err, display) {
|
||||||
parseInt(Math.random()*65535),
|
parseInt(Math.random()*65535),
|
||||||
parseInt(Math.random()*65535),
|
parseInt(Math.random()*65535),
|
||||||
parseInt(Math.random()*65535)]]);
|
parseInt(Math.random()*65535)]]);
|
||||||
|
|
||||||
console.log(colors);
|
console.log(colors);
|
||||||
|
|
||||||
var gradient = X.AllocID();
|
var gradient = X.AllocID();
|
||||||
Render.LinearGradient(gradient, [0, 0], [100+parseInt(Math.random()*500), parseInt(100+Math.random()*300)], colors);
|
Render.LinearGradient(gradient, [0, 0], [100+parseInt(Math.random()*500), parseInt(100+Math.random()*300)], colors);
|
||||||
|
|
@ -64,7 +64,7 @@ x11.createClient(function(err, display) {
|
||||||
var gid = parseInt(Math.random()*gradients.length);
|
var gid = parseInt(Math.random()*gradients.length);
|
||||||
console.log(gradients[gid]);
|
console.log(gradients[gid]);
|
||||||
Render.Composite(1, gradients[gid], 0, pict, 0, 0, 0, 0, 0, 0, 400, 300);
|
Render.Composite(1, gradients[gid], 0, pict, 0, 0, 0, 0, 0, 0, 400, 300);
|
||||||
}, 2000);
|
}, 2000);
|
||||||
});
|
});
|
||||||
//X.CreateGC(gc, wid, { foreground: black, background: white } );
|
//X.CreateGC(gc, wid, { foreground: black, background: white } );
|
||||||
//setInterval(function() {
|
//setInterval(function() {
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ var x11 = require('../../lib');
|
||||||
x11.createClient(function(err, display) {
|
x11.createClient(function(err, display) {
|
||||||
var X = display.client;
|
var X = display.client;
|
||||||
var root = display.screen[0].root;
|
var root = display.screen[0].root;
|
||||||
X.require('xc-misc', function(Misc) {
|
X.require('xc-misc', function(err, Misc) {
|
||||||
var xid = X.AllocID();
|
var xid = X.AllocID();
|
||||||
console.log("first ID from connection: " + xid);
|
console.log("first ID from connection: " + xid);
|
||||||
debugger;
|
debugger;
|
||||||
|
|
@ -15,5 +15,5 @@ x11.createClient(function(err, display) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
X.on('error', function(err) { console.log("Error", err); });
|
X.on('error', function(err) { console.log("Error", err); });
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ var x11 = require('../../lib');
|
||||||
var xclient = x11.createClient(function(err, display) {
|
var xclient = x11.createClient(function(err, display) {
|
||||||
var X = display.client;
|
var X = display.client;
|
||||||
var root = display.screen[0].root;
|
var root = display.screen[0].root;
|
||||||
display.client.require('xtest', function(Test) {
|
display.client.require('xtest', function(err, Test) {
|
||||||
console.log(Test);
|
console.log(Test);
|
||||||
setInterval(function() {
|
setInterval(function() {
|
||||||
Test.FakeInput(Test.KeyPress, 65, 0, root, 0, 0); // space
|
Test.FakeInput(Test.KeyPress, 65, 0, root, 0, 0); // space
|
||||||
|
|
|
||||||
|
|
@ -30,8 +30,8 @@ var KeyPress = x11.eventMask.KeyPress;
|
||||||
var KeyRelease = x11.eventMask.KeyRelease;
|
var KeyRelease = x11.eventMask.KeyRelease;
|
||||||
|
|
||||||
x11.createClient(function(err, display) {
|
x11.createClient(function(err, display) {
|
||||||
var X = display.client;
|
var X = display.client;
|
||||||
X.require('big-requests', function(BigReq) {
|
X.require('big-requests', function(err, BigReq) {
|
||||||
BigReq.Enable(function(err, maxLen) {
|
BigReq.Enable(function(err, maxLen) {
|
||||||
var keycode2keysym = [];
|
var keycode2keysym = [];
|
||||||
var min = display.min_keycode;
|
var min = display.min_keycode;
|
||||||
|
|
@ -54,19 +54,19 @@ x11.createClient(function(err, display) {
|
||||||
|
|
||||||
var wid = X.AllocID();
|
var wid = X.AllocID();
|
||||||
X.CreateWindow(wid, root, 0, 0, r.width, r.height);
|
X.CreateWindow(wid, root, 0, 0, r.width, r.height);
|
||||||
X.ChangeWindowAttributes(wid, {
|
X.ChangeWindowAttributes(wid, {
|
||||||
backgroundPixel: black,
|
backgroundPixel: black,
|
||||||
eventMask: Exposure|PointerMotion|ButtonPress|ButtonRelease|KeyPress|KeyRelease
|
eventMask: Exposure|PointerMotion|ButtonPress|ButtonRelease|KeyPress|KeyRelease
|
||||||
});
|
});
|
||||||
X.ChangeProperty(0, wid, X.atoms.WM_NAME, X.atoms.STRING, 8, r.title);
|
X.ChangeProperty(0, wid, X.atoms.WM_NAME, X.atoms.STRING, 8, r.title);
|
||||||
X.MapWindow(wid);
|
X.MapWindow(wid);
|
||||||
|
|
||||||
var gc = X.AllocID();
|
var gc = X.AllocID();
|
||||||
X.CreateGC(gc, wid, { foreground: black, background: white } );
|
X.CreateGC(gc, wid, { foreground: black, background: white } );
|
||||||
|
|
||||||
//var pixbuf = X.AllocID();
|
//var pixbuf = X.AllocID();
|
||||||
//X.CreatePixmap(pixbuf, wid, 32, r.width, r.height);
|
//X.CreatePixmap(pixbuf, wid, 32, r.width, r.height);
|
||||||
//var pic = X.AllocID();
|
//var pic = X.AllocID();
|
||||||
//Render.CreatePicture(pic, pixbuf, Render.rgba32);
|
//Render.CreatePicture(pic, pixbuf, Render.rgba32);
|
||||||
|
|
||||||
var buttonsState = 0;
|
var buttonsState = 0;
|
||||||
|
|
@ -86,7 +86,7 @@ x11.createClient(function(err, display) {
|
||||||
// set button bit
|
// set button bit
|
||||||
if (ev.type == 4)
|
if (ev.type == 4)
|
||||||
buttonsState |= buttonBit;
|
buttonsState |= buttonBit;
|
||||||
else
|
else
|
||||||
buttonsState &= ~buttonBit;
|
buttonsState &= ~buttonBit;
|
||||||
r.pointerEvent(ev.x, ev.y, buttonsState);
|
r.pointerEvent(ev.x, ev.y, buttonsState);
|
||||||
} else if (ev.type == 2 || ev.type == 3) {
|
} else if (ev.type == 2 || ev.type == 3) {
|
||||||
|
|
@ -121,7 +121,7 @@ x11.createClient(function(err, display) {
|
||||||
});
|
});
|
||||||
|
|
||||||
}); // r.on('connect)
|
}); // r.on('connect)
|
||||||
}); // GetKeyboardMapping
|
}); // GetKeyboardMapping
|
||||||
}); // BigReq.Enable
|
}); // BigReq.Enable
|
||||||
|
|
||||||
}); // require('big-requests
|
}); // require('big-requests
|
||||||
|
|
|
||||||
|
|
@ -80,7 +80,7 @@ function ManageWindow(wid)
|
||||||
|
|
||||||
x11.createClient(function(err, display) {
|
x11.createClient(function(err, display) {
|
||||||
X = display.client;
|
X = display.client;
|
||||||
X.require('render', function(Render) {
|
X.require('render', function(err, Render) {
|
||||||
X.Render = Render;
|
X.Render = Render;
|
||||||
|
|
||||||
root = display.screen[0].root;
|
root = display.screen[0].root;
|
||||||
|
|
|
||||||
386
lib/corereqs.js
386
lib/corereqs.js
|
|
@ -6,70 +6,207 @@ var hexy = require('./hexy').hexy;
|
||||||
|
|
||||||
var valueMask = {
|
var valueMask = {
|
||||||
CreateWindow: {
|
CreateWindow: {
|
||||||
backgroundPixmap: 0x00000001,
|
backgroundPixmap : {
|
||||||
backgroundPixel : 0x00000002,
|
mask: 0x00000001,
|
||||||
borderPixmap : 0x00000004,
|
format: 'L'
|
||||||
borderPixel : 0x00000008,
|
},
|
||||||
bitGravity : 0x00000010,
|
backgroundPixel : {
|
||||||
winGravity : 0x00000020,
|
mask: 0x00000002,
|
||||||
backingStore : 0x00000040,
|
format: 'L'
|
||||||
backingPlanes : 0x00000080,
|
},
|
||||||
backingPixel : 0x00000100,
|
borderPixmap : {
|
||||||
overrideRedirect: 0x00000200,
|
mask: 0x00000004,
|
||||||
saveUnder : 0x00000400,
|
format: 'L'
|
||||||
eventMask : 0x00000800,
|
},
|
||||||
doNotPropagateMask: 0x00001000,
|
borderPixel : {
|
||||||
colormap : 0x00002000,
|
mask: 0x00000008,
|
||||||
cursor : 0x00004000
|
format: 'L'
|
||||||
|
},
|
||||||
|
bitGravity : {
|
||||||
|
mask: 0x00000010,
|
||||||
|
format: 'C'
|
||||||
|
},
|
||||||
|
winGravity : {
|
||||||
|
mask: 0x00000020,
|
||||||
|
format: 'C'
|
||||||
|
},
|
||||||
|
backingStore : {
|
||||||
|
mask: 0x00000040,
|
||||||
|
format: 'C'
|
||||||
|
},
|
||||||
|
backingPlanes : {
|
||||||
|
mask: 0x00000080,
|
||||||
|
format: 'L'
|
||||||
|
},
|
||||||
|
backingPixel : {
|
||||||
|
mask: 0x00000100,
|
||||||
|
format: 'L'
|
||||||
|
},
|
||||||
|
overrideRedirect : {
|
||||||
|
mask: 0x00000200,
|
||||||
|
format: 'C'
|
||||||
|
},
|
||||||
|
saveUnder : {
|
||||||
|
mask: 0x00000400,
|
||||||
|
format: 'C'
|
||||||
|
},
|
||||||
|
eventMask : {
|
||||||
|
mask: 0x00000800,
|
||||||
|
format: 'L'
|
||||||
|
},
|
||||||
|
doNotPropagateMask : {
|
||||||
|
mask: 0x00001000,
|
||||||
|
format: 'L'
|
||||||
|
},
|
||||||
|
colormap : {
|
||||||
|
mask: 0x00002000,
|
||||||
|
format: 'L'
|
||||||
|
},
|
||||||
|
cursor : {
|
||||||
|
mask: 0x00004000,
|
||||||
|
format: 'L'
|
||||||
|
}
|
||||||
},
|
},
|
||||||
CreateGC: {
|
CreateGC: {
|
||||||
'function' : 0x00000001, // TODO: alias? _function?
|
'function' : { // TODO: alias? _function?
|
||||||
planeMask : 0x00000002,
|
mask: 0x00000001,
|
||||||
foreground : 0x00000004,
|
format: 'C'
|
||||||
background : 0x00000008,
|
},
|
||||||
lineWidth : 0x00000010,
|
planeMask : {
|
||||||
lineStyle : 0x00000020,
|
mask: 0x00000002,
|
||||||
capStyle : 0x00000040,
|
format: 'L'
|
||||||
joinStyle : 0x00000080,
|
},
|
||||||
fillStyle : 0x00000100,
|
foreground : {
|
||||||
fillRule : 0x00000200,
|
mask: 0x00000004,
|
||||||
tile : 0x00000400,
|
format: 'L'
|
||||||
stipple : 0x00000800,
|
},
|
||||||
tileStippleXOrigin: 0x00001000,
|
background : {
|
||||||
tileStippleYOrigin: 0x00002000,
|
mask: 0x00000008,
|
||||||
font : 0x00004000,
|
format: 'L'
|
||||||
subwindowMode: 0x00008000,
|
},
|
||||||
graphicsExposures: 0x00010000,
|
lineWidth : {
|
||||||
clipXOrigin : 0x00020000,
|
mask: 0x00000010,
|
||||||
clipYOrigin : 0x00040000,
|
format: 'S'
|
||||||
clipMask : 0x00080000,
|
},
|
||||||
dashOffset : 0x00100000,
|
lineStyle : {
|
||||||
dashes : 0x00200000,
|
mask: 0x00000020,
|
||||||
arcMode : 0x00400000
|
format: 'C'
|
||||||
|
},
|
||||||
|
capStyle : {
|
||||||
|
mask: 0x00000040,
|
||||||
|
format: 'C'
|
||||||
|
},
|
||||||
|
joinStyle : {
|
||||||
|
mask: 0x00000080,
|
||||||
|
format: 'C'
|
||||||
|
},
|
||||||
|
fillStyle : {
|
||||||
|
mask: 0x00000100,
|
||||||
|
format: 'C'
|
||||||
|
},
|
||||||
|
fillRule : {
|
||||||
|
mask: 0x00000200,
|
||||||
|
format: 'C'
|
||||||
|
},
|
||||||
|
tile : {
|
||||||
|
mask: 0x00000400,
|
||||||
|
format: 'L'
|
||||||
|
},
|
||||||
|
stipple : {
|
||||||
|
mask: 0x00000800,
|
||||||
|
format: 'L'
|
||||||
|
},
|
||||||
|
tileStippleXOrigin : {
|
||||||
|
mask: 0x00001000,
|
||||||
|
format: 's'
|
||||||
|
},
|
||||||
|
tileStippleYOrigin : {
|
||||||
|
mask: 0x00002000,
|
||||||
|
format: 's'
|
||||||
|
},
|
||||||
|
font : {
|
||||||
|
mask: 0x00004000,
|
||||||
|
format: 'L'
|
||||||
|
},
|
||||||
|
subwindowMode : {
|
||||||
|
mask: 0x00008000,
|
||||||
|
format: 'C'
|
||||||
|
},
|
||||||
|
graphicsExposures : {
|
||||||
|
mask: 0x00010000,
|
||||||
|
format: 'C'
|
||||||
|
},
|
||||||
|
clipXOrigin : {
|
||||||
|
mask: 0x00020000,
|
||||||
|
format: 'S'
|
||||||
|
},
|
||||||
|
clipYOrigin : {
|
||||||
|
mask: 0x00040000,
|
||||||
|
format: 'S'
|
||||||
|
},
|
||||||
|
clipMask : {
|
||||||
|
mask: 0x00080000,
|
||||||
|
format: 'L'
|
||||||
|
},
|
||||||
|
dashOffset : {
|
||||||
|
mask: 0x00100000,
|
||||||
|
format: 'S'
|
||||||
|
},
|
||||||
|
dashes : {
|
||||||
|
mask: 0x00200000,
|
||||||
|
format: 'C'
|
||||||
|
},
|
||||||
|
arcMode : {
|
||||||
|
mask: 0x00400000,
|
||||||
|
format: 'C'
|
||||||
|
}
|
||||||
},
|
},
|
||||||
ConfigureWindow: {
|
ConfigureWindow: {
|
||||||
x: 0x000001,
|
x : {
|
||||||
y: 0x000002,
|
mask: 0x000001,
|
||||||
width: 0x000004,
|
format: 'sxx'
|
||||||
height: 0x000008,
|
},
|
||||||
borderWidth: 0x000010,
|
y : {
|
||||||
sibling: 0x000020,
|
mask: 0x000002,
|
||||||
stackMode: 0x000040
|
format: 'sxx'
|
||||||
|
},
|
||||||
|
width : {
|
||||||
|
mask: 0x000004,
|
||||||
|
format: 'Sxx'
|
||||||
|
},
|
||||||
|
height : {
|
||||||
|
mask: 0x000008,
|
||||||
|
format: 'Sxx'
|
||||||
|
},
|
||||||
|
borderWidth : {
|
||||||
|
mask: 0x000010,
|
||||||
|
format: 'Sxx'
|
||||||
|
},
|
||||||
|
sibling : {
|
||||||
|
mask: 0x000020,
|
||||||
|
format: 'L'
|
||||||
|
},
|
||||||
|
stackMode : {
|
||||||
|
mask: 0x000040,
|
||||||
|
format: 'Cxxx'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
var valueMaskName = {};
|
var valueMaskName = {};
|
||||||
for (var req in valueMask) {
|
for (var req in valueMask) {
|
||||||
var masks = valueMask[req];
|
var masks = valueMask[req];
|
||||||
var names = valueMaskName[req] = {};
|
var names = valueMaskName[req] = {};
|
||||||
for (var m in masks)
|
for (var m in masks)
|
||||||
names[masks[m]] = m;
|
names[masks[m].mask] = m;
|
||||||
}
|
}
|
||||||
|
|
||||||
function packValueMask(reqname, values)
|
function packValueMask(reqname, values)
|
||||||
{
|
{
|
||||||
var bitmask = 0;
|
var bitmask = 0;
|
||||||
var masksList = [];
|
var masksList = [];
|
||||||
|
var format = '';
|
||||||
var reqValueMask = valueMask[reqname];
|
var reqValueMask = valueMask[reqname];
|
||||||
var reqValueMaskName = valueMaskName[reqname];
|
var reqValueMaskName = valueMaskName[reqname];
|
||||||
|
|
||||||
|
|
@ -78,7 +215,7 @@ function packValueMask(reqname, values)
|
||||||
|
|
||||||
for (var v in values)
|
for (var v in values)
|
||||||
{
|
{
|
||||||
var valueBit = reqValueMask[v];
|
var valueBit = reqValueMask[v].mask;
|
||||||
if (!valueBit)
|
if (!valueBit)
|
||||||
throw new Error(reqname + ': incorrect value param ' + v);
|
throw new Error(reqname + ': incorrect value param ' + v);
|
||||||
masksList.push(valueBit);
|
masksList.push(valueBit);
|
||||||
|
|
@ -89,9 +226,10 @@ function packValueMask(reqname, values)
|
||||||
for (m in masksList)
|
for (m in masksList)
|
||||||
{
|
{
|
||||||
var valueName = reqValueMaskName[masksList[m]];
|
var valueName = reqValueMaskName[masksList[m]];
|
||||||
|
format += reqValueMask[valueName].format
|
||||||
args.push( values[valueName] );
|
args.push( values[valueName] );
|
||||||
}
|
}
|
||||||
return [bitmask, args]
|
return [format, bitmask, args]
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -132,45 +270,21 @@ var templates = {
|
||||||
if (values === undefined)
|
if (values === undefined)
|
||||||
values = {}
|
values = {}
|
||||||
|
|
||||||
var packetLength = 8 + (values ? Object.keys(values).length : 0);
|
|
||||||
var format = 'CCSLLssSSSSLL';
|
var format = 'CCSLLssSSSSLL';
|
||||||
|
|
||||||
// create bitmask
|
|
||||||
var bitmask = 0;
|
|
||||||
// TODO: slice from function arguments?
|
// TODO: slice from function arguments?
|
||||||
var args = [1, depth, packetLength, id, parentId, x, y, width, height, borderWidth, _class, visual];
|
|
||||||
|
|
||||||
// TODO: the code is a little bit mess
|
// TODO: the code is a little bit mess
|
||||||
// additional values need to be packed in the following way:
|
// additional values need to be packed in the following way:
|
||||||
// bitmask (bytes #24 to #31 in the packet) - 32 bit indicating what adittional arguments we supply
|
// bitmask (bytes #24 to #31 in the packet) - 32 bit indicating what adittional arguments we supply
|
||||||
// values list (bytes #32 .. #32+4*num_values) in order of corresponding bits TODO: it's actually not 4*num. Some values are 4b ytes, some - 1 byte
|
// values list (bytes #32 .. #32+4*num_values) in order of corresponding bits TODO: it's actually not 4*num. Some values are 4b ytes, some - 1 byte
|
||||||
|
|
||||||
|
var vals = packValueMask('CreateWindow', values);
|
||||||
// TODO: replace with packValueMask
|
var packetLength = 8 + (values ? vals[2].length : 0);
|
||||||
var masksList = [];
|
var args = [1, depth, packetLength, id, parentId, x, y, width, height, borderWidth, _class, visual];
|
||||||
for (var v in values)
|
format += vals[0];
|
||||||
{
|
args.push(vals[1]);
|
||||||
var valueBit = valueMask['CreateWindow'][v];
|
args = args.concat(vals[2]);
|
||||||
if (!valueBit)
|
|
||||||
{
|
|
||||||
throw new Error('CreateWindow: incorrect value param ' + v);
|
|
||||||
}
|
|
||||||
masksList.push(valueBit);
|
|
||||||
bitmask |= valueBit;
|
|
||||||
format += 'L'; // TODO: not all values are 4 bytes CARD32!!!
|
|
||||||
}
|
|
||||||
// values packed in order of corresponding bit
|
|
||||||
masksList.sort();
|
|
||||||
// set bits to indicate additional values we are sending in this request
|
|
||||||
args.push(bitmask);
|
|
||||||
|
|
||||||
// add values in the order of the bits
|
|
||||||
// TODO: maybe it's better just to scan all 32 bits anstead of sorting parameters we are actually have?
|
|
||||||
for (var m in masksList)
|
|
||||||
{
|
|
||||||
var valueName = valueMaskName['CreateWindow'][masksList[m]];
|
|
||||||
args.push( values[valueName] );
|
|
||||||
}
|
|
||||||
return [format, args];
|
return [format, args];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -178,16 +292,13 @@ var templates = {
|
||||||
|
|
||||||
ChangeWindowAttributes:[
|
ChangeWindowAttributes:[
|
||||||
function(wid, values) {
|
function(wid, values) {
|
||||||
var format = 'CxSLL';
|
var format = 'CxSLSxx';
|
||||||
var packetLength = 3 + (values ? Object.keys(values).length : 0);
|
|
||||||
var vals = packValueMask('CreateWindow', values);
|
var vals = packValueMask('CreateWindow', values);
|
||||||
var args = [2, packetLength, wid, vals[0]];
|
var packetLength = 3 + (values ? vals[2].length : 0);
|
||||||
var valArr = vals[1];
|
var args = [2, packetLength, wid, vals[1]];
|
||||||
for (var v in valArr)
|
var valArr = vals[2];
|
||||||
{
|
format += vals[0];
|
||||||
format += 'L';
|
args = args.concat(valArr);
|
||||||
args.push(valArr[v]);
|
|
||||||
}
|
|
||||||
return [format, args];
|
return [format, args];
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
@ -248,60 +359,11 @@ var templates = {
|
||||||
* }
|
* }
|
||||||
*/
|
*/
|
||||||
function(win, options) {
|
function(win, options) {
|
||||||
var format = 'CxSLSxx';
|
var vals = packValueMask('ConfigureWindow', options);
|
||||||
var n = 3;
|
var format = 'CxSLSxx' + vals[0];
|
||||||
var mask = 0;
|
var args = [12, vals[2].length + 3, win, vals[1]];
|
||||||
var params = [];
|
args = args.concat(vals[2]);
|
||||||
if (options.x !== undefined) {
|
return [format, args];
|
||||||
mask |= valueMask.ConfigureWindow.x;
|
|
||||||
format += 'sxx';
|
|
||||||
params.push(options.x);
|
|
||||||
++ n;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (options.y !== undefined) {
|
|
||||||
mask |= valueMask.ConfigureWindow.y;
|
|
||||||
format += 'sxx';
|
|
||||||
params.push(options.y);
|
|
||||||
++ n;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (options.width !== undefined) {
|
|
||||||
mask |= valueMask.ConfigureWindow.width;
|
|
||||||
format += 'Sxx';
|
|
||||||
params.push(options.width);
|
|
||||||
++ n;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (options.height !== undefined) {
|
|
||||||
mask |= valueMask.ConfigureWindow.height;
|
|
||||||
format += 'Sxx';
|
|
||||||
params.push(options.height);
|
|
||||||
++ n;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (options.borderWidth !== undefined) {
|
|
||||||
mask |= valueMask.ConfigureWindow.borderWidth;
|
|
||||||
format += 'Sxx';
|
|
||||||
params.push(options.borderWidth);
|
|
||||||
++ n;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (options.sibling !== undefined) {
|
|
||||||
mask |= valueMask.ConfigureWindow.sibling;
|
|
||||||
format += 'L';
|
|
||||||
params.push(options.sibling);
|
|
||||||
++ n;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (options.stackMode !== undefined) {
|
|
||||||
mask |= valueMask.ConfigureWindow.stackMode;
|
|
||||||
format += 'Cxxx';
|
|
||||||
params.push(options.stackMode);
|
|
||||||
++ n;
|
|
||||||
}
|
|
||||||
|
|
||||||
return [format, [12, n, win, mask].concat(params)];
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
|
|
@ -412,7 +474,7 @@ var templates = {
|
||||||
},
|
},
|
||||||
|
|
||||||
function(buf, format) {
|
function(buf, format) {
|
||||||
var res = buf.unpack('LLL');
|
var res = buf.unpack('LLL');
|
||||||
var prop = {};
|
var prop = {};
|
||||||
prop.type = res[0];
|
prop.type = res[0];
|
||||||
prop.bytesAfter = res[1];
|
prop.bytesAfter = res[1];
|
||||||
|
|
@ -651,19 +713,35 @@ var templates = {
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
|
FreePixmap: [
|
||||||
|
function (pixmap) {
|
||||||
|
return [ 'CxSL', [54, 2, pixmap] ];
|
||||||
|
}
|
||||||
|
],
|
||||||
|
|
||||||
|
CreateCursor: [
|
||||||
|
function(cid, source, mask, foreRGB, backRGB, x, y) {
|
||||||
|
foreR = foreRGB.R
|
||||||
|
foreG = foreRGB.G
|
||||||
|
foreB = foreRGB.B
|
||||||
|
|
||||||
|
backR = backRGB.R
|
||||||
|
backG = backRGB.G
|
||||||
|
backB = backRGB.B
|
||||||
|
return [ 'CxSLLLSSSSSSSS', [93, 8, cid, source, mask, foreR, foreG, foreB, backR, backG, backB, x, y] ];
|
||||||
|
}
|
||||||
|
],
|
||||||
|
|
||||||
|
// opcode 55
|
||||||
CreateGC: [
|
CreateGC: [
|
||||||
function(cid, drawable, values) {
|
function(cid, drawable, values) {
|
||||||
var format = 'CxSLLL';
|
var format = 'CxSLLL';
|
||||||
var packetLength = 4 + (values ? Object.keys(values).length : 0);
|
|
||||||
var args = [55, packetLength, cid, drawable];
|
|
||||||
var vals = packValueMask('CreateGC', values);
|
var vals = packValueMask('CreateGC', values);
|
||||||
args.push(vals[0]); // values bitmask
|
var packetLength = 4 + (values ? vals[2].length : 0);
|
||||||
var valArr = vals[1];
|
var args = [55, packetLength, cid, drawable];
|
||||||
for (var v in valArr)
|
format += vals[0]
|
||||||
{
|
args.push(vals[1]); // values bitmask
|
||||||
format += 'L'; // TODO: we know format string length in advance and += inefficient for string
|
args = args.concat(vals[2])
|
||||||
args.push(valArr[v]);
|
|
||||||
}
|
|
||||||
return [format, args];
|
return [format, args];
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
@ -671,9 +749,9 @@ var templates = {
|
||||||
ChangeGC: [
|
ChangeGC: [
|
||||||
function(cid, values) {
|
function(cid, values) {
|
||||||
var format = 'CxSLL';
|
var format = 'CxSLL';
|
||||||
var packetLength = 3 + (values ? Object.keys(values).length : 0);
|
|
||||||
var args = [56, packetLength, cid];
|
|
||||||
var vals = packValueMask('CreateGC', values);
|
var vals = packValueMask('CreateGC', values);
|
||||||
|
var packetLength = 3 + (values ? vals[2].length : 0);
|
||||||
|
var args = [56, packetLength, cid];
|
||||||
args.push(vals[0]); // values bitmask
|
args.push(vals[0]); // values bitmask
|
||||||
var valArr = vals[1];
|
var valArr = vals[1];
|
||||||
for (var v in valArr)
|
for (var v in valArr)
|
||||||
|
|
@ -776,7 +854,7 @@ var templates = {
|
||||||
return {
|
return {
|
||||||
depth: depth,
|
depth: depth,
|
||||||
visualId: visualId,
|
visualId: visualId,
|
||||||
data: buf.slice(20)
|
data: buf.slice(24)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
|
||||||
|
|
@ -18,10 +18,10 @@ var xutil = require('../xutil');
|
||||||
#define X_AppleWMAttachTransient 13
|
#define X_AppleWMAttachTransient 13
|
||||||
*/
|
*/
|
||||||
|
|
||||||
exports.requireExt = function(display, callback)
|
exports.requireExt = function(display, callback)
|
||||||
{
|
{
|
||||||
var X = display.client;
|
var X = display.client;
|
||||||
X.QueryExtension('Apple-WM', function(err, ext) {
|
X.QueryExtension('Apple-WM', function(err, ext) {
|
||||||
|
|
||||||
if (!ext.present)
|
if (!ext.present)
|
||||||
callback(new Error('extension not available'));
|
callback(new Error('extension not available'));
|
||||||
|
|
@ -32,7 +32,7 @@ exports.requireExt = function(display, callback)
|
||||||
X.pack_stream.pack('CCS', [ext.majorOpcode, 0, 1]);
|
X.pack_stream.pack('CCS', [ext.majorOpcode, 0, 1]);
|
||||||
X.replies[X.seq_num] = [
|
X.replies[X.seq_num] = [
|
||||||
function(buf, opt) {
|
function(buf, opt) {
|
||||||
var res = buf.unpack('SSL');
|
var res = buf.unpack('SSL');
|
||||||
return res;
|
return res;
|
||||||
},
|
},
|
||||||
cb
|
cb
|
||||||
|
|
@ -52,7 +52,7 @@ exports.requireExt = function(display, callback)
|
||||||
X.pack_stream.pack('CCSSSSSSSSSSS', [ext.majorOpcode, 1, 6, frame_class, frame_rect, ix, iy, iw, ih, ox, oy, ow, oh, cb]);
|
X.pack_stream.pack('CCSSSSSSSSSSS', [ext.majorOpcode, 1, 6, frame_class, frame_rect, ix, iy, iw, ih, ox, oy, ow, oh, cb]);
|
||||||
X.replies[X.seq_num] = [
|
X.replies[X.seq_num] = [
|
||||||
function(buf, opt) {
|
function(buf, opt) {
|
||||||
var res = buf.unpack('SSSS');
|
var res = buf.unpack('SSSS');
|
||||||
return {
|
return {
|
||||||
x: res[0],
|
x: res[0],
|
||||||
y: res[1],
|
y: res[1],
|
||||||
|
|
@ -64,7 +64,7 @@ exports.requireExt = function(display, callback)
|
||||||
];
|
];
|
||||||
X.pack_stream.flush();
|
X.pack_stream.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
ext.FrameHitTest = function(frame_class, px, py, ix, iy, iw, ih, ox, oy, ow, oh, cb)
|
ext.FrameHitTest = function(frame_class, px, py, ix, iy, iw, ih, ox, oy, ow, oh, cb)
|
||||||
{
|
{
|
||||||
X.seq_num++;
|
X.seq_num++;
|
||||||
|
|
@ -80,7 +80,7 @@ exports.requireExt = function(display, callback)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// from /usr/include/Xplugin.h
|
// from /usr/include/Xplugin.h
|
||||||
ext.FrameClass = {
|
ext.FrameClass = {
|
||||||
DecorLarge: 1,
|
DecorLarge: 1,
|
||||||
Reserved1: 2,
|
Reserved1: 2,
|
||||||
|
|
@ -107,7 +107,7 @@ exports.requireExt = function(display, callback)
|
||||||
CloseBoxClicked: 0x800,
|
CloseBoxClicked: 0x800,
|
||||||
CollapseBoxClicked: 0x1000,
|
CollapseBoxClicked: 0x1000,
|
||||||
ZoomBoxClicked: 0x2000,
|
ZoomBoxClicked: 0x2000,
|
||||||
GrowBox: 0x4000
|
GrowBox: 0x4000
|
||||||
};
|
};
|
||||||
|
|
||||||
ext.FrameDraw = function(screen, window, frameClass, attr, ix, iy, iw, ih, ox, oy, ow, oh, title)
|
ext.FrameDraw = function(screen, window, frameClass, attr, ix, iy, iw, ih, ox, oy, ow, oh, title)
|
||||||
|
|
@ -189,7 +189,7 @@ exports.requireExt = function(display, callback)
|
||||||
var reqlen = 8;
|
var reqlen = 8;
|
||||||
var extlength = 0;
|
var extlength = 0;
|
||||||
items.forEach(function(i) {
|
items.forEach(function(i) {
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -209,13 +209,13 @@ exports.requireExt = function(display, callback)
|
||||||
X.pack_stream.flush();
|
X.pack_stream.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
callback(ext);
|
callback(null, ext);
|
||||||
/*
|
/*
|
||||||
ext.QueryVersion(function(err, vers) {
|
ext.QueryVersion(function(err, vers) {
|
||||||
ext.major = vers[0];
|
ext.major = vers[0];
|
||||||
ext.minor = vers[1];
|
ext.minor = vers[1];
|
||||||
ext.patch = vers[2];
|
ext.patch = vers[2];
|
||||||
callback(ext);
|
callback(null, ext);
|
||||||
});
|
});
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
@ -248,7 +248,7 @@ exports.requireExt = function(display, callback)
|
||||||
CopyToPasteboard: 0
|
CopyToPasteboard: 0
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
X.eventParsers[ext.firstEvent + ext.events.AppleWMControllerNotify] =
|
X.eventParsers[ext.firstEvent + ext.events.AppleWMControllerNotify] =
|
||||||
X.eventParsers[ext.firstEvent + ext.events.AppleWMActivationNotify] =
|
X.eventParsers[ext.firstEvent + ext.events.AppleWMActivationNotify] =
|
||||||
X.eventParsers[ext.firstEvent + ext.events.AppleWMPasteboardNotify] = function(type, seq, extra, code, raw)
|
X.eventParsers[ext.firstEvent + ext.events.AppleWMPasteboardNotify] = function(type, seq, extra, code, raw)
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
// http://www.x.org/releases/X11R7.6/doc/bigreqsproto/bigreq.html
|
// http://www.x.org/releases/X11R7.6/doc/bigreqsproto/bigreq.html
|
||||||
|
|
||||||
// TODO: move to templates
|
// TODO: move to templates
|
||||||
exports.requireExt = function(display, callback)
|
exports.requireExt = function(display, callback)
|
||||||
{
|
{
|
||||||
var X = display.client;
|
var X = display.client;
|
||||||
X.QueryExtension('BIG-REQUESTS', function(err, ext) {
|
X.QueryExtension('BIG-REQUESTS', function(err, ext) {
|
||||||
|
|
||||||
if (!ext.present)
|
if (!ext.present)
|
||||||
return callback(new Error('extension not available'));
|
return callback(new Error('extension not available'));
|
||||||
|
|
||||||
|
|
@ -21,6 +21,6 @@ exports.requireExt = function(display, callback)
|
||||||
];
|
];
|
||||||
X.pack_stream.flush();
|
X.pack_stream.flush();
|
||||||
}
|
}
|
||||||
callback(ext);
|
callback(null, ext);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,15 +14,15 @@
|
||||||
var x11 = require('..');
|
var x11 = require('..');
|
||||||
// TODO: move to templates
|
// TODO: move to templates
|
||||||
|
|
||||||
exports.requireExt = function(display, callback)
|
exports.requireExt = function(display, callback)
|
||||||
{
|
{
|
||||||
var X = display.client;
|
var X = display.client;
|
||||||
X.QueryExtension('Composite', function(err, ext) {
|
X.QueryExtension('Composite', function(err, ext) {
|
||||||
|
|
||||||
if (!ext.present)
|
if (!ext.present)
|
||||||
return callback(new Error('extension not available'));
|
return callback(new Error('extension not available'));
|
||||||
|
|
||||||
ext.Redirect = {
|
ext.Redirect = {
|
||||||
Automatic: 0,
|
Automatic: 0,
|
||||||
Manual: 1
|
Manual: 1
|
||||||
};
|
};
|
||||||
|
|
@ -33,7 +33,7 @@ exports.requireExt = function(display, callback)
|
||||||
X.pack_stream.pack('CCSLL', [ext.majorOpcode, 0, 3, clientMaj, clientMin]);
|
X.pack_stream.pack('CCSLL', [ext.majorOpcode, 0, 3, clientMaj, clientMin]);
|
||||||
X.replies[X.seq_num] = [
|
X.replies[X.seq_num] = [
|
||||||
function(buf, opt) {
|
function(buf, opt) {
|
||||||
var res = buf.unpack('LL');
|
var res = buf.unpack('LL');
|
||||||
return res;
|
return res;
|
||||||
},
|
},
|
||||||
callback
|
callback
|
||||||
|
|
@ -82,7 +82,7 @@ exports.requireExt = function(display, callback)
|
||||||
X.pack_stream.pack('CCSLL', [ext.majorOpcode, 6, 3, window, pixmap]);
|
X.pack_stream.pack('CCSLL', [ext.majorOpcode, 6, 3, window, pixmap]);
|
||||||
X.pack_stream.flush();
|
X.pack_stream.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
ext.GetOverlayWindow = function(window, callback)
|
ext.GetOverlayWindow = function(window, callback)
|
||||||
{
|
{
|
||||||
X.seq_num++;
|
X.seq_num++;
|
||||||
|
|
@ -96,19 +96,22 @@ exports.requireExt = function(display, callback)
|
||||||
];
|
];
|
||||||
X.pack_stream.flush();
|
X.pack_stream.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
ext.ReleaseOverlayWindow = function(window)
|
ext.ReleaseOverlayWindow = function(window)
|
||||||
{
|
{
|
||||||
X.seq_num++;
|
X.seq_num++;
|
||||||
X.pack_stream.pack('CCSL', [ext.majorOpcode, 8, 2, window]);
|
X.pack_stream.pack('CCSL', [ext.majorOpcode, 8, 2, window]);
|
||||||
X.pack_stream.flush();
|
X.pack_stream.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
// currently version 0.4 TODO: bump up with coordinate translations
|
// currently version 0.4 TODO: bump up with coordinate translations
|
||||||
ext.QueryVersion(0, 4, function(err, vers) {
|
ext.QueryVersion(0, 4, function(err, vers) {
|
||||||
|
if (err)
|
||||||
|
return callback(err);
|
||||||
|
|
||||||
ext.major = vers[0];
|
ext.major = vers[0];
|
||||||
ext.minor = vers[1];
|
ext.minor = vers[1];
|
||||||
callback(ext);
|
callback(null, ext);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,19 +3,19 @@
|
||||||
var x11 = require('..');
|
var x11 = require('..');
|
||||||
// TODO: move to templates
|
// TODO: move to templates
|
||||||
|
|
||||||
exports.requireExt = function(display, callback)
|
exports.requireExt = function(display, callback)
|
||||||
{
|
{
|
||||||
var X = display.client;
|
var X = display.client;
|
||||||
X.QueryExtension('DAMAGE', function(err, ext) {
|
X.QueryExtension('DAMAGE', function(err, ext) {
|
||||||
|
|
||||||
if (!ext.present)
|
if (!ext.present)
|
||||||
return callback(new Error('extension not available'));
|
return callback(new Error('extension not available'));
|
||||||
|
|
||||||
ext.ReportLevel = {
|
ext.ReportLevel = {
|
||||||
RawRectangles: 0,
|
RawRectangles: 0,
|
||||||
DeltaRectangles: 1,
|
DeltaRectangles: 1,
|
||||||
BoundingBox: 2,
|
BoundingBox: 2,
|
||||||
NonEmpty: 3
|
NonEmpty: 3
|
||||||
};
|
};
|
||||||
|
|
||||||
ext.QueryVersion = function(clientMaj, clientMin, callback)
|
ext.QueryVersion = function(clientMaj, clientMin, callback)
|
||||||
|
|
@ -24,7 +24,7 @@ exports.requireExt = function(display, callback)
|
||||||
X.pack_stream.pack('CCSLL', [ext.majorOpcode, 0, 3, clientMaj, clientMin]);
|
X.pack_stream.pack('CCSLL', [ext.majorOpcode, 0, 3, clientMaj, clientMin]);
|
||||||
X.replies[X.seq_num] = [
|
X.replies[X.seq_num] = [
|
||||||
function(buf, opt) {
|
function(buf, opt) {
|
||||||
var res = buf.unpack('LL');
|
var res = buf.unpack('LL');
|
||||||
return res;
|
return res;
|
||||||
},
|
},
|
||||||
callback
|
callback
|
||||||
|
|
@ -59,18 +59,20 @@ exports.requireExt = function(display, callback)
|
||||||
X.pack_stream.pack('CCSLL', [ext.majorOpcode, 4, 3, damage, region]);
|
X.pack_stream.pack('CCSLL', [ext.majorOpcode, 4, 3, damage, region]);
|
||||||
X.pack_stream.flush();
|
X.pack_stream.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
ext.QueryVersion(1, 1, function(err, vers) {
|
ext.QueryVersion(1, 1, function(err, vers) {
|
||||||
|
if (err)
|
||||||
|
return callback(err);
|
||||||
ext.major = vers[0];
|
ext.major = vers[0];
|
||||||
ext.minor = vers[1];
|
ext.minor = vers[1];
|
||||||
callback(ext);
|
callback(null, ext);
|
||||||
});
|
});
|
||||||
|
|
||||||
ext.events = {
|
ext.events = {
|
||||||
DamageNotify: 0
|
DamageNotify: 0
|
||||||
}
|
}
|
||||||
|
|
||||||
X.eventParsers[ext.firstEvent + ext.events.DamageNotify] = function(type, seq, extra, code, raw)
|
X.eventParsers[ext.firstEvent + ext.events.DamageNotify] = function(type, seq, extra, code, raw)
|
||||||
{
|
{
|
||||||
var event = {};
|
var event = {};
|
||||||
event.level = code;
|
event.level = code;
|
||||||
|
|
@ -80,16 +82,16 @@ exports.requireExt = function(display, callback)
|
||||||
event.damage = values[0];
|
event.damage = values[0];
|
||||||
event.time = values[1];
|
event.time = values[1];
|
||||||
event.area = {
|
event.area = {
|
||||||
x: values[2],
|
x: values[2],
|
||||||
y: values[3],
|
y: values[3],
|
||||||
w: values[4],
|
w: values[4],
|
||||||
h: values[5]
|
h: values[5]
|
||||||
};
|
};
|
||||||
event.geometry = {
|
event.geometry = {
|
||||||
x: values[6],
|
x: values[6],
|
||||||
y: values[7],
|
y: values[7],
|
||||||
w: values[8],
|
w: values[8],
|
||||||
h: values[9]
|
h: values[9]
|
||||||
};
|
};
|
||||||
event.name = 'DamageNotify';
|
event.name = 'DamageNotify';
|
||||||
return event;
|
return event;
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,7 @@ exports.requireExt = function(display, callback)
|
||||||
X.pack_stream.flush();
|
X.pack_stream.flush();
|
||||||
};
|
};
|
||||||
|
|
||||||
callback(ext);
|
callback(null, ext);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ function parse_rectangle(buf, pos) {
|
||||||
if (!pos) {
|
if (!pos) {
|
||||||
pos = 0;
|
pos = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
x : buf[pos],
|
x : buf[pos],
|
||||||
y : buf[pos + 1],
|
y : buf[pos + 1],
|
||||||
|
|
@ -16,10 +16,10 @@ function parse_rectangle(buf, pos) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.requireExt = function(display, callback)
|
exports.requireExt = function(display, callback)
|
||||||
{
|
{
|
||||||
var X = display.client;
|
var X = display.client;
|
||||||
X.QueryExtension('XFIXES', function(err, ext) {
|
X.QueryExtension('XFIXES', function(err, ext) {
|
||||||
|
|
||||||
if (!ext.present)
|
if (!ext.present)
|
||||||
return callback(new Error('extension not available'));
|
return callback(new Error('extension not available'));
|
||||||
|
|
@ -30,7 +30,7 @@ exports.requireExt = function(display, callback)
|
||||||
X.pack_stream.pack('CCSLL', [ext.majorOpcode, 0, 3, clientMaj, clientMin]);
|
X.pack_stream.pack('CCSLL', [ext.majorOpcode, 0, 3, clientMaj, clientMin]);
|
||||||
X.replies[X.seq_num] = [
|
X.replies[X.seq_num] = [
|
||||||
function(buf, opt) {
|
function(buf, opt) {
|
||||||
var res = buf.unpack('LL');
|
var res = buf.unpack('LL');
|
||||||
return res;
|
return res;
|
||||||
},
|
},
|
||||||
callback
|
callback
|
||||||
|
|
@ -68,7 +68,7 @@ exports.requireExt = function(display, callback)
|
||||||
X.pack_stream.pack(format, args);
|
X.pack_stream.pack(format, args);
|
||||||
X.pack_stream.flush();
|
X.pack_stream.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
ext.CreateRegionFromWindow = function(region, wid, kind) {
|
ext.CreateRegionFromWindow = function(region, wid, kind) {
|
||||||
X.seq_num ++;
|
X.seq_num ++;
|
||||||
X.pack_stream.pack('CCSLLCxxx', [ ext.majorOpcode, 7, 4, region, wid, kind ]);
|
X.pack_stream.pack('CCSLLCxxx', [ ext.majorOpcode, 7, 4, region, wid, kind ]);
|
||||||
|
|
@ -92,7 +92,7 @@ exports.requireExt = function(display, callback)
|
||||||
X.pack_stream.pack('CCSLss', [ ext.majorOpcode, 17, 3, region, dx, dy ]);
|
X.pack_stream.pack('CCSLss', [ ext.majorOpcode, 17, 3, region, dx, dy ]);
|
||||||
X.pack_stream.flush();
|
X.pack_stream.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
ext.FetchRegion = function(region, cb) {
|
ext.FetchRegion = function(region, cb) {
|
||||||
X.seq_num ++;
|
X.seq_num ++;
|
||||||
X.pack_stream.pack('CCSL', [ ext.majorOpcode, 19, 2, region ]);
|
X.pack_stream.pack('CCSL', [ ext.majorOpcode, 19, 2, region ]);
|
||||||
|
|
@ -110,7 +110,7 @@ exports.requireExt = function(display, callback)
|
||||||
for (var i = 0; i < n_rectangles; ++ i) {
|
for (var i = 0; i < n_rectangles; ++ i) {
|
||||||
reg.rectangles.push(parse_rectangle(res, 4 + (i << 2)));
|
reg.rectangles.push(parse_rectangle(res, 4 + (i << 2)));
|
||||||
}
|
}
|
||||||
|
|
||||||
return reg;
|
return reg;
|
||||||
},
|
},
|
||||||
cb
|
cb
|
||||||
|
|
@ -120,16 +120,18 @@ exports.requireExt = function(display, callback)
|
||||||
}
|
}
|
||||||
|
|
||||||
ext.QueryVersion(5, 0, function(err, vers) {
|
ext.QueryVersion(5, 0, function(err, vers) {
|
||||||
|
if (err)
|
||||||
|
return callback(err);
|
||||||
ext.major = vers[0];
|
ext.major = vers[0];
|
||||||
ext.minor = vers[1];
|
ext.minor = vers[1];
|
||||||
callback(ext);
|
callback(null, ext);
|
||||||
});
|
});
|
||||||
|
|
||||||
ext.events = {
|
ext.events = {
|
||||||
DamageNotify: 0
|
DamageNotify: 0
|
||||||
}
|
}
|
||||||
|
|
||||||
X.eventParsers[ext.firstEvent + ext.events.DamageNotify] = function(type, seq, extra, code, raw)
|
X.eventParsers[ext.firstEvent + ext.events.DamageNotify] = function(type, seq, extra, code, raw)
|
||||||
{
|
{
|
||||||
var event = {};
|
var event = {};
|
||||||
event.level = code;
|
event.level = code;
|
||||||
|
|
@ -139,16 +141,16 @@ exports.requireExt = function(display, callback)
|
||||||
event.damage = values[0];
|
event.damage = values[0];
|
||||||
event.time = values[1];
|
event.time = values[1];
|
||||||
event.area = {
|
event.area = {
|
||||||
x: values[2],
|
x: values[2],
|
||||||
y: values[3],
|
y: values[3],
|
||||||
w: values[4],
|
w: values[4],
|
||||||
h: values[5]
|
h: values[5]
|
||||||
};
|
};
|
||||||
event.geometry = {
|
event.geometry = {
|
||||||
x: values[6],
|
x: values[6],
|
||||||
y: values[7],
|
y: values[7],
|
||||||
w: values[8],
|
w: values[8],
|
||||||
h: values[9]
|
h: values[9]
|
||||||
};
|
};
|
||||||
event.name = 'DamageNotify';
|
event.name = 'DamageNotify';
|
||||||
return event;
|
return event;
|
||||||
|
|
|
||||||
|
|
@ -319,7 +319,7 @@ exports.requireExt = function(display, callback)
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
callback(ext);
|
callback(null, ext);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,15 +3,15 @@
|
||||||
var x11 = require('..');
|
var x11 = require('..');
|
||||||
// TODO: move to templates
|
// TODO: move to templates
|
||||||
|
|
||||||
exports.requireExt = function(display, callback)
|
exports.requireExt = function(display, callback)
|
||||||
{
|
{
|
||||||
var X = display.client;
|
var X = display.client;
|
||||||
X.QueryExtension('RANDR', function(err, ext) {
|
X.QueryExtension('RANDR', function(err, ext) {
|
||||||
|
|
||||||
if (!ext.present)
|
if (!ext.present)
|
||||||
return callback(new Error('extension not available'));
|
return callback(new Error('extension not available'));
|
||||||
|
|
||||||
//ext.ReportLevel = {
|
//ext.ReportLevel = {
|
||||||
//};
|
//};
|
||||||
|
|
||||||
ext.QueryVersion = function(clientMaj, clientMin, callback)
|
ext.QueryVersion = function(clientMaj, clientMin, callback)
|
||||||
|
|
@ -198,7 +198,7 @@ exports.requireExt = function(display, callback)
|
||||||
|
|
||||||
pos += res_modes[i + 11];
|
pos += res_modes[i + 11];
|
||||||
}
|
}
|
||||||
|
|
||||||
return resources;
|
return resources;
|
||||||
},
|
},
|
||||||
cb
|
cb
|
||||||
|
|
@ -223,7 +223,7 @@ exports.requireExt = function(display, callback)
|
||||||
height : res[4],
|
height : res[4],
|
||||||
mode : res[5],
|
mode : res[5],
|
||||||
rotation : res[6],
|
rotation : res[6],
|
||||||
rotations : res[7]
|
rotations : res[7]
|
||||||
};
|
};
|
||||||
|
|
||||||
pos += 24;
|
pos += 24;
|
||||||
|
|
@ -239,7 +239,7 @@ exports.requireExt = function(display, callback)
|
||||||
X.pack_stream.flush();
|
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 = {};
|
||||||
event.raw = raw;
|
event.raw = raw;
|
||||||
|
|
@ -263,6 +263,6 @@ exports.requireExt = function(display, callback)
|
||||||
return event;
|
return event;
|
||||||
};
|
};
|
||||||
|
|
||||||
callback(ext);
|
callback(null, ext);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -530,6 +530,8 @@ exports.requireExt = function(display, callback)
|
||||||
// 11 - colormap or none
|
// 11 - colormap or none
|
||||||
|
|
||||||
ext.QueryPictFormat(function(err, formats) {
|
ext.QueryPictFormat(function(err, formats) {
|
||||||
|
if (err)
|
||||||
|
return callback(err);
|
||||||
for (var i=0; i < formats.formats.length; ++i) {
|
for (var i=0; i < formats.formats.length; ++i) {
|
||||||
var f = formats.formats[i];
|
var f = formats.formats[i];
|
||||||
if (f[2] == 1 && f[10] == 1)
|
if (f[2] == 1 && f[10] == 1)
|
||||||
|
|
@ -542,7 +544,7 @@ exports.requireExt = function(display, callback)
|
||||||
if (f[2] == 8 && f[10] == 255)
|
if (f[2] == 8 && f[10] == 255)
|
||||||
ext.a8 = f[0];
|
ext.a8 = f[0];
|
||||||
}
|
}
|
||||||
callback(ext);
|
callback(null, ext);
|
||||||
});
|
});
|
||||||
|
|
||||||
[
|
[
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,10 @@
|
||||||
var x11 = require('..');
|
var x11 = require('..');
|
||||||
// TODO: move to templates
|
// TODO: move to templates
|
||||||
|
|
||||||
exports.requireExt = function(display, callback)
|
exports.requireExt = function(display, callback)
|
||||||
{
|
{
|
||||||
var X = display.client;
|
var X = display.client;
|
||||||
X.QueryExtension('MIT-SCREEN-SAVER', function(err, ext) {
|
X.QueryExtension('MIT-SCREEN-SAVER', function(err, ext) {
|
||||||
|
|
||||||
if (!ext.present)
|
if (!ext.present)
|
||||||
return callback(new Error('extension not available'));
|
return callback(new Error('extension not available'));
|
||||||
|
|
@ -18,7 +18,7 @@ exports.requireExt = function(display, callback)
|
||||||
X.pack_stream.pack('CCSCCxx', [ext.majorOpcode, 0, 2, clientMaj, clientMin]);
|
X.pack_stream.pack('CCSCCxx', [ext.majorOpcode, 0, 2, clientMaj, clientMin]);
|
||||||
X.replies[X.seq_num] = [
|
X.replies[X.seq_num] = [
|
||||||
function(buf, opt) {
|
function(buf, opt) {
|
||||||
var res = buf.unpack('CC');
|
var res = buf.unpack('CC');
|
||||||
return res;
|
return res;
|
||||||
},
|
},
|
||||||
cb
|
cb
|
||||||
|
|
@ -26,18 +26,18 @@ exports.requireExt = function(display, callback)
|
||||||
X.pack_stream.flush();
|
X.pack_stream.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
ext.State = {
|
ext.State = {
|
||||||
Off: 0,
|
Off: 0,
|
||||||
On: 1,
|
On: 1,
|
||||||
Disabled: 2
|
Disabled: 2
|
||||||
};
|
};
|
||||||
|
|
||||||
ext.Kind = {
|
ext.Kind = {
|
||||||
Blanked: 0,
|
Blanked: 0,
|
||||||
Internal: 1,
|
Internal: 1,
|
||||||
External: 2
|
External: 2
|
||||||
};
|
};
|
||||||
|
|
||||||
ext.QueryInfo = function(drawable, callback)
|
ext.QueryInfo = function(drawable, callback)
|
||||||
{
|
{
|
||||||
X.seq_num++;
|
X.seq_num++;
|
||||||
|
|
@ -51,7 +51,7 @@ exports.requireExt = function(display, callback)
|
||||||
info.until = res[1];
|
info.until = res[1];
|
||||||
info.idle = res[2];
|
info.idle = res[2];
|
||||||
info.eventMask = res[3];
|
info.eventMask = res[3];
|
||||||
info.kind = res[4]
|
info.kind = res[4]
|
||||||
return info;
|
return info;
|
||||||
},
|
},
|
||||||
callback
|
callback
|
||||||
|
|
@ -73,10 +73,11 @@ exports.requireExt = function(display, callback)
|
||||||
}
|
}
|
||||||
|
|
||||||
ext.QueryVersion(1, 1, function(err, vers) {
|
ext.QueryVersion(1, 1, function(err, vers) {
|
||||||
|
if (err)
|
||||||
|
return callback(err);
|
||||||
ext.major = vers[0];
|
ext.major = vers[0];
|
||||||
ext.minor = vers[1];
|
ext.minor = vers[1];
|
||||||
callback(ext);
|
callback(null, ext);
|
||||||
});
|
});
|
||||||
|
|
||||||
ext.events = {
|
ext.events = {
|
||||||
|
|
@ -89,7 +90,7 @@ exports.requireExt = function(display, callback)
|
||||||
Cycle: 2
|
Cycle: 2
|
||||||
}
|
}
|
||||||
|
|
||||||
X.eventParsers[ext.firstEvent + ext.events.ScreenSaverNotify] = function(type, seq, extra, code, raw)
|
X.eventParsers[ext.firstEvent + ext.events.ScreenSaverNotify] = function(type, seq, extra, code, raw)
|
||||||
{
|
{
|
||||||
var event = {};
|
var event = {};
|
||||||
event.state = code;
|
event.state = code;
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
var x11 = require('..');
|
var x11 = require('..');
|
||||||
// TODO: move to templates
|
// TODO: move to templates
|
||||||
|
|
||||||
exports.requireExt = function(display, callback)
|
exports.requireExt = function(display, callback)
|
||||||
{
|
{
|
||||||
function captureStack()
|
function captureStack()
|
||||||
{
|
{
|
||||||
|
|
@ -14,12 +14,12 @@ exports.requireExt = function(display, callback)
|
||||||
}
|
}
|
||||||
|
|
||||||
var X = display.client;
|
var X = display.client;
|
||||||
X.QueryExtension('SHAPE', function(err, ext) {
|
X.QueryExtension('SHAPE', function(err, ext) {
|
||||||
|
|
||||||
if (!ext.present)
|
if (!ext.present)
|
||||||
return callback(new Error('extension not available'));
|
return callback(new Error('extension not available'));
|
||||||
|
|
||||||
ext.Kind = {
|
ext.Kind = {
|
||||||
Bounding: 0,
|
Bounding: 0,
|
||||||
Clip: 1,
|
Clip: 1,
|
||||||
Input: 2
|
Input: 2
|
||||||
|
|
@ -40,7 +40,7 @@ exports.requireExt = function(display, callback)
|
||||||
X.pack_stream.pack('CCSLL', [ext.majorOpcode, 0, 1]);
|
X.pack_stream.pack('CCSLL', [ext.majorOpcode, 0, 1]);
|
||||||
X.replies[X.seq_num] = [
|
X.replies[X.seq_num] = [
|
||||||
function(buf, opt) {
|
function(buf, opt) {
|
||||||
var res = buf.unpack('SS');
|
var res = buf.unpack('SS');
|
||||||
return res;
|
return res;
|
||||||
},
|
},
|
||||||
cb
|
cb
|
||||||
|
|
@ -78,13 +78,13 @@ exports.requireExt = function(display, callback)
|
||||||
X.pack_stream.flush();
|
X.pack_stream.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
callback(ext);
|
callback(null, ext);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
ext.QueryVersion(function(err, version) {
|
ext.QueryVersion(function(err, version) {
|
||||||
ext.major = version[0];
|
ext.major = version[0];
|
||||||
ext.minor = version[1];
|
ext.minor = version[1];
|
||||||
callback(ext);
|
callback(null, ext);
|
||||||
});
|
});
|
||||||
*/
|
*/
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,10 @@
|
||||||
var x11 = require('..');
|
var x11 = require('..');
|
||||||
// TODO: move to templates
|
// TODO: move to templates
|
||||||
|
|
||||||
exports.requireExt = function(display, callback)
|
exports.requireExt = function(display, callback)
|
||||||
{
|
{
|
||||||
var X = display.client;
|
var X = display.client;
|
||||||
X.QueryExtension('XC-MISC', function(err, ext) {
|
X.QueryExtension('XC-MISC', function(err, ext) {
|
||||||
|
|
||||||
if (!ext.present)
|
if (!ext.present)
|
||||||
return callback(new Error('extension not available'));
|
return callback(new Error('extension not available'));
|
||||||
|
|
@ -17,7 +17,7 @@ exports.requireExt = function(display, callback)
|
||||||
X.pack_stream.pack('CCSSS', [ext.majorOpcode, 0, 2, clientMaj, clientMin]);
|
X.pack_stream.pack('CCSSS', [ext.majorOpcode, 0, 2, clientMaj, clientMin]);
|
||||||
X.replies[X.seq_num] = [
|
X.replies[X.seq_num] = [
|
||||||
function(buf, opt) {
|
function(buf, opt) {
|
||||||
var res = buf.unpack('SS');
|
var res = buf.unpack('SS');
|
||||||
return res;
|
return res;
|
||||||
},
|
},
|
||||||
cb
|
cb
|
||||||
|
|
@ -31,7 +31,7 @@ exports.requireExt = function(display, callback)
|
||||||
X.pack_stream.pack('CCS', [ext.majorOpcode, 1, 1]);
|
X.pack_stream.pack('CCS', [ext.majorOpcode, 1, 1]);
|
||||||
X.replies[X.seq_num] = [
|
X.replies[X.seq_num] = [
|
||||||
function(buf, opt) {
|
function(buf, opt) {
|
||||||
var res = buf.unpack('LL');
|
var res = buf.unpack('LL');
|
||||||
return {
|
return {
|
||||||
startId: res[0],
|
startId: res[0],
|
||||||
count: res[1]
|
count: res[1]
|
||||||
|
|
@ -60,9 +60,11 @@ exports.requireExt = function(display, callback)
|
||||||
}
|
}
|
||||||
|
|
||||||
ext.QueryVersion(1, 1, function(err, vers) {
|
ext.QueryVersion(1, 1, function(err, vers) {
|
||||||
|
if (err)
|
||||||
|
return callback(err);
|
||||||
ext.major = vers[0];
|
ext.major = vers[0];
|
||||||
ext.minor = vers[1];
|
ext.minor = vers[1];
|
||||||
callback(ext);
|
callback(null, ext);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,10 @@
|
||||||
|
|
||||||
var x11 = require('..');
|
var x11 = require('..');
|
||||||
// TODO: move to templates
|
// TODO: move to templates
|
||||||
exports.requireExt = function(display, callback)
|
exports.requireExt = function(display, callback)
|
||||||
{
|
{
|
||||||
var X = display.client;
|
var X = display.client;
|
||||||
X.QueryExtension('XTEST', function(err, ext) {
|
X.QueryExtension('XTEST', function(err, ext) {
|
||||||
|
|
||||||
if (!ext.present)
|
if (!ext.present)
|
||||||
return callback(new Error('extension not available'));
|
return callback(new Error('extension not available'));
|
||||||
|
|
@ -39,7 +39,7 @@ exports.requireExt = function(display, callback)
|
||||||
X.pack_stream.flush();
|
X.pack_stream.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
callback(ext);
|
callback(null, ext);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
94
lib/xcore.js
94
lib/xcore.js
|
|
@ -29,7 +29,7 @@ function XClient(stream, displayNum, screenNum, options)
|
||||||
// TODO: this is probably not used
|
// TODO: this is probably not used
|
||||||
this.core_requests = {};
|
this.core_requests = {};
|
||||||
this.ext_requests = {};
|
this.ext_requests = {};
|
||||||
|
|
||||||
this.displayNum = displayNum;
|
this.displayNum = displayNum;
|
||||||
this.screenNum = screenNum;
|
this.screenNum = screenNum;
|
||||||
this.authHost = os.hostname();
|
this.authHost = os.hostname();
|
||||||
|
|
@ -39,10 +39,10 @@ function XClient(stream, displayNum, screenNum, options)
|
||||||
// data received from stream is dispached to
|
// data received from stream is dispached to
|
||||||
// read requests set by calls to .unpack and .unpackTo
|
// read requests set by calls to .unpack and .unpackTo
|
||||||
//stream.pipe(pack_stream);
|
//stream.pipe(pack_stream);
|
||||||
|
|
||||||
// pack_stream write requests are buffered and
|
// pack_stream write requests are buffered and
|
||||||
// flushed to stream as result of call to .flush
|
// flushed to stream as result of call to .flush
|
||||||
// TODO: listen for drain event and flush automatically
|
// TODO: listen for drain event and flush automatically
|
||||||
//pack_stream.pipe(stream);
|
//pack_stream.pipe(stream);
|
||||||
var client = this;
|
var client = this;
|
||||||
pack_stream.on('data', function( data ) {
|
pack_stream.on('data', function( data ) {
|
||||||
|
|
@ -55,7 +55,7 @@ function XClient(stream, displayNum, screenNum, options)
|
||||||
//console.error(hexy(data, {prefix: 'to unpacker '}));
|
//console.error(hexy(data, {prefix: 'to unpacker '}));
|
||||||
//for (var i=0; i < data.length; ++i)
|
//for (var i=0; i < data.length; ++i)
|
||||||
// console.log('>>> ' + data[i]);
|
// console.log('>>> ' + data[i]);
|
||||||
pack_stream.write(data);
|
pack_stream.write(data);
|
||||||
});
|
});
|
||||||
stream.on('end', function() {
|
stream.on('end', function() {
|
||||||
client.emit('end');
|
client.emit('end');
|
||||||
|
|
@ -67,7 +67,7 @@ function XClient(stream, displayNum, screenNum, options)
|
||||||
var cli = this;
|
var cli = this;
|
||||||
if (cli.options.debug) {
|
if (cli.options.debug) {
|
||||||
this.seq_num_ = 0;
|
this.seq_num_ = 0;
|
||||||
this.seq2stack = {}; // debug: map seq_num to stack at the moment request was issued
|
this.seq2stack = {}; // debug: map seq_num to stack at the moment request was issued
|
||||||
Object.defineProperty(cli, "seq_num", {
|
Object.defineProperty(cli, "seq_num", {
|
||||||
set : function(v) {
|
set : function(v) {
|
||||||
cli.seq_num_ = v;
|
cli.seq_num_ = v;
|
||||||
|
|
@ -84,7 +84,7 @@ function XClient(stream, displayNum, screenNum, options)
|
||||||
this.seq_num = 0;
|
this.seq_num = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// in/out packets indexed by sequence ID
|
// in/out packets indexed by sequence ID
|
||||||
this.replies = {};
|
this.replies = {};
|
||||||
this.atoms = stdatoms;
|
this.atoms = stdatoms;
|
||||||
|
|
@ -96,15 +96,15 @@ function XClient(stream, displayNum, screenNum, options)
|
||||||
|
|
||||||
return names;
|
return names;
|
||||||
})();
|
})();
|
||||||
|
|
||||||
this.eventMask = em;
|
this.eventMask = em;
|
||||||
|
|
||||||
this.event_consumers = {}; // maps window id to eventemitter TODO: bad name
|
this.event_consumers = {}; // maps window id to eventemitter TODO: bad name
|
||||||
this.eventParsers = {};
|
this.eventParsers = {};
|
||||||
this.errorParsers = {};
|
this.errorParsers = {};
|
||||||
|
|
||||||
this.importRequestsFromTemplates(this, coreRequests);
|
this.importRequestsFromTemplates(this, coreRequests);
|
||||||
|
|
||||||
this.startHandshake();
|
this.startHandshake();
|
||||||
this._closing = false;
|
this._closing = false;
|
||||||
}
|
}
|
||||||
|
|
@ -143,20 +143,20 @@ XClient.prototype.importRequestsFromTemplates = function(target, reqs)
|
||||||
for (var r in reqs)
|
for (var r in reqs)
|
||||||
{
|
{
|
||||||
// r is request name
|
// r is request name
|
||||||
target[r] = (function(reqName) {
|
target[r] = (function(reqName) {
|
||||||
|
|
||||||
var reqFunc = function req_proxy() {
|
var reqFunc = function req_proxy() {
|
||||||
|
|
||||||
if (client._closing)
|
if (client._closing)
|
||||||
throw new Error('client is in closing state');
|
throw new Error('client is in closing state');
|
||||||
|
|
||||||
// simple overflow handling (this means that currently there is no way to have more than 65535 requests in the queue
|
// simple overflow handling (this means that currently there is no way to have more than 65535 requests in the queue
|
||||||
// TODO: edge cases testing
|
// TODO: edge cases testing
|
||||||
if (client.seq_num == 65535)
|
if (client.seq_num == 65535)
|
||||||
client.seq_num = 0;
|
client.seq_num = 0;
|
||||||
else
|
else
|
||||||
client.seq_num++;
|
client.seq_num++;
|
||||||
|
|
||||||
// is it fast?
|
// is it fast?
|
||||||
var args = Array.prototype.slice.call(req_proxy.arguments);
|
var args = Array.prototype.slice.call(req_proxy.arguments);
|
||||||
|
|
||||||
|
|
@ -185,20 +185,20 @@ XClient.prototype.importRequestsFromTemplates = function(target, reqs)
|
||||||
client.pending_atoms[client.seq_num] = value;
|
client.pending_atoms[client.seq_num] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// call template with input arguments (not including callback which is last argument TODO currently with callback. won't hurt)
|
// call template with input arguments (not including callback which is last argument TODO currently with callback. won't hurt)
|
||||||
//reqPack = reqTemplate.call(args);
|
//reqPack = reqTemplate.call(args);
|
||||||
var reqPack = reqTemplate.apply(this, req_proxy.arguments);
|
var reqPack = reqTemplate.apply(this, req_proxy.arguments);
|
||||||
var format = reqPack[0];
|
var format = reqPack[0];
|
||||||
var requestArguments = reqPack[1];
|
var requestArguments = reqPack[1];
|
||||||
|
|
||||||
if (callback)
|
if (callback)
|
||||||
this.replies[this.seq_num] = [reqReplTemplate[1], callback];
|
this.replies[this.seq_num] = [reqReplTemplate[1], callback];
|
||||||
|
|
||||||
client.pack_stream.pack(format, requestArguments);
|
client.pack_stream.pack(format, requestArguments);
|
||||||
var b = client.pack_stream.write_queue[0];
|
var b = client.pack_stream.write_queue[0];
|
||||||
client.pack_stream.flush();
|
client.pack_stream.flush();
|
||||||
|
|
||||||
} else if (templateType == 'Array'){
|
} else if (templateType == 'Array'){
|
||||||
if (reqName === 'GetAtomName') {
|
if (reqName === 'GetAtomName') {
|
||||||
var atom = req_proxy.arguments[0];
|
var atom = req_proxy.arguments[0];
|
||||||
|
|
@ -211,12 +211,12 @@ XClient.prototype.importRequestsFromTemplates = function(target, reqs)
|
||||||
client.pending_atoms[client.seq_num] = atom;
|
client.pending_atoms[client.seq_num] = atom;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var format = reqTemplate[0];
|
var format = reqTemplate[0];
|
||||||
var requestArguments = [];
|
var requestArguments = [];
|
||||||
|
|
||||||
for (var a = 0; a < reqTemplate[1].length; ++a)
|
for (var a = 0; a < reqTemplate[1].length; ++a)
|
||||||
requestArguments.push(reqTemplate[1][a]);
|
requestArguments.push(reqTemplate[1][a]);
|
||||||
for (var a in args)
|
for (var a in args)
|
||||||
requestArguments.push(args[a]);
|
requestArguments.push(args[a]);
|
||||||
|
|
||||||
|
|
@ -249,8 +249,8 @@ XClient.prototype.unpackEvent = function(type, seq, extra, code, raw, headerBuf)
|
||||||
var event = {}; // TODO: constructor & base functions
|
var event = {}; // TODO: constructor & base functions
|
||||||
// Remove the most significant bit. See Chapter 1, Event Format section in X11 protocol
|
// Remove the most significant bit. See Chapter 1, Event Format section in X11 protocol
|
||||||
// specification
|
// specification
|
||||||
type = type & 0x7F;
|
type = type & 0x7F;
|
||||||
event.type = type;
|
event.type = type;
|
||||||
event.seq = seq;
|
event.seq = seq;
|
||||||
|
|
||||||
var extUnpacker = this.eventParsers[type];
|
var extUnpacker = this.eventParsers[type];
|
||||||
|
|
@ -265,7 +265,7 @@ XClient.prototype.unpackEvent = function(type, seq, extra, code, raw, headerBuf)
|
||||||
// TODO: use unpackTo???
|
// TODO: use unpackTo???
|
||||||
event.name = [,,'KeyPress', 'KeyRelease', 'ButtonPress', 'ButtonRelease', 'MotionNotify'][type]
|
event.name = [,,'KeyPress', 'KeyRelease', 'ButtonPress', 'ButtonRelease', 'MotionNotify'][type]
|
||||||
event.time = extra;
|
event.time = extra;
|
||||||
event.keycode = code;
|
event.keycode = code;
|
||||||
event.root = values[0];
|
event.root = values[0];
|
||||||
event.wid = values[1];
|
event.wid = values[1];
|
||||||
event.child = values[2];
|
event.child = values[2];
|
||||||
|
|
@ -352,13 +352,13 @@ XClient.prototype.unpackEvent = function(type, seq, extra, code, raw, headerBuf)
|
||||||
event.width = values[3]
|
event.width = values[3]
|
||||||
event.height = values[4]
|
event.height = values[4]
|
||||||
event.borderWidth = values[5];
|
event.borderWidth = values[5];
|
||||||
//
|
//
|
||||||
// The value-mask indicates which components were specified in
|
// The value-mask indicates which components were specified in
|
||||||
// the request. The value-mask and the corresponding values are reported as given
|
// the request. The value-mask and the corresponding values are reported as given
|
||||||
// in the request. The remaining values are filled in from the current geometry of the
|
// in the request. The remaining values are filled in from the current geometry of the
|
||||||
// window, except in the case of sibling and stack-mode, which are reported as None
|
// window, except in the case of sibling and stack-mode, which are reported as None
|
||||||
// and Above (respectively) if not given in the request.
|
// and Above (respectively) if not given in the request.
|
||||||
event.mask = values[6];
|
event.mask = values[6];
|
||||||
// 322, [ 12582925, 0, 0, 484, 316, 1, 12, 0
|
// 322, [ 12582925, 0, 0, 484, 316, 1, 12, 0
|
||||||
//console.log([extra, code, values]);
|
//console.log([extra, code, values]);
|
||||||
} else if (type == 28) {// PropertyNotify
|
} else if (type == 28) {// PropertyNotify
|
||||||
|
|
@ -398,7 +398,7 @@ XClient.prototype.unpackEvent = function(type, seq, extra, code, raw, headerBuf)
|
||||||
event.type = raw.readUInt32LE(0);
|
event.type = raw.readUInt32LE(0);
|
||||||
var format = (code === 32) ? 'LLLLL' : (code === 16) ? 'SSSSSSSSSS' : 'CCCCCCCCCCCCCCCCCCCC';
|
var format = (code === 32) ? 'LLLLL' : (code === 16) ? 'SSSSSSSSSS' : 'CCCCCCCCCCCCCCCCCCCC';
|
||||||
event.data = raw.unpack(format, 4);
|
event.data = raw.unpack(format, 4);
|
||||||
} else if (type == 34) {
|
} else if (type == 34) {
|
||||||
event.name = 'MappingNotify';
|
event.name = 'MappingNotify';
|
||||||
event.request = headerBuf[4];
|
event.request = headerBuf[4];
|
||||||
event.firstKeyCode = headerBuf[5];
|
event.firstKeyCode = headerBuf[5];
|
||||||
|
|
@ -421,7 +421,7 @@ XClient.prototype.expectReplyHeader = function()
|
||||||
var bad_value = res[3];
|
var bad_value = res[3];
|
||||||
|
|
||||||
if (type == 0)
|
if (type == 0)
|
||||||
{
|
{
|
||||||
var error_code = res[1];
|
var error_code = res[1];
|
||||||
var error = new Error();
|
var error = new Error();
|
||||||
error.error = error_code;
|
error.error = error_code;
|
||||||
|
|
@ -433,7 +433,7 @@ XClient.prototype.expectReplyHeader = function()
|
||||||
|
|
||||||
// unpack error packet (32 bytes for all error types, 8 of them in CCSL header)
|
// unpack error packet (32 bytes for all error types, 8 of them in CCSL header)
|
||||||
client.pack_stream.get(24, function(buf) {
|
client.pack_stream.get(24, function(buf) {
|
||||||
|
|
||||||
var res = buf.unpack('SC');
|
var res = buf.unpack('SC');
|
||||||
error.message = xerrors.errorText[error_code];
|
error.message = xerrors.errorText[error_code];
|
||||||
error.badParam = bad_value;
|
error.badParam = bad_value;
|
||||||
|
|
@ -444,7 +444,7 @@ XClient.prototype.expectReplyHeader = function()
|
||||||
if (extUnpacker) {
|
if (extUnpacker) {
|
||||||
extUnpacker(error, error_code, seq_num, bad_value, buf);
|
extUnpacker(error, error_code, seq_num, bad_value, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
var handler = client.replies[seq_num];
|
var handler = client.replies[seq_num];
|
||||||
if (handler) {
|
if (handler) {
|
||||||
var callback = handler[1];
|
var callback = handler[1];
|
||||||
|
|
@ -458,7 +458,7 @@ XClient.prototype.expectReplyHeader = function()
|
||||||
} else
|
} else
|
||||||
client.emit('error', error);
|
client.emit('error', error);
|
||||||
client.expectReplyHeader();
|
client.expectReplyHeader();
|
||||||
} );
|
} );
|
||||||
return;
|
return;
|
||||||
} else if (type > 1)
|
} else if (type > 1)
|
||||||
{
|
{
|
||||||
|
|
@ -466,20 +466,20 @@ XClient.prototype.expectReplyHeader = function()
|
||||||
var extra = res[3];
|
var extra = res[3];
|
||||||
var code = res[1];
|
var code = res[1];
|
||||||
var ev = client.unpackEvent(type, seq_num, extra, code, buf, headerBuf);
|
var ev = client.unpackEvent(type, seq_num, extra, code, buf, headerBuf);
|
||||||
|
|
||||||
// raw event 32-bytes packet (primarily for use in SendEvent);
|
// raw event 32-bytes packet (primarily for use in SendEvent);
|
||||||
// TODO: Event::pack based on event parameters, inverse to unpackEvent
|
// TODO: Event::pack based on event parameters, inverse to unpackEvent
|
||||||
ev.rawData = new Buffer(32);
|
ev.rawData = new Buffer(32);
|
||||||
headerBuf.copy(ev.rawData);
|
headerBuf.copy(ev.rawData);
|
||||||
buf.copy(ev.rawData, 8);
|
buf.copy(ev.rawData, 8);
|
||||||
|
|
||||||
client.emit('event', ev);
|
client.emit('event', ev);
|
||||||
var ee = client.event_consumers[ev.wid];
|
var ee = client.event_consumers[ev.wid];
|
||||||
if (ee) {
|
if (ee) {
|
||||||
ee.emit('event', ev);
|
ee.emit('event', ev);
|
||||||
}
|
}
|
||||||
client.expectReplyHeader();
|
client.expectReplyHeader();
|
||||||
} );
|
} );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -488,7 +488,7 @@ XClient.prototype.expectReplyHeader = function()
|
||||||
var bodylength = 24 + length_total*4; // 24 is rest if 32-bytes header
|
var bodylength = 24 + length_total*4; // 24 is rest if 32-bytes header
|
||||||
|
|
||||||
client.pack_stream.get( bodylength, function( data ) {
|
client.pack_stream.get( bodylength, function( data ) {
|
||||||
|
|
||||||
var handler = client.replies[seq_num];
|
var handler = client.replies[seq_num];
|
||||||
if (handler) {
|
if (handler) {
|
||||||
var unpack = handler[0];
|
var unpack = handler[0];
|
||||||
|
|
@ -504,8 +504,8 @@ XClient.prototype.expectReplyHeader = function()
|
||||||
}
|
}
|
||||||
// wait for new packet from server
|
// wait for new packet from server
|
||||||
client.expectReplyHeader();
|
client.expectReplyHeader();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -514,7 +514,7 @@ XClient.prototype.startHandshake = function()
|
||||||
var client = this;
|
var client = this;
|
||||||
|
|
||||||
handshake.writeClientHello(this.pack_stream, this.displayNum, this.authHost);
|
handshake.writeClientHello(this.pack_stream, this.displayNum, this.authHost);
|
||||||
handshake.readServerHello(this.pack_stream, function(display)
|
handshake.readServerHello(this.pack_stream, function(display)
|
||||||
{
|
{
|
||||||
// TODO: readServerHello can set error state in display
|
// TODO: readServerHello can set error state in display
|
||||||
// emit error in that case
|
// emit error in that case
|
||||||
|
|
@ -522,7 +522,7 @@ XClient.prototype.startHandshake = function()
|
||||||
client.display = display;
|
client.display = display;
|
||||||
display.client = client;
|
display.client = client;
|
||||||
client.emit('connect', display);
|
client.emit('connect', display);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
XClient.prototype.require = function(extName, callback)
|
XClient.prototype.require = function(extName, callback)
|
||||||
|
|
@ -558,7 +558,7 @@ module.exports.createClient = function(options, initCb)
|
||||||
var screenNum = displayMatch[3];
|
var screenNum = displayMatch[3];
|
||||||
if (!screenNum)
|
if (!screenNum)
|
||||||
screenNum = 0;
|
screenNum = 0;
|
||||||
|
|
||||||
// open stream
|
// open stream
|
||||||
var stream;
|
var stream;
|
||||||
var socketPath;
|
var socketPath;
|
||||||
|
|
@ -569,13 +569,13 @@ module.exports.createClient = function(options, initCb)
|
||||||
if (process.platform == 'darwin' || process.platform == 'mac')
|
if (process.platform == 'darwin' || process.platform == 'mac')
|
||||||
{
|
{
|
||||||
// socket path on OSX is /tmp/launch-(some id)/org.x:0
|
// socket path on OSX is /tmp/launch-(some id)/org.x:0
|
||||||
if (display[0] == '/')
|
if (display[0] == '/')
|
||||||
{
|
{
|
||||||
socketPath = display;
|
socketPath = display;
|
||||||
}
|
}
|
||||||
} else if(host == '127.0.0.1') //TODO check if it's consistent with xlib (DISPLAY=127.0.0.1:0 -> local unix socket or port 6000?)
|
} else if(host == '127.0.0.1') //TODO check if it's consistent with xlib (DISPLAY=127.0.0.1:0 -> local unix socket or port 6000?)
|
||||||
socketPath = '/tmp/.X11-unix/X' + displayNum;
|
socketPath = '/tmp/.X11-unix/X' + displayNum;
|
||||||
}
|
}
|
||||||
//socketPath = '/tmp/.X11-unix/X' + displayNum;
|
//socketPath = '/tmp/.X11-unix/X' + displayNum;
|
||||||
if(socketPath)
|
if(socketPath)
|
||||||
{
|
{
|
||||||
|
|
@ -592,7 +592,9 @@ module.exports.createClient = function(options, initCb)
|
||||||
client.on('connect', function(display) {
|
client.on('connect', function(display) {
|
||||||
// opt-in BigReq
|
// opt-in BigReq
|
||||||
if (!options.disableBigRequests) {
|
if (!options.disableBigRequests) {
|
||||||
client.require('big-requests', function(BigReq) {
|
client.require('big-requests', function(err, BigReq) {
|
||||||
|
if (err)
|
||||||
|
return initCb(err)
|
||||||
BigReq.Enable(function(err, maxLen) {
|
BigReq.Enable(function(err, maxLen) {
|
||||||
display.max_request_length = maxLen;
|
display.max_request_length = maxLen;
|
||||||
cbCalled = true;
|
cbCalled = true;
|
||||||
|
|
|
||||||
|
|
@ -22,34 +22,35 @@ describe('ConfigureWindow', function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
client.on('error', done);
|
client.on('error', function (err) {
|
||||||
|
console.error('Error : ', err);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should ResizeWindow correctly to 200x300 pixels', function(done) {
|
it('should ResizeWindow correctly to 200x300 pixels', function(done) {
|
||||||
var self = this;
|
var self = this;
|
||||||
this.X.ResizeWindow(this.wid, 200, 300);
|
|
||||||
this.X.once('event', function(ev) {
|
this.X.once('event', function(ev) {
|
||||||
ev.type.should.equal(22); /* ConfigureNotify */
|
ev.type.should.equal(22); /* ConfigureNotify */
|
||||||
ev.height.should.equal(300);
|
ev.height.should.equal(300);
|
||||||
ev.width.should.equal(200);
|
ev.width.should.equal(200);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
this.X.ResizeWindow(this.wid, 200, 300);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should MoveWindow correctly to x: 100, y: 150 pixels', function(done) {
|
it('should MoveWindow correctly to x: 100, y: 150 pixels', function(done) {
|
||||||
var self = this;
|
var self = this;
|
||||||
this.X.MoveWindow(this.wid, 100, 150);
|
|
||||||
this.X.once('event', function(ev) {
|
this.X.once('event', function(ev) {
|
||||||
ev.type.should.equal(22); /* ConfigureNotify */
|
ev.type.should.equal(22); /* ConfigureNotify */
|
||||||
ev.x.should.equal(100);
|
ev.x.should.equal(100);
|
||||||
ev.y.should.equal(150);
|
ev.y.should.equal(150);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
this.X.MoveWindow(this.wid, 100, 150);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should MoveResizeWindow correctly to x: 200, y: 250 and 500x100 pixels', function(done) {
|
it('should MoveResizeWindow correctly to x: 200, y: 250 and 500x100 pixels', function(done) {
|
||||||
var self = this;
|
var self = this;
|
||||||
this.X.MoveResizeWindow(this.wid, 200, 250, 500, 100);
|
|
||||||
this.X.once('event', function(ev) {
|
this.X.once('event', function(ev) {
|
||||||
ev.type.should.equal(22); /* ConfigureNotify */
|
ev.type.should.equal(22); /* ConfigureNotify */
|
||||||
ev.x.should.equal(200);
|
ev.x.should.equal(200);
|
||||||
|
|
@ -58,22 +59,23 @@ describe('ConfigureWindow', function() {
|
||||||
ev.width.should.equal(500);
|
ev.width.should.equal(500);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
this.X.MoveResizeWindow(this.wid, 200, 250, 500, 100);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should RaiseWindow correctly', function(done) {
|
it('should RaiseWindow correctly', function(done) {
|
||||||
var self = this;
|
var self = this;
|
||||||
this.X.RaiseWindow(this.wid);
|
|
||||||
this.X.once('event', function(ev) {
|
this.X.once('event', function(ev) {
|
||||||
ev.type.should.equal(22); /* ConfigureNotify */
|
ev.type.should.equal(22); /* ConfigureNotify */
|
||||||
ev.aboveSibling.should.equal(self.wid_helper);
|
ev.aboveSibling.should.equal(self.wid_helper);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
this.X.RaiseWindow(this.wid);
|
||||||
});
|
});
|
||||||
|
|
||||||
after(function(done) {
|
after(function(done) {
|
||||||
this.X.DestroyWindow(this.wid);
|
this.X.DestroyWindow(this.wid);
|
||||||
this.X.DestroyWindow(this.wid_helper);
|
this.X.DestroyWindow(this.wid_helper);
|
||||||
this.X.terminate();
|
|
||||||
this.X.on('end', done);
|
this.X.on('end', done);
|
||||||
|
this.X.terminate();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
11
test/dpms.js
11
test/dpms.js
|
|
@ -12,13 +12,10 @@ describe('DPMS extension', function() {
|
||||||
if (!err) {
|
if (!err) {
|
||||||
display = dpy;
|
display = dpy;
|
||||||
X = display.client;
|
X = display.client;
|
||||||
X.require('dpms', function(ext) {
|
X.require('dpms', function(err, ext) {
|
||||||
if (util.isError(ext)) {
|
should.not.exist(err);
|
||||||
done(ext);
|
dpms = ext;
|
||||||
} else {
|
done();
|
||||||
dpms = ext;
|
|
||||||
done();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
done(err);
|
done(err);
|
||||||
|
|
|
||||||
|
|
@ -11,8 +11,8 @@ describe('RANDR extension', function() {
|
||||||
self.X = dpy.client;
|
self.X = dpy.client;
|
||||||
self.screen = dpy.screen[0];
|
self.screen = dpy.screen[0];
|
||||||
self.root = self.screen.root;
|
self.root = self.screen.root;
|
||||||
self.X.require('randr', function(ext) {
|
self.X.require('randr', function(err, ext) {
|
||||||
util.isError(ext).should.equal(false);
|
err.should.equal(null);
|
||||||
self.randr = ext;
|
self.randr = ext;
|
||||||
/* We HAVE to QueryVersion before using it. Otherwise it does not work as expected */
|
/* We HAVE to QueryVersion before using it. Otherwise it does not work as expected */
|
||||||
self.randr.QueryVersion(1, 2, done);
|
self.randr.QueryVersion(1, 2, done);
|
||||||
|
|
|
||||||
|
|
@ -12,13 +12,10 @@ describe('XTEST extension', function() {
|
||||||
if (!err) {
|
if (!err) {
|
||||||
display = dpy;
|
display = dpy;
|
||||||
X = display.client;
|
X = display.client;
|
||||||
X.require('xtest', function(ext) {
|
X.require('xtest', function(err, ext) {
|
||||||
if (util.isError(ext)) {
|
should.not.exist(err);
|
||||||
done(ext);
|
xtest = ext;
|
||||||
} else {
|
done();
|
||||||
xtest = ext;
|
|
||||||
done();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
done(err);
|
done(err);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue