Extensions, tests and exemples are now cps-style

This commit is contained in:
champii 2014-09-23 16:09:18 +02:00
parent 4feba92047
commit 6d6c8d3b9f
38 changed files with 180 additions and 169 deletions

View file

@ -15,7 +15,7 @@ var ButtonRelease = x11.eventMask.ButtonRelease;
var kbdImg = require('./node-jpg').readJpeg('./keyboard.jpg');
var keycoords = require('./coordinates');
// from https://github.com/substack/node-keysym
// from https://github.com/substack/node-keysym
var keysyms = require('./keysyms').records;
var ks2name = {};
for (var k in keysyms)
@ -23,18 +23,18 @@ for (var k in keysyms)
var kk2name = {};
x11.createClient(function(err, display)
x11.createClient(function(err, display)
{
var X = display.client;
X.require('big-requests', function(BigReq)
var X = display.client;
X.require('big-requests', function(err, BigReq)
{
X.require('render', function(Render) {
X.require('render', function(err, Render) {
X.Render = Render;
BigReq.Enable(function(err, maxLen)
{
var min = display.min_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
for (var i=0; i < list.length; ++i)
@ -62,26 +62,26 @@ function main(X)
var win = X.AllocID();
X.CreateWindow(
win, root,
0, 0, kbdImg.width, kbdImg.height,
win, root,
0, 0, kbdImg.width, kbdImg.height,
0, 0, 0, 0,
{
backgroundPixel: white, eventMask: Exposure|KeyPress|ButtonPress
{
backgroundPixel: white, eventMask: Exposure|KeyPress|ButtonPress
}
);
X.MapWindow(win);
var win1 = X.AllocID();
X.CreateWindow(
win1, root,
0, 0, kbdImg.width, kbdImg.height,
win1, root,
0, 0, kbdImg.width, kbdImg.height,
0, 0, 0, 0,
{
backgroundPixel: white, eventMask: Exposure|KeyPress|ButtonPress
{
backgroundPixel: white, eventMask: Exposure|KeyPress|ButtonPress
}
);
X.MapWindow(win1);
var gc = X.AllocID();
X.CreateGC(gc, win);
@ -103,15 +103,15 @@ function main(X)
var picKbd = X.AllocID();
X.PutImage(2, pixmapKbd, gc, kbdImg.width, kbdImg.height, 0, 0, 0, 24, kbdImg.data);
Render.CreatePicture(picKbd, pixmapKbd, Render.rgb24);
var pixmapHeat = X.AllocID();
X.CreatePixmap(pixmapHeat, win, 32, kbdImg.width, kbdImg.height);
var picHeat = X.AllocID();
Render.CreatePicture(picHeat, pixmapHeat, Render.rgba32);
var picWin = X.AllocID();
Render.CreatePicture(picWin, win, Render.rgb24);
var picWin1 = X.AllocID();
Render.CreatePicture(picWin1, win1, Render.rgb24);
@ -135,12 +135,12 @@ function main(X)
mindist = dist;
}
}
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);
} if (ev.type == 2) {
var name = kk2name[ev.keycode];
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, picWin1, 0, 0, 0, 0, pt[0] -150/2, pt[1]-150/2, 150, 150);
break;
} else {
//console.log(name);

View file

@ -294,7 +294,7 @@ x11.createClient(function(error, display) {
var root = display.screen[0].root;
var width = 500;
var height = 500;
X.require('glx', function(GLX) {
X.require('glx', function(err, GLX) {
var depth = 24;
findBestVisual(display, function(err, visual) {

View file

@ -13,7 +13,7 @@ var listId = 1;
x11.createClient(function(err, display) {
var X = display.client;
var root = display.screen[0].root;
X.require('glx', function(GLX) {
X.require('glx', function(err, GLX) {
var visual = 0;
var visuals = display.screen[0].depths[24];
for (visual in visuals) {

View file

@ -304,7 +304,7 @@ x11.createClient(function(err, display) {
var root = display.screen[0].root;
var width = 1000;
var height = 1000;
X.require('glx', function(GLX) {
X.require('glx', function(err, GLX) {
var visual = 0xa1;
var win = X.AllocID();
X.CreateWindow(win, root, 0, 0, width, height, 0, 0, 0, 0, { eventMask: eventmask });

View file

@ -8,7 +8,7 @@ for(var i=0; i < 20000; ++i) {
var xclient = x11.createClient(function(err, display) {
var X = display.client;
var root = display.screen[0].root;
X.require('glx', function(GLX) {
X.require('glx', function(err, GLX) {
var screen = 0;
var isDirect = 0;
var ctx = X.AllocID();

View file

@ -10,10 +10,10 @@ var gradNo = 0;
var xclient = x11.createClient(function(err, display) {
X = display.client;
var root = display.screen[0].root;
X.require('render', function(rendExt) {
X.require('render', function(err, rendExt) {
Render = rendExt;
var wid = X.AllocID();
var white = display.screen[0].white_pixel;
var black = display.screen[0].black_pixel;
X.CreateWindow(wid, root, 10, 10, 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) {
Render.Composite(3, pictGrad[gradNo], 0, pict, 0, 0, 0, 0, x-50, y-50, 100, 100);
}
}
X.on('event', function(ev) {
if (ev.type == 4 && ev.keycode == 1)
pressed = true;
@ -45,14 +45,14 @@ var xclient = x11.createClient(function(err, display) {
pressed = false;
else if (ev.type == 5 && ev.keycode == 4)
{
gradNo--;
gradNo--;
if (gradNo < 0)
gradNo = 0;
console.log(gradNo);
}
else if (ev.type == 5 && ev.keycode == 5)
{
gradNo++;
gradNo++;
if (gradNo > 9)
gradNo = 9;
console.log(gradNo);

View file

@ -7,7 +7,7 @@ var Exposure = x11.eventMask.Exposure;
x11.createClient(function(err, display)
{
var X = display.client;
X.require('render', function(Render) {
X.require('render', function(err, Render) {
var root = display.screen[0].root;
main(root, X, Render);
});
@ -15,7 +15,7 @@ x11.createClient(function(err, display)
function main(root, X, Render) {
var win, picWin, pic, gc;
win = X.AllocID();
@ -39,7 +39,7 @@ function main(root, X, Render) {
Render.CreatePicture(logoPicture, logoPixmap, Render.rgb24);
var winPicture = X.AllocID();
Render.CreatePicture(winPicture, win, Render.rgb24);
X.on('event', function(ev) {
if (ev.name == 'Expose')
Render.Composite(3, logoPicture, 0, winPicture, 0, 0, 0, 0, 0, 0, logo.width, logo.height);

View file

@ -9,21 +9,21 @@ var x11 = require('../../lib');
x11.createClient(
function(err, display) {
var X = display.client;
X.require('render', function(Render) {
X.require('render', function(err, Render) {
var root = display.screen[0].root;
var win = X.AllocID();
var white = display.screen[0].white_pixel;
var black = display.screen[0].black_pixel;
X.CreateWindow(win, root, 0, 0, 500, 500, 0, 0, 0, 0,
{
backgroundPixel: white,
X.CreateWindow(win, root, 0, 0, 500, 500, 0, 0, 0, 0,
{
backgroundPixel: white,
eventMask: x11.eventMask.Exposure | x11.eventMask.ButtonPress | x11.eventMask.PointerMotion
});
X.MapWindow(win);
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();
X.CreatePixmap(pixmap, win, 32, 2500, 2500);
var pix_pict = X.AllocID();
@ -34,30 +34,30 @@ x11.createClient(
//RenderRadialGradient(pic_grad, [0,0], [1000,100], 10, 1000,
//RenderConicalGradient(pic_grad, [250,250], 360,
[
[0, [0,0,0,0x3000 ] ],
[0.1, [0xfff, 0, 0xffff, 0x1000] ] ,
[0.25, [0xffff, 0, 0xfff, 0x3000] ] ,
[0.5, [0xffff, 0, 0xffff, 0x4000] ] ,
[1, [0xffff, 0xffff, 0, 0x8000] ]
[0, [0,0,0,0x3000 ] ],
[0.1, [0xfff, 0, 0xffff, 0x1000] ] ,
[0.25, [0xffff, 0, 0xfff, 0x3000] ] ,
[0.5, [0xffff, 0, 0xffff, 0x4000] ] ,
[1, [0xffff, 0xffff, 0, 0x8000] ]
]);
var pic_grad1 = X.AllocID();
Render.ConicalGradient(pic_grad1, [250,250], 10,
[
[0, [0,0,0,0x5000 ] ],
[0.1, [0xfff, 0, 0xffff, 0x3000] ] ,
[0.25, [0xffff, 0, 0xfff, 0x2000] ] ,
[0.5, [0xffff, 0, 0xffff, 0x1000] ] ,
[1, [0xffff, 0xffff, 0, 0x8000] ]
[0, [0,0,0,0x5000 ] ],
[0.1, [0xfff, 0, 0xffff, 0x3000] ] ,
[0.25, [0xffff, 0, 0xfff, 0x2000] ] ,
[0.5, [0xffff, 0, 0xffff, 0x1000] ] ,
[1, [0xffff, 0xffff, 0, 0x8000] ]
]);
var pic_grad2 = X.AllocID();
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] ],
[1, [0xffff, 0xffff, 0, 0x0] ]
[1, [0xffff, 0xffff, 0, 0x0] ]
]);
var pixmap1 = X.AllocID();
@ -112,7 +112,7 @@ x11.createClient(
draw();
} else {
draw();
}
}
});
});
}

View file

@ -4,7 +4,7 @@ var PointerMotion = x11.eventMask.PointerMotion;
var xclient = x11.createClient(function(err, display) {
var X = display.client;
var root = display.screen[0].root;
display.client.require('render', function(Render) {
display.client.require('render', function(err, Render) {
var wid = X.AllocID();
var white = display.screen[0].white_pixel;
varblack = display.screen[0].black_pixel;
@ -24,8 +24,8 @@ var xclient = x11.createClient(function(err, display) {
function draw(x, y) {
Render.Composite(3, pictGrad, 0, pict, 0, 0, 0, 0, x-26, y-26, 52, 52);
}
}
X.on('event', function(ev) {
draw(ev.x, ev.y);
});

View file

@ -39,7 +39,7 @@ function padWidth(buf, width) {
var xclient = x11.createClient({ debug: true }, function(err, display) {
var X = display.client;
var root = display.screen[0].root;
display.client.require('render', function(Render) {
display.client.require('render', function(err, Render) {
var wid = X.AllocID();
var white = display.screen[0].white_pixel;
varblack = display.screen[0].black_pixel;

View file

@ -3,18 +3,18 @@ var x11 = require('../../lib');
x11.createClient(function(err, display) {
var X = display.client;
var root = display.screen[0].root;
X.require('apple-wm', function(AppleWM) {
X.require('apple-wm', function(err, AppleWM) {
//AppleWM.SetFrontProcess();
//AppleWM.CanQuit(true);
//AppleWM.CanQuit(true);
AppleWM.SelectInput(AppleWM.NotifyMask.All)
/*
for (level in AppleWM.WindowLevel)
{
var win = X.AllocID();
X.CreateWindow(win, root, 0, 0, 300, 300);
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]);
};
*/
@ -22,7 +22,7 @@ x11.createClient(function(err, display) {
var win1 = X.AllocID();
X.CreateWindow(win1, root, 0, 0, 300, 300);
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();
X.CreateWindow(win2, root, 0, 0, 200, 200);
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)
var gc = X.AllocID();
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");}
//setInterval(df, 100);
X.on('event', function(ev) { console.log("Event", ev); df(); });
});
X.on('error', function(err) { console.log("Error", err); });
});

View file

@ -3,8 +3,8 @@ var x11 = require('../../lib');
x11.createClient(function(err, display) {
var X = display.client;
var root = display.screen[0].root;
X.require('composite', function(Composite) {
X.require('damage', function(Damage) {
X.require('composite', function(err, Composite) {
X.require('damage', function(err, Damage) {
var wid = parseInt(process.argv[2]);
//Composite.GetOverlayWindow(wid, function(err, overlayid) {
// console.log("OVERLAY:", err, overlayid);

View file

@ -3,7 +3,7 @@ var x11 = require('../../lib');
x11.createClient(function(err, display) {
var X = display.client;
var root = display.screen[0].root;
X.require('damage', function(Damage) {
X.require('damage', function(err, Damage) {
console.log(Damage);
var id = parseInt(process.argv[2]);
var damage = X.AllocID();
@ -14,5 +14,5 @@ x11.createClient(function(err, display) {
});
});
X.on('error', function(err) { console.log(err); });
});

View file

@ -3,7 +3,7 @@ var x11 = require('../../lib');
x11.createClient(function(err, display) {
var X = display.client;
var root = display.screen[0].root;
X.require('fixes', function(Fixes) {
X.require('fixes', function(err, Fixes) {
console.log(Fixes);
var win = X.AllocID();
X.CreateWindow(win, root, 0, 0, 100, 100);

View file

@ -23,7 +23,7 @@ x11.createClient(function(err, display) {
if (err) throw err;
var X = display.client;
X.require('render', function(Render) {
X.require('render', function(err, Render) {
var root = display.screen[0].root;
var white = display.screen[0].white_pixel;

View file

@ -3,7 +3,7 @@ var x11 = require('../../lib');
x11.createClient(function(err, display) {
var X = display.client;
var root = display.screen[0].root;
X.require('randr', function(Randr) {
X.require('randr', function(err, Randr) {
//console.log(Randr);
//Randr.QueryVersion(1, 4, console.log);
Randr.SelectInput(root, Randr.NotifyMask.ScreenChange);

View file

@ -3,11 +3,11 @@ var x11 = require('../../lib');
x11.createClient(function(err, display) {
var X = display.client;
var root = display.screen[0].root;
X.require('shape', function(Shape) {
X.require('shape', function(err, Shape) {
var win = X.AllocID();
X.CreateWindow(win, root, 0, 0, 200, 200);
var gc = X.AllocID();
X.CreateGC(gc, win);
X.CreateGC(gc, win);
//X.MapWindow(win);
Shape.SelectInput(win, 1);
Shape.InputSelected(win, function(err, isSelected) {
@ -23,5 +23,5 @@ x11.createClient(function(err, display) {
});
});
X.on('error', function(err) { console.log(err); });
});

View file

@ -7,7 +7,7 @@ x11.createClient(function(err, display) {
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);
//console.log(SS);
//setTimeout(function() {
@ -15,7 +15,7 @@ x11.createClient(function(err, display) {
//}, 5000);
setInterval(function() {
SS.QueryInfo(root, function(err, info) {
console.log(info.until);
console.log(info.until);
//SS.SelectInput(root, SS.eventMask.Notify|SS.eventMask.Cycle);
});
}, 1000);
@ -24,5 +24,5 @@ x11.createClient(function(err, display) {
});
});
X.on('error', function(err) { console.log(err); });
});

View file

@ -25,18 +25,18 @@ x11.createClient(function(err, display) {
var cmid = X.AllocID();
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.MapWindow(wid);
var gc = X.AllocID();
X.require('render', function(Render) {
X.require('render', function(err, Render) {
var pict = X.AllocID();
Render.CreatePicture(pict, wid, Render.rgba32);
var gradients = [];
function randomLinear() {
var stops = [];
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)]]);
console.log(colors);
console.log(colors);
var gradient = X.AllocID();
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);
console.log(gradients[gid]);
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 } );
//setInterval(function() {

View file

@ -3,7 +3,7 @@ var x11 = require('../../lib');
x11.createClient(function(err, display) {
var X = display.client;
var root = display.screen[0].root;
X.require('xc-misc', function(Misc) {
X.require('xc-misc', function(err, Misc) {
var xid = X.AllocID();
console.log("first ID from connection: " + xid);
debugger;
@ -15,5 +15,5 @@ x11.createClient(function(err, display) {
});
});
X.on('error', function(err) { console.log("Error", err); });
});

View file

@ -3,7 +3,7 @@ var x11 = require('../../lib');
var xclient = x11.createClient(function(err, display) {
var X = display.client;
var root = display.screen[0].root;
display.client.require('xtest', function(Test) {
display.client.require('xtest', function(err, Test) {
console.log(Test);
setInterval(function() {
Test.FakeInput(Test.KeyPress, 65, 0, root, 0, 0); // space

View file

@ -30,8 +30,8 @@ var KeyPress = x11.eventMask.KeyPress;
var KeyRelease = x11.eventMask.KeyRelease;
x11.createClient(function(err, display) {
var X = display.client;
X.require('big-requests', function(BigReq) {
var X = display.client;
X.require('big-requests', function(err, BigReq) {
BigReq.Enable(function(err, maxLen) {
var keycode2keysym = [];
var min = display.min_keycode;
@ -54,19 +54,19 @@ x11.createClient(function(err, display) {
var wid = X.AllocID();
X.CreateWindow(wid, root, 0, 0, r.width, r.height);
X.ChangeWindowAttributes(wid, {
backgroundPixel: black,
eventMask: Exposure|PointerMotion|ButtonPress|ButtonRelease|KeyPress|KeyRelease
X.ChangeWindowAttributes(wid, {
backgroundPixel: black,
eventMask: Exposure|PointerMotion|ButtonPress|ButtonRelease|KeyPress|KeyRelease
});
X.ChangeProperty(0, wid, X.atoms.WM_NAME, X.atoms.STRING, 8, r.title);
X.MapWindow(wid);
var gc = X.AllocID();
X.CreateGC(gc, wid, { foreground: black, background: white } );
//var pixbuf = X.AllocID();
//X.CreatePixmap(pixbuf, wid, 32, r.width, r.height);
//var pic = X.AllocID();
//var pic = X.AllocID();
//Render.CreatePicture(pic, pixbuf, Render.rgba32);
var buttonsState = 0;
@ -86,7 +86,7 @@ x11.createClient(function(err, display) {
// set button bit
if (ev.type == 4)
buttonsState |= buttonBit;
else
else
buttonsState &= ~buttonBit;
r.pointerEvent(ev.x, ev.y, buttonsState);
} else if (ev.type == 2 || ev.type == 3) {
@ -121,7 +121,7 @@ x11.createClient(function(err, display) {
});
}); // r.on('connect)
}); // GetKeyboardMapping
}); // GetKeyboardMapping
}); // BigReq.Enable
}); // require('big-requests

View file

@ -80,7 +80,7 @@ function ManageWindow(wid)
x11.createClient(function(err, display) {
X = display.client;
X.require('render', function(Render) {
X.require('render', function(err, Render) {
X.Render = Render;
root = display.screen[0].root;

View file

@ -18,10 +18,10 @@ var xutil = require('../xutil');
#define X_AppleWMAttachTransient 13
*/
exports.requireExt = function(display, callback)
exports.requireExt = function(display, callback)
{
var X = display.client;
X.QueryExtension('Apple-WM', function(err, ext) {
X.QueryExtension('Apple-WM', function(err, ext) {
if (!ext.present)
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.replies[X.seq_num] = [
function(buf, opt) {
var res = buf.unpack('SSL');
var res = buf.unpack('SSL');
return res;
},
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.replies[X.seq_num] = [
function(buf, opt) {
var res = buf.unpack('SSSS');
var res = buf.unpack('SSSS');
return {
x: res[0],
y: res[1],
@ -64,7 +64,7 @@ exports.requireExt = function(display, callback)
];
X.pack_stream.flush();
}
ext.FrameHitTest = function(frame_class, px, py, ix, iy, iw, ih, ox, oy, ow, oh, cb)
{
X.seq_num++;
@ -80,7 +80,7 @@ exports.requireExt = function(display, callback)
}
// from /usr/include/Xplugin.h
// from /usr/include/Xplugin.h
ext.FrameClass = {
DecorLarge: 1,
Reserved1: 2,
@ -107,7 +107,7 @@ exports.requireExt = function(display, callback)
CloseBoxClicked: 0x800,
CollapseBoxClicked: 0x1000,
ZoomBoxClicked: 0x2000,
GrowBox: 0x4000
GrowBox: 0x4000
};
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 extlength = 0;
items.forEach(function(i) {
});
}
@ -209,13 +209,13 @@ exports.requireExt = function(display, callback)
X.pack_stream.flush();
}
callback(ext);
callback(null, ext);
/*
ext.QueryVersion(function(err, vers) {
ext.major = vers[0];
ext.minor = vers[1];
ext.patch = vers[2];
callback(ext);
callback(null, ext);
});
*/
@ -248,7 +248,7 @@ exports.requireExt = function(display, callback)
CopyToPasteboard: 0
}
};
X.eventParsers[ext.firstEvent + ext.events.AppleWMControllerNotify] =
X.eventParsers[ext.firstEvent + ext.events.AppleWMActivationNotify] =
X.eventParsers[ext.firstEvent + ext.events.AppleWMPasteboardNotify] = function(type, seq, extra, code, raw)

View file

@ -1,11 +1,11 @@
// http://www.x.org/releases/X11R7.6/doc/bigreqsproto/bigreq.html
// TODO: move to templates
exports.requireExt = function(display, callback)
exports.requireExt = function(display, callback)
{
var X = display.client;
X.QueryExtension('BIG-REQUESTS', function(err, ext) {
X.QueryExtension('BIG-REQUESTS', function(err, ext) {
if (!ext.present)
return callback(new Error('extension not available'));
@ -21,6 +21,6 @@ exports.requireExt = function(display, callback)
];
X.pack_stream.flush();
}
callback(ext);
callback(null, ext);
});
}

View file

@ -61,6 +61,8 @@ exports.requireExt = function(display, callback)
}
ext.QueryVersion(1, 1, function(err, vers) {
if (err)
return callback(err);
ext.major = vers[0];
ext.minor = vers[1];
callback(null, ext);

View file

@ -94,7 +94,7 @@ exports.requireExt = function(display, callback)
X.pack_stream.flush();
};
callback(ext);
callback(null, ext);
});
};

View file

@ -7,7 +7,7 @@ function parse_rectangle(buf, pos) {
if (!pos) {
pos = 0;
}
return {
x : buf[pos],
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;
X.QueryExtension('XFIXES', function(err, ext) {
X.QueryExtension('XFIXES', function(err, ext) {
if (!ext.present)
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.replies[X.seq_num] = [
function(buf, opt) {
var res = buf.unpack('LL');
var res = buf.unpack('LL');
return res;
},
callback
@ -68,7 +68,7 @@ exports.requireExt = function(display, callback)
X.pack_stream.pack(format, args);
X.pack_stream.flush();
}
ext.CreateRegionFromWindow = function(region, wid, kind) {
X.seq_num ++;
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.flush();
}
ext.FetchRegion = function(region, cb) {
X.seq_num ++;
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) {
reg.rectangles.push(parse_rectangle(res, 4 + (i << 2)));
}
return reg;
},
cb
@ -120,16 +120,18 @@ exports.requireExt = function(display, callback)
}
ext.QueryVersion(5, 0, function(err, vers) {
if (err)
return callback(err);
ext.major = vers[0];
ext.minor = vers[1];
callback(ext);
callback(null, ext);
});
ext.events = {
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 = {};
event.level = code;
@ -139,16 +141,16 @@ exports.requireExt = function(display, callback)
event.damage = values[0];
event.time = values[1];
event.area = {
x: values[2],
y: values[3],
w: values[4],
h: values[5]
x: values[2],
y: values[3],
w: values[4],
h: values[5]
};
event.geometry = {
x: values[6],
y: values[7],
w: values[8],
h: values[9]
x: values[6],
y: values[7],
w: values[8],
h: values[9]
};
event.name = 'DamageNotify';
return event;

View file

@ -319,7 +319,7 @@ exports.requireExt = function(display, callback)
};
});
callback(ext);
callback(null, ext);
});
}

View file

@ -3,15 +3,15 @@
var x11 = require('..');
// TODO: move to templates
exports.requireExt = function(display, callback)
exports.requireExt = function(display, callback)
{
var X = display.client;
X.QueryExtension('RANDR', function(err, ext) {
X.QueryExtension('RANDR', function(err, ext) {
if (!ext.present)
return callback(new Error('extension not available'));
//ext.ReportLevel = {
//ext.ReportLevel = {
//};
ext.QueryVersion = function(clientMaj, clientMin, callback)
@ -198,7 +198,7 @@ exports.requireExt = function(display, callback)
pos += res_modes[i + 11];
}
return resources;
},
cb
@ -223,7 +223,7 @@ exports.requireExt = function(display, callback)
height : res[4],
mode : res[5],
rotation : res[6],
rotations : res[7]
rotations : res[7]
};
pos += 24;
@ -239,7 +239,7 @@ exports.requireExt = function(display, callback)
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 = {};
event.raw = raw;
@ -263,6 +263,6 @@ exports.requireExt = function(display, callback)
return event;
};
callback(ext);
callback(null, ext);
});
}

View file

@ -530,6 +530,8 @@ exports.requireExt = function(display, callback)
// 11 - colormap or none
ext.QueryPictFormat(function(err, formats) {
if (err)
return callback(err);
for (var i=0; i < formats.formats.length; ++i) {
var f = formats.formats[i];
if (f[2] == 1 && f[10] == 1)
@ -542,7 +544,7 @@ exports.requireExt = function(display, callback)
if (f[2] == 8 && f[10] == 255)
ext.a8 = f[0];
}
callback(ext);
callback(null, ext);
});
[

View file

@ -3,10 +3,10 @@
var x11 = require('..');
// TODO: move to templates
exports.requireExt = function(display, callback)
exports.requireExt = function(display, callback)
{
var X = display.client;
X.QueryExtension('MIT-SCREEN-SAVER', function(err, ext) {
X.QueryExtension('MIT-SCREEN-SAVER', function(err, ext) {
if (!ext.present)
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.replies[X.seq_num] = [
function(buf, opt) {
var res = buf.unpack('CC');
var res = buf.unpack('CC');
return res;
},
cb
@ -26,18 +26,18 @@ exports.requireExt = function(display, callback)
X.pack_stream.flush();
}
ext.State = {
ext.State = {
Off: 0,
On: 1,
Disabled: 2
};
ext.Kind = {
ext.Kind = {
Blanked: 0,
Internal: 1,
External: 2
};
ext.QueryInfo = function(drawable, callback)
{
X.seq_num++;
@ -51,7 +51,7 @@ exports.requireExt = function(display, callback)
info.until = res[1];
info.idle = res[2];
info.eventMask = res[3];
info.kind = res[4]
info.kind = res[4]
return info;
},
callback
@ -73,10 +73,11 @@ exports.requireExt = function(display, callback)
}
ext.QueryVersion(1, 1, function(err, vers) {
if (err)
return callback(err);
ext.major = vers[0];
ext.minor = vers[1];
callback(ext);
callback(null, ext);
});
ext.events = {
@ -89,7 +90,7 @@ exports.requireExt = function(display, callback)
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 = {};
event.state = code;

View file

@ -3,7 +3,7 @@
var x11 = require('..');
// TODO: move to templates
exports.requireExt = function(display, callback)
exports.requireExt = function(display, callback)
{
function captureStack()
{
@ -14,12 +14,12 @@ exports.requireExt = function(display, callback)
}
var X = display.client;
X.QueryExtension('SHAPE', function(err, ext) {
X.QueryExtension('SHAPE', function(err, ext) {
if (!ext.present)
return callback(new Error('extension not available'));
ext.Kind = {
ext.Kind = {
Bounding: 0,
Clip: 1,
Input: 2
@ -40,7 +40,7 @@ exports.requireExt = function(display, callback)
X.pack_stream.pack('CCSLL', [ext.majorOpcode, 0, 1]);
X.replies[X.seq_num] = [
function(buf, opt) {
var res = buf.unpack('SS');
var res = buf.unpack('SS');
return res;
},
cb
@ -78,13 +78,13 @@ exports.requireExt = function(display, callback)
X.pack_stream.flush();
}
callback(ext);
callback(null, ext);
/*
ext.QueryVersion(function(err, version) {
ext.major = version[0];
ext.minor = version[1];
callback(ext);
callback(null, ext);
});
*/
});

View file

@ -3,10 +3,10 @@
var x11 = require('..');
// TODO: move to templates
exports.requireExt = function(display, callback)
exports.requireExt = function(display, callback)
{
var X = display.client;
X.QueryExtension('XC-MISC', function(err, ext) {
X.QueryExtension('XC-MISC', function(err, ext) {
if (!ext.present)
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.replies[X.seq_num] = [
function(buf, opt) {
var res = buf.unpack('SS');
var res = buf.unpack('SS');
return res;
},
cb
@ -31,7 +31,7 @@ exports.requireExt = function(display, callback)
X.pack_stream.pack('CCS', [ext.majorOpcode, 1, 1]);
X.replies[X.seq_num] = [
function(buf, opt) {
var res = buf.unpack('LL');
var res = buf.unpack('LL');
return {
startId: res[0],
count: res[1]
@ -60,9 +60,11 @@ exports.requireExt = function(display, callback)
}
ext.QueryVersion(1, 1, function(err, vers) {
if (err)
return callback(err);
ext.major = vers[0];
ext.minor = vers[1];
callback(ext);
callback(null, ext);
});
});
}

View file

@ -592,7 +592,9 @@ module.exports.createClient = function(options, initCb)
client.on('connect', function(display) {
// opt-in BigReq
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) {
display.max_request_length = maxLen;
cbCalled = true;

View file

@ -12,8 +12,8 @@ describe('DPMS extension', function() {
if (!err) {
display = dpy;
X = display.client;
X.require('dpms', function(ext) {
if (util.isError(ext)) {
X.require('dpms', function(err, ext) {
if (err) {
done(ext);
} else {
dpms = ext;

View file

@ -11,8 +11,8 @@ describe('RANDR extension', function() {
self.X = dpy.client;
self.screen = dpy.screen[0];
self.root = self.screen.root;
self.X.require('randr', function(ext) {
util.isError(ext).should.equal(false);
self.X.require('randr', function(err, ext) {
err.should.equal(null);
self.randr = ext;
/* We HAVE to QueryVersion before using it. Otherwise it does not work as expected */
self.randr.QueryVersion(1, 2, done);

View file

@ -12,8 +12,8 @@ describe('XTEST extension', function() {
if (!err) {
display = dpy;
X = display.client;
X.require('xtest', function(ext) {
if (util.isError(ext)) {
X.require('xtest', function(err, ext) {
if (err) {
done(ext);
} else {
xtest = ext;