From 29a04525afb00db9bee298ffb9585ad18352d998 Mon Sep 17 00:00:00 2001 From: Andrey Sidorov Date: Wed, 11 Apr 2012 16:43:13 +1000 Subject: [PATCH] new argument depth in CreateWindow --- test/changeprop.js | 19 ++++++++++--------- test/getkeyboardmapping.js | 6 +++--- test/listext.js | 2 +- test/polypoint.js | 9 ++++----- test/query_ext.js | 4 ++-- test/query_pointer.js | 19 +++++++++---------- test/querytree.js | 3 ++- test/testwnd.js | 7 ++----- test/wndwrap.js | 5 +++-- 9 files changed, 36 insertions(+), 38 deletions(-) diff --git a/test/changeprop.js b/test/changeprop.js index a70eb94..5ddee45 100644 --- a/test/changeprop.js +++ b/test/changeprop.js @@ -1,22 +1,23 @@ var x11 = require('../lib/x11'); -var xclient = x11.createClient(); var PointerMotion = x11.eventMask.PointerMotion; - -xclient.on('connect', function(display) { - var X = this; +x11.createClient(function(display) { + var X = display.client; var root = display.screen[0].root; var wid = X.AllocID(); var white = display.screen[0].white_pixel; var black = display.screen[0].black_pixel; - X.CreateWindow(wid, root, 10, 10, 400, 300, 1, 1, 0, { backgroundPixel: white, eventMask: PointerMotion }); + X.CreateWindow(wid, root, 0, 0, 400, 300, 0, 0, 0, 0, { backgroundPixel: white, eventMask: PointerMotion }); X.MapWindow(wid); // mode: 0 replace, 1 prepend, 2 append // mode, wid, name, type, format, data - X.ChangeProperty(0, wid, xclient.atoms.WM_NAME, xclient.atoms.STRING, 8, 'Hello, NodeJS'); - setInterval(function() { - X.ChangeProperty(0, wid, xclient.atoms.WM_NAME, xclient.atoms.STRING, 8, 'Hello, NodeJS ' + new Date()); + X.ChangeProperty(0, wid, X.atoms.WM_NAME, X.atoms.STRING, 8, 'Hello, NodeJS'); + var interval = setInterval(function() { + X.ChangeProperty(0, wid, X.atoms.WM_NAME, X.atoms.STRING, 8, 'Hello, NodeJS ' + new Date()); }, 100); -}); \ No newline at end of file + X.on('end', function() { + clearInterval(interval); + }); +}); diff --git a/test/getkeyboardmapping.js b/test/getkeyboardmapping.js index 6def7af..cd20aee 100644 --- a/test/getkeyboardmapping.js +++ b/test/getkeyboardmapping.js @@ -10,7 +10,7 @@ x11.createClient(function(display) { var X = display.client; var min = display.min_keycode; var max = display.max_keycode; - X.GetKeyboardMapping(min, max-min, function(list) { + X.GetKeyboardMapping(min, max-min, function(err, list) { for (var i=0; i < list.length; ++i) { var name = kk2Name[i+min] = []; @@ -23,11 +23,11 @@ x11.createClient(function(display) { var wid = X.AllocID(); var white = display.screen[0].white_pixel; var black = display.screen[0].black_pixel; - X.CreateWindow(wid, root, 10, 10, 400, 300, 1, 1, 0, { backgroundPixel: white, eventMask: x11.eventMask.KeyPress}); + X.CreateWindow(wid, root, 10, 10, 400, 300, 0, 0, 0, 0, { backgroundPixel: white, eventMask: x11.eventMask.KeyPress}); X.MapWindow(wid); X.on('event', function(ev) { - console.log(kk2Name[ev.keycode]); + console.log([ev.keycode, kk2Name[ev.keycode]]); }); }); }); diff --git a/test/listext.js b/test/listext.js index 0ec2fe6..76a35f8 100644 --- a/test/listext.js +++ b/test/listext.js @@ -1,7 +1,7 @@ var x11 = require('../lib/x11'); var X = x11.createClient(); X.on('connect', function(display) { - X.ListExtensions(function(list) { + X.ListExtensions(function(err, list) { list.forEach(function(ext) { console.log(ext); }); diff --git a/test/polypoint.js b/test/polypoint.js index d5764d1..59a27be 100644 --- a/test/polypoint.js +++ b/test/polypoint.js @@ -1,12 +1,11 @@ var x11 = require('../lib/x11'); -var xclient = x11.createClient(); var Exposure = x11.eventMask.Exposure; var PointerMotion = x11.eventMask.PointerMotion; var pts = []; -xclient.on('connect', function(display) { - var X = this; +x11.createClient(function(display) { + var X = display.client; var root = display.screen[0].root; var white = display.screen[0].white_pixel; var black = display.screen[0].black_pixel; @@ -14,8 +13,8 @@ xclient.on('connect', function(display) { var wid = X.AllocID(); X.CreateWindow( wid, root, - 10, 10, 400, 300, - 1, 1, 0, + 0, 0, 400, 300, + 0, 0, 0, 0, { backgroundPixel: white, eventMask: Exposure|PointerMotion } diff --git a/test/query_ext.js b/test/query_ext.js index 52a539a..e29b061 100644 --- a/test/query_ext.js +++ b/test/query_ext.js @@ -2,11 +2,11 @@ var x11 = require('../lib/x11'); var X = x11.createClient(); var numExt = 0; X.on('connect', function(display) { - X.ListExtensions(function(list) { + X.ListExtensions(function(err, list) { console.log(list); list.forEach(function(ext) { numExt++; - X.QueryExtension(ext, function(e) { + X.QueryExtension(ext, function(err, e) { e.name = ext; console.log(e); if (--numExt == 0) diff --git a/test/query_pointer.js b/test/query_pointer.js index ccc18a2..df2d442 100644 --- a/test/query_pointer.js +++ b/test/query_pointer.js @@ -1,20 +1,19 @@ var x11 = require('../lib/x11'); -var X = x11.createClient(); - -X.on('connect', function(display) { - +x11.createClient(function(display) { + var X = display.client; var screen = display.screen[0]; var wid = X.AllocID(); - X.CreateWindow(wid, screen.root, 10, 10, 400, 300, 1, 1, 0, { backgroundPixel: screen.white_pixel }); + X.CreateWindow(wid, screen.root, 0, 0, 400, 300); X.MapWindow(wid); - setInterval( function() { - X.QueryPointer(wid, function(res) { + var interval = setInterval( function() { + X.QueryPointer(wid, function(err, res) { console.log(res); }); }, 1000); + X.on('error', function(err) { + console.log(err); + }); + X.on('end', function () { clearInterval(interval); }); }); -X.on('error', function(err) { - console.log(err); -}); diff --git a/test/querytree.js b/test/querytree.js index 4713d76..27f4acd 100644 --- a/test/querytree.js +++ b/test/querytree.js @@ -5,7 +5,8 @@ var wids = []; x11.createClient(function(display) { var X = display.client; var root = display.screen[0].root; - X.QueryTree(wid ? wid : root, function(tree) { + X.QueryTree(wid ? wid : root, function(err, tree) { console.log(tree); + X.terminate(); }); }); diff --git a/test/testwnd.js b/test/testwnd.js index bceac14..ddd7ea4 100644 --- a/test/testwnd.js +++ b/test/testwnd.js @@ -4,12 +4,10 @@ var Window = require('./wndwrap'); var width = 700; var height = 500; -var xclient = x11.createClient(); var pts = []; +x11.createClient(function(display) { -xclient.on('connect', function(display) { - - var mainwnd = new Window(xclient, 0, 0, width, height); + var mainwnd = new Window(display.client, 0, 0, width, height); mainwnd.on('mousemove', function(ev) { pts.push(ev.x); @@ -22,5 +20,4 @@ xclient.on('connect', function(display) { ev.gc.drawText(pts[i], pts[i+1], 'Hello, NodeJS!'); }); mainwnd.map(); - }); diff --git a/test/wndwrap.js b/test/wndwrap.js index 824f65b..beecb1f 100644 --- a/test/wndwrap.js +++ b/test/wndwrap.js @@ -97,9 +97,10 @@ function Window(parent, x, y, w, h, bg) var borderWidth = 1; var _class = 1; // InputOutput var visual = 0; // CopyFromParent + var depth = 0; this.xclient.CreateWindow( this.id, this.parent.id, this.x, this.y, this.w, this.h, - borderWidth, _class, visual, + borderWidth, depth, _class, visual, { backgroundPixel: bg, eventMask: Exposure|PointerMotion|ButtonPress|ButtonRelease|SubstructureNotify|StructureNotify @@ -196,4 +197,4 @@ Window.prototype.createPixmap = function(width, height) return pixmap; } -module.exports = Window; \ No newline at end of file +module.exports = Window;