mirror of
https://github.com/danbulant/node-x11
synced 2026-06-15 04:31:17 +00:00
Merge branch 'master' of https://github.com/sidorares/node-x11
This commit is contained in:
commit
2678daa7b8
1 changed files with 9 additions and 66 deletions
75
README.md
75
README.md
|
|
@ -8,40 +8,28 @@ Windows users:
|
|||
1) install [XMing](http://www.straightrunning.com/XmingNotes/) or [Cygwin/X](http://x.cygwin.com/)
|
||||
2) get node-x11 copy (using [git](http://code.google.com/p/msysgit/downloads/list?can=3) or from [Github](https://github.com/sidorares/node-x11/archives/master ))
|
||||
|
||||
# status
|
||||
|
||||
[implemented requests documentation](https://github.com/sidorares/node-x11/wiki/Core-requests)
|
||||
|
||||
# example
|
||||
|
||||
Core requsests usage:
|
||||
|
||||
var x11 = require('../lib/x11');
|
||||
var x11 = require('x11');
|
||||
|
||||
var xclient = x11.createClient();
|
||||
var Exposure = x11.eventMask.Exposure;
|
||||
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 white = display.screen[0].white_pixel;
|
||||
var black = display.screen[0].black_pixel;
|
||||
|
||||
var wid = X.AllocID();
|
||||
X.CreateWindow(
|
||||
wid, root,
|
||||
0, 0, 100, 100,
|
||||
1, 1, 0,
|
||||
{
|
||||
backgroundPixel: white, eventMask: Exposure|PointerMotion
|
||||
}
|
||||
wid, root, // new window id, parent
|
||||
0, 0, 100, 100, // x, y, w, h
|
||||
0, 0, 0, 0, // border, depth, class, visual
|
||||
{ eventMask: Exposure|PointerMotion } // other parameters
|
||||
);
|
||||
X.MapWindow(wid);
|
||||
|
||||
X.MapWindow(wid);
|
||||
var gc = X.AllocID();
|
||||
X.CreateGC(gc, wid, { foreground: black, background: white } );
|
||||
|
||||
X.CreateGC(gc, wid);
|
||||
X.on('event', function(ev) {
|
||||
if (ev.type == 12)
|
||||
{
|
||||
|
|
@ -53,51 +41,6 @@ Core requsests usage:
|
|||
});
|
||||
});
|
||||
|
||||
|
||||
'click&draw' demo using simple Window wrapper:
|
||||
|
||||
var x11 = require('../lib/x11');
|
||||
var Window = require('./wndwrap');
|
||||
|
||||
x11.createClient(function(display) {
|
||||
|
||||
var pts = [];
|
||||
new Window(display.client, 0, 0, 700, 500)
|
||||
.handle({
|
||||
|
||||
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!';
|
||||
});
|
||||
|
||||
# Screenshots
|
||||
|
||||

|
||||
|
|
|
|||
Loading…
Reference in a new issue