mirror of
https://github.com/danbulant/node-x11
synced 2026-06-24 17:21:47 +00:00
Merge branch 'master' of https://github.com/sidorares/node-x11
This commit is contained in:
commit
be8a5c76d5
1 changed files with 41 additions and 9 deletions
50
README.md
50
README.md
|
|
@ -47,20 +47,52 @@ Core requsests usage:
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
Simple core requests Window wrapper:
|
'click&draw' demo using simple Window wrapper:
|
||||||
|
|
||||||
var x11 = require('x11');
|
var x11 = require('../lib/x11');
|
||||||
var Window = require('./wndwrap');
|
var Window = require('./wndwrap');
|
||||||
var xclient = x11.createClient();
|
|
||||||
xclient.on('connect', function(display) {
|
x11.createClient(function(display) {
|
||||||
var mainwnd = new Window(xclient, 0, 0, 100, 100);
|
|
||||||
mainwnd.on('expose', function(ev) {
|
var pts = [];
|
||||||
ev.gc.drawText(50, 50, 'Hello, NodeJS!');
|
new Window(display.client, 0, 0, 700, 500)
|
||||||
});
|
.handle({
|
||||||
mainwnd.map();
|
|
||||||
|
mousemove: function(ev) {
|
||||||
|
if (this.pressed)
|
||||||
|
{
|
||||||
|
var lastpoly = pts[pts.length - 1];
|
||||||
|
lastpoly.push(ev.x);
|
||||||
|
lastpoly.push(ev.y);
|
||||||
|
if (lastpoly.length > 3)
|
||||||
|
this.gc.polyLine(lastpoly.slice(-4));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
mousedown: function(ev) {
|
||||||
|
if (ev.keycode == 1) { // left button
|
||||||
|
this.pressed = true;
|
||||||
|
pts.push([]); // start next polyline
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
mouseup: function(ev) {
|
||||||
|
if (ev.keycode == 1) // left button
|
||||||
|
this.pressed = false;
|
||||||
|
},
|
||||||
|
|
||||||
|
expose: function(ev) {
|
||||||
|
for (var i=0; i < pts.length ; ++i)
|
||||||
|
this.gc.polyLine(pts[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
.map()
|
||||||
|
.title = 'Hello, world!';
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Protocol documentation
|
# Protocol documentation
|
||||||
|
|
||||||
- http://www.x.org/releases/X11R7.6/doc/
|
- http://www.x.org/releases/X11R7.6/doc/
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue