From ea8bc9ed5bc50053de0a872e11c7e9d52f837230 Mon Sep 17 00:00:00 2001 From: Andrey Sidorov Date: Tue, 19 Jul 2011 08:25:41 +1000 Subject: [PATCH] PolyPoint request + test --- lib/x11/corereqs.js | 17 ++++++++++++++++- test/polypoint.js | 43 +++++++++++++++++++++++++++++++++++++++++++ test/polytext8.js | 3 +-- 3 files changed, 60 insertions(+), 3 deletions(-) create mode 100644 test/polypoint.js diff --git a/lib/x11/corereqs.js b/lib/x11/corereqs.js index 770f553..8cff01c 100644 --- a/lib/x11/corereqs.js +++ b/lib/x11/corereqs.js @@ -217,6 +217,21 @@ module.exports = { return [format, args]; } ], + + PolyPoint: [ + function(coordMode, drawable, gc, points) + { + var format = 'CCSLL'; + var args = [64, coordMode, 3+points.length, drawable, gc]; + for (var i=0; i < points.length; ++i) + { + format += 'S'; + args.push(points[i]); + } + console.error([format, args]); + return [format, args]; + } + ], PolyText8: [ function(drawable, gc, x, y, items) { @@ -251,4 +266,4 @@ module.exports = { return [format, args]; } ] -} \ No newline at end of file +} diff --git a/test/polypoint.js b/test/polypoint.js new file mode 100644 index 0000000..83f731b --- /dev/null +++ b/test/polypoint.js @@ -0,0 +1,43 @@ +var x11 = require('../lib/x11'); + +var xclient = x11.createClient(); +var Exposure = x11.eventMask.Exposure; +var PointerMotion = x11.eventMask.PointerMotion; +var pts = []; + + +xclient.on('connect', function(display) { + var X = this; + var root = display.screen[0].root; + var white = display.screen[0].white_pixel; + var black = display.screen[0].black_pixel; + + var wid = X.AllocID(); + X.CreateWindow( + wid, root, + 10, 10, 400, 300, + 1, 1, 0, + { + backgroundPixel: white, eventMask: Exposure|PointerMotion + } + ); + X.MapWindow(wid); + + var gc = X.AllocID(); + X.CreateGC(gc, wid, { foreground: black, background: white } ); + + X.on('event', function(ev) { + if (ev.type == 12) + { + X.PolyPoint(0, wid, gc, pts); + } else if (ev.type == 6) { + pts.push(ev.x); + pts.push(ev.y); + X.PolyPoint(0, wid, gc, [ev.x, ev.y]); + } + }); + + X.on('error', function(e) { + console.log(e); + }); +}); diff --git a/test/polytext8.js b/test/polytext8.js index ec57559..eded925 100644 --- a/test/polytext8.js +++ b/test/polytext8.js @@ -22,7 +22,6 @@ xclient.on('connect', function(display) { X.MapWindow(wid); var gc = X.AllocID(); - console.log('GC: ' + gc); X.CreateGC(gc, wid, { foreground: black, background: white } ); X.on('event', function(ev) { @@ -34,4 +33,4 @@ xclient.on('connect', function(display) { X.on('error', function(e) { console.log(e); }); -}); \ No newline at end of file +});