diff --git a/lib/x11/eventmask.js b/lib/x11/eventmask.js index 1b3b95c..a70fe66 100644 --- a/lib/x11/eventmask.js +++ b/lib/x11/eventmask.js @@ -24,5 +24,5 @@ module.exports.eventMask = { PropertyChange: 0x00400000, ColormapChange: 0x00800000, OwnerGrabButton: 0x01000000 - // add more names for common masks combinations + // TODO: add more names for common masks combinations } diff --git a/lib/x11/xcore.js b/lib/x11/xcore.js index cb07096..5465558 100644 --- a/lib/x11/xcore.js +++ b/lib/x11/xcore.js @@ -185,6 +185,16 @@ XClient.prototype.unpackEvent = function(type, seq, extra, code, raw) event.width = values[2]; event.height = values[3]; event.count = values[4]; // TODO: ??? + } else if (type == 16) { // CreateNotify + var values = raw.unpack('LLSSSSS'); + event.parent = extra; + event.wid = values[0]; + // x, y, width, height, border + console.log(event); + } else if (type == 19) { // MapNotify + var values = raw.unpack('LLC'); + //event.wid = extra; + event.wid = values[0]; } return event; } diff --git a/test/testwnd.js b/test/testwnd.js index 280825a..bceac14 100644 --- a/test/testwnd.js +++ b/test/testwnd.js @@ -14,7 +14,7 @@ xclient.on('connect', function(display) { { pts.push(ev.x); pts.push(ev.y); - this.gc.drawText(ev.x, ev.y, 'Hello, NodeJS!'); + this.gc.text(ev.x, ev.y, 'Hello, NodeJS!'); mainwnd.title = ev.x + ' ' + ev.y; }); mainwnd.on('expose', function(ev) { diff --git a/test/wndwrap.js b/test/wndwrap.js index 14f661d..136348a 100644 --- a/test/wndwrap.js +++ b/test/wndwrap.js @@ -3,6 +3,8 @@ var Exposure = x11.eventMask.Exposure; var PointerMotion = x11.eventMask.PointerMotion; var ButtonPress = x11.eventMask.ButtonPress; var ButtonRelease = x11.eventMask.ButtonRelease; +var SubstructureNotify = x11.eventMask.SubstructureNotify; +var StructureNotify = x11.eventMask.StructureNotify; var EventEmitter = require('events').EventEmitter; var util = require('util'); // util.inherits @@ -12,7 +14,8 @@ function GraphicContext(win) this.win = win; this.xclient = win.xclient; this.id = this.xclient.AllocID(); - win.xclient.CreateGC(this.id, win.id); + var screen = this.xclient.display.screen[0]; + win.xclient.CreateGC(this.id, win.id, { foreground: screen.black_pixel, background: screen.white_pixel}); } GraphicContext.prototype.polyLine = function(points) @@ -51,6 +54,12 @@ GraphicContext.prototype.points = function(points, opts) this.xclient.PolyPoint(coordinateMode, this.win.id, this.id, points); } +GraphicContext.prototype.copy = function(srcDrawable, srcX, srcY, dstX, dstY, width, height) +{ + // CopyArea: srcDrawable, dstDrawable, gc, srcX, srcY, dstX, dstY, width, height + this.xclient.CopyArea(srcDrawable.id, this.win.id, this.id, srcX, srcY, dstX, dstY, width, height); +} + function Window(parent, x, y, w, h) { if (parent.constructor && parent.constructor.name == 'XClient') @@ -89,7 +98,7 @@ function Window(parent, x, y, w, h) borderWidth, _class, visual, { backgroundPixel: this.white, - eventMask: Exposure|PointerMotion|ButtonPress|ButtonRelease + eventMask: Exposure|PointerMotion|ButtonPress|ButtonRelease|SubstructureNotify|StructureNotify } ); @@ -98,8 +107,10 @@ function Window(parent, x, y, w, h) eventType2eventName = { 4: 'mousedown', 5: 'mouseup', - 6: 'mousemove', - 12: 'expose' + 6: 'mousemove', + 12: 'expose', + 16: 'create', + 19: 'map' }; var ee = new EventEmitter(); @@ -162,4 +173,23 @@ Window.prototype.getProperty = function(name, cb) { return this; } -module.exports = Window; +Window.prototype.createPixmap = function(width, height) +{ + var pid = this.xclient.AllocID(); + // function(depth, pid, drawable, width, height) { + this.xclient.CreatePixmap( this.xclient.display.screen[0].root_depth, pid, this.id, width, height); + var pixmap = {}; + pixmap.id = pid; + pixmap.__defineGetter__('gc', function() + { + if (!this._gc) + { + this._gc = new GraphicContext(this); + } + return this._gc; + }); + pixmap.xclient = this.xclient; + return pixmap; +} + +module.exports = Window; \ No newline at end of file